Browse Source

ui info plot

master
daivph 5 years ago
parent
commit
e84865f68b
3 changed files with 214 additions and 213 deletions
  1. +36
    -0
      lib/presentation/custom_widgets/bloc/widget_row_plot_info.dart
  2. +142
    -199
      lib/presentation/screens/plot_detail/sc_plot_information.dart
  3. +36
    -14
      lib/presentation/screens/plot_detail/sc_plot_parameter.dart

+ 36
- 0
lib/presentation/custom_widgets/bloc/widget_row_plot_info.dart View File

@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';

class WidgetRowPlotInfo extends StatelessWidget {
final Color color;
final String name;
final String value;
WidgetRowPlotInfo(
{@required this.color, @required this.name, @required this.value});
@override
Widget build(BuildContext context) {
return Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Container(
padding: EdgeInsets.all(12),
color: color,
child: Text(
name,
style: TextStyle(fontSize: 16),
),
),
),
Container(width: 2, height: 40, color: Colors.white),
Expanded(
child: Container(
padding: EdgeInsets.all(12),
color: color,
child: Text(value ?? '--', style: TextStyle(fontSize: 16))),
),
],
),
);
}
}

+ 142
- 199
lib/presentation/screens/plot_detail/sc_plot_information.dart View File

@@ -1,9 +1,10 @@
import 'package:farm_tpf/custom_model/CropPlot.dart';
import 'package:farm_tpf/data/api/app_exception.dart';
import 'package:farm_tpf/data/repository/repository.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_toast.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/bloc_plot_information.dart';
import 'package:farm_tpf/utils/const_color.dart';
@@ -24,32 +25,23 @@ class _PlotInformationScreenState extends State<PlotInformationScreen>
with AutomaticKeepAliveClientMixin {
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
GlobalKey<FormState> _formKey = GlobalKey();
TextEditingController _statusController = TextEditingController();
TextEditingController _houseNameController = TextEditingController();
TextEditingController _codeController = TextEditingController();
TextEditingController _supplyNameController = TextEditingController();
TextEditingController _seedingDateController = TextEditingController();
TextEditingController _timeSoakSeedController = TextEditingController();
TextEditingController _timeNurserySeedController = TextEditingController();
TextEditingController _quantityPlantController = TextEditingController();
TextEditingController _currentPlantController = TextEditingController();
TextEditingController _timeEndGrowController = TextEditingController();
TextEditingController _mainTechnicianController = TextEditingController();
TextEditingController _areaController = TextEditingController();
TextEditingController _descriptionController = TextEditingController();

bool _autoValidate = false;
CropPlot cropPlot = CropPlot();
TbCropDTO _crop = TbCropDTO();
final controller = Get.put(DescriptionChangeControler());
Repository _repository = Repository();
String statusCrop = plot_status_unknown;
String technicians = '--';

@override
void initState() {
super.initState();
getPlotInfoBloc.getPlotInfo(widget.cropId, (data) {
var result = data as CropPlot;
cropPlot = result;
_crop = result.tbCropDTO;
var statusCrop;
switch (_crop.status) {
case "STATUS_ARE_ACTIVE":
statusCrop = plot_status_active;
@@ -60,26 +52,8 @@ class _PlotInformationScreenState extends State<PlotInformationScreen>
default:
statusCrop = plot_status_unknown;
}

_statusController.text = statusCrop;
_houseNameController.text = _crop.netHouseName?.toString();
_codeController.text = _crop.code?.toString();
_supplyNameController.text = _crop.suppliesName?.toString();
_areaController.text = _crop.areaM2.formatNumtoStringDecimal();
_seedingDateController.text = result.sowingDate.format_DDMMYY_HHmm();
_timeSoakSeedController.text =
result.soakSeedsTime.formatNumtoStringDecimal();
_timeNurserySeedController.text =
result.soakSeedsTime.formatNumtoStringDecimal();
_quantityPlantController.text =
result.numberPlants.formatNumtoStringDecimal();
_currentPlantController.text =
result.numberCurrentPlants.formatNumtoStringDecimal();
_timeEndGrowController.text = _crop.endDate.format_DDMMYY_HHmm();
_descriptionController.text =
_crop.description == null ? "" : _crop.description.toString();
var technicians = _crop.tbDetailUsers.map((e) => e.fullName).join(", ");
_mainTechnicianController.text = technicians;
}, (err) {});
}

@@ -100,113 +74,25 @@ class _PlotInformationScreenState extends State<PlotInformationScreen>
}
}

