[baozhangchao] 3 лет назад
Родитель
Сommit
66ec43dabe

+ 45
- 68
lib/pages/MoreCars/index.dart Просмотреть файл

@@ -50,78 +50,55 @@ class _MoreCarsState extends State<MoreCars> with TickerProviderStateMixin  {
50 50
         ),
51 51
 
52 52
       ),
53
-      body: ListView(
54
-          children: [Column(
55
-          children: [
56
-            Container(
57
-              padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
58
-
59
-              decoration: BoxDecoration(
60
-                color: Colors.white
61
-              ),
62
-              // child:Search(),
63
-              child:          Container(
64
-                  height: 32.w,
65
-                  decoration: const BoxDecoration(
66
-                      color: Colors.white
67
-                  ),
68
-                  child: GestureDetector(
69
-                      onTap: (){
70
-                        print('点击了搜索');
71
-                      },
72
-                      child: Container(
73
-                        decoration: const BoxDecoration(
74
-                          // color: Colors.red,
75
-                          color: Color(0x30cccccc),
76
-                          borderRadius: BorderRadius.all(Radius.circular(25)),
77
-                        ),
78
-                        child: Row(
79
-                          children: [
80
-                            Padding(padding: EdgeInsets.fromLTRB(15, 0, 5, 0),
81
-                              child: Icon(Icons.search,size: 19,color:Color(0xff666666) ,),
82
-                            ),
83
-                            Text('请输入关键字查询',style: TextStyle(color: Color(0xff666666),fontSize: 14),)
84
-                          ],
85
-                        ),
86
-                      )
87
-                    // Search(),
53
+      body: Container(
54
+        decoration: BoxDecoration(
55
+            color: Colors.white
56
+        ),
57
+        child:       ListView(
58
+            children: [Column(
59
+              children: [
60
+                Container(
61
+                  padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
62
+                  width: 350.w,
63
+                  child: TypeHeader(type: false,),
64
+                ),
65
+
66
+                TabBar(
67
+                  labelStyle: TextStyle(fontSize: ScreenUtil().setSp(19),fontWeight: FontWeight.bold), //选中的样式
68
+                  unselectedLabelStyle: TextStyle(fontSize:ScreenUtil().setSp(16)), //未选中的样式
69
+                  controller: _controller,
70
+                  isScrollable: true, //可滚动
71
+                  indicatorColor: Colors.black, //指示器的颜色
72
+                  labelColor: Colors.black, //选中文字颜色
73
+                  unselectedLabelColor: Color(0xffadadad),
74
+                  // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
75
+                  tabs: tabText.map((e) => Tab(text: e)).toList(),
76
+                  onTap: (int i) {
77
+                    print('当前+${i}');
78
+                  },
79
+
80
+                ),
81
+                Container(
82
+                  child: Column(
83
+                    children: [
84
+                      CarsCard(),
85
+                      CarsCard(),
86
+                      CarsCard(),
87
+                      CarsCard(),
88
+                    ],
88 89
                   )
89
-              ),
90
-            ),
91
-            
92
-            TabBar(
93
-              labelStyle: TextStyle(fontSize: ScreenUtil().setSp(19),fontWeight: FontWeight.bold), //选中的样式
94
-              unselectedLabelStyle: TextStyle(fontSize:ScreenUtil().setSp(16)), //未选中的样式
95
-              controller: _controller,
96
-              isScrollable: true, //可滚动
97
-              indicatorColor: Colors.black, //指示器的颜色
98
-              labelColor: Colors.black, //选中文字颜色
99
-              unselectedLabelColor: Color(0xffadadad),
100
-              // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
101
-              tabs: tabText.map((e) => Tab(text: e)).toList(),
102
-              onTap: (int i) {
103
-                print('当前+${i}');
104
-              },
105
-
106
-            ),
107
-            Container(
108
-              child: Column(
109
-                children: [
110
-                  CarsCard(),
111
-                  CarsCard(),
112
-                  CarsCard(),
113
-                  CarsCard(),
114
-                ],
115
-              )
116
-              ,
117
-            )
118
-
119
-
120
-          ],
121
-        )]
90
+                  ,
91
+                )
92
+
93
+
94
+              ],
95
+            )]
122 96
 
97
+        ),
123 98
       )
124 99
 
100
+
101
+
125 102
     );
126 103
   }
127 104
 }

+ 3
- 1
lib/pages/TabBar/widgets/home/index.dart Просмотреть файл

