|
@@ -5,7 +5,9 @@ import 'package:one_key/constant/state.dart'; |
|
@@ -5,7 +5,9 @@ import 'package:one_key/constant/state.dart'; |
|
5
|
import 'package:one_key/pages/coupon/coupon_item.dart';
|
5
|
import 'package:one_key/pages/coupon/coupon_item.dart';
|
|
6
|
import 'package:one_key/provider/coupon_provider.dart';
|
6
|
import 'package:one_key/provider/coupon_provider.dart';
|
|
7
|
import 'package:one_key/res/colors.dart';
|
7
|
import 'package:one_key/res/colors.dart';
|
|
|
|
8
|
+import 'package:one_key/utils/event_bus.dart';
|
|
8
|
import 'package:one_key/utils/navigator_util.dart';
|
9
|
import 'package:one_key/utils/navigator_util.dart';
|
|
|
|
10
|
+import 'package:one_key/utils/utils.dart';
|
|
9
|
import 'package:one_key/widgets/h_empty_view.dart';
|
11
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
10
|
import 'package:one_key/widgets/page_exception.dart';
|
12
|
import 'package:one_key/widgets/page_exception.dart';
|
|
11
|
import 'package:one_key/widgets/round_button.dart';
|
13
|
import 'package:one_key/widgets/round_button.dart';
|
|
@@ -49,6 +51,7 @@ class _CouponSelectPageState extends State<CouponSelectPage> { |
|
@@ -49,6 +51,7 @@ class _CouponSelectPageState extends State<CouponSelectPage> { |
|
49
|
'优惠券',
|
51
|
'优惠券',
|
|
50
|
onTap: () {
|
52
|
onTap: () {
|
|
51
|
Navigator.pop(context);
|
53
|
Navigator.pop(context);
|
|
|
|
54
|
+ Utils.changeStatusColor(color: Colors.transparent);
|
|
52
|
},
|
55
|
},
|
|
53
|
rightImgName: couponProvider.checkValue ? '取消全选' : '全选',
|
56
|
rightImgName: couponProvider.checkValue ? '取消全选' : '全选',
|
|
54
|
onTapRight: () {
|
57
|
onTapRight: () {
|
|
@@ -59,117 +62,124 @@ class _CouponSelectPageState extends State<CouponSelectPage> { |
|
@@ -59,117 +62,124 @@ class _CouponSelectPageState extends State<CouponSelectPage> { |
|
59
|
}
|
62
|
}
|
|
60
|
},
|
63
|
},
|
|
61
|
),
|
64
|
),
|
|
62
|
- body: Column(
|
|
|
|
63
|
- children: [
|
|
|
|
64
|
- Expanded(child: Consumer<CouponProvider>(
|
|
|
|
65
|
- builder: (context, model, _) {
|
|
|
|
66
|
- if (model.pageStateSelect != PageState.Success) {
|
|
|
|
67
|
- return ExceptionPage(
|
|
|
|
68
|
- pageState: model.pageStateSelect,
|
|
|
|
69
|
- callback: () {
|
|
|
|
70
|
- // offset = 0;
|
|
|
|
71
|
- // getMessage(showLoading: true);
|
65
|
+ body: WillPopScope(
|
|
|
|
66
|
+ child: Column(
|
|
|
|
67
|
+ children: [
|
|
|
|
68
|
+ Expanded(child: Consumer<CouponProvider>(
|
|
|
|
69
|
+ builder: (context, model, _) {
|
|
|
|
70
|
+ if (model.pageStateSelect != PageState.Success) {
|
|
|
|
71
|
+ return ExceptionPage(
|
|
|
|
72
|
+ pageState: model.pageStateSelect,
|
|
|
|
73
|
+ callback: () {
|
|
|
|
74
|
+ // offset = 0;
|
|
|
|
75
|
+ // getMessage(showLoading: true);
|
|
|
|
76
|
+ },
|
|
|
|
77
|
+ emptyMsg: "暂时没有列表信息哦",
|
|
|
|
78
|
+ emptyImg: "empty_search",
|
|
|
|
79
|
+ showMsg: "加载中,请稍后...",
|
|
|
|
80
|
+ );
|
|
|
|
81
|
+ } else {
|
|
|
|
82
|
+ return EasyRefresh.custom(
|
|
|
|
83
|
+ controller: _controller,
|
|
|
|
84
|
+ shrinkWrap: true,
|
|
|
|
85
|
+ slivers: [
|
|
|
|
86
|
+ SliverList(
|
|
|
|
87
|
+ delegate: SliverChildBuilderDelegate(
|
|
|
|
88
|
+ (BuildContext context, int index) {
|
|
|
|
89
|
+ return InkWell(
|
|
|
|
90
|
+ onTap: () {
|
|
|
|
91
|
+ couponProvider.listData[index]['checked'] =
|
|
|
|
92
|
+ !couponProvider.listData[index]['checked'];
|
|
|
|
93
|
+ if (couponProvider.listData[index]['checked']) {
|
|
|
|
94
|
+ couponProvider.addData(index);
|
|
|
|
95
|
+ } else {
|
|
|
|
96
|
+ couponProvider.cancelData(index);
|
|
|
|
97
|
+ }
|
|
|
|
98
|
+ couponProvider.getCheckValue();
|
|
|
|
99
|
+ },
|
|
|
|
100
|
+ child: Row(
|
|
|
|
101
|
+ children: [
|
|
|
|
102
|
+ HEmptyView(30),
|
|
|
|
103
|
+ Checkbox(
|
|
|
|
104
|
+ value: couponProvider.listData[index]
|
|
|
|
105
|
+ ['checked'],
|
|
|
|
106
|
+ checkColor: MyColours.color_ffffff,
|
|
|
|
107
|
+ activeColor: MyColours.app_main,
|
|
|
|
108
|
+ onChanged: (bool value) {
|
|
|
|
109
|
+ couponProvider.listData[index]['checked'] =
|
|
|
|
110
|
+ !couponProvider.listData[index]
|
|
|
|
111
|
+ ['checked'];
|
|
|
|
112
|
+ if (couponProvider.listData[index]
|
|
|
|
113
|
+ ['checked']) {
|
|
|
|
114
|
+ couponProvider.addData(index);
|
|
|
|
115
|
+ } else {
|
|
|
|
116
|
+ couponProvider.cancelData(index);
|
|
|
|
117
|
+ }
|
|
|
|
118
|
+ couponProvider.getCheckValue();
|
|
|
|
119
|
+ },
|
|
|
|
120
|
+ ),
|
|
|
|
121
|
+ // Image.asset(
|
|
|
|
122
|
+ // couponProvider.listData[index]['checked']
|
|
|
|
123
|
+ // ? 'assets/select.png'
|
|
|
|
124
|
+ // : 'assets/unselect.png',
|
|
|
|
125
|
+ // width: ScreenUtil().setWidth(44)),
|
|
|
|
126
|
+ Expanded(
|
|
|
|
127
|
+ child: CouponItem(
|
|
|
|
128
|
+ index: index,
|
|
|
|
129
|
+ couponProvider: couponProvider,
|
|
|
|
130
|
+ onPressed: () {
|
|
|
|
131
|
+ couponProvider.listData[index]['checked'] =
|
|
|
|
132
|
+ !couponProvider.listData[index]
|
|
|
|
133
|
+ ['checked'];
|
|
|
|
134
|
+ if (couponProvider.listData[index]
|
|
|
|
135
|
+ ['checked']) {
|
|
|
|
136
|
+ couponProvider.addData(index);
|
|
|
|
137
|
+ } else {
|
|
|
|
138
|
+ couponProvider.cancelData(index);
|
|
|
|
139
|
+ }
|
|
|
|
140
|
+ couponProvider.getCheckValue();
|
|
|
|
141
|
+ },
|
|
|
|
142
|
+ ))
|
|
|
|
143
|
+ ],
|
|
|
|
144
|
+ ),
|
|
|
|
145
|
+ );
|
|
|
|
146
|
+ }, childCount: couponProvider.listData.length),
|
|
|
|
147
|
+ )
|
|
|
|
148
|
+ ],
|
|
|
|
149
|
+ onRefresh: () async {
|
|
|
|
150
|
+ // offset = 0;
|
|
|
|
151
|
+ // getMessage(showLoading: false);
|
|
|
|
152
|
+ },
|
|
|
|
153
|
+ onLoad: () async {
|
|
|
|
154
|
+ // offset++;
|
|
|
|
155
|
+ // getMessage(showLoading: false);
|
|
|
|
156
|
+ },
|
|
|
|
157
|
+ );
|
|
|
|
158
|
+ }
|
|
|
|
159
|
+ },
|
|
|
|
160
|
+ )),
|
|
|
|
161
|
+ VEmptyView(20),
|
|
|
|
162
|
+ Padding(
|
|
|
|
163
|
+ padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
|
|
|
|
164
|
+ ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
|
|
|
|
165
|
+ child: RoundButton(
|
|
|
|
166
|
+ onPressed: () {
|
|
|
|
167
|
+ Navigator.pop(context);
|
|
72
|
},
|
168
|
},
|
|
73
|
- emptyMsg: "暂时没有列表信息哦",
|
|
|
|
74
|
- emptyImg: "empty_search",
|
|
|
|
75
|
- showMsg: "加载中,请稍后...",
|
|
|
|
76
|
- );
|
|
|
|
77
|
- } else {
|
|
|
|
78
|
- return EasyRefresh.custom(
|
|
|
|
79
|
- controller: _controller,
|
|
|
|
80
|
- shrinkWrap: true,
|
|
|
|
81
|
- slivers: [
|
|
|
|
82
|
- SliverList(
|
|
|
|
83
|
- delegate: SliverChildBuilderDelegate(
|
|
|
|
84
|
- (BuildContext context, int index) {
|
|
|
|
85
|
- return InkWell(
|
|
|
|
86
|
- onTap: () {
|
|
|
|
87
|
- couponProvider.listData[index]['checked'] =
|
|
|
|
88
|
- !couponProvider.listData[index]['checked'];
|
|
|
|
89
|
- if (couponProvider.listData[index]['checked']) {
|
|
|
|
90
|
- couponProvider.addData(index);
|
|
|
|
91
|
- } else {
|
|
|
|
92
|
- couponProvider.cancelData(index);
|
|
|
|
93
|
- }
|
|
|
|
94
|
- couponProvider.getCheckValue();
|
|
|
|
95
|
- },
|
|
|
|
96
|
- child: Row(
|
|
|
|
97
|
- children: [
|
|
|
|
98
|
- HEmptyView(30),
|
|
|
|
99
|
- Checkbox(
|
|
|
|
100
|
- value: couponProvider.listData[index]
|
|
|
|
101
|
- ['checked'],
|
|
|
|
102
|
- checkColor: MyColours.color_ffffff,
|
|
|
|
103
|
- activeColor: MyColours.app_main,
|
|
|
|
104
|
- onChanged: (bool value) {
|
|
|
|
105
|
- couponProvider.listData[index]['checked'] =
|
|
|
|
106
|
- !couponProvider.listData[index]
|
|
|
|
107
|
- ['checked'];
|
|
|
|
108
|
- if (couponProvider.listData[index]
|
|
|
|
109
|
- ['checked']) {
|
|
|
|
110
|
- couponProvider.addData(index);
|
|
|
|
111
|
- } else {
|
|
|
|
112
|
- couponProvider.cancelData(index);
|
|
|
|
113
|
- }
|
|
|
|
114
|
- couponProvider.getCheckValue();
|
|
|
|
115
|
- },
|
|
|
|
116
|
- ),
|
|
|
|
117
|
- // Image.asset(
|
|
|
|
118
|
- // couponProvider.listData[index]['checked']
|
|
|
|
119
|
- // ? 'assets/select.png'
|
|
|
|
120
|
- // : 'assets/unselect.png',
|
|
|
|
121
|
- // width: ScreenUtil().setWidth(44)),
|
|
|
|
122
|
- Expanded(
|
|
|
|
123
|
- child: CouponItem(
|
|
|
|
124
|
- index: index,
|
|
|
|
125
|
- couponProvider: couponProvider,
|
|
|
|
126
|
- onPressed: () {
|
|
|
|
127
|
- couponProvider.listData[index]['checked'] =
|
|
|
|
128
|
- !couponProvider.listData[index]
|
|
|
|
129
|
- ['checked'];
|
|
|
|
130
|
- if (couponProvider.listData[index]
|
|
|
|
131
|
- ['checked']) {
|
|
|
|
132
|
- couponProvider.addData(index);
|
|
|
|
133
|
- } else {
|
|
|
|
134
|
- couponProvider.cancelData(index);
|
|
|
|
135
|
- }
|
|
|
|
136
|
- couponProvider.getCheckValue();
|
|
|
|
137
|
- },
|
|
|
|
138
|
- ))
|
|
|
|
139
|
- ],
|
|
|
|
140
|
- ),
|
|
|
|
141
|
- );
|
|
|
|
142
|
- }, childCount: couponProvider.listData.length),
|
|
|
|
143
|
- )
|
|
|
|
144
|
- ],
|
|
|
|
145
|
- onRefresh: () async {
|
|
|
|
146
|
- // offset = 0;
|
|
|
|
147
|
- // getMessage(showLoading: false);
|
|
|
|
148
|
- },
|
|
|
|
149
|
- onLoad: () async {
|
|
|
|
150
|
- // offset++;
|
|
|
|
151
|
- // getMessage(showLoading: false);
|
|
|
|
152
|
- },
|
|
|
|
153
|
- );
|
|
|
|
154
|
- }
|
|
|
|
155
|
- },
|
|
|
|
156
|
- )),
|
|
|
|
157
|
- VEmptyView(20),
|
|
|
|
158
|
- Padding(
|
|
|
|
159
|
- padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
|
|
|
|
160
|
- ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
|
|
|
|
161
|
- child: RoundButton(
|
|
|
|
162
|
- onPressed: () {
|
|
|
|
163
|
- Navigator.pop(context);
|
|
|
|
164
|
- },
|
|
|
|
165
|
- text: '已选${couponProvider.coupons.length}个 确定',
|
|
|
|
166
|
- fontSize: 34,
|
|
|
|
167
|
- isBold: false,
|
|
|
|
168
|
- height: ScreenUtil().setWidth(80),
|
|
|
|
169
|
- width: double.infinity,
|
|
|
|
170
|
- radius: ScreenUtil().setWidth(10),
|
|
|
|
171
|
- ))
|
|
|
|
172
|
- ],
|
169
|
+ text: '已选${couponProvider.coupons.length}个 确定',
|
|
|
|
170
|
+ fontSize: 34,
|
|
|
|
171
|
+ isBold: false,
|
|
|
|
172
|
+ height: ScreenUtil().setWidth(80),
|
|
|
|
173
|
+ width: double.infinity,
|
|
|
|
174
|
+ radius: ScreenUtil().setWidth(10),
|
|
|
|
175
|
+ ))
|
|
|
|
176
|
+ ],
|
|
|
|
177
|
+ ),
|
|
|
|
178
|
+ onWillPop: () async {
|
|
|
|
179
|
+ Utils.changeStatusColor(color: Colors.transparent);
|
|
|
|
180
|
+ Navigator.of(context).pop();
|
|
|
|
181
|
+ return true;
|
|
|
|
182
|
+ },
|
|
173
|
),
|
183
|
),
|
|
174
|
);
|
184
|
);
|
|
175
|
}
|
185
|
}
|