Widget _statusField() {
return TextFormField(
enabled: false,
controller: _statusController,
decoration: InputDecoration(labelText: "Trạng thái"),
);
}

Widget _houseNameField() {
return TextFormField(
enabled: false,
controller: _houseNameController,
decoration: InputDecoration(labelText: "Nhà màng"),
);
}

Widget _codeField() {
return TextFormField(
enabled: false,
controller: _codeController,
decoration: InputDecoration(labelText: "Mã lô"),
);
}

Widget _supplyNameField() {
return TextFormField(
enabled: false,
controller: _supplyNameController,
decoration: InputDecoration(labelText: "Giống"),
);
}

Widget _seedingDateField() {
return TextFormField(
enabled: false,
controller: _seedingDateController,
decoration: InputDecoration(labelText: "Ngày gieo trồng"),
);
}

Widget _timeSoakSeedField() {
return TextFormField(
enabled: false,
controller: _timeSoakSeedController,
decoration: InputDecoration(labelText: "Thời gian ngâm hạt"),
);
}

Widget _timeNurserySeedField() {
return TextFormField(
enabled: false,
controller: _timeNurserySeedController,
decoration: InputDecoration(labelText: "Thời gian vô khây ươm"),
);
}

Widget _quantityPlantField() {
return TextFormField(
enabled: false,
controller: _quantityPlantController,
decoration: InputDecoration(labelText: "Số lượng cây trồng"),
);
}

Widget _currentPlantField() {
return TextFormField(
enabled: false,
controller: _currentPlantController,
decoration: InputDecoration(labelText: "Số lượng cây hiện tại"),
);
}

Widget _timeEndGrowField() {
return TextFormField(
enabled: false,
controller: _timeEndGrowController,
decoration: InputDecoration(labelText: "Ngày kết thúc canh tác"),
);
}

Widget _mainTechnicianField() {
return TextFormField(
enabled: false,
controller: _mainTechnicianController,
decoration: InputDecoration(labelText: "Kỹ sư trực tiếp"),
);
}

Widget _areaField() {
return TextFormField(
enabled: false,
controller: _areaController,
decoration: InputDecoration(labelText: "Diện tích (m\u00B2)"),
);
}

Widget _descriptionField() {
return TextFormField(
keyboardType: TextInputType.text,
controller: _descriptionController,
decoration: InputDecoration(labelText: "Ghi chú"),
onSaved: (newValue) {
_crop.description = newValue;
},
onChanged: (newValue) {
controller.changeValue(_crop.description, newValue);
},
return Container(
padding: EdgeInsets.all(8),
color: Colors.yellow[100],
child: TextFormField(
keyboardType: TextInputType.text,
controller: _descriptionController,
decoration: InputDecoration(
labelText: "Ghi chú",
hintText: 'Ghi chú',
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey, width: 0.35))),
onSaved: (newValue) {
_crop.description = newValue;
},
onChanged: (newValue) {
controller.changeValue(_crop.description, newValue);
},
),
);
}

