123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'package:get_storage/get_storage.dart';
- import 'package:intl/intl.dart';
-
- class OrderConfirmation extends StatefulWidget {
- const OrderConfirmation({Key? key}) : super(key: key);
-
- @override
- State<OrderConfirmation> createState() => _OrderConfirmationState();
- }
-
- class _OrderConfirmationState extends State<OrderConfirmation> {
- TextEditingController _unameController = TextEditingController();
- TextEditingController _pwdController = TextEditingController();
- GlobalKey _formKey = GlobalKey<FormState>();
-
- var selectDate; //选择的时间
- var workingArea;
- String address = '请选择详细地址';
- @override
- void initState() {
- super.initState();
- //到底哪里错了 唉
- // if (GetStorage().read("address") != null) {
- // address = GetStorage().read("address").address;
- // }
- }
- // 20:59:59
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- resizeToAvoidBottomInset: false,
- appBar: AppBar(
- elevation: 0,
- centerTitle: true,
- backgroundColor: Colors.white,
- title: Text(
- '预约',
- style: TextStyle(
- color: Colors.black,
- fontSize: 17.sp,
- letterSpacing: 2,
- fontWeight: FontWeight.bold),
- ),
- ),
- body: Form(
- key: _formKey, //设置globalKey,用于后面获取FormState
- autovalidateMode: AutovalidateMode.onUserInteraction,
- child: Column(
- children: <Widget>[
- Container(
- margin: EdgeInsets.fromLTRB(15, 20, 0, 0),
- alignment: Alignment.topLeft,
- child: Text(
- '作业面积/公顷',
- style: TextStyle(
- color: Color(0xff222222),
- fontSize: 17.sp,
- fontWeight: FontWeight.bold),
- ),
- ),
- TextFormField(
- // autofocus: true,
- keyboardType: TextInputType.number,
- controller: _unameController,
- decoration: const InputDecoration(
- isCollapsed: true,
- contentPadding:
- EdgeInsets.symmetric(vertical: 8, horizontal: 16),
- counterText: '', //去掉计数
- /// UnderlineInputBorder 只有下边框 默认使用的就是下边框
- border: UnderlineInputBorder(
- borderRadius: BorderRadius.all(Radius.circular(10)),
- borderSide: BorderSide(
- color: Color(0x30000000),
- width: 2.0,
- ),
- ),
- floatingLabelBehavior: FloatingLabelBehavior.never,
- hintText: "请输入具体面积(公顷)",
- ),
- onChanged: (e) {
- setState(() {
- workingArea = e;
- });
- },
- // 校验用户名
- validator: (v) {
- return v!.trim().isNotEmpty ? null : "作业面积/公顷不能为空";
- },
- ),
- Container(
- margin: EdgeInsets.fromLTRB(15, 20, 0, 0),
- alignment: Alignment.topLeft,
- child: Text(
- '作业时间:',
- style: TextStyle(
- color: Color(0xff222222),
- fontSize: 17.sp,
- fontWeight: FontWeight.bold),
- ),
- ),
- Container(
- width: 345.w,
- padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
- decoration: const BoxDecoration(
- border: Border(
- bottom: BorderSide(width: 1, color: Color(0x20000000)
- // 0x17000000
- )),
- ),
- child: Row(
- children: [
- Image(
- image: AssetImage('images/icons/timeImage.png'),
- fit: BoxFit.cover,
- width: 18.w,
- height: 18.w,
- ),
- Padding(
- padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
- child: GestureDetector(
- onTap: () async {
- var handleChnage = await showDatePicker(
- context: context,
- helpText: '请选择作业开始时间',
- cancelText: '取消',
- confirmText: '确定',
- initialDate: selectDate == null
- ? DateTime.now()
- : selectDate,
- firstDate: DateTime.now(),
- lastDate: DateTime(2030),
- );
- setState(() {
- selectDate = handleChnage;
- print('${selectDate}+');
- });
- },
- child: Text(selectDate == null
- ? '请选择日期'
- : '${DateFormat("yyyy-MM-dd").format(selectDate)}'),
- ),
- )
- ],
- )),
- Container(
- margin: EdgeInsets.fromLTRB(15, 20, 0, 0),
- alignment: Alignment.topLeft,
- child: Text(
- '作业位置:',
- style: TextStyle(
- color: Color(0xff222222),
- fontSize: 17.sp,
- fontWeight: FontWeight.bold),
- ),
- ),
- Container(
- width: 345.w,
- padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(width: 1, color: Color(0x20000000)
- // 0x17000000
- )),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- Image(
- image: AssetImage('images/gpsImgae.png'),
- fit: BoxFit.cover,
- width: 14.w,
- height: 17.h,
- ),
- Padding(
- padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
- child: GestureDetector(
- onTap: () {
- Get.toNamed('/addressList',
- arguments: {'isBack': true});
- },
- child: Container(
- width: 290.w,
- child: Text(
- address,
- softWrap: true,
- maxLines: 1,
- textAlign: TextAlign.left,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- ))
- ],
- ),
- ),
-
- Spacer(),
- Container(
- alignment: Alignment.bottomCenter,
- child: SizedBox(
- width: 315.w,
- height: 49.h,
- child: ElevatedButton(
- onPressed: () {
- if ((_formKey.currentState as FormState).validate()) {
- var a = {selectDate, workingArea};
- print('我确定了$a');
- //验证通过提交数据
- Get.toNamed('/orderPageInfo');
- }
- },
- child: const Text(
- "确定",
- style: TextStyle(
- fontSize: 18,
- color: Colors.white,
- fontWeight: FontWeight.bold),
- ),
- style: ButtonStyle(
- elevation: MaterialStateProperty.all(0),
- backgroundColor:
- MaterialStateProperty.all(const Color(0xFFFF703B)),
- shape: MaterialStateProperty.all(
- const RoundedRectangleBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(24.4)))),
- ),
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.fromLTRB(0, 30.w, 0, 30.w),
- alignment: Alignment.bottomCenter,
- child: SizedBox(
- width: 315.w,
- height: 49.h,
- child: ElevatedButton(
- onPressed: () {
- Get.back();
- },
- child: const Text(
- "取消",
- style: TextStyle(
- fontSize: 18,
- color: Color(0xFFFF703B),
- fontWeight: FontWeight.bold),
- ),
- style: ButtonStyle(
- side: MaterialStateProperty.all(
- BorderSide(width: 1, color: Color(0xFFFF703B))), //边框
- elevation: MaterialStateProperty.all(0),
- backgroundColor: MaterialStateProperty.all(Colors.white),
- shape: MaterialStateProperty.all(
- RoundedRectangleBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(24.4))),
- ),
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
|