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.

195 lines
6.2KB

  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. iconButton = IconButton(
  92. icon: Icon(
  93. Icons.done,
  94. ),
  95. onPressed: () {},
  96. );
  97. return <Widget>[iconButton];
  98. }
  99. @override
  100. Widget build(BuildContext context) => KeyboardDismisser(
  101. gestures: [
  102. GestureType.onTap,
  103. GestureType.onPanUpdateDownDirection,
  104. ],
  105. child: Container(
  106. color: COLOR_CONST.ITEM_BG,
  107. child: SafeArea(
  108. top: false,
  109. bottom: true,
  110. child: Scaffold(
  111. key: _scaffoldKey,
  112. appBar: AppBar(
  113. centerTitle: true,
  114. title: Text("Thông tin lô"),
  115. actions: _actionAppBar()),
  116. body: KeyboardDismisser(
  117. child: Form(
  118. key: _formKey,
  119. autovalidate: _autoValidate,
  120. child: SingleChildScrollView(
  121. padding: EdgeInsets.all(8.0),
  122. child: Column(
  123. children: <Widget>[
  124. _statusField(),
  125. SizedBox(
  126. height: 4.0,
  127. ),
  128. _houseNameField(),
  129. SizedBox(
  130. height: 4.0,
  131. ),
  132. _codeField(),
  133. SizedBox(
  134. height: 4.0,
  135. ),
  136. _supplyNameField(),
  137. SizedBox(
  138. height: 4.0,
  139. ),
  140. _seedingDateField(),
  141. SizedBox(
  142. height: 4.0,
  143. ),
  144. _timeSoakSeedField(),
  145. SizedBox(
  146. height: 4.0,
  147. ),
  148. _timeNurserySeedField(),
  149. SizedBox(
  150. height: 4.0,
  151. ),
  152. _quantityPlantField(),
  153. SizedBox(
  154. height: 4.0,
  155. ),
  156. _currentPlantField(),
  157. SizedBox(
  158. height: 4.0,
  159. ),
  160. _timeEndGrowField(),
  161. SizedBox(
  162. height: 4.0,
  163. ),
  164. _mainTechnicianField(),
  165. SizedBox(
  166. height: 4.0,
  167. ),
  168. _areaField(),
  169. SizedBox(
  170. height: 4.0,
  171. ),
  172. _descriptionField()
  173. ],
  174. ),
  175. )))))));
  176. }