@@ -247,10 +133,6 @@ class _PlotInformationScreenState extends State<PlotInformationScreen>
bottom: true,
child: Scaffold(
key: _scaffoldKey,
appBar: AppBar(
centerTitle: true,
title: Text("Thông tin lô"),
actions: _actionAppBar()),
body: KeyboardDismisser(
child: StreamBuilder(
stream: getPlotInfoBloc.actions,
@@ -264,55 +146,128 @@ class _PlotInformationScreenState extends State<PlotInformationScreen>
padding: EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
_statusField(),
SizedBox(
height: 4.0,
),
_houseNameField(),
SizedBox(
height: 4.0,
),
_codeField(),
SizedBox(
height: 4.0,
),
_supplyNameField(),
SizedBox(
height: 4.0,
),
_seedingDateField(),
SizedBox(
height: 4.0,
),
_timeSoakSeedField(),
SizedBox(
height: 4.0,
),
_timeNurserySeedField(),
SizedBox(
height: 4.0,
),
_quantityPlantField(),
SizedBox(
height: 4.0,
),
_currentPlantField(),
SizedBox(
height: 4.0,
),
_timeEndGrowField(),
SizedBox(
height: 4.0,
),
_mainTechnicianField(),
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.sowingDate ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT
.withOpacity(0.3),
name: 'Thời gian ngâm hạt',
value:
'${cropPlot.soakSeedsTime ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT
.withOpacity(0.1),
name: 'Ngày vô khây ươm',
value:
'${cropPlot.seedIncubationTime ?? '--'}'),
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 ?? '--'}'),
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: 4.0,
height: 8,
),
_areaField(),
_descriptionField(),
SizedBox(
height: 4.0,
height: 16,
),
_descriptionField()
GetBuilder<
DescriptionChangeControler>(
builder: (_) {
return SizedBox(
width: double.infinity,
height: 55,
child: FlatButton(
onPressed:
controller.isChanged ==
false
? () {}
: () {
FocusScopeNode
currentFocus =
FocusScope.of(
context);
if (!currentFocus
.hasPrimaryFocus) {
currentFocus
.unfocus();
}
_validateInputs();
},
color: controller.isChanged
? AppColors.DEFAULT
: Colors.grey[400],
shape:
RoundedRectangleBorder(
borderRadius:
new BorderRadius
.circular(7.0),
),
child: Text(
'Cập nhật'
.toUpperCase(),
style: TextStyle(
fontWeight:
FontWeight.bold,
color:
AppColors.WHITE,
fontSize: 18)),
),
);
},
)
],
),
));
@@ -327,18 +282,6 @@ class _PlotInformationScreenState extends State<PlotInformationScreen>

@override
void dispose() {
_statusController.dispose();
_houseNameController.dispose();
_codeController.dispose();
_supplyNameController.dispose();
_seedingDateController.dispose();
_timeSoakSeedController.dispose();
_timeNurserySeedController.dispose();
_quantityPlantController.dispose();
_currentPlantController.dispose();
_timeEndGrowController.dispose();
_mainTechnicianController.dispose();
_areaController.dispose();
_descriptionController.dispose();
super.dispose();
}

+ 36
- 14
lib/presentation/screens/plot_detail/sc_plot_parameter.dart View File

@@ -4,6 +4,7 @@ import 'package:farm_tpf/custom_model/EnvironmentParameter.dart';
import 'package:farm_tpf/data/repository/repository.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/utils/const_color.dart';
import 'package:farm_tpf/utils/const_string.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -52,7 +53,9 @@ class _PlotParameterScreenState extends State<PlotParameterScreen>
return Center(child: Text(label_list_empty));
}
return RefreshIndicator(
child: ListView.builder(
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2),
physics: AlwaysScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return index >= state.items.length
@@ -95,19 +98,38 @@ class ItemInfinityWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Card(
child: ListTile(
title: Text(
"${item.name ?? ''}",
style: TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(
item.index.formatNumtoStringDecimal(),
style: TextStyle(
color: item.status ? Colors.red : Colors.blue,
fontWeight: FontWeight.bold),
),
trailing: Text(item.executeDate.format_DDMMYY_HHmm()),
return Container(
margin: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.grey[300], width: 0.35),
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.grey[300], blurRadius: 4, offset: Offset(0, 3))
]),
padding: EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.index.formatNumtoStringDecimal(),
style: TextStyle(
color: item.status ? Colors.red : AppColors.YELLOW,
fontWeight: FontWeight.bold,
fontSize: 28),
),
Expanded(child: Container()),
Flexible(
child: Text(
"${item.name ?? ''}",
maxLines: 2,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
),
Text(item.executeDate.format_DDMMYY_HHmm(),
style: TextStyle(fontSize: 15, color: Colors.grey))
],
),
);
}

Loading…
Cancel
Save