|
|
|
@@ -2,6 +2,7 @@ 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/media_helper_bloc.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_field_time_picker.dart'; |
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; |
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/widget_media_picker.dart'; |
|
|
|
@@ -116,79 +117,81 @@ class _ActionScreenState extends State<ActionScreen> { |
|
|
|
key: _formKey, |
|
|
|
child: SafeArea( |
|
|
|
child: SingleChildScrollView( |
|
|
|
child: BlocConsumer<ActionUiCubit, ActionUiState>( |
|
|
|
listener: (context, state) async { |
|
|
|
child: BlocBuilder<ActionUiCubit, ActionUiState>( |
|
|
|
builder: (context, state) { |
|
|
|
if (state is ActionUiLoading) { |
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
print('loading...'); |
|
|
|
return Center(child: CircularProgressIndicator()); |
|
|
|
} else if (state is ActionUiSuccess) { |
|
|
|
LoadingDialog.hideLoadingDialog(context); |
|
|
|
} else if (state is ActionUiFailure) { |
|
|
|
LoadingDialog.showLoadingDialog(context); |
|
|
|
} |
|
|
|
}, |
|
|
|
builder: (context, state) { |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
Padding( |
|
|
|
padding: const EdgeInsets.all(8.0), |
|
|
|
child: Column( |
|
|
|
children: <Widget>[ |
|
|
|
Container( |
|
|
|
width: double.infinity, |
|
|
|
child: Text( |
|
|
|
"Ngày thực hiện *", |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.black54, |
|
|
|
fontSize: 13.0), |
|
|
|
print('success'); |
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
Padding( |
|
|
|
padding: const EdgeInsets.all(8.0), |
|
|
|
child: Column( |
|
|
|
children: <Widget>[ |
|
|
|
Container( |
|
|
|
width: double.infinity, |
|
|
|
child: Text( |
|
|
|
"Ngày thực hiện *", |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.black54, |
|
|
|
fontSize: 13.0), |
|
|
|
), |
|
|
|
), |
|
|
|
_btnExecuteTimePicker(), |
|
|
|
SizedBox( |
|
|
|
height: 8.0, |
|
|
|
), |
|
|
|
), |
|
|
|
_btnExecuteTimePicker(), |
|
|
|
SizedBox( |
|
|
|
height: 8.0, |
|
|
|
), |
|
|
|
_executeByField(), |
|
|
|
SizedBox( |
|
|
|
height: 8.0, |
|
|
|
), |
|
|
|
], |
|
|
|
_executeByField(), |
|
|
|
SizedBox( |
|
|
|
height: 8.0, |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
Container( |
|
|
|
width: double.infinity, |
|
|
|
height: 16, |
|
|
|
color: Colors.grey[200], |
|
|
|
), |
|
|
|
BlocBuilder<MediaHelperBloc, |
|
|
|
MediaHelperState>( |
|
|
|
builder: (context, state) { |
|
|
|
if (state is MediaHelperSuccess) { |
|
|
|
return WidgetMediaPicker( |
|
|
|
currentItems: state.items, |
|
|
|
onChangeFiles: (newPathFiles, |
|
|
|
deletePathFiles) async { |
|
|
|
Get.find<ChangeFileController>() |
|
|
|
.change(newPathFiles, |
|
|
|
deletePathFiles); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
return Center( |
|
|
|
child: CircularProgressIndicator()); |
|
|
|
} |
|
|
|
}), |
|
|
|
Padding( |
|
|
|
padding: const EdgeInsets.all(8.0), |
|
|
|
child: ButtonWidget( |
|
|
|
title: 'CẬP NHẬT', |
|
|
|
onPressed: () { |
|
|
|
FocusScopeNode currentFocus = |
|
|
|
FocusScope.of(context); |
|
|
|
if (!currentFocus.hasPrimaryFocus) { |
|
|
|
currentFocus.unfocus(); |
|
|
|
} |
|
|
|
_validateInputs(); |
|
|
|
}), |
|
|
|
), |
|
|
|
), |
|
|
|
Container( |
|
|
|
width: double.infinity, |
|
|
|
height: 16, |
|
|
|
color: Colors.grey[200], |
|
|
|
), |
|
|
|
BlocBuilder<MediaHelperBloc, MediaHelperState>( |
|
|
|
builder: (context, state) { |
|
|
|
if (state is MediaHelperSuccess) { |
|
|
|
return WidgetMediaPicker( |
|
|
|
currentItems: state.items, |
|
|
|
onChangeFiles: (newPathFiles, |
|
|
|
deletePathFiles) async { |
|
|
|
Get.find<ChangeFileController>() |
|
|
|
.change(newPathFiles, |
|
|
|
deletePathFiles); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
return Center( |
|
|
|
child: CircularProgressIndicator()); |
|
|
|
} |
|
|
|
}), |
|
|
|
Padding( |
|
|
|
padding: const EdgeInsets.all(8.0), |
|
|
|
child: ButtonWidget( |
|
|
|
title: 'CẬP NHẬT', |
|
|
|
onPressed: () { |
|
|
|
FocusScopeNode currentFocus = |
|
|
|
FocusScope.of(context); |
|
|
|
if (!currentFocus.hasPrimaryFocus) { |
|
|
|
currentFocus.unfocus(); |
|
|
|
} |
|
|
|
_validateInputs(); |
|
|
|
}), |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
], |
|
|
|
); |
|
|
|
} else if (state is ActionUiFailure) { |
|
|
|
print('error'); |
|
|
|
return Text(state.errorString); |
|
|
|
// LoadingDialog.hideLoadingDialog(context); |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
), |