张延森 3 лет назад
Родитель
Сommit
37890283f0

Двоичные данные
images/locationImage.png Просмотреть файл


+ 0
- 1
lib/models/Store.dart Просмотреть файл

@@ -1 +0,0 @@
1
-// TODO Implement this library.

+ 0
- 15
lib/models/User.dart Просмотреть файл

@@ -1,15 +0,0 @@
1
-
2
-import 'package:farmer_client/models/entities/person.dart';
3
-import 'package:get/get.dart';
4
-
5
-class User extends GetxController {
6
-  Person? _person;
7
-  Person? get person => _person;
8
-  set person (Person? p) {
9
-    _person = p;
10
-    update();
11
-  }
12
-
13
-  bool get isLogin => _person != null;
14
-
15
-}

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

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

+ 0
- 22
lib/pages/machinery/map.dart Просмотреть файл

@@ -1,22 +0,0 @@
1
-
2
-import 'package:farmer_client/widgets/amap/amap.dart';
3
-import 'package:flutter/material.dart';
4
-import 'package:flutter/widgets.dart';
5
-
6
-class MachineryMapPage extends StatelessWidget {
7
-
8
-  Widget page(BuildContext context) {
9
-    return Column(children: [
10
-      Expanded( flex: 1, child: AMap(),),
11
-      Expanded( flex: 1, child: Container(),),
12
-      Expanded( flex: 1, child: Container(),),
13
-    ],);
14
-  }
15
-
16
-  @override
17
-  Widget build(BuildContext context) {
18
-    return Scaffold(appBar: AppBar(title: const Text("查看地图"), centerTitle: true,), body: page(context),);
19
-  }
20
-  
21
-}
22
-

+ 23
- 0
lib/pages/machinery/map/index.dart Просмотреть файл

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

+ 143
- 0
lib/pages/machinery/map/widgets/detail.dart Просмотреть файл

@@ -0,0 +1,143 @@
1
+
2
+
3
+import 'package:flutter/material.dart';
4
+import 'package:flutter/widgets.dart';
5
+import 'package:flutter_screenutil/flutter_screenutil.dart';
6
+import 'package:amap_flutter_base/amap_flutter_base.dart';
7
+import 'package:farmer_client/widgets/amap/amap.dart';
8
+
9
+Widget page({ required BuildContext context, required Size appbarSize, required void Function() handleClick}) {
10
+  final _offset = 20.h;
11
+  final width = MediaQuery.of(context).size.width;
12
+  final height = MediaQuery.of(context).size.height
13
+      - appbarSize.height
14
+      - MediaQuery.of(context).padding.top;
15
+  final mapHeight = height * 0.3;
16
+  final cardHeight = (height - mapHeight) / 2 + _offset;
17
+
18
+
19
+  final img = 'https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/index-icon19.jpg';
20
+  final LatLng position = LatLng(32.690712, 112.091892);
21
+
22
+  return Stack(
23
+    alignment: Alignment.topCenter,
24
+    children: [
25
+      // 第一个组件用来撑满全屏
26
+      SizedBox(
27
+        width: width,
28
+        height: height,
29
+      ),
30
+      SizedBox(
31
+        width: width,
32
+        height: mapHeight,
33
+        child: AMap(position: position),
34
+      ),
35
+      Positioned(
36
+        left: 0,
37
+        top: mapHeight - _offset,
38
+        height: cardHeight,
39
+        child: _thumb(context, img),
40
+      ),
41
+      Positioned(
42
+        left: 0,
43
+        top: mapHeight + cardHeight - 2 * _offset,
44
+        height: cardHeight,
45
+        child: _content(context, handleClick),
46
+      ),
47
+    ],);
48
+}
49
+
50
+Widget _card(BuildContext context, Widget child) {
51
+  final _border = 20.w;
52
+  return Container(
53
+    width: MediaQuery.of(context).size.width,
54
+    clipBehavior: Clip.hardEdge,
55
+    decoration: BoxDecoration(
56
+        borderRadius: BorderRadius.vertical(top: Radius.circular(_border))
57
+    ),
58
+    child: child,
59
+  );
60
+}
61
+
62
+Widget _thumb(BuildContext context, String imgUrl) {
63
+  return _card(context, Image.network(imgUrl, fit: BoxFit.cover));
64
+}
65
+
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
+
108
+Widget _button(void Function() handleClick) {
109
+  return ElevatedButton(
110
+    child: const Text("预约"),
111
+    style: ElevatedButton.styleFrom(
112
+        primary: const Color(0xFFFF703B),
113
+        textStyle: TextStyle(color: Colors.white, fontSize: 20.sp, letterSpacing: 5.sp),
114
+        elevation: 0,
115
+        minimumSize: Size(double.infinity, 49.w),
116
+        shape: RoundedRectangleBorder(
117
+          borderRadius: BorderRadius.all(Radius.circular(24.5.w)),
118
+        )
119
+    ),
120
+    onPressed: handleClick,
121
+  );
122
+}
123
+
124
+Widget _content(BuildContext context, void Function() handleClick) {
125
+  return _card(context, Container(
126
+    padding: EdgeInsets.only(top: 45.w, left: 15.w, right: 15.w, bottom: 20.w),
127
+    decoration: const BoxDecoration(
128
+      color: Colors.white,
129
+    ),
130
+    child: Column(
131
+
132
+      children: [
133
+        _title(),
134
+        SizedBox(height: 20.h,),
135
+        _desc(),
136
+        SizedBox(height: 20.h,),
137
+        _detail(),
138
+        SizedBox(height: 20.h,),
139
+        _button(handleClick),
140
+      ],
141
+    ),
142
+  ));
143
+}

+ 3
- 3
lib/widgets/amap/amap.dart Просмотреть файл

@@ -20,8 +20,7 @@ class AMap extends StatelessWidget {
20 20
     if (null != position) {
21 21
       Marker marker = Marker(
22 22
         position: position!,
23
-        //使用默认hue的方式设置Marker的图标
24
-        icon: BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueOrange),
23
+        icon: BitmapDescriptor.fromIconPath("images/locationImage.png")
25 24
       );
26 25
       _markers[marker.id] = marker;
27 26
     }
@@ -35,7 +34,8 @@ class AMap extends StatelessWidget {
35 34
       privacyStatement: ConstConfig.amapPrivacyStatement,
36 35
       apiKey: ConstConfig.amapApiKeys,
37 36
       markers: Set<Marker>.of(_markers.values),
38
-      initialCameraPosition: const CameraPosition(target: LatLng(31.230378, 121.473658)),
37
+      // 默认是邓州市中心
38
+      initialCameraPosition: const CameraPosition(target: LatLng(32.687732, 112.08745)),
39 39
     );
40 40
   }
41 41
 

+ 1
- 0
pubspec.yaml Просмотреть файл

@@ -87,6 +87,7 @@ flutter:
87 87
     - images/feedbacks.png
88 88
     - images/userRight.png
89 89
     - images/versionUpdate.png
90
+    - images/locationImage.png
90 91
 
91 92
   # An image asset can refer to one or more resolution-specific "variants", see
92 93
   # https://flutter.dev/assets-and-images/#resolution-aware.