Browse Source

update show action ui

smf
daivph 4 years ago
parent
commit
34b50a00bd
6 changed files with 84 additions and 78 deletions
  1. +1
    -1
      ios/Flutter/.last_build_id
  2. +3
    -2
      lib/data/repository/repository.dart
  3. +3
    -2
      lib/presentation/screens/actions/cubit/action_ui_cubit.dart
  4. +72
    -69
      lib/presentation/screens/actions/sc_action.dart
  5. +2
    -2
      lib/presentation/screens/plot_detail/bloc/cubit/plot_action_type_cubit.dart
  6. +3
    -2
      lib/presentation/screens/plot_detail/sc_plot_action.dart

+ 1
- 1
ios/Flutter/.last_build_id View File

f12343393e4c0205a158a79507ffa031
471e09183e20ec9c20cca9b580fecc10

+ 3
- 2
lib/data/repository/repository.dart View File

} }


//NEW IMPLEMENT //NEW IMPLEMENT
Future<void> allActionTypes(
Future<void> allActionTypes(int cropTypeId,
Function(List<ActionType>) onSuccess, Function(dynamic) onError) async { Function(List<ActionType>) onSuccess, Function(dynamic) onError) async {
try { try {
var url = '${ConstCommon.baseUrl}/api/tb-activity-types';
var url =
'${ConstCommon.baseUrl}/api/listActivityTypesCulture/$cropTypeId';


final Response<List<dynamic>> _result = await dio.get(url); final Response<List<dynamic>> _result = await dio.get(url);
var value = _result.data var value = _result.data

+ 3
- 2
lib/presentation/screens/actions/cubit/action_ui_cubit.dart View File

Future<void> getActionUIForm(int idAction) async { Future<void> getActionUIForm(int idAction) async {
try { try {
emit(ActionUiLoading()); emit(ActionUiLoading());
var result = await repository.getActionUIForm(idAction: idAction);
emit(ActionUiSuccess(item: result));
repository.getActionUIForm(idAction: idAction).then((value) {
emit(ActionUiSuccess(item: value));
});
} on DioError catch (e) { } on DioError catch (e) {
emit(ActionUiFailure(errorString: AppException.handleError(e))); emit(ActionUiFailure(errorString: AppException.handleError(e)));
} }

+ 72
- 69
lib/presentation/screens/actions/sc_action.dart View File

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/custom_widgets/bloc/media_helper_bloc.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/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_field_time_picker.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_media_picker.dart'; import 'package:farm_tpf/presentation/custom_widgets/widget_media_picker.dart';
key: _formKey, key: _formKey,
child: SafeArea( child: SafeArea(
child: SingleChildScrollView( child: SingleChildScrollView(
child: BlocConsumer<ActionUiCubit, ActionUiState>(
listener: (context, state) async {
child: BlocBuilder<ActionUiCubit, ActionUiState>(
builder: (context, state) {
if (state is ActionUiLoading) { if (state is ActionUiLoading) {
LoadingDialog.hideLoadingDialog(context);
print('loading...');
return Center(child: CircularProgressIndicator());
} else if (state is ActionUiSuccess) { } 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);
}
}, },
), ),
), ),

+ 2
- 2
lib/presentation/screens/plot_detail/bloc/cubit/plot_action_type_cubit.dart View File

final Repository repository; final Repository repository;
PlotActionTypeCubit(this.repository) : super(PlotActionTypeInitial()); PlotActionTypeCubit(this.repository) : super(PlotActionTypeInitial());


Future<void> getAllActionTypes() async {
Future<void> getAllActionTypes(int cropTypeId) async {
try { try {
emit(PlotActionTypeLoading()); emit(PlotActionTypeLoading());
await repository.allActionTypes((data) {
await repository.allActionTypes(cropTypeId, (data) {
emit(PlotActionTypeSuccess(data)); emit(PlotActionTypeSuccess(data));
}, (error) { }, (error) {
emit(PlotActionTypeError(AppException.handleError(error))); emit(PlotActionTypeError(AppException.handleError(error)));

+ 3
- 2
lib/presentation/screens/plot_detail/sc_plot_action.dart View File

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:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';


@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider( return BlocProvider(
create: (contex) =>
PlotActionTypeCubit(Repository())..getAllActionTypes(),
create: (contex) => PlotActionTypeCubit(Repository())
..getAllActionTypes(widget.cropType),
child: BlocBuilder<PlotActionTypeCubit, PlotActionTypeState>( child: BlocBuilder<PlotActionTypeCubit, PlotActionTypeState>(
builder: (context, state) { builder: (context, state) {
if (state is PlotActionTypeLoading) { if (state is PlotActionTypeLoading) {

Loading…
Cancel
Save