|
@@ -1 +1,110 @@
|
|
1
|
+import 'package:farmer_client/models/entities/Address.dart';
|
|
2
|
+import 'package:farmer_client/widgets/DefaultButton.dart';
|
1
|
3
|
import 'package:flutter/material.dart';
|
|
4
|
+import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
5
|
+import 'package:fluttertoast/fluttertoast.dart';
|
|
6
|
+import 'package:get/get.dart';
|
|
7
|
+
|
|
8
|
+class AddAddress extends StatefulWidget {
|
|
9
|
+ const AddAddress({Key? key}) : super(key: key);
|
|
10
|
+
|
|
11
|
+ @override
|
|
12
|
+ _AddAddress createState() => _AddAddress();
|
|
13
|
+}
|
|
14
|
+
|
|
15
|
+class _AddAddress extends State<AddAddress> {
|
|
16
|
+ late Address address=Address();
|
|
17
|
+ late String text = '';
|
|
18
|
+
|
|
19
|
+ @override
|
|
20
|
+ void initState() {
|
|
21
|
+ super.initState();
|
|
22
|
+ if (Get.arguments != null) {
|
|
23
|
+ address = Get.arguments['item'];
|
|
24
|
+ text = address.address.toString();
|
|
25
|
+ }
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ @override
|
|
29
|
+ Widget build(BuildContext context) {
|
|
30
|
+ return Scaffold(
|
|
31
|
+ appBar: AppBar(
|
|
32
|
+ elevation: 0,
|
|
33
|
+ centerTitle: true,
|
|
34
|
+ backgroundColor: Colors.white,
|
|
35
|
+ title: Text(
|
|
36
|
+ '添加地址',
|
|
37
|
+ style: TextStyle(
|
|
38
|
+ color: Colors.black,
|
|
39
|
+ fontSize: 17.sp,
|
|
40
|
+ letterSpacing: 2,
|
|
41
|
+ fontWeight: FontWeight.bold),
|
|
42
|
+ ),
|
|
43
|
+ ),
|
|
44
|
+ body: Container(
|
|
45
|
+ padding: EdgeInsets.all(15.w),
|
|
46
|
+ child: Column(
|
|
47
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
48
|
+ children: [
|
|
49
|
+ Text(
|
|
50
|
+ '详细地址:',
|
|
51
|
+ style: TextStyle(
|
|
52
|
+ fontWeight: FontWeight.bold,
|
|
53
|
+ fontSize: 17.sp,
|
|
54
|
+ color: const Color(0xFF333333)),
|
|
55
|
+ ),
|
|
56
|
+ Container(
|
|
57
|
+ margin: EdgeInsets.fromLTRB(0, 0, 0, 50.h),
|
|
58
|
+ padding: EdgeInsets.symmetric(vertical: 5.w, horizontal: 18.5.w),
|
|
59
|
+ decoration: BoxDecoration(
|
|
60
|
+ color: const Color(0xFFfefefe),
|
|
61
|
+ borderRadius: BorderRadius.all(Radius.circular(10.w)),
|
|
62
|
+ border: Border.all(
|
|
63
|
+ color: const Color(0xcc000000),
|
|
64
|
+ width: 1.h,
|
|
65
|
+ style: BorderStyle.solid)),
|
|
66
|
+ child: TextFormField(
|
|
67
|
+ initialValue: text,
|
|
68
|
+ minLines: 6,
|
|
69
|
+ maxLines: 6,
|
|
70
|
+ style: TextStyle(fontSize: 17.sp, height: 1.5),
|
|
71
|
+ decoration: const InputDecoration(
|
|
72
|
+ isCollapsed: true,
|
|
73
|
+ hintText: '请输入地址信息',
|
|
74
|
+ border: InputBorder.none,
|
|
75
|
+ counterText: '',
|
|
76
|
+ floatingLabelBehavior: FloatingLabelBehavior.never,
|
|
77
|
+ ),
|
|
78
|
+ onChanged: (e) {
|
|
79
|
+ setState(() {
|
|
80
|
+ address.address = e;
|
|
81
|
+ });
|
|
82
|
+ },
|
|
83
|
+ ),
|
|
84
|
+ ),
|
|
85
|
+ DefaultButton(
|
|
86
|
+ color: const Color(0xffffffff),
|
|
87
|
+ backColor: const Color(0xFFFF703B),
|
|
88
|
+ width: 345.w,
|
|
89
|
+ height: 49.h,
|
|
90
|
+ text: '保存',
|
|
91
|
+ onPressed: () {
|
|
92
|
+ if(address.address==null){
|
|
93
|
+ Fluttertoast.showToast(
|
|
94
|
+ msg: '请输入地址!');
|
|
95
|
+ } else{
|
|
96
|
+ Fluttertoast.showToast(
|
|
97
|
+ msg: '保存成功!');
|
|
98
|
+ Get.back();
|
|
99
|
+ }
|
|
100
|
+ },
|
|
101
|
+ margin: const EdgeInsets.all(0),
|
|
102
|
+ fontSize: 20.sp,
|
|
103
|
+ radius: 24.5.w,
|
|
104
|
+ ),
|
|
105
|
+ ],
|
|
106
|
+ ),
|
|
107
|
+ ),
|
|
108
|
+ );
|
|
109
|
+ }
|
|
110
|
+}
|