|
@@ -1,9 +1,11 @@
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
+import 'package:fluttertoast/fluttertoast.dart';
|
|
import 'package:taskservice/Common/JXColors.dart';
|
|
import 'package:taskservice/Common/JXColors.dart';
|
|
import 'package:taskservice/Common/JXCommon.dart';
|
|
import 'package:taskservice/Common/JXCommon.dart';
|
|
import 'package:taskservice/Model/JXServiceModel.dart';
|
|
import 'package:taskservice/Model/JXServiceModel.dart';
|
|
|
|
+import 'package:taskservice/database/DataBase.dart';
|
|
import 'package:taskservice/src/custom_widgets.dart';
|
|
import 'package:taskservice/src/custom_widgets.dart';
|
|
|
|
|
|
class CreateAddService extends StatefulWidget {
|
|
class CreateAddService extends StatefulWidget {
|
|
@@ -21,11 +23,11 @@ class _CreateAddService extends State<CreateAddService> {
|
|
/*类型*/
|
|
/*类型*/
|
|
TextEditingController _kindController = TextEditingController(text: '');
|
|
TextEditingController _kindController = TextEditingController(text: '');
|
|
/*周期*/
|
|
/*周期*/
|
|
- final TextEditingController _cycleController = TextEditingController(text: '');
|
|
|
|
|
|
+ TextEditingController _cycleController = TextEditingController(text: '0');
|
|
/*提醒*/
|
|
/*提醒*/
|
|
- final TextEditingController _remandController = TextEditingController(text: '0');
|
|
|
|
|
|
+ TextEditingController _remandController = TextEditingController(text: '0');
|
|
/*备注*/
|
|
/*备注*/
|
|
- final TextEditingController _remarkConotroller = TextEditingController(text: '');
|
|
|
|
|
|
+ TextEditingController _remarkConotroller = TextEditingController(text: '');
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
@@ -74,7 +76,7 @@ class _CreateAddService extends State<CreateAddService> {
|
|
Expanded(
|
|
Expanded(
|
|
child: SizedBox(width: 0,),
|
|
child: SizedBox(width: 0,),
|
|
),
|
|
),
|
|
- theInputDayView('周期', '个月', _cycleController),
|
|
|
|
|
|
+ theInputDayView('周期', '月', _cycleController),
|
|
theInputDayView('提醒', '日', _remandController),
|
|
theInputDayView('提醒', '日', _remandController),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
@@ -198,13 +200,27 @@ class _CreateAddService extends State<CreateAddService> {
|
|
|
|
|
|
/**点击事件**/
|
|
/**点击事件**/
|
|
/*保存*/
|
|
/*保存*/
|
|
- void saveBtnClickAction() {
|
|
|
|
|
|
+ Future<void> saveBtnClickAction() async {
|
|
_service.kind = _kindController.text;
|
|
_service.kind = _kindController.text;
|
|
_service.cycle = int.parse(_cycleController.text);
|
|
_service.cycle = int.parse(_cycleController.text);
|
|
_service.remindDay = int.parse(_remandController.text);
|
|
_service.remindDay = int.parse(_remandController.text);
|
|
_service.remark = _remarkConotroller.text;
|
|
_service.remark = _remarkConotroller.text;
|
|
_service.cycleUnit = '月';
|
|
_service.cycleUnit = '月';
|
|
- _service.id = 12;
|
|
|
|
|
|
+
|
|
|
|
+ /*检查数据*/
|
|
|
|
+ if (_service.kind.length == 0) {
|
|
|
|
+ Fluttertoast.showToast(
|
|
|
|
+ msg: "This is Center Short Toast",
|
|
|
|
+ toastLength: Toast.LENGTH_SHORT,
|
|
|
|
+ gravity: ToastGravity.CENTER,
|
|
|
|
+ timeInSecForIos: 1,
|
|
|
|
+ backgroundColor: JXColors.k1F2529,
|
|
|
|
+ textColor: JXColors.kFFFFFF,
|
|
|
|
+ );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ /*添加到数据库中,从数据库中取值返回*/
|
|
|
|
+ (await MyDataBase.database).saveService(_service);
|
|
print(_service.toMap());
|
|
print(_service.toMap());
|
|
Navigator.of(context).pop(_service);
|
|
Navigator.of(context).pop(_service);
|
|
}
|
|
}
|