|
@@ -1,27 +1,48 @@
|
|
|
-
|
|
|
-import 'dart:html';
|
|
|
-
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/services.dart';
|
|
|
import 'package:taskservice/Common/JXColors.dart';
|
|
|
+import 'package:taskservice/Common/JXCommon.dart';
|
|
|
import 'package:taskservice/Model/JXServiceModel.dart';
|
|
|
import 'package:taskservice/src/custom_widgets.dart';
|
|
|
|
|
|
class CreateAddService extends StatefulWidget {
|
|
|
@override
|
|
|
_CreateAddService createState() => _CreateAddService();
|
|
|
+
|
|
|
+ /*服务*/
|
|
|
+ final JXServiceModel service;
|
|
|
+ CreateAddService({Key key, this.service}) : super(key: key);
|
|
|
}
|
|
|
|
|
|
class _CreateAddService extends State<CreateAddService> {
|
|
|
/*服务*/
|
|
|
JXServiceModel _service;
|
|
|
/*类型*/
|
|
|
- TextEditingController kindController = TextEditingController();
|
|
|
+ TextEditingController kindController;
|
|
|
+ /*周期*/
|
|
|
+ TextEditingController cycleController;
|
|
|
+ /*提醒*/
|
|
|
+ TextEditingController remandController;
|
|
|
+ /*备注*/
|
|
|
+ TextEditingController remarkConotroller;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
// TODO: implement initState
|
|
|
super.initState();
|
|
|
- _service = JXServiceModel();
|
|
|
+ if (widget.service == null) {
|
|
|
+ print('新建服务');
|
|
|
+ _service = JXServiceModel();
|
|
|
+ } else {
|
|
|
+ print('编辑服务');
|
|
|
+ _service = widget.service;
|
|
|
+ /*设置值*/
|
|
|
+ kindController = TextEditingController(text: _service.kind);
|
|
|
+ cycleController = TextEditingController(text: _service.cycle.toString());
|
|
|
+ remandController = TextEditingController(text: '0');
|
|
|
+ remarkConotroller = TextEditingController(text: _service.remark);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -50,13 +71,19 @@ class _CreateAddService extends State<CreateAddService> {
|
|
|
Container(
|
|
|
padding: EdgeInsets.all(0),
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
- height: 46.0,
|
|
|
+ height: 52.0,
|
|
|
child: Row(
|
|
|
children: <Widget>[
|
|
|
-
|
|
|
+ Expanded(
|
|
|
+ child: SizedBox(width: 0,),
|
|
|
+ ),
|
|
|
+ theInputDayView('周期', '个月', cycleController),
|
|
|
+ theInputDayView('提醒', '日', remandController),
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
+ SizedBox(height: 12.0,),
|
|
|
+ theRemarkView(remarkConotroller),
|
|
|
],
|
|
|
),
|
|
|
),
|
|
@@ -81,10 +108,106 @@ class _CreateAddService extends State<CreateAddService> {
|
|
|
),);
|
|
|
}
|
|
|
|
|
|
+ /*天数输入框,限制2数字输入*/
|
|
|
+ Widget theInputDayView(String mark, String unit, TextEditingController controller) {
|
|
|
+ /*文字style*/
|
|
|
+ TextStyle style = TextStyle(fontSize: 16.0, color: JXColors.k1F2529,);
|
|
|
+ return Container(
|
|
|
+ height: 52.0,
|
|
|
+ padding: EdgeInsets.only(left: 12.0, top: 12.0, right: 12.0),
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.only(left: 12.0, right: 12.0),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: JXColors.kFFFFFF,
|
|
|
+ borderRadius: BorderRadius.circular(12.0),
|
|
|
+ border: Border.all(color: JXColors.kE6E6E6, width: 1),
|
|
|
+ ),
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ Text(
|
|
|
+ mark,
|
|
|
+ style: style,
|
|
|
+ ),
|
|
|
+ SizedBox(width: 6.0,),
|
|
|
+ Container(
|
|
|
+ width: 24.0,
|
|
|
+ height: 46.0,
|
|
|
+ child: Center(
|
|
|
+ child: TextField(
|
|
|
+ expands: false,
|
|
|
+ textAlignVertical: TextAlignVertical.center,
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ decoration: InputDecoration.collapsed(hintText: '0',),
|
|
|
+ style: style,
|
|
|
+ keyboardType: TextInputType.numberWithOptions(signed: true,decimal: false),
|
|
|
+ inputFormatters: [
|
|
|
+ LengthLimitingTextInputFormatter(2),
|
|
|
+ WhitelistingTextInputFormatter.digitsOnly,
|
|
|
+ ],
|
|
|
+ controller: controller,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ SizedBox(width: 6.0,),
|
|
|
+ Text(
|
|
|
+ unit,
|
|
|
+ style: style,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /*备注输入框*/
|
|
|
+ Widget theRemarkView(TextEditingController controller) {
|
|
|
+ TextStyle style = TextStyle(fontSize: 16.0, color: JXColors.k1F2529,);
|
|
|
+ return Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: <Widget>[
|
|
|
+ SizedBox(width: 24.0,),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 8),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ child: Text(
|
|
|
+ '备注',
|
|
|
+ style: style,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ border: Border.all(color: JXColors.kE6E6E6, width: 1),
|
|
|
+ borderRadius: BorderRadius.circular(12)),
|
|
|
+ height: 88,
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.all(6.0),
|
|
|
+ child: TextField(
|
|
|
+ minLines: 1,
|
|
|
+ maxLines: 4,
|
|
|
+ decoration: null,
|
|
|
+ style: style,
|
|
|
+ textInputAction: TextInputAction.done,
|
|
|
+ controller: controller,
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ )),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**点击事件**/
|
|
|
/*保存*/
|
|
|
void saveBtnClickAction() {
|
|
|
- print('保存');
|
|
|
+ _service.kind = kindController.text;
|
|
|
+ _service.cycle = int.parse(cycleController.text);
|
|
|
+ _service.remindDay = int.parse(remandController.text);
|
|
|
+ _service.remark = remarkConotroller.text;
|
|
|
+ _service.cycleUnit = '月';
|
|
|
+ print(_service.toMap());
|
|
|
}
|
|
|
-
|
|
|
- /*输入框*/
|
|
|
}
|