185 lines
5.0 KiB
Dart
185 lines
5.0 KiB
Dart
/*
|
|
* @Author: Aimee~
|
|
* @Date: 2022-06-01 11:11:40
|
|
* @LastEditTime: 2022-06-02 17:51:22
|
|
* @LastEditors: Aimee
|
|
* @FilePath: /gl_dao/lib/pages/address/adds_add/adds_add_page.dart
|
|
* @Description: 新增地址
|
|
*/
|
|
// import 'package:address_picker/address_picker.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_pickers/address_picker/locations_data.dart';
|
|
import 'package:flutter_pickers/pickers.dart';
|
|
import '../../../main_color.dart';
|
|
|
|
class AddressAddPage extends StatefulWidget {
|
|
const AddressAddPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<AddressAddPage> createState() => _AddressAddPageState();
|
|
}
|
|
|
|
class _AddressAddPageState extends State<AddressAddPage> {
|
|
String initProvince = '', initCity = '', initTown = '';
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: appBar(),
|
|
body: Container(
|
|
padding: const EdgeInsets.fromLTRB(16, 30, 16, 30),
|
|
child: ListView(
|
|
children: [
|
|
const TextField(
|
|
decoration: InputDecoration(
|
|
hintText: "收货人姓名",
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
),
|
|
icon: Text(
|
|
'收 货 人:',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const Divider(),
|
|
const TextField(
|
|
decoration: InputDecoration(
|
|
hintText: "收货人联系电话",
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
),
|
|
icon: Text(
|
|
'联系电话:',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const Divider(),
|
|
GestureDetector(
|
|
onTap: _chooseArea,
|
|
child: TextField(
|
|
decoration: InputDecoration(
|
|
hintText: initProvince.isEmpty
|
|
? "请选择省市区"
|
|
: "$initProvince - $initCity - $initTown",
|
|
border: const OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
),
|
|
enabled: false,
|
|
focusedBorder: const OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
),
|
|
icon: const Text(
|
|
'省 市 区:',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const Divider(),
|
|
const TextField(
|
|
maxLength: 120,
|
|
maxLines: 3,
|
|
decoration: InputDecoration(
|
|
hintText: "请输入详细地址",
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
),
|
|
icon: Text(
|
|
'详细地址:',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const Divider(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _chooseArea() async {
|
|
Pickers.showAddressPicker(
|
|
context,
|
|
initProvince: initProvince,
|
|
initCity: initCity,
|
|
initTown: initTown,
|
|
onConfirm: (p, c, t) {
|
|
setState(() {
|
|
initProvince = p;
|
|
initCity = c;
|
|
initTown = t!;
|
|
});
|
|
|
|
/// 根据城市名 查询城市code(有先后顺序)
|
|
print(
|
|
Address.getCityCodeByName(
|
|
provinceName: p,
|
|
cityName: c,
|
|
townName: t,
|
|
),
|
|
);
|
|
|
|
/// 根据城市code 查询城市名称
|
|
print(
|
|
Address.getCityNameByCode(
|
|
provinceCode: "510000",
|
|
cityCode: "510100",
|
|
townCode: "510104",
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
// 自定义顶部导航
|
|
PreferredSizeWidget appBar() {
|
|
return AppBar(
|
|
backgroundColor: tMainRedColor,
|
|
title: const Text(
|
|
'新增收货地址',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () {},
|
|
child: const Text(
|
|
'保存',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|