|
@@ -5,6 +5,7 @@ import 'package:taskservice/Common/JXColors.dart';
|
|
|
import 'package:taskservice/Model/JXMemberModel.dart';
|
|
|
import 'package:taskservice/Model/JXServiceModel.dart';
|
|
|
import 'package:taskservice/database/DataBase.dart';
|
|
|
+import 'package:taskservice/src/custom_widgets.dart';
|
|
|
|
|
|
class CreateAccPage extends StatefulWidget {
|
|
|
@override
|
|
@@ -14,6 +15,11 @@ class CreateAccPage extends StatefulWidget {
|
|
|
class _CreateAccPageState extends State<CreateAccPage> {
|
|
|
List<JXServiceModel> services;
|
|
|
JXMemberModel member;
|
|
|
+ TextEditingController nameController = TextEditingController();
|
|
|
+ TextEditingController phoneController = TextEditingController();
|
|
|
+ TextEditingController birthController = TextEditingController();
|
|
|
+ TextEditingController addrConotroller = TextEditingController();
|
|
|
+ TextEditingController remarkConotroller = TextEditingController();
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
@@ -49,52 +55,58 @@ class _CreateAccPageState extends State<CreateAccPage> {
|
|
|
..cycleUnit = '个月'
|
|
|
..remark = '备注111111',
|
|
|
];
|
|
|
+
|
|
|
+ member = JXMemberModel();
|
|
|
+ nameController.addListener(onInfoChanged);
|
|
|
+ phoneController.addListener(onInfoChanged);
|
|
|
+ birthController.addListener(onInfoChanged);
|
|
|
+ addrConotroller.addListener(onInfoChanged);
|
|
|
+ remarkConotroller.addListener(onInfoChanged);
|
|
|
+ }
|
|
|
+
|
|
|
+ void onInfoChanged() {
|
|
|
+ member.name = nameController.value.text;
|
|
|
+ member.tel = phoneController.value.text;
|
|
|
+ member.birth = birthController.value.text;
|
|
|
+ member.addr = addrConotroller.value.text;
|
|
|
+ member.remark = remarkConotroller.value.text;
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
-
|
|
|
- return SafeArea(
|
|
|
- child: Scaffold(
|
|
|
- appBar: AppBar(
|
|
|
- centerTitle: true,
|
|
|
- title: Text('新建会员'),
|
|
|
- backgroundColor: JXColors.k1F2529,
|
|
|
- ),
|
|
|
- body: Column(
|
|
|
- children: <Widget>[
|
|
|
- Expanded(
|
|
|
- child: CustomScrollView(
|
|
|
- slivers: <Widget>[
|
|
|
- buildEditPart(),
|
|
|
- buildItemsPart(),
|
|
|
- SliverToBoxAdapter(
|
|
|
- child: Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- borderRadius: BorderRadius.circular(12),
|
|
|
- border: Border.all(
|
|
|
- width: 1,
|
|
|
- )),
|
|
|
- margin: EdgeInsets.symmetric(vertical: 12, horizontal: 80),
|
|
|
- child: InkWell(
|
|
|
- onTap: () => null,
|
|
|
- child: Container(
|
|
|
- padding: EdgeInsets.all(8),
|
|
|
- child: Text(
|
|
|
- '添加服务',
|
|
|
- textAlign: TextAlign.center,
|
|
|
- style: TextStyle(fontSize: 18),
|
|
|
- ),
|
|
|
+ return MyScaffold(title: '新建会员', body: Column(
|
|
|
+ children: <Widget>[
|
|
|
+ Expanded(
|
|
|
+ child: CustomScrollView(
|
|
|
+ slivers: <Widget>[
|
|
|
+ buildEditPart(),
|
|
|
+ buildItemsPart(),
|
|
|
+ SliverToBoxAdapter(
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(12),
|
|
|
+ border: Border.all(
|
|
|
+ width: 1,
|
|
|
+ )),
|
|
|
+ margin: EdgeInsets.symmetric(vertical: 12, horizontal: 80),
|
|
|
+ child: InkWell(
|
|
|
+ onTap: () => null,
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.all(8),
|
|
|
+ child: Text(
|
|
|
+ '添加服务',
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ style: TextStyle(fontSize: 18),
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
- ],
|
|
|
- ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
),
|
|
|
- GestureDetector(onTap: onClickSave, child: Container(width: MediaQuery.of(context).size.width, child: Text('保存', textAlign: TextAlign.center, style: TextStyle(fontSize: 16, color: JXColors.kFFFFFF),), padding: EdgeInsets.symmetric(vertical: 16), decoration: BoxDecoration(color: JXColors.k101E40),)),
|
|
|
- ],
|
|
|
- ),
|
|
|
+ ),
|
|
|
+ GestureDetector(onTap: onClickSave, child: Container(width: MediaQuery.of(context).size.width, child: Text('保存', textAlign: TextAlign.center, style: TextStyle(fontSize: 16, color: JXColors.kFFFFFF),), padding: EdgeInsets.symmetric(vertical: 16), decoration: BoxDecoration(color: JXColors.k101E40),)),
|
|
|
+ ],
|
|
|
));
|
|
|
}
|
|
|
|
|
@@ -151,7 +163,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
|
|
|
Expanded(
|
|
|
child: Padding(
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
- child: TextField(),
|
|
|
+ child: TextField(controller: nameController,),
|
|
|
)),
|
|
|
],
|
|
|
),
|
|
@@ -168,7 +180,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
|
|
|
Expanded(
|
|
|
child: Padding(
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
- child: TextField(),
|
|
|
+ child: TextField(controller: phoneController,),
|
|
|
)),
|
|
|
],
|
|
|
),
|
|
@@ -185,7 +197,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
|
|
|
Expanded(
|
|
|
child: Padding(
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
- child: TextField(),
|
|
|
+ child: TextField(controller: birthController,),
|
|
|
)),
|
|
|
],
|
|
|
),
|
|
@@ -240,7 +252,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
|
|
|
border: Border.all(color: JXColors.kE6E6E6, width: 2),
|
|
|
borderRadius: BorderRadius.circular(12)),
|
|
|
height: 150,
|
|
|
- child: TextField(decoration: null)),
|
|
|
+ child: TextField(decoration: null, controller: addrConotroller,)),
|
|
|
)),
|
|
|
],
|
|
|
),
|
|
@@ -270,7 +282,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
|
|
|
border: Border.all(color: JXColors.kE6E6E6, width: 2),
|
|
|
borderRadius: BorderRadius.circular(12)),
|
|
|
height: 150,
|
|
|
- child: TextField(decoration: null)),
|
|
|
+ child: TextField(decoration: null, controller: remarkConotroller,)),
|
|
|
)),
|
|
|
],
|
|
|
),
|
|
@@ -289,7 +301,7 @@ class _CreateAccPageState extends State<CreateAccPage> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- void onClickSave() {
|
|
|
- MyDataBase.getInstance().saveMember(member);
|
|
|
+ Future<void> onClickSave() async {
|
|
|
+ (await MyDataBase.database).saveMember(member);
|
|
|
}
|
|
|
}
|