| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_information.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/utils/const_icons.dart'; | import 'package:farm_tpf/utils/const_icons.dart'; | ||||
| import 'package:farm_tpf/utils/pref.dart'; | import 'package:farm_tpf/utils/pref.dart'; | ||||
| import 'package:firebase_messaging/firebase_messaging.dart'; | import 'package:firebase_messaging/firebase_messaging.dart'; | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return Scaffold( | return Scaffold( | ||||
| key: _scaffoldKey, | key: _scaffoldKey, | ||||
| backgroundColor: Colors.white, | |||||
| appBar: AppBarWidget( | appBar: AppBarWidget( | ||||
| isBack: false, | isBack: false, | ||||
| ), | ), | ||||
| Navigator.push( | Navigator.push( | ||||
| context, | context, | ||||
| MaterialPageRoute( | MaterialPageRoute( | ||||
| builder: (BuildContext context) => PlotDetailScreen( | |||||
| builder: (BuildContext context) => PlotParameterScreen( | |||||
| cropId: item.tbCropId, | cropId: item.tbCropId, | ||||
| cropType: item.type, | |||||
| isShowAppbar: true, | |||||
| ))).then((value) { | ))).then((value) { | ||||
| if (item.isRead == 0) { | if (item.isRead == 0) { | ||||
| _updateReadNotification( | _updateReadNotification( | ||||
| builder: (BuildContext context) => | builder: (BuildContext context) => | ||||
| PlotInformationScreen( | PlotInformationScreen( | ||||
| cropId: item.tbCropId, | cropId: item.tbCropId, | ||||
| isShowAppbar: true, | |||||
| ))).then((value) { | ))).then((value) { | ||||
| if (item.isRead == 0) { | if (item.isRead == 0) { | ||||
| _updateReadNotification( | _updateReadNotification( |
| import 'package:farm_tpf/presentation/screens/plot/widget_search.dart'; | import 'package:farm_tpf/presentation/screens/plot/widget_search.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_information.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/utils/const_assets.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:farm_tpf/utils/const_common.dart'; | import 'package:farm_tpf/utils/const_common.dart'; | ||||
| noti = NotificationDTO.fromJson(message); | noti = NotificationDTO.fromJson(message); | ||||
| } | } | ||||
| if (noti.contents == "ENV_UPDATE") { | if (noti.contents == "ENV_UPDATE") { | ||||
| Get.to(PlotDetailScreen( | |||||
| Get.to(PlotParameterScreen( | |||||
| cropId: noti.tbCropId, | cropId: noti.tbCropId, | ||||
| cropType: noti.type, | |||||
| isShowAppbar: true, | |||||
| )); | )); | ||||
| } else if (noti.contents == "PIC_UPDATE") { | } else if (noti.contents == "PIC_UPDATE") { | ||||
| Get.to(PlotInformationScreen( | Get.to(PlotInformationScreen( | ||||
| cropId: item.id, | cropId: item.id, | ||||
| initialIndex: 0, | initialIndex: 0, | ||||
| cropType: item.type, | cropType: item.type, | ||||
| code: item.code, | |||||
| areaM2: item.areaM2, | |||||
| suppliesName: item.suppliesName, | |||||
| ))); | ))); | ||||
| }); | }); | ||||
| } | } |
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.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/presentation/screens/plot_detail/widget_tab.dart'; | ||||
| import 'package:farm_tpf/utils/const_assets.dart'; | import 'package:farm_tpf/utils/const_assets.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | |||||
| import 'package:farm_tpf/utils/formatter.dart'; | |||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| class PlotDetailScreen extends StatefulWidget { | class PlotDetailScreen extends StatefulWidget { | ||||
| String cropCode; | String cropCode; | ||||
| int cropType; | int cropType; | ||||
| int initialIndex; | int initialIndex; | ||||
| String code; | |||||
| num areaM2; | |||||
| String suppliesName; | |||||
| PlotDetailScreen( | PlotDetailScreen( | ||||
| {this.cropId, | {this.cropId, | ||||
| this.initialIndex = 0, | this.initialIndex = 0, | ||||
| this.cropCode, | this.cropCode, | ||||
| @required this.cropType}); | |||||
| @required this.cropType, | |||||
| @required this.code, | |||||
| @required this.areaM2, | |||||
| @required this.suppliesName}); | |||||
| @override | @override | ||||
| _PlotDetailScreenState createState() => _PlotDetailScreenState(); | _PlotDetailScreenState createState() => _PlotDetailScreenState(); | ||||
| } | } | ||||
| crossAxisAlignment: CrossAxisAlignment.start, | crossAxisAlignment: CrossAxisAlignment.start, | ||||
| mainAxisSize: MainAxisSize.min, | mainAxisSize: MainAxisSize.min, | ||||
| children: [ | children: [ | ||||
| Text('Rau muống trắng 6 sạch, 3 an toàn', | |||||
| Text('${widget.suppliesName ?? ''}', | |||||
| style: TextStyle( | style: TextStyle( | ||||
| fontWeight: FontWeight.bold, fontSize: 18)), | fontWeight: FontWeight.bold, fontSize: 18)), | ||||
| Expanded( | Expanded( | ||||
| ), | ), | ||||
| Row( | Row( | ||||
| children: [ | children: [ | ||||
| SizedBox( | |||||
| width: 4, | |||||
| ), | |||||
| Text('item.startDate', | |||||
| Text('Mã lô: ${widget.code ?? ''}', | |||||
| style: TextStyle(color: Colors.grey)), | style: TextStyle(color: Colors.grey)), | ||||
| SizedBox( | SizedBox( | ||||
| width: 16, | width: 16, | ||||
| ), | ), | ||||
| Text('item.startDate', | |||||
| Text( | |||||
| 'Diện tích: ${widget.areaM2.formatNumtoStringDecimal() ?? '0'} m\u00B2', | |||||
| style: TextStyle(color: Colors.grey)) | style: TextStyle(color: Colors.grey)) | ||||
| ], | ], | ||||
| ) | ) |
| import 'package:farm_tpf/custom_model/CropPlot.dart'; | import 'package:farm_tpf/custom_model/CropPlot.dart'; | ||||
| import 'package:farm_tpf/data/api/app_exception.dart'; | import 'package:farm_tpf/data/api/app_exception.dart'; | ||||
| import 'package:farm_tpf/data/repository/repository.dart'; | import 'package:farm_tpf/data/repository/repository.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/bloc/widget_row_plot_info.dart'; | import 'package:farm_tpf/presentation/custom_widgets/bloc/widget_row_plot_info.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/button_widget.dart'; | import 'package:farm_tpf/presentation/custom_widgets/button_widget.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | ||||
| class PlotInformationScreen extends StatefulWidget { | class PlotInformationScreen extends StatefulWidget { | ||||
| final int cropId; | final int cropId; | ||||
| PlotInformationScreen({@required this.cropId}); | |||||
| final bool isShowAppbar; | |||||
| PlotInformationScreen({@required this.cropId, this.isShowAppbar}); | |||||
| @override | @override | ||||
| _PlotInformationScreenState createState() => _PlotInformationScreenState(); | _PlotInformationScreenState createState() => _PlotInformationScreenState(); | ||||
| } | } | ||||
| ); | ); | ||||
| } | } | ||||
| _actionAppBar() { | |||||
| return <Widget>[ | |||||
| GetBuilder<DescriptionChangeControler>( | |||||
| builder: (_) { | |||||
| return IconButton( | |||||
| icon: Icon( | |||||
| Icons.done, | |||||
| ), | |||||
| disabledColor: Colors.grey, | |||||
| onPressed: controller.isChanged == false | |||||
| ? null | |||||
| : () { | |||||
| FocusScopeNode currentFocus = FocusScope.of(context); | |||||
| if (!currentFocus.hasPrimaryFocus) { | |||||
| currentFocus.unfocus(); | |||||
| } | |||||
| _validateInputs(); | |||||
| }, | |||||
| ); | |||||
| }, | |||||
| ) | |||||
| ]; | |||||
| } | |||||
| @override | @override | ||||
| Widget build(BuildContext context) => KeyboardDismisser( | Widget build(BuildContext context) => KeyboardDismisser( | ||||
| gestures: [ | gestures: [ | ||||
| top: false, | top: false, | ||||
| bottom: true, | bottom: true, | ||||
| child: Scaffold( | child: Scaffold( | ||||
| appBar: widget.isShowAppbar | |||||
| ? AppBarWidget() | |||||
| : PreferredSize( | |||||
| preferredSize: Size(0, 0), | |||||
| child: SizedBox(), | |||||
| ), | |||||
| key: _scaffoldKey, | key: _scaffoldKey, | ||||
| body: KeyboardDismisser( | body: KeyboardDismisser( | ||||
| child: StreamBuilder( | child: StreamBuilder( |
| import 'package:farm_tpf/custom_model/EnvironmentParameter.dart'; | import 'package:farm_tpf/custom_model/EnvironmentParameter.dart'; | ||||
| import 'package:farm_tpf/data/repository/repository.dart'; | import 'package:farm_tpf/data/repository/repository.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| class PlotParameterScreen extends StatefulWidget { | class PlotParameterScreen extends StatefulWidget { | ||||
| final int cropId; | final int cropId; | ||||
| PlotParameterScreen({@required this.cropId}); | |||||
| final bool isShowAppbar; | |||||
| PlotParameterScreen({@required this.cropId, this.isShowAppbar = false}); | |||||
| @override | @override | ||||
| _PlotParameterScreenState createState() => _PlotParameterScreenState(); | _PlotParameterScreenState createState() => _PlotParameterScreenState(); | ||||
| } | } | ||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return Column( | |||||
| children: <Widget>[ | |||||
| Expanded( | |||||
| child: BlocBuilder<PlotParameterBloc, PlotParameterState>( | |||||
| cubit: plotParameterBloc, | |||||
| builder: (context, state) { | |||||
| if (state is PlotParameterFailure) { | |||||
| return Center(child: Text(state.errorString)); | |||||
| } | |||||
| if (state is PlotParameterSuccess) { | |||||
| if (state.items.isEmpty) { | |||||
| return Center(child: Text(label_list_empty)); | |||||
| } | |||||
| return RefreshIndicator( | |||||
| child: GridView.builder( | |||||
| gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | |||||
| crossAxisCount: 2), | |||||
| physics: AlwaysScrollableScrollPhysics(), | |||||
| itemBuilder: (BuildContext context, int index) { | |||||
| return index >= state.items.length | |||||
| ? BottomLoader() | |||||
| : ItemInfinityWidget(item: state.items[index]); | |||||
| }, | |||||
| itemCount: state.hasReachedMax | |||||
| ? state.items.length | |||||
| : state.items.length + 1, | |||||
| controller: _scrollController, | |||||
| ), | |||||
| onRefresh: () async { | |||||
| plotParameterBloc.add(OnRefresh(cropId: widget.cropId)); | |||||
| }); | |||||
| } | |||||
| return Center( | |||||
| child: LoadingListPage(), | |||||
| ); | |||||
| }, | |||||
| )) | |||||
| ], | |||||
| return Scaffold( | |||||
| backgroundColor: Colors.white, | |||||
| appBar: widget.isShowAppbar | |||||
| ? AppBarWidget() | |||||
| : PreferredSize( | |||||
| preferredSize: Size(0, 0), | |||||
| child: SizedBox(), | |||||
| ), | |||||
| body: SafeArea( | |||||
| child: Column( | |||||
| children: <Widget>[ | |||||
| Expanded( | |||||
| child: BlocBuilder<PlotParameterBloc, PlotParameterState>( | |||||
| cubit: plotParameterBloc, | |||||
| builder: (context, state) { | |||||
| if (state is PlotParameterFailure) { | |||||
| return Center(child: Text(state.errorString)); | |||||
| } | |||||
| if (state is PlotParameterSuccess) { | |||||
| if (state.items.isEmpty) { | |||||
| return Center(child: Text(label_list_empty)); | |||||
| } | |||||
| return RefreshIndicator( | |||||
| child: GridView.builder( | |||||
| gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | |||||
| crossAxisCount: 2), | |||||
| physics: AlwaysScrollableScrollPhysics(), | |||||
| itemBuilder: (BuildContext context, int index) { | |||||
| return index >= state.items.length | |||||
| ? BottomLoader() | |||||
| : ItemInfinityWidget(item: state.items[index]); | |||||
| }, | |||||
| itemCount: state.hasReachedMax | |||||
| ? state.items.length | |||||
| : state.items.length + 1, | |||||
| controller: _scrollController, | |||||
| ), | |||||
| onRefresh: () async { | |||||
| plotParameterBloc.add(OnRefresh(cropId: widget.cropId)); | |||||
| }); | |||||
| } | |||||
| return Center( | |||||
| child: LoadingListPage(), | |||||
| ); | |||||
| }, | |||||
| )) | |||||
| ], | |||||
| ), | |||||
| ), | |||||
| ); | ); | ||||
| } | } | ||||