Browse Source

add resultTime action spraying

master
daivph 5 years ago
parent
commit
493cb24e12
2 changed files with 64 additions and 4 deletions
  1. +63
    -3
      lib/presentation/screens/actions/spraying/sc_edit_action_spraying.dart
  2. +1
    -1
      lib/presentation/screens/actions/spraying/widget_spraying_supply.dart

+ 63
- 3
lib/presentation/screens/actions/spraying/sc_edit_action_spraying.dart View File

@@ -53,6 +53,8 @@ class _EditActionSprayingScreenState extends State<EditActionSprayingScreen> {

String executeTimeView;
DateTime executeTime = DateTime.now();
String resultAtView;
DateTime resultAtTime;
List<String> filePaths = List<String>();
var changeFileController = Get.put(ChangeFileController());

@@ -180,6 +182,41 @@ class _EditActionSprayingScreenState extends State<EditActionSprayingScreen> {
)));
}

Widget _btnResultAtTimePicker() {
return FlatButton(
padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0),
onPressed: () {
DatePicker.showDateTimePicker(context,
showTitleActions: true, onChanged: (date) {}, onConfirm: (date) {
setState(() {
var parsedDate =
DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(date);
_spraying.resultAt = "$parsedDate";
resultAtView = DateFormat("dd/MM/yyyy HH:mm").format(date);
});
}, currentTime: resultAtTime, locale: LocaleType.vi);
},
child: Container(
padding:
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 10.5, left: 0.0),
decoration: BoxDecoration(
border: kBorderTextField,
),
child: Row(
children: [
Expanded(
child: Text(
resultAtView == null ? "" : resultAtView,
style: TextStyle(fontSize: 14.0, color: Colors.black87),
)),
Icon(
Icons.date_range,
color: Colors.blue,
),
],
)));
}

Widget _purposeField() {
return TextFormField(
keyboardType: TextInputType.text,
@@ -315,10 +352,20 @@ class _EditActionSprayingScreenState extends State<EditActionSprayingScreen> {
executeTime =
DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
.parse(_spraying.executeDate);
executeTimeView =
DateFormat("dd/MM/yyyy HH:mm")
.format(executeTime);
} catch (_) {}

try {
resultAtTime =
DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
.parse(_spraying.resultAt);
resultAtView =
DateFormat("dd/MM/yyyy HH:mm")
.format(resultAtTime);
} catch (_) {}
executeTimeView =
DateFormat("dd/MM/yyyy HH:mm")
.format(executeTime);

//Show media
if (_spraying.media != null) {
await UtilAction.cacheFiles(_spraying.media)
@@ -364,6 +411,19 @@ class _EditActionSprayingScreenState extends State<EditActionSprayingScreen> {
SizedBox(
height: 8.0,
),
Container(
width: double.infinity,
child: Text(
"Thời gian ghi nhận kết quả",
style: TextStyle(
color: Colors.black54,
fontSize: 13.0),
),
),
_btnResultAtTimePicker(),
SizedBox(
height: 8.0,
),
_weatherField(),
SizedBox(
height: 8.0,

+ 1
- 1
lib/presentation/screens/actions/spraying/widget_spraying_supply.dart View File

@@ -155,7 +155,7 @@ class _WidgetSprayingSupplyState extends State<WidgetSprayingSupply> {
.push(MaterialPageRoute(
builder: (_) => ResourceHelperScreen(
titleName: "Thuốc BVTV",
type: ConstCommon.supplyTypeAll,
type: ConstCommon.supplyTypeProtectPlant,
selectedId: changeSelectedSupply.selectedSupplyId),
fullscreenDialog: false))
.then((value) {

Loading…
Cancel
Save