| _PlotActionScreenState createState() => _PlotActionScreenState(); | _PlotActionScreenState createState() => _PlotActionScreenState(); | ||||
| } | } | ||||
| class _PlotActionScreenState extends State<PlotActionScreen> { | |||||
| class _PlotActionScreenState extends State<PlotActionScreen> | |||||
| with AutomaticKeepAliveClientMixin { | |||||
| List<ActionType> actions = new List<ActionType>(); | List<ActionType> actions = new List<ActionType>(); | ||||
| ScrollController _scrollController; | ScrollController _scrollController; | ||||
| var blocPlotDetail = PlotDetailBloc(repository: Repository()); | var blocPlotDetail = PlotDetailBloc(repository: Repository()); | ||||
| ); | ); | ||||
| }); | }); | ||||
| } | } | ||||
| @override | |||||
| bool get wantKeepAlive => true; | |||||
| } | } | ||||
| class InfinityView extends StatefulWidget { | class InfinityView extends StatefulWidget { |
| import 'package:farm_tpf/presentation/custom_widgets/widget_rounded_rect_indicator.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_action.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_information.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_parameter.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot_detail/widget_tab.dart'; | |||||
| import 'package:farm_tpf/utils/const_assets.dart'; | |||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | |||||
| import 'package:get/get.dart'; | |||||
| class PlotDetailScreen extends StatefulWidget { | class PlotDetailScreen extends StatefulWidget { | ||||
| int cropId; | int cropId; | ||||
| class _PlotDetailScreenState extends State<PlotDetailScreen> { | class _PlotDetailScreenState extends State<PlotDetailScreen> { | ||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return Container( | |||||
| color: AppColors.ITEM_BG, | |||||
| child: SafeArea( | |||||
| top: false, | |||||
| bottom: true, | |||||
| child: Scaffold( | |||||
| appBar: AppBar( | |||||
| centerTitle: true, | |||||
| title: Text("Chi tiết lô"), | |||||
| actions: <Widget>[ | |||||
| IconButton( | |||||
| icon: Icon(FontAwesomeIcons.infoCircle), | |||||
| onPressed: () { | |||||
| Get.to(PlotInformationScreen( | |||||
| cropId: widget.cropId, | |||||
| )); | |||||
| }) | |||||
| ], | |||||
| ), | |||||
| body: DefaultTabController( | |||||
| initialIndex: widget.initialIndex, | |||||
| length: 2, | |||||
| child: new Scaffold( | |||||
| backgroundColor: AppColors.ITEM_BG, | |||||
| body: TabBarView( | |||||
| children: [ | |||||
| PlotParameterScreen( | |||||
| cropId: widget.cropId, | |||||
| ), | |||||
| PlotActionScreen( | |||||
| cropId: widget.cropId, | |||||
| cropCode: widget.cropCode, | |||||
| cropType: widget.cropType, | |||||
| ) | |||||
| ], | |||||
| ), | |||||
| bottomNavigationBar: new TabBar( | |||||
| tabs: [ | |||||
| Tab( | |||||
| text: ''' Chỉ số ''', | |||||
| ), | |||||
| Tab( | |||||
| text: "Canh tác", | |||||
| ), | |||||
| ], | |||||
| labelColor: AppColors.DEFAULT, | |||||
| unselectedLabelColor: AppColors.GRAY1_70, | |||||
| indicatorSize: TabBarIndicatorSize.label, | |||||
| indicator: RoundedRectIndicator( | |||||
| color: AppColors.DEFAULT, | |||||
| radius: 2, | |||||
| padding: 22, | |||||
| weight: 3.0), | |||||
| return Scaffold( | |||||
| appBar: AppBarWidget(), | |||||
| body: Column( | |||||
| children: [ | |||||
| Container( | |||||
| padding: EdgeInsets.all(8), | |||||
| width: double.infinity, | |||||
| color: Colors.white, | |||||
| child: Row( | |||||
| children: [ | |||||
| SizedBox( | |||||
| width: 12, | |||||
| ), | |||||
| Expanded( | |||||
| child: Container( | |||||
| height: 75, | |||||
| child: Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| mainAxisSize: MainAxisSize.min, | |||||
| children: [ | |||||
| Text('Rau muống trắng 6 sạch, 3 an toàn', | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.bold, fontSize: 18)), | |||||
| Expanded( | |||||
| child: SizedBox(), | |||||
| ), | |||||
| Row( | |||||
| children: [ | |||||
| SizedBox( | |||||
| width: 4, | |||||
| ), | |||||
| Text('item.startDate', | |||||
| style: TextStyle(color: Colors.grey)), | |||||
| SizedBox( | |||||
| width: 16, | |||||
| ), | |||||
| Text('item.startDate', | |||||
| style: TextStyle(color: Colors.grey)) | |||||
| ], | |||||
| ) | |||||
| ], | |||||
| ), | |||||
| ), | ), | ||||
| ), | ), | ||||
| ), | |||||
| ))); | |||||
| Image.asset( | |||||
| AppAssets.tempImage, | |||||
| width: 75, | |||||
| height: 75, | |||||
| ) | |||||
| ], | |||||
| ), | |||||
| ), | |||||
| Expanded( | |||||
| child: HomeTabbarWidget( | |||||
| cropType: widget.cropType, | |||||
| cropId: widget.cropId, | |||||
| cropCode: widget.cropCode, | |||||
| initialIndex: widget.initialIndex, | |||||
| )) | |||||
| ], | |||||
| ), | |||||
| ); | |||||
| } | } | ||||
| } | } |
| import 'package:flutter/material.dart'; | |||||
| class PlotHistoryScreen extends StatefulWidget { | |||||
| @override | |||||
| _PlotHistoryScreenState createState() => _PlotHistoryScreenState(); | |||||
| } | |||||
| class _PlotHistoryScreenState extends State<PlotHistoryScreen> | |||||
| with AutomaticKeepAliveClientMixin { | |||||
| @override | |||||
| Widget build(BuildContext context) { | |||||
| return Container(); | |||||
| } | |||||
| @override | |||||
| bool get wantKeepAlive => true; | |||||
| } |
| _PlotInformationScreenState createState() => _PlotInformationScreenState(); | _PlotInformationScreenState createState() => _PlotInformationScreenState(); | ||||
| } | } | ||||
| class _PlotInformationScreenState extends State<PlotInformationScreen> { | |||||
| class _PlotInformationScreenState extends State<PlotInformationScreen> | |||||
| with AutomaticKeepAliveClientMixin { | |||||
| final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); | final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); | ||||
| GlobalKey<FormState> _formKey = GlobalKey(); | GlobalKey<FormState> _formKey = GlobalKey(); | ||||
| TextEditingController _statusController = TextEditingController(); | TextEditingController _statusController = TextEditingController(); | ||||
| _descriptionController.dispose(); | _descriptionController.dispose(); | ||||
| super.dispose(); | super.dispose(); | ||||
| } | } | ||||
| @override | |||||
| bool get wantKeepAlive => true; | |||||
| } | } | ||||
| class DescriptionChangeControler extends GetxController { | class DescriptionChangeControler extends GetxController { |
| _PlotParameterScreenState createState() => _PlotParameterScreenState(); | _PlotParameterScreenState createState() => _PlotParameterScreenState(); | ||||
| } | } | ||||
| class _PlotParameterScreenState extends State<PlotParameterScreen> { | |||||
| class _PlotParameterScreenState extends State<PlotParameterScreen> | |||||
| with AutomaticKeepAliveClientMixin { | |||||
| var plotParameterBloc = PlotParameterBloc(repository: Repository()); | var plotParameterBloc = PlotParameterBloc(repository: Repository()); | ||||
| final _scrollController = ScrollController(); | final _scrollController = ScrollController(); | ||||
| final _scrollThreshold = 250.0; | final _scrollThreshold = 250.0; | ||||
| plotParameterBloc.close(); | plotParameterBloc.close(); | ||||
| super.dispose(); | super.dispose(); | ||||
| } | } | ||||
| @override | |||||
| bool get wantKeepAlive => true; | |||||
| } | } | ||||
| class ItemInfinityWidget extends StatelessWidget { | class ItemInfinityWidget extends StatelessWidget { |
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_history.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_parameter.dart'; | |||||
| import 'package:farm_tpf/utils/const_color.dart'; | |||||
| import 'package:flutter/material.dart'; | |||||
| import 'package:get/get.dart'; | |||||
| import 'sc_plot_action.dart'; | |||||
| import 'sc_plot_information.dart'; | |||||
| class HomeTabbarWidget extends StatefulWidget { | |||||
| int cropId; | |||||
| String cropCode; | |||||
| int cropType; | |||||
| int initialIndex; | |||||
| HomeTabbarWidget( | |||||
| {this.cropId, | |||||
| this.initialIndex = 0, | |||||
| this.cropCode, | |||||
| @required this.cropType}); | |||||
| @override | |||||
| _HomeTabbarWidgetState createState() => _HomeTabbarWidgetState(); | |||||
| } | |||||
| class _HomeTabbarWidgetState extends State<HomeTabbarWidget> | |||||
| with TickerProviderStateMixin { | |||||
| TabController tabbarController; | |||||
| final homeTabSelected = Get.put(HomeTabbarSelected()); | |||||
| @override | |||||
| void initState() { | |||||
| super.initState(); | |||||
| homeTabSelected.init(); | |||||
| tabbarController = TabController(vsync: this, length: 4); | |||||
| tabbarController.addListener(() { | |||||
| homeTabSelected.changeTab(tabbarController.index); | |||||
| }); | |||||
| } | |||||
| @override | |||||
| void dispose() { | |||||
| super.dispose(); | |||||
| tabbarController.dispose(); | |||||
| } | |||||
| @override | |||||
| Widget build(BuildContext context) { | |||||
| return Container( | |||||
| color: Colors.white, | |||||
| padding: EdgeInsets.only(top: 4, bottom: 4), | |||||
| child: DefaultTabController( | |||||
| length: 4, | |||||
| child: Scaffold( | |||||
| backgroundColor: Colors.white, | |||||
| appBar: PreferredSize( | |||||
| preferredSize: Size.fromHeight(40), | |||||
| child: Align( | |||||
| alignment: Alignment.centerLeft, | |||||
| child: GetBuilder<HomeTabbarSelected>(builder: (selectedTab) { | |||||
| return TabBar( | |||||
| controller: tabbarController, | |||||
| isScrollable: false, | |||||
| indicatorColor: AppColors.DEFAULT, | |||||
| onTap: (index) { | |||||
| homeTabSelected.changeTab(index); | |||||
| }, | |||||
| tabs: [ | |||||
| Container( | |||||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||||
| child: Text( | |||||
| 'Chỉ số', | |||||
| style: TextStyle( | |||||
| color: selectedTab.index == 0 | |||||
| ? AppColors.DEFAULT | |||||
| : Colors.black), | |||||
| ), | |||||
| ), | |||||
| Container( | |||||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||||
| child: Text('Thông tin', | |||||
| style: TextStyle( | |||||
| color: selectedTab.index == 1 | |||||
| ? AppColors.DEFAULT | |||||
| : Colors.black)), | |||||
| ), | |||||
| Container( | |||||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||||
| child: Text('Canh tác', | |||||
| style: TextStyle( | |||||
| color: selectedTab.index == 2 | |||||
| ? AppColors.DEFAULT | |||||
| : Colors.black)), | |||||
| ), | |||||
| Container( | |||||
| padding: EdgeInsets.only(top: 8, bottom: 8), | |||||
| child: Text('Lịch sử', | |||||
| style: TextStyle( | |||||
| color: selectedTab.index == 3 | |||||
| ? AppColors.DEFAULT | |||||
| : Colors.black)), | |||||
| ) | |||||
| ], | |||||
| ); | |||||
| }), | |||||
| ), | |||||
| ), | |||||
| body: TabBarView( | |||||
| controller: tabbarController, | |||||
| children: [ | |||||
| PlotParameterScreen( | |||||
| cropId: widget.cropId, | |||||
| ), | |||||
| PlotInformationScreen( | |||||
| cropId: widget.cropId, | |||||
| ), | |||||
| PlotActionScreen( | |||||
| cropId: widget.cropId, | |||||
| cropCode: widget.cropCode, | |||||
| cropType: widget.cropType, | |||||
| ), | |||||
| PlotHistoryScreen(), | |||||
| ], | |||||
| ), | |||||
| ), | |||||
| ), | |||||
| ); | |||||
| } | |||||
| } | |||||
| class HomeTabbarSelected extends GetxController { | |||||
| int index; | |||||
| void init() { | |||||
| index = 0; | |||||
| update(); | |||||
| } | |||||
| void changeTab(int changeIndex) { | |||||
| index = changeIndex; | |||||
| update(); | |||||
| } | |||||
| } |