|
|
|
@@ -4,6 +4,7 @@ import 'package:farm_tpf/data/api/app_exception.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/button_widget.dart'; |
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; |
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; |
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; |
|
|
|
@@ -104,113 +105,110 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> with Auto |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) => KeyboardDismisser( |
|
|
|
gestures: [GestureType.onTap], |
|
|
|
child: Container( |
|
|
|
gestures: [GestureType.onTap], |
|
|
|
child: Container( |
|
|
|
color: AppColors.ITEM_BG, |
|
|
|
child: SafeArea( |
|
|
|
top: false, |
|
|
|
bottom: true, |
|
|
|
child: Scaffold( |
|
|
|
appBar: widget.isShowAppbar ? AppBarWidget() : null, |
|
|
|
// PreferredSize( |
|
|
|
// preferredSize: Size(0, 0), |
|
|
|
// child: SizedBox(), |
|
|
|
// ), |
|
|
|
key: _scaffoldKey, |
|
|
|
body: KeyboardDismisser( |
|
|
|
child: StreamBuilder( |
|
|
|
stream: getPlotInfoBloc.actions, |
|
|
|
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) { |
|
|
|
if (snapshot.hasData) { |
|
|
|
return Form( |
|
|
|
key: _formKey, |
|
|
|
child: SingleChildScrollView( |
|
|
|
padding: EdgeInsets.all(8.0), |
|
|
|
child: Column( |
|
|
|
children: <Widget>[ |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), name: 'Mã lô', value: '${cropPlot.tbCropDTO?.code ?? ''}'), |
|
|
|
WidgetRowPlotInfo(color: AppColors.DEFAULT.withOpacity(0.3), name: 'Trạng thái', value: '$statusCrop'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), |
|
|
|
name: 'Nhà màng', |
|
|
|
value: '${cropPlot.tbCropDTO?.netHouseName ?? '--'}'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), |
|
|
|
name: 'Giống', |
|
|
|
value: '${cropPlot.tbCropDTO?.suppliesName ?? '--'}'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), |
|
|
|
name: 'Ngày gieo trồng', |
|
|
|
value: cropPlot.tbCropDTO?.tbCropTypeId == 0 |
|
|
|
? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}' |
|
|
|
: '--'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), |
|
|
|
name: 'Ngày vô khây ươm', |
|
|
|
value: cropPlot.tbCropDTO?.tbCropTypeId == 1 |
|
|
|
? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}' |
|
|
|
: '--'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), |
|
|
|
name: 'Thời gian ngâm hạt', |
|
|
|
value: '${cropPlot.seedIncubationTime ?? '--'} ngày'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), |
|
|
|
name: 'Số lượng cây trồng', |
|
|
|
value: '${cropPlot.numberPlants ?? '--'}'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), |
|
|
|
name: 'Số lượng cây hiện tại', |
|
|
|
value: '${cropPlot.numberCurrentPlants ?? '--'}'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), |
|
|
|
name: 'Ngày kết thúc canh tác', |
|
|
|
value: '${cropPlot.tbCropDTO?.endDate?.format_DDMMYY_HHmm() ?? '--'}'), |
|
|
|
WidgetRowPlotInfo(color: AppColors.DEFAULT.withOpacity(0.1), name: 'Kỹ sư trực tiếp', value: '$technicians'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), |
|
|
|
name: 'Diện tích (m\u00B2)', |
|
|
|
value: '${cropPlot.tbCropDTO?.areaM2?.formatNumtoStringDecimal()}'), |
|
|
|
SizedBox( |
|
|
|
height: 8, |
|
|
|
), |
|
|
|
_descriptionField(), |
|
|
|
SizedBox( |
|
|
|
height: 16, |
|
|
|
), |
|
|
|
GetBuilder<DescriptionChangeControler>( |
|
|
|
builder: (_) { |
|
|
|
return SizedBox( |
|
|
|
width: double.infinity, |
|
|
|
height: 55, |
|
|
|
child: TextButton( |
|
|
|
onPressed: controller.isChanged == false |
|
|
|
? () {} |
|
|
|
: () { |
|
|
|
FocusScopeNode currentFocus = FocusScope.of(context); |
|
|
|
if (!currentFocus.hasPrimaryFocus) { |
|
|
|
currentFocus.unfocus(); |
|
|
|
} |
|
|
|
_validateInputs(); |
|
|
|
}, |
|
|
|
child: Text('Cập nhật'.toUpperCase(), |
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: AppColors.WHITE, fontSize: 18)), |
|
|
|
), |
|
|
|
); |
|
|
|
}, |
|
|
|
) |
|
|
|
], |
|
|
|
), |
|
|
|
)); |
|
|
|
} else if (snapshot.hasError) { |
|
|
|
return Center( |
|
|
|
child: Text(snapshot.error.toString()), |
|
|
|
); |
|
|
|
} else { |
|
|
|
return LoadingListPage(); |
|
|
|
} |
|
|
|
})))))); |
|
|
|
top: false, |
|
|
|
bottom: true, |
|
|
|
child: Scaffold( |
|
|
|
appBar: widget.isShowAppbar ? AppBarWidget() : null, |
|
|
|
// PreferredSize( |
|
|
|
// preferredSize: Size(0, 0), |
|
|
|
// child: SizedBox(), |
|
|
|
// ), |
|
|
|
key: _scaffoldKey, |
|
|
|
body: KeyboardDismisser( |
|
|
|
child: StreamBuilder( |
|
|
|
stream: getPlotInfoBloc.actions, |
|
|
|
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) { |
|
|
|
if (snapshot.hasData) { |
|
|
|
return Form( |
|
|
|
key: _formKey, |
|
|
|
child: SingleChildScrollView( |
|
|
|
padding: EdgeInsets.all(8.0), |
|
|
|
child: Column( |
|
|
|
children: <Widget>[ |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), name: 'Mã lô', value: '${cropPlot.tbCropDTO?.code ?? ''}'), |
|
|
|
WidgetRowPlotInfo(color: AppColors.DEFAULT.withOpacity(0.3), name: 'Trạng thái', value: '$statusCrop'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), |
|
|
|
name: 'Nhà màng', |
|
|
|
value: '${cropPlot.tbCropDTO?.netHouseName ?? '--'}'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), name: 'Giống', value: '${cropPlot.tbCropDTO?.suppliesName ?? '--'}'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), |
|
|
|
name: 'Ngày gieo trồng', |
|
|
|
value: cropPlot.tbCropDTO?.tbCropTypeId == 0 |
|
|
|
? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}' |
|
|
|
: '--'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), |
|
|
|
name: 'Ngày vô khây ươm', |
|
|
|
value: cropPlot.tbCropDTO?.tbCropTypeId == 1 |
|
|
|
? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}' |
|
|
|
: '--'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), |
|
|
|
name: 'Thời gian ngâm hạt', |
|
|
|
value: '${cropPlot.seedIncubationTime ?? '--'} ngày'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), name: 'Số lượng cây trồng', value: '${cropPlot.numberPlants ?? '--'}'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.1), |
|
|
|
name: 'Số lượng cây hiện tại', |
|
|
|
value: '${cropPlot.numberCurrentPlants ?? '--'}'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), |
|
|
|
name: 'Ngày kết thúc canh tác', |
|
|
|
value: '${cropPlot.tbCropDTO?.endDate?.format_DDMMYY_HHmm() ?? '--'}'), |
|
|
|
WidgetRowPlotInfo(color: AppColors.DEFAULT.withOpacity(0.1), name: 'Kỹ sư trực tiếp', value: '$technicians'), |
|
|
|
WidgetRowPlotInfo( |
|
|
|
color: AppColors.DEFAULT.withOpacity(0.3), |
|
|
|
name: 'Diện tích (m\u00B2)', |
|
|
|
value: '${cropPlot.tbCropDTO?.areaM2?.formatNumtoStringDecimal()}'), |
|
|
|
SizedBox( |
|
|
|
height: 8, |
|
|
|
), |
|
|
|
_descriptionField(), |
|
|
|
SizedBox( |
|
|
|
height: 16, |
|
|
|
), |
|
|
|
GetBuilder<DescriptionChangeControler>( |
|
|
|
builder: (_) { |
|
|
|
return ButtonWidget( |
|
|
|
title: 'CẬP NHẬT', |
|
|
|
onPressed: controller.isChanged == false |
|
|
|
? () {} |
|
|
|
: () { |
|
|
|
FocusScopeNode currentFocus = FocusScope.of(context); |
|
|
|
if (!currentFocus.hasPrimaryFocus) { |
|
|
|
currentFocus.unfocus(); |
|
|
|
} |
|
|
|
_validateInputs(); |
|
|
|
}, |
|
|
|
); |
|
|
|
}, |
|
|
|
) |
|
|
|
], |
|
|
|
), |
|
|
|
)); |
|
|
|
} else if (snapshot.hasError) { |
|
|
|
return Center( |
|
|
|
child: Text(snapshot.error.toString()), |
|
|
|
); |
|
|
|
} else { |
|
|
|
return LoadingListPage(); |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
|
|
|
|
@override |
|
|
|
void dispose() { |