Commit 4e01db3a authored by 林生雨's avatar 林生雨

temp

parent d94ecc47
/*
* @author lsy
* @date 2020-01-02
**/
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_common/flutter_common.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
class MessageBarView extends StatelessWidget {
final LiveData<int> topIndexLive;
final LiveData<double> topScrollLive;
final PageController pageController;
bool leftShow = false;
bool rightShow = false;
MessageBarView({
this.topIndexLive,
this.topScrollLive,
this.pageController,
}) {}
@override
Widget build(BuildContext context) {
return topView(context);
}
Widget topViewItem(String text, int index) {
return StreamBuilder(
stream: topIndexLive.stream,
initialData: topIndexLive.data ?? 0.0,
builder: (con, data) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
// pageController.jumpToPage(index);
pageController.animateToPage(index,
duration: Duration(milliseconds: 200), curve: Curves.ease);
},
child: Container(
alignment: Alignment.bottomCenter,
width: double.maxFinite,
height: double.maxFinite,
child: baseText(text, 16,
data.data == index ? Color(0xff282828) : Color(0xffB5B5B5)),
),
);
},
);
}
Widget topView(BuildContext context) {
return Container(
height: 49,
width: double.maxFinite,
child: Column(
children: <Widget>[
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(child: topViewItem("价格", 0)),
Expanded(child: topViewItem("医院", 1)),
Expanded(child: topViewItem("医生", 2)),
Expanded(child: topViewItem("评价", 3)),
],
),
),
Container(
alignment: Alignment.topLeft,
height: 8,
margin: EdgeInsets.only(top: 4, bottom: 5),
width: double.maxFinite,
child: StreamBuilder(
stream: topScrollLive.stream,
initialData: topScrollLive.data ?? 0.0,
builder: (con, data) {
return Container(
margin: EdgeInsets.only(
left: MediaQuery.of(context).size.width / 12 +
4.5 +
data.data),
width: 22,
height: 3,
decoration: BoxDecoration(
borderRadius: new BorderRadius.circular((1.5)),
color: Color(0xff3FB5AF),
),
);
},
),
)
],
),
);
}
}
...@@ -6,6 +6,7 @@ import 'package:cached_network_image/cached_network_image.dart'; ...@@ -6,6 +6,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart'; import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
import 'package:gm_flutter/ClueModel/view/FiveStarView.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart'; import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/base/BaseUtil.dart'; import 'package:gm_flutter/commonModel/base/BaseUtil.dart';
...@@ -161,7 +162,12 @@ class LevelOneItem extends StatelessWidget { ...@@ -161,7 +162,12 @@ class LevelOneItem extends StatelessWidget {
Positioned( Positioned(
bottom: 67, bottom: 67,
left: 57, left: 57,
child: baseText(cards.hospital.name, 12, Color(0xff666666)), child: baseText(cards.hospital.address, 12, Color(0xff666666)),
),
Positioned(
left: 57,
top: 43.5,
child: FiveStarView(cards.hospital.star, 5),
) )
], ],
), ),
...@@ -191,7 +197,7 @@ class LevelOneItem extends StatelessWidget { ...@@ -191,7 +197,7 @@ class LevelOneItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[ children: <Widget>[
baseText("¥", 12, Color(0xffFF5963)), baseText("¥", 12, Color(0xffFF5963)),
baseText(cards.plan, 15, Color(0xffFF5963)) baseText(cards.plan.maxPrice, 15, Color(0xffFF5963))
], ],
), ),
), ),
......
/*
* @author lsy
* @date 2020/6/29
**/
import 'package:flutter_common/commonModel/live/BaseModel.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
import 'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
import 'package:gm_flutter/commonModel/GMBase.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart';
import 'package:gm_flutter/commonModel/rx/RxDispose.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class LevelOneModel extends BaseModel {
LiveData<double> appBarLive = LiveData();
LiveData<List<String>> rectLive = LiveData();
LiveData<List<String>> explainLive = LiveData();
LiveData<bool> showTab = LiveData();
LiveData<int> topIndexLive = new LiveData();
LiveData<double> topScrollLive = new LiveData();
RxDispose rxDispose = RxDispose();
LiveData<Pair<int,List<Cards>>> cardsLive = LiveData();
Map<int, List<Cards>> data = new Map();
List list = ["plan", "hospital", "doctor", "diary"];
List pageList = [1, 1, 1, 1];
void refreshView(bool clear, {RefreshController refreshListener}) {
int index = currentIndex;
if (clear) {
data.clear();
pageList = [1, 1, 1, 1];
}
ClueApiImpl.getInstance()
.getLevelOneList(
DioUtil.getInstance().getDio(), 123, list[index], pageList[index])
.listen((event) {
}).addToDispose(rxDispose).onError((err) {
});
}
int currentIndex = 0;
@override
void dispose() {
showTab.dispost();
cardsLive.dispost();
appBarLive.dispost();
rectLive.dispost();
topIndexLive.dispost();
topScrollLive.dispost();
}
void selectPage(int index) {
if (currentIndex == index) {
return;
}
currentIndex = index;
}
}
...@@ -2,25 +2,472 @@ ...@@ -2,25 +2,472 @@
* @author lsy * @author lsy
* @date 2020/6/29 * @date 2020/6/29
**/ **/
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
import 'package:gm_flutter/ClueModel/page/levelOne/LevelOneModel.dart';
import 'package:gm_flutter/ClueModel/util/PosUtil.dart';
import 'package:gm_flutter/ClueModel/view/FiveStarView.dart'; import 'package:gm_flutter/ClueModel/view/FiveStarView.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/base/BaseState.dart'; import 'package:gm_flutter/commonModel/base/BaseState.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'LevelOneBar.dart';
class LevelOnePage extends StatefulWidget { class LevelOnePage extends StatefulWidget {
@override @override
State<StatefulWidget> createState() => LevelOneState(); State<StatefulWidget> createState() => LevelOneState();
} }
class LevelOneState extends BaseState<LevelOnePage> { class LevelOneState extends BaseState<LevelOnePage>
with TickerProviderStateMixin {
LevelOneModel _model = new LevelOneModel();
RefreshController _refreshController = RefreshController();
PageController pageController = new PageController();
GlobalKey keyTop = new GlobalKey();
GlobalKey key1 = new GlobalKey();
double screenWidth;
List<Widget> oneList = new List();
@override
void initState() {
super.initState();
pageController.addListener(() {
if (screenWidth != null) {
_model.topScrollLive.notifyView(
pageController.offset / screenWidth * (screenWidth / 4));
}
});
oneList.add(head());
oneList.add(good());
oneList.add(rect());
oneList.add(explain());
oneList.add(Container(
height: 5,
color: Color(0xffF7F6FA),
));
oneList.add(feed());
oneList.add(pages());
}
void _onScroll(double offset) {
print("OFFSET ${offset}");
if (offset < 10) {
_model.appBarLive.notifyView(0.0);
} else if (offset < 500) {
var topPos = PosUtil.findPos(keyTop);
if (topPos != null && topPos.dy < 0) {
double dy = -topPos.dy;
if (dy < 20) {
dy = 0;
}
double alpha = dy / 112;
if (alpha < 0) {
alpha = 0;
} else if (alpha > 1) {
alpha = 1;
}
_model.appBarLive.notifyView(alpha);
}
}
if (offset > 100) {
var key1Pos = PosUtil.findPos(key1);
if (key1Pos != null) {
if (key1Pos.dy < 86) {
_model.showTab.notifyView(true);
} else {
_model.showTab.notifyView(false);
}
}
}
}
@override
void dispose() {
_model.dispose();
pageController.dispose();
_refreshController.dispose();
pageController.dispose();
super.dispose();
}
@override @override
Widget buildItem(BuildContext context) { Widget buildItem(BuildContext context) {
screenWidth = MediaQuery.of(context).size.width;
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Stack( body: Column(
children: <Widget>[ FiveStarView(3, 5), children: <Widget>[
Expanded(
child: Stack(
children: <Widget>[
MediaQuery.removePadding(
removeTop: true,
context: context,
child: NotificationListener(
onNotification: (scrollNotification) {
if (scrollNotification is ScrollUpdateNotification &&
scrollNotification.metrics.axisDirection.index ==
2) {
_onScroll(scrollNotification.metrics.pixels);
}
return false;
},
child: baseRefreshView(_refreshController, () {
//TODO
// _refreshController.refreshCompleted();
}, null, null,
customScrollView: CustomScrollView(
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return oneList[index];
},
childCount: oneList.length,
),
),
],
)),
)),
StreamBuilder<double>(
stream: _model.appBarLive.stream,
initialData: _model.appBarLive.data ?? 0.0,
builder: (c, data) {
return Opacity(
opacity: data.data,
child: Container(
height: 86,
decoration: BoxDecoration(color: Colors.white),
child: Center(
child: Padding(
padding: EdgeInsets.only(top: 20),
child: Text('文案'),
),
),
),
);
},
),
Positioned(
top: 86,
child: StreamBuilder<bool>(
stream: _model.showTab.stream,
initialData: _model.showTab.data ?? false,
builder: (c, data) {
return Opacity(
opacity: data.data ? 1.0 : 0.0,
child: Container(
width: MediaQuery.of(context).size.width,
color: Colors.white,
child: MessageBarView(
topIndexLive: _model.topIndexLive,
topScrollLive: _model.topScrollLive,
pageController: pageController,
),
));
},
),
)
],
),
),
Container(
height: 0.5,
width: double.maxFinite,
color: Color(0xffE5E5E5),
),
Container(
width: double.maxFinite,
height: 55,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 18),
width: 30,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 22,
height: 22,
child: Image.asset("assets/vs_black.png"),
),
Container(
margin: EdgeInsets.only(top: 3),
child: baseText("去比较", 10, Color(0xff282828)),
)
],
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
margin: EdgeInsets.only(left: 15),
width: 135,
height: 40,
decoration: BoxDecoration(
color: Color(0xff51CDC7),
borderRadius: BorderRadius.circular(20)),
alignment: Alignment.center,
child: baseText("咨询", 14, Colors.white, bold: true),
)),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
margin: EdgeInsets.only(left: 15),
width: 135,
height: 40,
decoration: BoxDecoration(
color: Color(0xffF96079),
borderRadius: BorderRadius.circular(20)),
alignment: Alignment.center,
child: baseText("获取底价", 14, Colors.white, bold: true),
)),
Expanded(
child: Container(),
)
],
),
)
],
));
}
Widget head() {
return Container(
key: keyTop,
width: double.maxFinite,
height: 200,
alignment: Alignment.topLeft,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
"https://pic.igengmei.com/2018/09/11/1513/b7e825a4e4c1-w"))),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
//TODO
},
child: Container(
width: 30,
height: 30,
decoration:
BoxDecoration(color: Color(0x99FFFFFF), shape: BoxShape.circle),
margin: EdgeInsets.only(top: 49, left: 15),
alignment: Alignment.center,
child: Container(
width: 7,
height: 14,
child: Image.asset("assets/left_arrow.png"),
),
)),
);
}
Widget good() {
return Container(
width: double.maxFinite,
height: 54,
margin: EdgeInsets.only(top: 18, bottom: 12),
child: Stack(
children: <Widget>[
Positioned(
top: 6,
left: 15,
child: baseText("TODO", 18, Color(0xff282828), bold: true),
),
Positioned(
bottom: 8,
left: 15,
child: baseText("TODO", 12, Color(0xff999999)),
),
Positioned(
right: 0,
child: Container(
width: 100,
height: 54,
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
Color(0xFFFFF0F5),
Color(0xffFFF8FA),
Color(0xFFFFFFFF)
], begin: FractionalOffset(1, 0), end: FractionalOffset(0, 1))),
),
),
Positioned(
right: 15,
top: 6,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
baseText("好评率", 11, Color(0xff282828)),
Container(
margin: EdgeInsets.only(left: 4),
child: baseText("99", 20, Color(0xffFF5963)),
),
baseText("%", 11, Color(0xffFF5963)),
],
),
),
Positioned(
right: 15,
bottom: 8,
child: baseText("销量110", 11, Color(0xff666666)),
)
], ],
), ),
); );
} }
Widget rect() {
return StreamBuilder<List<String>>(
stream: _model.rectLive.stream,
initialData: ["w", "w", "q", "w"],
builder: (c, data) {
List<Widget> list = List();
for (int i = 0; i < data.data.length; i += 2) {
list.add(Expanded(
child: Container(
alignment: Alignment.center,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
baseText(data.data[i], 14, Color(0xff282828), bold: true),
baseText(data.data[i + 1], 11, Color(0xff999999)),
],
),
),
));
if (i < data.data.length - 2) {
list.add(Container(
width: 0.5,
height: 18,
color: Color(0xFFE5E5E5),
));
}
}
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: Color(0xffF9F8FB),
),
width: double.maxFinite,
height: 62,
margin: EdgeInsets.only(left: 15, right: 15, bottom: 20),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: list,
),
);
},
);
}
Widget explain() {
return StreamBuilder<List<String>>(
stream: _model.explainLive.stream,
initialData: ["www", "www", "www", "??"],
builder: (c, data) {
List<Widget> list = [];
list.add(Container(
height: 31,
child: Row(
children: <Widget>[
baseText("项目说明", 15, Color(0xff282828)),
Expanded(
child: Container(),
),
GestureDetector(
onTap: () {
//TODO
},
behavior: HitTestBehavior.opaque,
child: baseText("了解更多", 12, Color(0xff3FB5AF)),
)
],
),
));
for (int i = 0; i < data.data.length; i += 2) {
list.add(Container(
height: 28,
child: Row(
children: <Widget>[
baseText(data.data[i], 13, Color(0xff999999)),
Container(
margin: EdgeInsets.only(left: 12),
child: baseText(data.data[i + 1], 13, Color(0xff666666)),
)
],
),
));
}
return Container(
margin: EdgeInsets.only(left: 15, right: 15, bottom: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: list,
),
);
},
);
}
Widget feed() {
return Container(
key: key1,
child: MessageBarView(
topIndexLive: _model.topIndexLive,
topScrollLive: _model.topScrollLive,
pageController: pageController,
));
}
List temp = [20, 10, 10, 10];
int currentIndex;
Widget pages() {
// return StreamBuilder(
// stream: _model.cardsLive.stream,
// initialData: _model.cardsLive.data??[],
// builder: (c,data){
//
// },
// )
double height = 500;
return Container(
width: double.maxFinite,
height: height,
child: PageView.builder(
itemBuilder: (c, index) {
return Container(
width: double.maxFinite,
height: height,
color: Colors.red,
child: ListView.builder(itemBuilder: (c,index){
},itemCount: 10,),
);
},
allowImplicitScrolling: false,
dragStartBehavior: DragStartBehavior.down,
controller: pageController,
itemCount: 4,
onPageChanged: (index) {
_model.topIndexLive.notifyView(index);
_model.selectPage(index);
},
),
);
}
} }
...@@ -3,10 +3,13 @@ ...@@ -3,10 +3,13 @@
* @date 2020/6/28 * @date 2020/6/28
**/ **/
import 'package:flutter_common/Annotations/anno/Get.dart'; import 'package:flutter_common/Annotations/anno/Get.dart';
import 'package:flutter_common/Annotations/anno/Query.dart';
import 'package:flutter_common/Annotations/anno/ServiceCenter.dart'; import 'package:flutter_common/Annotations/anno/ServiceCenter.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
@ServiceCenter() @ServiceCenter()
class ClueApi { abstract class ClueApi {
@Get("api/janus/plans/plan_feed")
LevelOneFeedList getLevelOneList(@Query("plan_id") int plan_id,
} @Query("tab_type") String tab_type, @Query("page") int page);
\ No newline at end of file }
...@@ -14,6 +14,8 @@ import 'package:dio/dio.dart'; ...@@ -14,6 +14,8 @@ import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
const bool inProduction = const bool.fromEnvironment("dart.vm.product"); const bool inProduction = const bool.fromEnvironment("dart.vm.product");
class ClueApiImpl { class ClueApiImpl {
...@@ -30,6 +32,23 @@ class ClueApiImpl { ...@@ -30,6 +32,23 @@ class ClueApiImpl {
return _instance; return _instance;
} }
Stream<LevelOneFeedList> getLevelOneList(
Dio _dio, int plan_id, String tab_type, int page) {
return Stream.fromFuture(get(_dio, 'api/janus/plans/plan_feed', data: {
'plan_id': plan_id,
'tab_type': tab_type,
'page': page,
})).flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Stream.fromFuture(
compute(parseLevelOneFeedList, value.toString()));
} else {
throw Exception("--未知网络错误--");
}
});
}
///==================base method================== ///==================base method==================
Future<Response> get(Dio _dio, url, {data, options, cancelToken}) async { Future<Response> get(Dio _dio, url, {data, options, cancelToken}) async {
...@@ -166,3 +185,7 @@ class ClueApiImpl { ...@@ -166,3 +185,7 @@ class ClueApiImpl {
return reason; return reason;
} }
} }
LevelOneFeedList parseLevelOneFeedList(String value) {
return LevelOneFeedList.fromJson(json.decode(value));
}
...@@ -10,7 +10,9 @@ class LevelOneFeedList { ...@@ -10,7 +10,9 @@ class LevelOneFeedList {
LevelOneFeedList.fromJson(Map<String, dynamic> json) { LevelOneFeedList.fromJson(Map<String, dynamic> json) {
if (json['cards'] != null) { if (json['cards'] != null) {
cards = new List<Cards>(); cards = new List<Cards>();
json['cards'].forEach((v) { cards.add(new Cards.fromJson(v)); }); json['cards'].forEach((v) {
cards.add(new Cards.fromJson(v));
});
} }
} }
...@@ -35,8 +37,11 @@ class Cards { ...@@ -35,8 +37,11 @@ class Cards {
Cards.fromJson(Map<String, dynamic> json) { Cards.fromJson(Map<String, dynamic> json) {
cardType = json['card_type']; cardType = json['card_type'];
plan = json['plan'] != null ? new Plan.fromJson(json['plan']) : null; plan = json['plan'] != null ? new Plan.fromJson(json['plan']) : null;
hospital = json['hospital'] != null ? new Hospital.fromJson(json['hospital']) : null; hospital = json['hospital'] != null
doctor = json['doctor'] != null ? new Hospital.fromJson(json['doctor']) : null; ? new Hospital.fromJson(json['hospital'])
: null;
doctor =
json['doctor'] != null ? new Hospital.fromJson(json['doctor']) : null;
diary = json['diary'] != null ? new Diary.fromJson(json['diary']) : null; diary = json['diary'] != null ? new Diary.fromJson(json['diary']) : null;
} }
...@@ -70,7 +75,16 @@ class Plan { ...@@ -70,7 +75,16 @@ class Plan {
String consultUrl; String consultUrl;
String phoneAuthroize; String phoneAuthroize;
Plan({this.planName, this.minPrice, this.maxPrice, this.positiveRate, this.salesCount, this.baseAttrs, this.projectImage, this.consultUrl, this.phoneAuthroize}); Plan(
{this.planName,
this.minPrice,
this.maxPrice,
this.positiveRate,
this.salesCount,
this.baseAttrs,
this.projectImage,
this.consultUrl,
this.phoneAuthroize});
Plan.fromJson(Map<String, dynamic> json) { Plan.fromJson(Map<String, dynamic> json) {
planName = json['plan_name']; planName = json['plan_name'];
...@@ -80,7 +94,9 @@ class Plan { ...@@ -80,7 +94,9 @@ class Plan {
salesCount = json['sales_count']; salesCount = json['sales_count'];
if (json['base_attrs'] != null) { if (json['base_attrs'] != null) {
baseAttrs = new List<BaseAttrs>(); baseAttrs = new List<BaseAttrs>();
json['base_attrs'].forEach((v) { baseAttrs.add(new BaseAttrs.fromJson(v)); }); json['base_attrs'].forEach((v) {
baseAttrs.add(new BaseAttrs.fromJson(v));
});
} }
projectImage = json['project_image']; projectImage = json['project_image'];
consultUrl = json['consult_url']; consultUrl = json['consult_url'];
...@@ -128,20 +144,33 @@ class Hospital { ...@@ -128,20 +144,33 @@ class Hospital {
String name; String name;
String minPrice; String minPrice;
String maxPrice; String maxPrice;
String address;
int star;
List<BaseAttrs> baseAttrs; List<BaseAttrs> baseAttrs;
String consultUrl; String consultUrl;
String phoneAuthroize; String phoneAuthroize;
Hospital({this.portrait, this.name, this.minPrice, this.maxPrice, this.baseAttrs, this.consultUrl, this.phoneAuthroize}); Hospital(
{this.portrait,
this.name,
this.minPrice,
this.maxPrice,
this.baseAttrs,
this.consultUrl,
this.phoneAuthroize});
Hospital.fromJson(Map<String, dynamic> json) { Hospital.fromJson(Map<String, dynamic> json) {
portrait = json['portrait']; portrait = json['portrait'];
name = json['name']; name = json['name'];
star = json['star'];
address = json['address'];
minPrice = json['min_price']; minPrice = json['min_price'];
maxPrice = json['max_price']; maxPrice = json['max_price'];
if (json['base_attrs'] != null) { if (json['base_attrs'] != null) {
baseAttrs = new List<BaseAttrs>(); baseAttrs = new List<BaseAttrs>();
json['base_attrs'].forEach((v) { baseAttrs.add(new BaseAttrs.fromJson(v)); }); json['base_attrs'].forEach((v) {
baseAttrs.add(new BaseAttrs.fromJson(v));
});
} }
consultUrl = json['consult_url']; consultUrl = json['consult_url'];
phoneAuthroize = json['phone_authroize']; phoneAuthroize = json['phone_authroize'];
...@@ -153,6 +182,8 @@ class Hospital { ...@@ -153,6 +182,8 @@ class Hospital {
data['name'] = this.name; data['name'] = this.name;
data['min_price'] = this.minPrice; data['min_price'] = this.minPrice;
data['max_price'] = this.maxPrice; data['max_price'] = this.maxPrice;
data['address'] = this.address;
data['star'] = this.star;
if (this.baseAttrs != null) { if (this.baseAttrs != null) {
data['base_attrs'] = this.baseAttrs.map((v) => v.toJson()).toList(); data['base_attrs'] = this.baseAttrs.map((v) => v.toJson()).toList();
} }
...@@ -201,7 +232,44 @@ class Diary { ...@@ -201,7 +232,44 @@ class Diary {
UserLevel userLevel; UserLevel userLevel;
int serviceId; int serviceId;
Diary({this.diaryNum, this.videoUrl, this.isIdentification, this.isLiked, this.titleStyleType, this.replyNum, this.lasestTopicCreatedTime, this.images, this.relationServiceSku, this.createdTime, this.latestTopicId, this.id, this.city, this.userId, this.title, this.isVoted, this.diaryId, this.preImageList, this.voteNum, this.tagsNewEra, this.content, this.videoPic, this.shortVideoUrl, this.diaryAmount, this.diaryTitle, this.authorType, this.tags, this.contentLevel, this.lastModified, this.user, this.isOnline, this.date, this.membershipLevel, this.viewNum, this.postImageList, this.userLevel, this.serviceId}); Diary(
{this.diaryNum,
this.videoUrl,
this.isIdentification,
this.isLiked,
this.titleStyleType,
this.replyNum,
this.lasestTopicCreatedTime,
this.images,
this.relationServiceSku,
this.createdTime,
this.latestTopicId,
this.id,
this.city,
this.userId,
this.title,
this.isVoted,
this.diaryId,
this.preImageList,
this.voteNum,
this.tagsNewEra,
this.content,
this.videoPic,
this.shortVideoUrl,
this.diaryAmount,
this.diaryTitle,
this.authorType,
this.tags,
this.contentLevel,
this.lastModified,
this.user,
this.isOnline,
this.date,
this.membershipLevel,
this.viewNum,
this.postImageList,
this.userLevel,
this.serviceId});
Diary.fromJson(Map<String, dynamic> json) { Diary.fromJson(Map<String, dynamic> json) {
diaryNum = json['diary_num']; diaryNum = json['diary_num'];
...@@ -213,9 +281,13 @@ class Diary { ...@@ -213,9 +281,13 @@ class Diary {
lasestTopicCreatedTime = json['lasest_topic_created_time']; lasestTopicCreatedTime = json['lasest_topic_created_time'];
if (json['images'] != null) { if (json['images'] != null) {
images = new List<Images>(); images = new List<Images>();
json['images'].forEach((v) { images.add(new Images.fromJson(v)); }); json['images'].forEach((v) {
images.add(new Images.fromJson(v));
});
} }
relationServiceSku = json['relation_service_sku'] != null ? new RelationServiceSku.fromJson(json['relation_service_sku']) : null; relationServiceSku = json['relation_service_sku'] != null
? new RelationServiceSku.fromJson(json['relation_service_sku'])
: null;
createdTime = json['created_time']; createdTime = json['created_time'];
latestTopicId = json['latest_topic_id']; latestTopicId = json['latest_topic_id'];
id = json['id']; id = json['id'];
...@@ -228,7 +300,9 @@ class Diary { ...@@ -228,7 +300,9 @@ class Diary {
voteNum = json['vote_num']; voteNum = json['vote_num'];
if (json['tags_new_era'] != null) { if (json['tags_new_era'] != null) {
tagsNewEra = new List<TagsNewEra>(); tagsNewEra = new List<TagsNewEra>();
json['tags_new_era'].forEach((v) { tagsNewEra.add(new TagsNewEra.fromJson(v)); }); json['tags_new_era'].forEach((v) {
tagsNewEra.add(new TagsNewEra.fromJson(v));
});
} }
content = json['content']; content = json['content'];
videoPic = json['video_pic']; videoPic = json['video_pic'];
...@@ -238,7 +312,9 @@ class Diary { ...@@ -238,7 +312,9 @@ class Diary {
authorType = json['author_type']; authorType = json['author_type'];
if (json['tags'] != null) { if (json['tags'] != null) {
tags = new List<Tags>(); tags = new List<Tags>();
json['tags'].forEach((v) { tags.add(new Tags.fromJson(v)); }); json['tags'].forEach((v) {
tags.add(new Tags.fromJson(v));
});
} }
contentLevel = json['content_level']; contentLevel = json['content_level'];
lastModified = json['last_modified']; lastModified = json['last_modified'];
...@@ -248,7 +324,9 @@ class Diary { ...@@ -248,7 +324,9 @@ class Diary {
membershipLevel = json['membership_level']; membershipLevel = json['membership_level'];
viewNum = json['view_num']; viewNum = json['view_num'];
postImageList = json['post_image_list'].cast<String>(); postImageList = json['post_image_list'].cast<String>();
userLevel = json['user_level'] != null ? new UserLevel.fromJson(json['user_level']) : null; userLevel = json['user_level'] != null
? new UserLevel.fromJson(json['user_level'])
: null;
serviceId = json['service_id']; serviceId = json['service_id'];
} }
...@@ -318,7 +396,16 @@ class Images { ...@@ -318,7 +396,16 @@ class Images {
String imageHalf; String imageHalf;
String desc; String desc;
Images({this.imageWide, this.imageType, this.image, this.sImagePlatform, this.imageSlimwidth, this.smallWide, this.imageThumb, this.imageHalf, this.desc}); Images(
{this.imageWide,
this.imageType,
this.image,
this.sImagePlatform,
this.imageSlimwidth,
this.smallWide,
this.imageThumb,
this.imageHalf,
this.desc});
Images.fromJson(Map<String, dynamic> json) { Images.fromJson(Map<String, dynamic> json) {
imageWide = json['image_wide']; imageWide = json['image_wide'];
...@@ -348,17 +435,14 @@ class Images { ...@@ -348,17 +435,14 @@ class Images {
} }
class RelationServiceSku { class RelationServiceSku {
RelationServiceSku(); RelationServiceSku();
RelationServiceSku.fromJson(Map<String, dynamic> json) { RelationServiceSku.fromJson(Map<String, dynamic> json) {}
}
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
return data; return data;
} }
} }
class TagsNewEra { class TagsNewEra {
...@@ -395,7 +479,14 @@ class User { ...@@ -395,7 +479,14 @@ class User {
String userName; String userName;
String membershipLevel; String membershipLevel;
User({this.city, this.userId, this.topicNumPosted, this.voteNumGained, this.portrait, this.userName, this.membershipLevel}); User(
{this.city,
this.userId,
this.topicNumPosted,
this.voteNumGained,
this.portrait,
this.userName,
this.membershipLevel});
User.fromJson(Map<String, dynamic> json) { User.fromJson(Map<String, dynamic> json) {
city = json['city']; city = json['city'];
......
/*
* @author lsy
* @date 2020/6/30
**/
import 'package:flutter/cupertino.dart';
class PosUtil {
static Offset findPos(GlobalKey globalKey) {
Offset offset;
if (globalKey.currentContext != null) {
RenderBox box = globalKey.currentContext.findRenderObject();
offset = box.localToGlobal(Offset.zero);
}
return offset;
}
}
...@@ -9,4 +9,3 @@ export 'base/BaseUtil.dart'; ...@@ -9,4 +9,3 @@ export 'base/BaseUtil.dart';
export 'net/Api.dart'; export 'net/Api.dart';
export 'net/DioUtil.dart'; export 'net/DioUtil.dart';
export 'picker/loadingPicker.dart'; export 'picker/loadingPicker.dart';
export 'util/DartUtil.dart';
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_common/commonModel/eventbus/GlobalEventBus.dart'; import 'package:flutter_common/commonModel/eventbus/GlobalEventBus.dart';
import 'package:flutter_common/commonModel/view/iOSLoading.dart'; import 'package:flutter_common/commonModel/view/iOSLoading.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:gm_flutter/commonModel/GMBase.dart'; import 'package:gm_flutter/commonModel/GMBase.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart';
import 'package:gm_flutter/commonModel/view/ImagesAnimation.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
double SCREENWIDTH; double SCREENWIDTH;
...@@ -25,9 +28,8 @@ AppBar baseAppBar( ...@@ -25,9 +28,8 @@ AppBar baseAppBar(
double elevation = 0.0, double elevation = 0.0,
Widget titleWidget = null}) { Widget titleWidget = null}) {
return _baseAppBarChangeTitle( return _baseAppBarChangeTitle(
title: title == null title:
? Container() title == null ? Container() : baseText(title, 16, Color(0xff323232)),
: baseText(title, 16, Color(0xff323232)),
action: action, action: action,
centerTitle: centerTitle, centerTitle: centerTitle,
backClick: backClick, backClick: backClick,
...@@ -248,8 +250,86 @@ Widget baseRedPoint(int num) { ...@@ -248,8 +250,86 @@ Widget baseRedPoint(int num) {
alignment: Alignment.center, alignment: Alignment.center,
width: 15, width: 15,
height: 15, height: 15,
decoration: decoration: BoxDecoration(shape: BoxShape.circle, color: Color(0xffFF5963)),
BoxDecoration(shape: BoxShape.circle, color: Color(0xffFF5963)),
child: baseText("${num}", 11, Color(0xffFFFFFF)), child: baseText("${num}", 11, Color(0xffFFFFFF)),
); );
} }
Widget baseRefreshView(RefreshController refreshController,
VoidCallback refresh, Widget topFix, Widget List,
{bool pullUp = false,
bool pullDown = true,
VoidCallback onLoading,
ScrollController scrollController,
CustomScrollView customScrollView}) {
return SmartRefresher(
enablePullDown: pullDown,
enablePullUp: pullUp,
onLoading: onLoading ?? () {},
header: normalRefreshHeader(),
controller: refreshController,
onRefresh: refresh,
footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode) {
Widget body;
// if (mode == LoadStatus.idle) {
// body = baseText("准备加载", 12, Color(0xff545454));
// } else
if (mode == LoadStatus.loading) {
body = baseText("加载中", 12, Color(0xff545454));
} else if (mode == LoadStatus.failed) {
body = baseText("加载失败", 12, Color(0xff545454));
} else if (mode == LoadStatus.noMore) {
body = baseText("没有更多数据了", 12, Color(0xff545454));
} else {
body = Container();
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
),
child: customScrollView ??
CustomScrollView(
controller: scrollController,
slivers: <Widget>[
SliverToBoxAdapter(
child: topFix,
),
List,
],
));
}
Widget normalRefreshHeader() {
return CustomHeader(
builder: (BuildContext context, RefreshStatus mode) {
Widget body;
// if (mode == RefreshStatus.idle) {
//
// } else
if (mode == RefreshStatus.refreshing) {
body = ImagesAnimation(
w: 46,
h: 15,
durationSeconds: 1500,
entry: ImagesAnimationEntry(1, 20, "assets/ptr_header_loading"));
}
// else if (mode == RefreshStatus.failed) {
// body = Text("Load Failed!Click retry!");
// }
else {
body = Image.asset(
"assets/ptr_header_loading01.png",
width: 46,
height: 15,
);
}
return Container(
height: 55.0,
child: Center(child: body),
);
},
);
}
...@@ -70,7 +70,7 @@ class MyApp extends State<MyAppWidget> { ...@@ -70,7 +70,7 @@ class MyApp extends State<MyAppWidget> {
WindowUtil.setBarStatus(true); WindowUtil.setBarStatus(true);
return MaterialApp( return MaterialApp(
theme: ThemeData(), theme: ThemeData(),
builder: FlutterBoost.init(postPush: _onRoutePushed), // builder: FlutterBoost.init(postPush: _onRoutePushed),
home: RouterCenterImpl().findClueRouter().getLevelOnePage()); home: RouterCenterImpl().findClueRouter().getLevelOnePage());
} }
......
...@@ -3,7 +3,7 @@ description: A new flutter module project. ...@@ -3,7 +3,7 @@ description: A new flutter module project.
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ">=2.1.0 <3.0.0" sdk: ">=2.6.0 <3.0.0"
dependencies: dependencies:
flutter: flutter:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment