瀏覽代碼

'首页改为全屏滚动去掉刷新功能'

李志伟 3 年之前
父節點
當前提交
897e356e81
共有 2 個檔案被更改,包括 87 行新增88 行删除
  1. 76
    79
      lib/pages/home/index.dart
  2. 11
    9
      lib/widgets/RefreshMoreList.dart

+ 76
- 79
lib/pages/home/index.dart 查看文件

@@ -198,87 +198,84 @@ class Home extends BasicPage {
198 198
     return Container(
199 199
       decoration: const BoxDecoration(color: Colors.white),
200 200
       padding: EdgeInsets.only(top: 15.w, left: 15.w, right: 15.w),
201
-      child: Column(
202
-        children: [
203
-          const headers(),
204
-          //banner
205
-          Container(
206
-            margin: EdgeInsets.fromLTRB(0, 15.h, 0, 15.h),
207
-            child: Obx(() => CarouselSlider(
208
-                  items: bannerList.value
209
-                      .map((item) => Center(
210
-                          child: Image.network(item.thumb.toString(),
211
-                              fit: BoxFit.cover, width: 345.w)))
201
+      child: RefreshMoreList(
202
+        pPrams: params,
203
+        cardText: '暂无订单',
204
+        fetch: getJobList,
205
+        isHome: true,
206
+        useState: (state) {
207
+          jobList(GetList(state));
208
+        },
209
+        builder: ({required BuildContext context, required Function toggle}) {
210
+          Refresh = toggle;
211
+          return Column(
212
+            children: [
213
+              const headers(),
214
+              //banner
215
+              Container(
216
+                margin: EdgeInsets.fromLTRB(0, 15.h, 0, 15.h),
217
+                child: Obx(() => CarouselSlider(
218
+                      items: bannerList.value
219
+                          .map((item) => Center(
220
+                              child: Image.network(item.thumb.toString(),
221
+                                  fit: BoxFit.cover, width: 345.w)))
222
+                          .toList(),
223
+                      options: CarouselOptions(
224
+                        autoPlay: true,
225
+                        enlargeCenterPage: false,
226
+                        //图片中心放大
227
+                        viewportFraction: 1,
228
+                        //每个页面应占据的视口部分。默认为 0.8,这意味着每个页面填充 80% 的轮播。
229
+                        // aspectRatio: 1.6,//纵横比
230
+                        height: 214.w,
231
+                        initialPage: 1, //初始页
232
+                      ),
233
+                    )),
234
+              ),
235
+              Container(
236
+                margin: EdgeInsets.fromLTRB(0, 15.h, 0, 20.h),
237
+                child: Row(
238
+                  children: [
239
+                    Padding(
240
+                      padding: EdgeInsets.fromLTRB(0, 0, 10.w, 0),
241
+                      child: Image.asset(
242
+                        'images/index/orderList.png',
243
+                        width: 20.w,
244
+                      ),
245
+                    ),
246
+                    Text(
247
+                      '作业列表',
248
+                      style: TextStyle(
249
+                          color: Color(0xff222222),
250
+                          fontSize: 20.sp,
251
+                          fontWeight: FontWeight.w800),
252
+                    )
253
+                  ],
254
+                ),
255
+              ),
256
+              Obx(
257
+                () => Column(
258
+                  children: jobList.value
259
+                      .map(
260
+                        (item) => MyCard(
261
+                          item: item,
262
+                          job: true,
263
+                          detail: false,
264
+                          onClick: () {
265
+                            changeJob(item);
266
+                          },
267
+                          goDetail: () {
268
+                            goDetail(item);
269
+                          },
270
+                          buttomText: item.status == 0 ? '开始作业' : '完成作业',
271
+                        ),
272
+                      )
212 273
                       .toList(),
213
-                  options: CarouselOptions(
214
-                    autoPlay: true,
215
-                    enlargeCenterPage: false,
216
-                    //图片中心放大
217
-                    viewportFraction: 1,
218
-                    //每个页面应占据的视口部分。默认为 0.8,这意味着每个页面填充 80% 的轮播。
219
-                    // aspectRatio: 1.6,//纵横比
220
-                    height: 214.w,
221
-                    initialPage: 1, //初始页
222
-                  ),
223
-                )),
224
-          ),
225
-          Container(
226
-            margin: EdgeInsets.fromLTRB(0, 15.h, 0, 20.h),
227
-            child: Row(
228
-              children: [
229
-                Padding(
230
-                  padding: EdgeInsets.fromLTRB(0, 0, 10.w, 0),
231
-                  child: Image.asset(
232
-                    'images/index/orderList.png',
233
-                    width: 20.w,
234
-                  ),
235 274
                 ),
236
-                Text(
237
-                  '作业列表',
238
-                  style: TextStyle(
239
-                      color: Color(0xff222222),
240
-                      fontSize: 20.sp,
241
-                      fontWeight: FontWeight.w800),
242
-                )
243
-              ],
244
-            ),
245
-          ),
246
-          Expanded(
247
-            flex: 1,
248
-            child: RefreshMoreList(
249
-              pPrams: params,
250
-              cardText: '暂无订单',
251
-              fetch: getJobList,
252
-              useState: (state) {
253
-                jobList(GetList(state));
254
-              },
255
-              builder: (
256
-                  {required BuildContext context, required Function toggle}) {
257
-                Refresh = toggle;
258
-                return Obx(
259
-                  () => Column(
260
-                    children: jobList.value
261
-                        .map(
262
-                          (item) => MyCard(
263
-                            item: item,
264
-                            job: true,
265
-                            detail: false,
266
-                            onClick: () {
267
-                              changeJob(item);
268
-                            },
269
-                            goDetail: () {
270
-                              goDetail(item);
271
-                            },
272
-                            buttomText: item.status == 0 ? '开始作业' : '完成作业',
273
-                          ),
274
-                        )
275
-                        .toList(),
276
-                  ),
277
-                );
278
-              },
279
-            ),
280
-          )
281
-        ],
275
+              )
276
+            ],
277
+          );
278
+        },
282 279
       ),
283 280
     );
284 281
   }

+ 11
- 9
lib/widgets/RefreshMoreList.dart 查看文件

@@ -11,10 +11,12 @@ class RefreshMoreList extends StatefulWidget {
11 11
     required this.fetch,
12 12
     required this.builder,
13 13
     required this.useState,
14
+    this.isHome,
14 15
   }) : super(key: key);
15 16
   final String cardText;
16 17
   final Rx<Map<String, dynamic>> pPrams;
17 18
   final Function fetch;
19
+  bool? isHome;
18 20
   Function(List<dynamic> state) useState;
19 21
   Widget Function({
20 22
     required BuildContext context,
@@ -104,15 +106,15 @@ class _RefreshMoreList extends State<RefreshMoreList> {
104 106
           infoColor: const Color(0xff666666),
105 107
         ),
106 108
         // firstRefresh: true,//是否首次刷新
107
-        onRefresh: () async {
108
-          await Future.delayed(const Duration(seconds: 1), () {
109
-            // print("下拉刷新-----");
110
-            getNewData();
111
-            _count = dataList.value.length;
112
-            // print("最新条数" + _count.toString());
113
-            _controller.resetLoadState();
114
-          });
115
-        },
109
+        onRefresh: widget.isHome != null
110
+            ? null
111
+            : () async {
112
+                await Future.delayed(const Duration(seconds: 1), () {
113
+                  getNewData();
114
+                  _count = dataList.value.length;
115
+                  _controller.resetLoadState();
116
+                });
117
+              },
116 118
         onLoad: () async {
117 119
           await Future.delayed(const Duration(seconds: 1), () {
118 120
             // print("上拉加载-----");