|
@@ -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
|
+}
|