张延森 před 3 roky
rodič
revize
fe1c535b67

+ 1
- 0
lib/pages/index.dart Zobrazit soubor

@@ -3,4 +3,5 @@ export 'TabBar/index.dart';
3 3
 export 'splash/splash.dart';
4 4
 export 'login/login.dart';
5 5
 export 'machinery/map/index.dart';
6
+export 'machinery/detail/index.dart';
6 7
 // export 'main/index.dart';

+ 25
- 0
lib/pages/machinery/detail/index.dart Zobrazit soubor

@@ -0,0 +1,25 @@
1
+
2
+import 'package:flutter/material.dart';
3
+import 'package:get/get.dart';
4
+import 'widgets/detail.dart';
5
+
6
+class MachineryDetailPage extends StatelessWidget {
7
+
8
+  final title = Rx<String>('查看详情');
9
+
10
+  // 响应预约事件
11
+  void handleClick() {
12
+
13
+  }
14
+
15
+  @override
16
+  Widget build(BuildContext context) {
17
+    final appBar = AppBar(title: Obx(() => Text(title.value)), centerTitle: true,);
18
+
19
+    return Scaffold(
20
+      appBar: appBar,
21
+      body: page(context: context, appbarSize: appBar.preferredSize, handleClick: handleClick),
22
+    );
23
+  }
24
+
25
+}

+ 61
- 0
lib/pages/machinery/detail/widgets/detail.dart Zobrazit soubor

@@ -0,0 +1,61 @@
1
+
2
+import 'package:flutter/widgets.dart';
3
+import 'package:flutter/material.dart';
4
+import 'package:flutter_screenutil/flutter_screenutil.dart';
5
+
6
+import '../../widgets/summary.dart';
7
+
8
+Widget page({ required BuildContext context, required Size appbarSize, required void Function() handleClick}) {
9
+  final _offset = 20.w;
10
+  final width = MediaQuery.of(context).size.width;
11
+  final height = MediaQuery.of(context).size.height
12
+      - appbarSize.height
13
+      - MediaQuery.of(context).padding.top;
14
+  final _bannerHeight = 250.w;
15
+  final img = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg';
16
+
17
+  return Stack(
18
+    alignment: Alignment.topCenter,
19
+      children: [
20
+        // 第一个组件用来撑满全屏
21
+        SizedBox(
22
+          width: width,
23
+          height: height,
24
+        ),
25
+        Positioned(
26
+          left: 0,
27
+          top: 0,
28
+          child: SizedBox(
29
+            height: _bannerHeight,
30
+            child: _banner(img),
31
+          ),
32
+        ),
33
+        Positioned(
34
+          left: 0,
35
+          top: _bannerHeight - _offset,
36
+          child: _content(context),
37
+        ),
38
+      ],
39
+  );
40
+}
41
+
42
+Widget _banner(String imgUrl) {
43
+  return Image.network(imgUrl);
44
+}
45
+
46
+Widget _content(BuildContext context) {
47
+  final _border = 20.w;
48
+  return Container(
49
+    width: MediaQuery.of(context).size.width,
50
+    padding: EdgeInsets.only(top: 45.w, left: 15.w, right: 15.w, bottom: 20.w),
51
+    decoration: BoxDecoration(
52
+      color: Colors.white,
53
+        borderRadius: BorderRadius.vertical(top: Radius.circular(_border))
54
+    ),
55
+    child: Column(
56
+      children: [
57
+        summary(),
58
+      ],
59
+    ),
60
+  );
61
+}

+ 4
- 49
lib/pages/machinery/map/widgets/detail.dart Zobrazit soubor

@@ -1,13 +1,14 @@
1 1
 
2
-
3 2
 import 'package:flutter/material.dart';
4 3
 import 'package:flutter/widgets.dart';
5 4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
6 5
 import 'package:amap_flutter_base/amap_flutter_base.dart';
7 6
 import 'package:farmer_client/widgets/amap/amap.dart';
8 7
 
