瀏覽代碼

'首页删除刷新功能改成全屏滚动'

李志伟 2 年之前
父節點
當前提交
308241952f
共有 2 個文件被更改,包括 67 次插入65 次删除
  1. 54
    56
      lib/pages/home/index.dart
  2. 13
    9
      lib/widgets/RefreshMoreList.dart

+ 54
- 56
lib/pages/home/index.dart 查看文件

@@ -34,67 +34,65 @@ class Home extends BasicPage {
34 34
     return Container(
35 35
       decoration: const BoxDecoration(color: Colors.white),
36 36
       padding: EdgeInsets.fromLTRB(15.w, 5.w, 15.w, 0),
37
-      child: Column(
38
-        children: [
39
-          const searchBannerHeader(),
40
-          Row(
41
-            mainAxisAlignment: MainAxisAlignment.spaceBetween,
37
+      child: RefreshMoreList(
38
+        pPrams: params,
39
+        cardText: '暂无农机',
40
+        fetch: getMachinery,
41
+        isHome: true,
42
+        useState: (state) {
43
+          machineryList(GetList(state));
44
+        },
45
+        builder: ({required BuildContext context, required Function toggle}) {
46
+          Refresh = toggle;
47
+          return Column(
42 48
             children: [
43
-              Container(
44
-                padding: EdgeInsets.symmetric(vertical: 15.h),
45
-                child: Row(
46
-                  children: [
47
-                    Padding(
48
-                      padding: const EdgeInsets.only(right: 8),
49
-                      child: Image(
50
-                        image:
51
-                            const AssetImage('images/icons/carsListImga.png'),
52
-                        fit: BoxFit.cover,
53
-                        width: 20.w,
54
-                      ),
49
+              const searchBannerHeader(),
50
+              Row(
51
+                mainAxisAlignment: MainAxisAlignment.spaceBetween,
52
+                children: [
53
+                  Container(
54
+                    padding: EdgeInsets.symmetric(vertical: 15.h),
55
+                    child: Row(
56
+                      children: [
57
+                        Padding(
58
+                          padding: const EdgeInsets.only(right: 8),
59
+                          child: Image(
60
+                            image: const AssetImage(
61
+                                'images/icons/carsListImga.png'),
62
+                            fit: BoxFit.cover,
63
+                            width: 20.w,
64
+                          ),
65
+                        ),
66
+                        Text(
67
+                          '农机列表',
68
+                          style: TextStyle(
69
+                              color: const Color(0xff222222),
70
+                              fontSize: 20.sp,
71
+                              fontWeight: FontWeight.bold),
72
+                        )
73
+                      ],
55 74
                     ),
56
-                    Text(
57
-                      '农机列表',
58
-                      style: TextStyle(
59
-                          color: const Color(0xff222222),
60
-                          fontSize: 20.sp,
61
-                          fontWeight: FontWeight.bold),
62
-                    )
63
-                  ],
75
+                  ),
76
+                  GestureDetector(
77
+                    child: const Text('更多 >>'),
78
+                    onTap: () {
79
+                      Get.to(const MoreCars());
80
+                    },
81
+                  )
82
+                ],
83
+              ),
84
+              Obx(
85
+                () => Column(
86
+                  children: machineryList.value
87
+                      .map(
88
+                        (item) => CarsCard(item: item),
89
+                      )
90
+                      .toList(),
64 91
                 ),
65 92
               ),
66
-              GestureDetector(
67
-                child: const Text('更多 >>'),
68
-                onTap: () {
69
-                  Get.to(const MoreCars());
70
-                },
71
-              )
72 93
             ],
73
-          ),
74
-          Expanded(
75
-            child: RefreshMoreList(
76
-              pPrams: params,
77
-              cardText: '暂无农机',
78
-              fetch: getMachinery,
79
-              useState: (state) {
80
-                machineryList(GetList(state));
81
-              },
82
-              builder: (
83
-                  {required BuildContext context, required Function toggle}) {
84
-                Refresh = toggle;
85
-                return Obx(
86
-                  () => Column(
87
-                    children: machineryList.value
88
-                        .map(
89
-                          (item) => CarsCard(item: item),
90
-                        )
91
-                        .toList(),
92
-                  ),
93
-                );
94
-              },
95
-            ),
96
-          ),
97
-        ],
94
+          );
95
+        },
98 96
       ),
99 97
     );
100 98
   }

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

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