page_crtacc.dart 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:taskservice/Common/JXColors.dart';
  5. import 'package:taskservice/Model/JXMemberModel.dart';
  6. import 'package:taskservice/Model/JXServiceModel.dart';
  7. import 'package:taskservice/database/DataBase.dart';
  8. class CreateAccPage extends StatefulWidget {
  9. @override
  10. _CreateAccPageState createState() => _CreateAccPageState();
  11. }
  12. class _CreateAccPageState extends State<CreateAccPage> {
  13. List<JXServiceModel> services;
  14. JXMemberModel member;
  15. @override
  16. void initState() {
  17. super.initState();
  18. services = [
  19. JXServiceModel()
  20. ..kind = '清洗'
  21. ..cycle = 3
  22. ..cycleUnit = '个月'
  23. ..remark = '备注1',
  24. JXServiceModel()
  25. ..kind = '清洗2'
  26. ..cycle = 1
  27. ..cycleUnit = '个月'
  28. ..remark = '备注11',
  29. JXServiceModel()
  30. ..kind = '清洗3'
  31. ..cycle = 2
  32. ..cycleUnit = '个月'
  33. ..remark = '备注1111',
  34. JXServiceModel()
  35. ..kind = '清洗4'
  36. ..cycle = 30
  37. ..cycleUnit = '个月'
  38. ..remark = '备注111111',
  39. JXServiceModel()
  40. ..kind = '清洗5'
  41. ..cycle = 12
  42. ..cycleUnit = '个月'
  43. ..remark = '备注111111',
  44. JXServiceModel()
  45. ..kind = '清洗6'
  46. ..cycle = 2
  47. ..cycleUnit = '个月'
  48. ..remark = '备注111111',
  49. ];
  50. }
  51. @override
  52. Widget build(BuildContext context) {
  53. return SafeArea(
  54. child: Scaffold(
  55. appBar: AppBar(
  56. centerTitle: true,
  57. title: Text('新建会员'),
  58. backgroundColor: JXColors.k1F2529,
  59. ),
  60. body: Column(
  61. children: <Widget>[
  62. Expanded(
  63. child: CustomScrollView(
  64. slivers: <Widget>[
  65. buildEditPart(),
  66. buildItemsPart(),
  67. SliverToBoxAdapter(
  68. child: Container(
  69. decoration: BoxDecoration(
  70. borderRadius: BorderRadius.circular(12),
  71. border: Border.all(
  72. width: 1,
  73. )),
  74. margin: EdgeInsets.symmetric(vertical: 12, horizontal: 80),
  75. child: InkWell(
  76. onTap: () => null,
  77. child: Container(
  78. padding: EdgeInsets.all(8),
  79. child: Text(
  80. '添加服务',
  81. textAlign: TextAlign.center,
  82. style: TextStyle(fontSize: 18),
  83. ),
  84. ),
  85. ),
  86. ),
  87. ),
  88. ],
  89. ),
  90. ),
  91. 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),)),
  92. ],
  93. ),
  94. ));
  95. }
  96. SliverList buildItemsPart() {
  97. return SliverList(
  98. delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
  99. if (index <= services.length - 1) {
  100. var service = services[index];
  101. return Container(
  102. padding: EdgeInsets.symmetric(horizontal: 16),
  103. child: Column(
  104. children: <Widget>[
  105. SizedBox(height: 8,),
  106. Row(
  107. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  108. children: <Widget>[
  109. Text('类型: ${service.kind}'),
  110. Text('周期: ${service.cycle}${service.cycleUnit}'),
  111. ],
  112. ),
  113. SizedBox(height: 20,),
  114. Row(
  115. children: <Widget>[
  116. Text('备注 ${service.remark}'),
  117. ],
  118. ),
  119. SizedBox(height: 8,),
  120. Divider(
  121. height: 2,
  122. thickness: 2,
  123. ),
  124. ],
  125. ),
  126. );
  127. } else {
  128. return null;
  129. }
  130. }));
  131. }
  132. SliverList buildEditPart() {
  133. return SliverList(
  134. delegate: SliverChildListDelegate([
  135. Row(
  136. mainAxisSize: MainAxisSize.max,
  137. children: <Widget>[
  138. SizedBox(
  139. width: 20,
  140. ),
  141. Text(
  142. '姓名',
  143. style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
  144. ),
  145. Expanded(
  146. child: Padding(
  147. padding: const EdgeInsets.symmetric(horizontal: 20),
  148. child: TextField(),
  149. )),
  150. ],
  151. ),
  152. Row(
  153. mainAxisSize: MainAxisSize.max,
  154. children: <Widget>[
  155. SizedBox(
  156. width: 20,
  157. ),
  158. Text(
  159. '电话',
  160. style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
  161. ),
  162. Expanded(
  163. child: Padding(
  164. padding: const EdgeInsets.symmetric(horizontal: 20),
  165. child: TextField(),
  166. )),
  167. ],
  168. ),
  169. Row(
  170. mainAxisSize: MainAxisSize.max,
  171. children: <Widget>[
  172. SizedBox(
  173. width: 20,
  174. ),
  175. Text(
  176. '生日',
  177. style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
  178. ),
  179. Expanded(
  180. child: Padding(
  181. padding: const EdgeInsets.symmetric(horizontal: 20),
  182. child: TextField(),
  183. )),
  184. ],
  185. ),
  186. Container(
  187. height: 44,
  188. child: Row(
  189. mainAxisSize: MainAxisSize.max,
  190. children: <Widget>[
  191. SizedBox(
  192. width: 20,
  193. ),
  194. Text(
  195. '地址',
  196. style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
  197. ),
  198. Expanded(
  199. child: Padding(
  200. padding: const EdgeInsets.symmetric(horizontal: 20),
  201. child: Container(
  202. margin: EdgeInsets.only(bottom: 1),
  203. child: Text('省份/城市/区域')),
  204. )),
  205. ],
  206. ),
  207. ),
  208. Divider(
  209. height: 1,
  210. ),
  211. SizedBox(
  212. height: 12,
  213. ),
  214. Row(
  215. crossAxisAlignment: CrossAxisAlignment.start,
  216. children: <Widget>[
  217. SizedBox(
  218. width: 12,
  219. ),
  220. Container(
  221. margin: EdgeInsets.only(top: 8),
  222. width: 60,
  223. alignment: Alignment.center,
  224. child: Text(
  225. '详细地址',
  226. style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
  227. ),
  228. ),
  229. Expanded(
  230. child: Padding(
  231. padding: const EdgeInsets.symmetric(horizontal: 20),
  232. child: Container(
  233. decoration: BoxDecoration(
  234. border: Border.all(color: JXColors.kE6E6E6, width: 2),
  235. borderRadius: BorderRadius.circular(12)),
  236. height: 150,
  237. child: TextField(decoration: null)),
  238. )),
  239. ],
  240. ),
  241. SizedBox(
  242. height: 12,
  243. ),
  244. Row(
  245. crossAxisAlignment: CrossAxisAlignment.start,
  246. children: <Widget>[
  247. SizedBox(
  248. width: 12,
  249. ),
  250. Container(
  251. margin: EdgeInsets.only(top: 8),
  252. width: 60,
  253. alignment: Alignment.center,
  254. child: Text(
  255. '备注',
  256. style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
  257. ),
  258. ),
  259. Expanded(
  260. child: Padding(
  261. padding: const EdgeInsets.symmetric(horizontal: 20),
  262. child: Container(
  263. decoration: BoxDecoration(
  264. border: Border.all(color: JXColors.kE6E6E6, width: 2),
  265. borderRadius: BorderRadius.circular(12)),
  266. height: 150,
  267. child: TextField(decoration: null)),
  268. )),
  269. ],
  270. ),
  271. SizedBox(
  272. height: 12,
  273. ),
  274. Container(
  275. padding: EdgeInsets.all(12),
  276. decoration: BoxDecoration(color: JXColors.kE6E6E6),
  277. child: Text(
  278. '服务',
  279. style: TextStyle(color: JXColors.k2E3032),
  280. ),
  281. ),
  282. ]),
  283. );
  284. }
  285. void onClickSave() {
  286. MyDataBase.getInstance().saveMember(member);
  287. }
  288. }