You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
6.3KB

  1. import 'package:farm_tpf/models/Plot.dart';
  2. import 'package:farm_tpf/presentation/custom_widgets/widget_media_helper.dart';
  3. import 'package:farm_tpf/utils/const_color.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:keyboard_dismisser/keyboard_dismisser.dart';
  6. class PlotInformationScreen extends StatefulWidget {
  7. final Plot plot;
  8. PlotInformationScreen({this.plot});
  9. @override
  10. _PlotInformationScreenState createState() => _PlotInformationScreenState();
  11. }
  12. class _PlotInformationScreenState extends State<PlotInformationScreen> {
  13. final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
  14. GlobalKey<FormState> _formKey = GlobalKey();
  15. bool _autoValidate = false;
  16. Plot _plot = Plot();
  17. _validateInputs() async {
  18. if (_formKey.currentState.validate()) {
  19. _formKey.currentState.save();
  20. } else {
  21. _autoValidate = true;
  22. }
  23. }
  24. Widget _statusField() {
  25. return TextFormField(
  26. decoration: InputDecoration(labelText: "Trạng thái"),
  27. );
  28. }
  29. Widget _houseNameField() {
  30. return TextFormField(
  31. decoration: InputDecoration(labelText: "Nhà màng"),
  32. );
  33. }
  34. Widget _codeField() {
  35. return TextFormField(
  36. decoration: InputDecoration(labelText: "Mã lô"),
  37. );
  38. }
  39. Widget _supplyNameField() {
  40. return TextFormField(
  41. decoration: InputDecoration(labelText: "Giống"),
  42. );
  43. }
  44. Widget _seedingDateField() {
  45. return TextFormField(
  46. decoration: InputDecoration(labelText: "Ngày gieo trồng"),
  47. );
  48. }
  49. Widget _timeSoakSeedField() {
  50. return TextFormField(
  51. decoration: InputDecoration(labelText: "Thời gian ngâm hạt"),
  52. );
  53. }
  54. Widget _timeNurserySeedField() {
  55. return TextFormField(
  56. decoration: InputDecoration(labelText: "Thời gian vô khây ươm"),
  57. );
  58. }
  59. Widget _quantityPlantField() {
  60. return TextFormField(
  61. decoration: InputDecoration(labelText: "Số lượng cây trồng"),
  62. );
  63. }
  64. Widget _currentPlantField() {
  65. return TextFormField(
  66. decoration: InputDecoration(labelText: "Số lượng cây hiện tại"),
  67. );
  68. }
  69. Widget _timeEndGrowField() {
  70. return TextFormField(
  71. decoration: InputDecoration(labelText: "Ngày kết thúc canh tác"),
  72. );
  73. }
  74. Widget _mainTechnicianField() {
  75. return TextFormField(
  76. decoration: InputDecoration(labelText: "Kỹ sư trực tiếp"),
  77. );
  78. }
  79. Widget _areaField() {
  80. return TextFormField(
  81. decoration: InputDecoration(labelText: "Diện tích (m\u00B2)"),
  82. );
  83. }
  84. Widget _descriptionField() {
  85. return TextFormField(
  86. decoration: InputDecoration(labelText: "Ghi chú"),
  87. );
  88. }
  89. _actionAppBar() {
  90. IconButton iconButton;
  91. if (_plot.id != null) {
  92. iconButton = IconButton(
  93. icon: Icon(
  94. Icons.done,
  95. color: COLOR_CONST.DEFAULT,
  96. ),
  97. onPressed: () {},
  98. );
  99. return <Widget>[iconButton];
  100. }
  101. return <Widget>[Container()];
  102. }
  103. @override
  104. Widget build(BuildContext context) => KeyboardDismisser(
  105. gestures: [
  106. GestureType.onTap,
  107. GestureType.onPanUpdateDownDirection,
  108. ],
  109. child: Container(
  110. color: COLOR_CONST.ITEM_BG,
  111. child: SafeArea(
  112. top: false,
  113. bottom: true,
  114. child: Scaffold(
  115. key: _scaffoldKey,
  116. appBar: AppBar(
  117. centerTitle: true,
  118. title: Text("Thông tin lô"),
  119. actions: _actionAppBar()),
  120. body: KeyboardDismisser(
  121. child: Form(
  122. key: _formKey,
  123. autovalidate: _autoValidate,
  124. child: SingleChildScrollView(
  125. padding: EdgeInsets.all(8.0),
  126. child: Column(
  127. children: <Widget>[
  128. _statusField(),
  129. SizedBox(
  130. height: 4.0,
  131. ),
  132. _houseNameField(),
  133. SizedBox(
  134. height: 4.0,
  135. ),
  136. _codeField(),
  137. SizedBox(
  138. height: 4.0,
  139. ),
  140. _supplyNameField(),
  141. SizedBox(
  142. height: 4.0,
  143. ),
  144. _seedingDateField(),
  145. SizedBox(
  146. height: 4.0,
  147. ),
  148. _timeSoakSeedField(),
  149. SizedBox(
  150. height: 4.0,
  151. ),
  152. _timeNurserySeedField(),
  153. SizedBox(
  154. height: 4.0,
  155. ),
  156. _quantityPlantField(),
  157. SizedBox(
  158. height: 4.0,
  159. ),
  160. _currentPlantField(),
  161. SizedBox(
  162. height: 4.0,
  163. ),
  164. _timeEndGrowField(),
  165. SizedBox(
  166. height: 4.0,
  167. ),
  168. _mainTechnicianField(),
  169. SizedBox(
  170. height: 4.0,
  171. ),
  172. _areaField(),
  173. SizedBox(
  174. height: 4.0,
  175. ),
  176. _descriptionField()
  177. ],
  178. ),
  179. )))))));
  180. }