Commit 2c292f66 authored by 朱璇's avatar 朱璇

对比详情

parent bec8036f
......@@ -2,7 +2,7 @@
* @Author: zx
* @Date: 2020-06-30 17:43:13
* @Last Modified by: zx
* @Last Modified time: 2020-07-01 20:04:23
* @Last Modified time: 2020-07-02 13:50:15
*/
import 'package:flutter_common/commonModel/live/BaseModel.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
......@@ -10,25 +10,43 @@ import 'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanCompareDetail.dart';
import 'package:gm_flutter/commonModel/GMBase.dart';
import 'package:gm_flutter/commonModel/rx/RxDispose.dart';
import 'package:flutter_common/commonModel/toast/NativeToast.dart';
import 'package:gm_flutter/commonModel/util/PrintUtil.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart';
class PlanCompareDetailModel extends BaseModel {
LiveData<PlanCompareDetail> detailLive = LiveData();
LiveData<Pair<int, List<Groups>>> detailLive = LiveData();
LiveData<Pair<int, List<PlansInfo>>> headerLive = LiveData();
RxDispose rxDispose = RxDispose();
void init() {
void init(List<int> planIds) {
ClueApiImpl.getInstance()
.getPlanCompareDetail(DioUtil.getInstance().getDio(), [1,2])
.getPlanCompareDetail(DioUtil.getInstance().getDio(), planIds)
.listen((event) {
if (event.error == 0) {
detailLive.notifyView(event);
if (event.data.plansInfo == null || event.data.groups.isEmpty) {
headerLive.notifyView(Pair(ENDLOADING, []));
detailLive.notifyView(Pair(ENDLOADING, []));
} else {
detailLive.notifyView(Pair(ENDLOADING, event.data.groups));
}
} else {
NativeToast.showNativeToast(event.message);
headerLive.notifyView(Pair(FAIL, null));
detailLive.notifyView(Pair(FAIL, null));
}
})
.addToDispose(rxDispose)
.onError((err) {});
.onError((err) {
headerLive.notifyView(Pair(FAIL, null));
detailLive.notifyView(Pair(FAIL, null));
NativeToast.showNativeToast(err.message);
});
}
@override
void dispose() {
detailLive.dispost();
}
}
\ No newline at end of file
}
......@@ -2,7 +2,7 @@
* @Author: zx
* @Date: 2020-06-30 17:40:43
* @Last Modified by: zx
* @Last Modified time: 2020-07-02 10:20:25
* @Last Modified time: 2020-07-02 18:44:20
*/
import 'package:cached_network_image/cached_network_image.dart';
......@@ -14,34 +14,26 @@ import 'package:gm_flutter/ClueModel/server/entity/PlanCompareDetail.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/bean/Pair.dart';
class PlanCompareDetailPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => PlanCompareDetailPageState();
State<StatefulWidget> createState() => PlanCompareDetailPageState();
}
class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
PlanCompareDetailModel _model = new PlanCompareDetailModel();
PageController pageController = new PageController();
double screenWidth;
PlanCompareDetailModel _model = new PlanCompareDetailModel();
double screenWidth;
List<Widget> viewList = new List();
@override
@override
void initState() {
super.initState();
pageController.addListener(() {
});
Groups groups;
viewList.add(planNormalEffectiveAttrsView(groups));
viewList.add(planNormalEffectiveAttrsView(groups));
viewList.add(planNormalEffectiveAttrsView(groups));
_model.init([1, 2]);
}
@override
void dispose() {
_model.dispose();
pageController.dispose();
pageController.dispose();
super.dispose();
}
......@@ -49,85 +41,88 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
Widget buildItem(BuildContext context) {
screenWidth = MediaQuery.of(context).size.width;
return Scaffold(
appBar: baseAppBar(
title: "对比详情",
centerTitle: true,
backClick: () {
Navigator.pop(context);
}),
body: Container(
child: head(),
// planPopularityView()
// planNormalEffectiveAttrsView()
// setupHome([], []),
// reloadPage(),
)
);
appBar: baseAppBar(
title: "对比详情",
centerTitle: true,
backClick: () {
Navigator.pop(context);
}),
body: Container(
child:
// head(),
// planPopularityView()
// planNormalEffectiveAttrsView()
// setupHome([], []),
reloadPage(),
));
}
Widget reloadPage () {
return StreamBuilder(
Widget reloadPage() {
return StreamBuilder(
stream: _model.detailLive.stream,
initialData: PlanCompareDetail(),
initialData: _model.detailLive.data ?? Pair(LOADING, null),
builder: (c, data) {
PlanCompareDetail detail = data.data;
if (detail == null || detail.data == null || detail.data.groups == null) {
if (data.data.first == FAIL) {
return errorItem(MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height, () {
_model.init([1, 2]);
});
}
if (data.data.first == LOADING || _model.detailLive == null) {
return loadingItem();
}
return setupHome(detail.data.plansInfo, detail.data.groups);
if (data.data.second.length == 0) {
return emptyItem(MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height);
}
return setupHome([], data.data.second);
},
);
}
}
Widget setupHome(List<PlansInfo> plansInfo, List<Groups> groups) {
return Column(
children: <Widget>[
head(),
Expanded(
child: Stack(
children: <Widget>[
head(),
Expanded (
child: Container(
margin: EdgeInsets.fromLTRB(15, 105, 15, 0),
child:
// ListView.builder(
// itemBuilder: (BuildContext context, int index) {
// Groups group = groups[index];
// switch (group.groupType) {
// case 'hot':
// return planPopularityView(group);
// break;
// case 'normal_attrs':
// return planNormalEffectiveAttrsView(group);
// break;
// case 'effective_attrs':
// return planNormalEffectiveAttrsView(group);
// break;
// default:
// return planNormalEffectiveAttrsView(group);
// }
// },
// itemCount: groups.length,
// )
CustomScrollView(
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return viewList[index];
},
childCount: viewList.length,
),
),
],
),
)
),
],
),
child: Container(
margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
color: Colors.green,
child: ListView.builder(
itemBuilder: (BuildContext context, int index) {
Groups group = groups[index];
switch (group.groupType) {
case 'hot':
// return planPopularityView(plansInfo);
// return planNormalEffectiveAttrsView(group);
return Container(
height: 100,
color: Colors.red,
);
break;
case 'normal_attrs':
return Container(
// height: double.maxFinite,
color: Colors.yellow,
child: planNormalEffectiveAttrsView(group),
);
// return planNormalEffectiveAttrsView(group);
break;
case 'effective_attrs':
return Container(
// height: double.maxFinite,
color: Colors.blue,
child: planNormalEffectiveAttrsView(group),
);
// return planNormalEffectiveAttrsView(group);
break;
default:
return planNormalEffectiveAttrsView(group);
}
},
itemCount: groups.length,
)),
)
],
);
......@@ -144,55 +139,39 @@ Widget reloadPage () {
margin: EdgeInsets.fromLTRB(9.5, 0, 9.5, 0),
child: Row(children: <Widget>[
// 根据 flex系数,分配剩余空间
Expanded(
flex:1,
child: headItem(plan)
),
Expanded(
flex: 1,
child: headItem(plan)
)
]
),
);
Expanded(flex: 1, child: headItem(plan)),
Expanded(flex: 1, child: headItem(plan))
]),
);
}
Widget headItem(PlansInfo plan) {
return Container(
child: Stack(
children: <Widget>[
Positioned(
child: ClipRRect (
borderRadius: BorderRadius.circular(15),
child: Container(
alignment: Alignment.center,
color: Colors.cyan,
margin: EdgeInsets.fromLTRB(5.5, 15, 5.5, 15),
child: Image.asset('plan_compare_detail_info_bg'),
),
)
),
Positioned(
left: 17.5,
top: 31,
child: baseText('11111', 15, Color(0xff333333),
bold: true),
),
Positioned(
left: 17.5,
bottom: 31,
child: baseText('¥¥¥¥¥¥¥¥¥¥', 14, Colors.red,
bold: true),
),
return Container(
child: Stack(children: <Widget>[
Positioned(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
),
alignment: Alignment.center,
margin: EdgeInsets.fromLTRB(5.5, 15, 5.5, 15),
child: Image.asset('assets/plan_compare_detail_info_bg.png',
fit: BoxFit.cover),
)),
Positioned(
left: 17.5,
top: 31,
child: baseText('11111', 15, Color(0xff333333), bold: true),
),
Positioned(
left: 17.5,
bottom: 31,
child: baseText('¥¥¥¥¥¥¥¥¥¥', 14, Colors.red, bold: true),
),
]));
}
]
)
);
}
Widget titleView() {
Widget titleView(String title) {
return Container(
height: 81,
width: screenWidth,
......@@ -200,259 +179,190 @@ Widget titleView() {
margin: EdgeInsets.fromLTRB(0, 30, 0, 13),
alignment: Alignment.topCenter,
child: Container(
child: baseText('基础属性', 21, Colors.black, bold: true),
child: baseText(title, 21, Colors.black, bold: true),
),
);
}
);
}
Widget planPopularityView() {
Widget planPopularityView(List<PlansInfo> planInfo) {
return Container(
color: Colors.green,
height: 265,
child: Container (
child: Column(
children: <Widget>[
titleView(),
Row(
children: <Widget>[
Expanded(
flex:1,
child: planPopularityLeftItem()
),
Expanded(
flex: 1,
child: planPopularityRightItem()
)
]
)
]
)
),
child: Container(
child: Column(children: <Widget>[
titleView('111111'),
Row(children: <Widget>[
Expanded(flex: 1, child: planPopularityLeftItem(planInfo[0])),
Expanded(flex: 1, child: planPopularityRightItem(planInfo[1]))
])
])),
);
}
Widget planPopularityLeftItem() {
return Container(
color: Colors.red,
// height: 80,
child:
Expanded(
child: Stack(
children: <Widget>[
Positioned(
right: 20,
top: 12,
child: baseText('99%', 21, Color(0xffF25874),
bold: true)
),
Positioned(
right: 20,
top: 33,
// bottom: 12,
child: baseText('好评率', 12, Color(0xff666666),
bold: false),
),
Positioned(
right: 20,
top: 55,
// bottom: 12,
child: FiveStarView(3,5),
),
Positioned(
right: 20,
top: 98,
bottom: 12,
child: baseText('13679个', 21, Color(0xffF25874),
bold: true),
),
Positioned(
right: 20,
top: 112,
bottom: 12,
child: baseText('销量', 12, Color(0xff666666),
bold: false),
),
Positioned(
right: 20,
top: 132,
bottom: 12,
child: baseText('', 12, Color(0xff666666),
bold: false),
),
]
)
)
);
}
Widget planPopularityRightItem() {
return Container(
color: Colors.red,
// height: 80,
child:
Expanded(
child: Stack(
children: <Widget>[
Positioned(
left: 20,
top: 12,
child: baseText('99%', 21, Color(0xffF25874),
bold: true)
),
Positioned(
left: 20,
top: 33,
// bottom: 12,
child: baseText('好评率', 12, Color(0xff666666),
bold: false),
),
Positioned(
left: 20,
top: 55,
// bottom: 12,
child: FiveStarView(3,5),
),
Positioned(
left: 20,
top: 98,
bottom: 12,
child: baseText('13679个', 21, Color(0xffF25874),
bold: true),
),
Positioned(
left: 20,
top: 112,
bottom: 12,
child: baseText('销量', 12, Color(0xff666666),
bold: false),
),
Widget planPopularityLeftItem(PlansInfo plan) {
return Container(
color: Colors.red,
// height: 80,
child: Expanded(
child: Stack(children: <Widget>[
Positioned(
right: 20,
top: 12,
child: baseText('99%', 21, Color(0xffF25874), bold: true)),
Positioned(
right: 20,
top: 33,
// bottom: 12,
child: baseText('好评率', 12, Color(0xff666666), bold: false),
),
Positioned(
right: 20,
top: 55,
// bottom: 12,
child: FiveStarView(3, 5),
),
Positioned(
right: 20,
top: 98,
bottom: 12,
child: baseText('13679个', 21, Color(0xffF25874), bold: true),
),
Positioned(
right: 20,
top: 112,
bottom: 12,
child: baseText('销量', 12, Color(0xff666666), bold: false),
),
Positioned(
right: 20,
top: 132,
bottom: 12,
child: baseText('', 12, Color(0xff666666), bold: false),
),
])));
}
Positioned(
left: 20,
top: 132,
bottom: 12,
child: baseText('', 12, Color(0xff666666),
bold: false),
),
]
)
)
);
}
Widget planPopularityRightItem(PlansInfo plan) {
return Container(
color: Colors.red,
// height: 80,
child: Expanded(
child: Stack(children: <Widget>[
Positioned(
left: 20,
top: 12,
child: baseText('99%', 21, Color(0xffF25874), bold: true)),
Positioned(
left: 20,
top: 33,
// bottom: 12,
child: baseText('好评率', 12, Color(0xff666666), bold: false),
),
Positioned(
left: 20,
top: 55,
// bottom: 12,
child: FiveStarView(3, 5),
),
Positioned(
left: 20,
top: 98,
bottom: 12,
child: baseText('13679个', 21, Color(0xffF25874), bold: true),
),
Positioned(
left: 20,
top: 112,
bottom: 12,
child: baseText('销量', 12, Color(0xff666666), bold: false),
),
Positioned(
left: 20,
top: 132,
bottom: 12,
child: baseText('', 12, Color(0xff666666), bold: false),
),
])));
}
Widget planNormalEffectiveAttrsView(Groups groups) {
List<Widget> list = new List();
list.add(titleView(groups.groupName));
groups.plans.forEach((element) {
list.add(planBaseAttrsView(element));
});
return Container(
color: Colors.green,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Stack(
children: <Widget>[
titleView(),
Expanded (
child: Container(
margin: EdgeInsets.fromLTRB(0, 68, 0, 0),
child:
ListView.builder(
itemBuilder: (c, index) {
return planBaseAttrsView();
},
itemCount: 5,
)
)
)
]
)
)
]
)
);
color: Colors.green,
child:
Column(mainAxisAlignment: MainAxisAlignment.center, children: list
// <Widget>[
// Expanded(
// child: Stack(children: <Widget>[
// ,
// Expanded(
// child: Container(
// margin: EdgeInsets.fromLTRB(0, 68, 0, 0),
// child:
// ListView.builder(
// shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
// itemBuilder: (c, index) {
// return planBaseAttrsView(groups.plans);
// },
// itemCount: 5,
// )))
// ]))
));
}
Widget planBaseAttrsView() {
Widget planBaseAttrsView(Plans plans) {
return Container(
color: Colors.red,
height: 80,
child: Row(
children: <Widget>[
Expanded(
flex:1,
child: planBaseAttrsLeftView()
),
Expanded(
flex: 1,
child: planBaseAttrsRightView()
)
]
)
);
color: Colors.red,
height: 80,
child: Row(children: <Widget>[
Expanded(flex: 1, child: planBaseAttrsLeftView(plans)),
Expanded(flex: 1, child: planBaseAttrsRightView(plans))
]));
}
Widget planBaseAttrsLeftView() {
return Container(
color: Colors.red,
height: 80,
child: Stack(
children: <Widget>[
Positioned(
right: 20,
top: 12,
child: baseText('嘻嘻嘻嘻嘻嘻', 14, Color(0xff3FB5AF),
bold: true)
),
Positioned(
right: 20,
// top: 12,
bottom: 12,
child: baseText('哈哈哈哈', 12, Color(0xff666666),
bold: false),
),
]
)
);
}
Widget planBaseAttrsRightView() {
return Container(
color: Colors.red,
height: 80,
child: Stack(
children: <Widget>[
Positioned(
left: 20,
top: 12,
child: baseText('嘻嘻嘻嘻嘻嘻', 14, Color(0xffF25874),
bold: true)
),
Positioned(
left: 20,
// top: 12,
bottom: 12,
child: baseText('哈哈哈哈', 12, Color(0xff666666),
bold: false),
),
Widget planBaseAttrsLeftView(Plans plan) {
return Container(
color: Colors.red,
height: 80,
child: Stack(children: <Widget>[
Positioned(
right: 20,
top: 12,
child: baseText(plan.attrs[0].attrValue, 14, Color(0xff3FB5AF),
bold: true)),
Positioned(
right: 20,
// top: 12,
bottom: 12,
child: baseText(plan.attrs[0].attrName, 12, Color(0xff666666),
bold: false),
),
]));
}
]
)
);
}
}
\ No newline at end of file
Widget planBaseAttrsRightView(Plans plan) {
return Container(
color: Colors.red,
height: 80,
child: Stack(children: <Widget>[
Positioned(
left: 20,
top: 12,
child: baseText(plan.attrs[0].attrValue, 14, Color(0xffF25874),
bold: true)),
Positioned(
left: 20,
// top: 12,
bottom: 12,
child: baseText(plan.attrs[0].attrName, 12, Color(0xff666666),
bold: false),
),
]));
}
}
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