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.

113 lines
3.8KB

  1. import 'package:farm_tpf/utils/const_color.dart';
  2. import 'package:farm_tpf/utils/const_string.dart';
  3. import 'package:flutter/material.dart';
  4. class PlotActionScreen extends StatefulWidget {
  5. @override
  6. _PlotActionScreenState createState() => _PlotActionScreenState();
  7. }
  8. class _PlotActionScreenState extends State<PlotActionScreen> {
  9. List<ActionType> actions = new List<ActionType>();
  10. @override
  11. void initState() {
  12. super.initState();
  13. actions.add(ActionType(plot_action_nursery, null, null));
  14. actions.add(ActionType(plot_action_plant, null, null));
  15. actions.add(ActionType(plot_action_crop_status, null, null));
  16. actions.add(ActionType(plot_action_environment_update, null, null));
  17. actions.add(ActionType(plot_action_dung, null, null));
  18. actions.add(ActionType(plot_action_spraying, null, null));
  19. actions.add(ActionType(plot_action_disease, null, null));
  20. actions.add(ActionType(plot_action_use_water, null, null));
  21. actions.add(ActionType(plot_action_other, null, null));
  22. actions.add(ActionType(plot_action_harvest, null, null));
  23. actions.add(ActionType(plot_action_finish, null, null));
  24. }
  25. Widget _createShrimpUpdate(ActionType actionType) {
  26. return GestureDetector(
  27. onTap: () {
  28. Navigator.of(context).push(
  29. MaterialPageRoute(builder: (context) => actionType.listScreen));
  30. },
  31. child: Container(
  32. height: 75,
  33. margin: EdgeInsets.all(4.0),
  34. padding: EdgeInsets.all(0.0),
  35. decoration: BoxDecoration(
  36. color: COLOR_CONST.WHITE,
  37. borderRadius: BorderRadius.only(
  38. topLeft: Radius.circular(8.0),
  39. bottomLeft: Radius.circular(8.0),
  40. bottomRight: Radius.circular(8.0),
  41. topRight: Radius.circular(8.0)),
  42. boxShadow: <BoxShadow>[
  43. BoxShadow(
  44. color: COLOR_CONST.GRAY1.withOpacity(0.2),
  45. offset: Offset(1.1, 1.1),
  46. blurRadius: 10.0),
  47. ],
  48. ),
  49. child: Stack(
  50. children: <Widget>[
  51. Positioned(
  52. top: -10,
  53. right: -3,
  54. child: (actionType.addScreen == null)
  55. ? Container()
  56. : IconButton(
  57. icon: Icon(
  58. Icons.add_circle,
  59. size: 40,
  60. color: Colors.green,
  61. ),
  62. onPressed: () {
  63. Navigator.of(context).push(MaterialPageRoute(
  64. builder: (context) => actionType.addScreen));
  65. })),
  66. Positioned.fill(
  67. child: Align(
  68. alignment: Alignment.center,
  69. child: Text(
  70. actionType.actionName,
  71. textAlign: TextAlign.center,
  72. style: TextStyle(
  73. fontWeight: FontWeight.w400,
  74. fontSize: 16,
  75. color: COLOR_CONST.BLACK2,
  76. ),
  77. )),
  78. ),
  79. ],
  80. ),
  81. ));
  82. }
  83. @override
  84. Widget build(BuildContext context) {
  85. return Scaffold(
  86. body: GridView.count(
  87. crossAxisCount: 2,
  88. childAspectRatio: 16 / 6,
  89. children: actions.map(
  90. (item) {
  91. return _createShrimpUpdate(item);
  92. },
  93. ).toList()),
  94. );
  95. }
  96. }
  97. class ActionType {
  98. Widget addScreen;
  99. Widget listScreen;
  100. String actionName;
  101. ActionType(String actionName, Widget addScreen, Widget listScreen) {
  102. this.actionName = actionName;
  103. this.addScreen = addScreen;
  104. this.listScreen = listScreen;
  105. }
  106. }