8
+import '../../widgets/summary.dart';
9
+
9 10
 Widget page({ required BuildContext context, required Size appbarSize, required void Function() handleClick}) {
10
-  final _offset = 20.h;
11
+  final _offset = 20.w;
11 12
   final width = MediaQuery.of(context).size.width;
12 13
   final height = MediaQuery.of(context).size.height
13 14
       - appbarSize.height
@@ -63,47 +64,6 @@ Widget _thumb(BuildContext context, String imgUrl) {
63 64
   return _card(context, Image.network(imgUrl, fit: BoxFit.cover));
64 65
 }
65 66
 
66
-Widget _title() {
67
-  return Row(
68
-    children: [
69
-      Expanded(
70
-          child: Text("收割机001--S001",
71
-              style: TextStyle(
72
-                color: Color(0xFF222222),
73
-                fontSize: 18.sp,
74
-              )),
75
-          flex: 1),
76
-      Container(
77
-        width: 100.w,
78
-        alignment: Alignment.centerRight,
79
-        child: Text("450元",
80
-            style: TextStyle(
81
-              color: Color(0xFFB61515),
82
-              fontSize: 22.sp,
83
-            )),
84
-      )
85
-    ],
86
-  );
87
-}
88
-
89
-Widget _desc() {
90
-  return Row(
91
-    children: [
92
-      Icon(Icons.location_on_outlined, size: 16.sp,),
93
-      Expanded(
94
-        flex: 1,
95
-        child: Text("距离当前位置2.3公里 >>", style: TextStyle(color: Color(0xFF222222), fontSize: 15.sp),),
96
-      ),
97
-    ],
98
-  );
99
-}
100
-
101
-Widget _detail() {
102
-  return Container(
103
-    alignment: Alignment.centerLeft,
104
-    child: Text("农机手1的收割机", style: TextStyle(color: Color(0xFF222222), fontSize: 15.sp),),
105
-  );
106
-}
107 67
 
108 68
 Widget _button(void Function() handleClick) {
109 69
   return ElevatedButton(
@@ -130,12 +90,7 @@ Widget _content(BuildContext context, void Function() handleClick) {
130 90
     child: Column(
131 91
 
132 92
       children: [
133
-        _title(),
134
-        SizedBox(height: 20.h,),
135
-        _desc(),
136
-        SizedBox(height: 20.h,),
137
-        _detail(),
138
-        SizedBox(height: 20.h,),
93
+        summary(),
139 94
         _button(handleClick),
140 95
       ],
141 96
     ),

+ 90
- 0
lib/pages/machinery/widgets/summary.dart Zobrazit soubor

@@ -0,0 +1,90 @@
1
+import 'dart:ui' as ui;
2
+import 'package:flutter/material.dart';
3
+import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+
5
+import 'package:farmer_client/widgets/LinearGradientText.dart';
6
+
7
+Widget summary() {
8
+  return Column(
9
+    children: [
10
+      _title(),
11
+      SizedBox(height: 20.w,),
12
+      _desc(),
13
+      SizedBox(height: 20.w,),
14
+      _detail(),
15
+      SizedBox(height: 20.w,),
16
+    ],
17
+  );
18
+}
19
+
20
+Widget _title() {
21
+  return Row(
22
+    children: [
23
+      Expanded(
24
+          child: Text("收割机001--S001",
25
+              style: TextStyle(
26
+                color: Color(0xFF222222),
27
+                fontSize: 18.sp,
28
+                fontWeight: FontWeight.bold,
29
+              )),
30
+          flex: 1),
31
+      Container(
32
+        width: 100.w,
33
+        alignment: Alignment.centerRight,
34
+        child: LinearGradientText(
35
+          colors: const <Color>[
36
+            Color(0xFFFA7878),
37
+            Color(0xFFB61515),
38
+          ],
39
+          child: RichText(
40
+            text: TextSpan(
41
+                children: <InlineSpan>[
42
+                  TextSpan(
43
+                      text: "450",
44
+                      style: TextStyle(
45
+                        fontSize: 22.sp,
46
+                        fontWeight: FontWeight.bold,
47
+                      )),
48
+                  TextSpan(
49
+                      text: "元/",
50
+                      style: TextStyle(
51
+                        fontSize: 22.sp,
52
+                        fontWeight: FontWeight.bold,
53
+                      )),
54
+                  TextSpan(
55
+                      text: "公顷",
56
+                      style: TextStyle(
57
+                        fontSize: 12.sp,
58
+                        fontWeight: FontWeight.bold,
59
+                      )),
60
+                ]
61
+            ),
62
+          ),
63
+
64
+
65
+
66
+
67
+        ),
68
+      )
69
+    ],
70
+  );
71
+}
72
+
73
+Widget _desc() {
74
+  return Row(
75
+    children: [
76
+      Icon(Icons.location_on_outlined, size: 16.sp,),
77
+      Expanded(
78
+        flex: 1,
79
+        child: Text("距离当前位置2.3公里 >>", style: TextStyle(color: Color(0xFF222222), fontSize: 15.sp),),
80
+      ),
81
+    ],
82
+  );
83
+}
84
+
85
+Widget _detail() {
86
+  return Container(
87
+    alignment: Alignment.centerLeft,
88
+    child: Text("农机手1的收割机", style: TextStyle(color: Color(0xFF222222), fontSize: 15.sp),),
89
+  );
90
+}

+ 1
- 1
lib/routes/pages.dart Zobrazit soubor

@@ -10,7 +10,7 @@ import '../pages/index.dart';
10 10
 List<GetPage> pages = [
11 11
   GetPage(name: '/', page: () =>  Home()),
12 12
   GetPage(name: '/ArticleInfo', page: () =>  ArticleInfo()),//资讯详情
13
-  GetPage(name: '/splash', page: () => SplashScreen()),//SplashScreen
13
+  GetPage(name: '/splash', page: () => MachineryDetailPage()),//SplashScreen
14 14
   GetPage(name: '/login', page: () =>  MyRouteLogin()),
15 15
   GetPage(name: '/addressList', page: () =>  AddressList()),
16 16
   GetPage(name: '/addAddress', page: () =>  AddAddress()),

+ 31
- 0
lib/widgets/LinearGradientText.dart Zobrazit soubor

@@ -0,0 +1,31 @@
1
+
2
+import 'package:flutter/widgets.dart';
3
+
4
+class LinearGradientText extends StatelessWidget {
5
+  final AlignmentGeometry begin;
6
+  final AlignmentGeometry end;
7
+  final List<Color> colors;
8
+  Widget child;
9
+
10
+  LinearGradientText({
11
+    Key? key,
12
+    required this.colors,
13
+    required this.child,
14
+    this.begin = Alignment.topCenter,
15
+    this.end = Alignment.bottomCenter,
16
+  }) : super(key: key);
17
+
18
+  Shader _linearGradient(Rect bounds) {
19
+    Gradient gradient = LinearGradient(colors: colors, begin: begin, end: end);
20
+    return gradient.createShader(bounds);
21
+  }
22
+
23
+  @override
24
+  Widget build(BuildContext context) {
25
+    return ShaderMask(
26
+      blendMode: BlendMode.srcIn,
27
+      shaderCallback: (bounds) => _linearGradient(bounds),
28
+      child: child,
29
+    );
30
+  }
31
+}