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.

194 lines
6.2KB

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