@@ -34,7 +34,9 @@ class _HomePageState extends State<HomePage> {
34 34
       padding: EdgeInsets.fromLTRB(15.w, 0, 15.w, 0),
35 35
       child: ListView(
36 36
         children: [
37
-          headers(),
37
+
38
+          TypeHeader(type: true,),
39
+
38 40
           Container(
39 41
             margin: EdgeInsets.fromLTRB(0, 15, 0, 0),
40 42
             child: CarouselSlider(

+ 113
- 59
lib/pages/TabBar/widgets/home/widgets/headers.dart Просмотреть файл

@@ -1,73 +1,127 @@
1 1
 import 'package:flutter/material.dart';
2 2
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 3
 
4
+class TypeHeader extends StatefulWidget {
5
+  TypeHeader({Key? key, required this.type}) : super(key: key);
4 6
 
5
-class headers extends StatelessWidget {
6
-  const headers({Key? key}) : super(key: key);
7
+  final bool type;
7 8
 
9
+  @override
10
+  State<TypeHeader> createState() => _TypeHeaderState();
11
+}
12
+
13
+class _TypeHeaderState extends State<TypeHeader> {
8 14
   @override
9 15
   Widget build(BuildContext context) {
10
-    return Container(
11
-      child:           Row(
12
-        children: [
13
-          Container(
14
-            height: 32.w,
15
-            decoration: BoxDecoration(
16
-                color: Colors.white
17
-            ),
18
-            child: Row(
19
-              children: [
20
-                Image(
21
-                  image: AssetImage('images/gpsImgae.png'),
22
-                  fit: BoxFit.cover,
23
-                  width: 14.w,
24
-                  height: 17.h,
25
-                ),
26
-                Padding(padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
27
-                  child: Text('邓州市',
28
-                    style: TextStyle(
29
-                      color: Color(0xff202020),
30
-                      fontSize: 16.sp,
31
-                      fontWeight: FontWeight.bold,
16
+    if (widget.type) {
17
+      return Container(
18
+        child: Row(
19
+          children: [
20
+            Container(
21
+              height: 32.w,
22
+              decoration: BoxDecoration(color: Colors.white),
23
+              child: Row(
24
+                children: [
25
+                  Image(
26
+                    image: AssetImage('images/gpsImgae.png'),
27
+                    fit: BoxFit.cover,
28
+                    width: 14.w,
29
+                    height: 17.h,
30
+                  ),
31
+                  Padding(
32
+                    padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
33
+                    child: Text(
34
+                      '邓州市',
35
+                      style: TextStyle(
36
+                        color: Color(0xff202020),
37
+                        fontSize: 16.sp,
38
+                        fontWeight: FontWeight.bold,
39
+                      ),
32 40
                     ),
33 41
                   ),
34
-                ),
35
-                const Icon(Icons.arrow_drop_down)
36
-              ],
37
-
38
-            ),
39
-          ),
40
-          Container(
41
-              padding: EdgeInsets.fromLTRB(15.w, 0, 0, 0),
42
-              width: 260.w,
43
-              height: 32.w,
44
-              decoration: const BoxDecoration(
45
-                  color: Colors.white
42
+                  const Icon(Icons.arrow_drop_down),
43
+                  Container(
44
+                      padding: EdgeInsets.fromLTRB(15.w, 0, 0, 0),
45
+                      width: 260.w,
46
+                      height: 32.w,
47
+                      decoration: const BoxDecoration(color: Colors.white),
48
+                      child: GestureDetector(
49
+                          onTap: () {
50
+                            print('点击了搜索');
51
+                          },
52
+                          child: Container(
53
+                            decoration: const BoxDecoration(
54
+                              // color: Colors.red,
55
+                              color: Color(0x30cccccc),
56
+                              borderRadius:
57
+                                  BorderRadius.all(Radius.circular(25)),
58
+                            ),
59
+                            child: Row(
60
+                              children: [
61
+                                Padding(
62
+                                  padding: EdgeInsets.fromLTRB(15, 0, 5, 0),
63
+                                  child: Icon(
64
+                                    Icons.search,
65
+                                    size: 19,
66
+                                    color: Color(0xff666666),
67
+                                  ),
68
+                                ),
69
+                                Text(
70
+                                  '请输入关键字查询',
71
+                                  style: TextStyle(
72
+                                      color: Color(0xff666666), fontSize: 14),
73
+                                )
74
+                              ],
75
+                            ),
76
+                          )
77
+                          // Search(),
78
+                          )),
79
+                ],
46 80
               ),
47
-              child: GestureDetector(
48
-                  onTap: (){
49
-                    print('点击了搜索');
50
-                  },
51
-                  child: Container(
52
-                    decoration: const BoxDecoration(
53
-                      // color: Colors.red,
54
-                      color: Color(0x30cccccc),
55
-                      borderRadius: BorderRadius.all(Radius.circular(25)),
56
-                    ),
57
-                    child: Row(
58
-                      children: [
59
-                        Padding(padding: EdgeInsets.fromLTRB(15, 0, 5, 0),
60
-                          child: Icon(Icons.search,size: 19,color:Color(0xff666666) ,),
61
-                        ),
62
-                        Text('请输入关键字查询',style: TextStyle(color: Color(0xff666666),fontSize: 14),)
63
-                      ],
81
+            ),
82
+          ],
83
+        ),
84
+      );
85
+    } else {
86
+      return Container(
87
+          padding: EdgeInsets.fromLTRB(15.w, 0, 0, 0),
88
+          width: 260.w,
89
+          height: 32.w,
90
+          decoration: const BoxDecoration(color: Colors.white),
91
+          child: GestureDetector(
92
+              onTap: () {
93
+                print('点击了搜索');
94
+              },
95
+              child: Container(
96
+                decoration: const BoxDecoration(
97
+                  // color: Colors.red,
98
+                  color: Color(0x30cccccc),
99
+                  borderRadius: BorderRadius.all(Radius.circular(25)),
100
+                ),
101
+                child: Row(
102
+                  children: [
103
+                    Padding(
104
+                      padding: EdgeInsets.fromLTRB(15, 0, 5, 0),
105
+                      child: Icon(
106
+                        Icons.search,
107
+                        size: 19,
108
+                        color: Color(0xff666666),
109
+                      ),
64 110
                     ),
65
-                  )
66
-                // Search(),
111
+                    Text(
112
+                      '请输入关键字查询',
113
+                      style: TextStyle(color: Color(0xff666666), fontSize: 14),
114
+                    )
115
+                  ],
116
+                ),
67 117
               )
68
-          )
69
-        ],
70
-      ),
71
-    );
118
+              // Search(),
119
+              ));
120
+    }
72 121
   }
73 122
 }
123
+
124
+// Widget _initWidget (TypeHeader flag) {
125
+//
126
+//
127
+// }