Browse Source

add action to screen harvest

master
daivph 5 years ago
parent
commit
b08e03f989
5 changed files with 91 additions and 31 deletions
  1. +2
    -2
      lib/data/api/rest_client.dart
  2. +12
    -12
      lib/data/api/rest_client.g.dart
  3. +4
    -2
      lib/data/repository/repository.dart
  4. +1
    -2
      lib/presentation/custom_widgets/widget_media_picker.dart
  5. +72
    -13
      lib/presentation/screens/actions/harvest/sc_edit_action_harvest.dart

+ 2
- 2
lib/data/api/rest_client.dart View File

@@ -47,13 +47,13 @@ abstract class RestClient {
Future<List<Crop>> getPlots(
{@Path() int page = 0, @Path() int size = 20, @Path() String query = ""});
@GET("/api/listActivityTypesOther")
Future<List<ActionType>> getActionTypes();
Future<List<ActionType>> getActionTypes({@DioOptions() Options options});

@GET("/api/water-types")
Future<List<WaterType>> getWaterTypes({@DioOptions() Options options});

@GET("/api/tb-harvests")
Future<List<Harvest>> getHarvests();
Future<List<Harvest>> getHarvests({@DioOptions() Options options});

//Crop
@GET(

+ 12
- 12
lib/data/api/rest_client.g.dart View File

@@ -187,18 +187,18 @@ class _RestClient implements RestClient {
}

@override
getActionTypes() async {
getActionTypes({options}) async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
queryParameters.removeWhere((k, v) => v == null);
final _data = <String, dynamic>{};
final newOptions = newRequestOptions(options);
newOptions.extra.addAll(_extra);
newOptions.headers.addAll(<String, dynamic>{});
final Response<List<dynamic>> _result = await _dio.request(
'/api/listActivityTypesOther',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
options: newOptions.merge(method: 'GET', baseUrl: baseUrl),
data: _data);
var value = _result.data
.map((dynamic i) => ActionType.fromJson(i as Map<String, dynamic>))
@@ -227,18 +227,18 @@ class _RestClient implements RestClient {
}

@override
getHarvests() async {
getHarvests({options}) async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
queryParameters.removeWhere((k, v) => v == null);
final _data = <String, dynamic>{};
final newOptions = newRequestOptions(options);
newOptions.extra.addAll(_extra);
newOptions.headers.addAll(<String, dynamic>{});
final Response<List<dynamic>> _result = await _dio.request(
'/api/tb-harvests',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
options: newOptions.merge(method: 'GET', baseUrl: baseUrl),
data: _data);
var value = _result.data
.map((dynamic i) => Harvest.fromJson(i as Map<String, dynamic>))

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

@@ -22,12 +22,14 @@ class Repository {

Future<List<ActionType>> getActionTypes() {
final client = RestClient(dio);
return client.getActionTypes();
var op = buildConfigurableCacheOptions(forceRefresh: true);
return client.getActionTypes(options: op);
}

Future<List<Harvest>> getHarvests() {
final client = RestClient(dio);
return client.getHarvests();
var op = buildConfigurableCacheOptions(forceRefresh: true);
return client.getHarvests(options: op);
}

Future<List<WaterType>> getWaterTypes() {

+ 1
- 2
lib/presentation/custom_widgets/widget_media_picker.dart View File

@@ -44,7 +44,7 @@ class _WidgetMediaPickerState extends State<WidgetMediaPicker> {
} else if (state is MediaHelperSuccess) {
currentItems = widget.currentItems ?? [];
return Container(
padding: EdgeInsets.all(8),
padding: EdgeInsets.only(top: 8, bottom: 8),
child: Column(
children: <Widget>[
SizedBox(
@@ -86,7 +86,6 @@ class _WidgetMediaPickerState extends State<WidgetMediaPicker> {
height: 8.0,
),
Container(
height: 150,
child: _buildListPoster(),
),
],

+ 72
- 13
lib/presentation/screens/actions/harvest/sc_edit_action_harvest.dart View File

@@ -393,19 +393,78 @@ class _EditActionHarvestScreenState extends State<EditActionHarvestScreen> {
child: CircularProgressIndicator());
}
}),
IconButton(
icon: Icon(Icons.ac_unit),
onPressed: () {
if (_harvest.id != null) {
Get.to(EditActionPackingScreen(
cropId: widget.cropId,
harvestId: _harvest.id,
));
} else {
Get.to(EditActionPackingScreen(
cropId: widget.cropId));
}
})
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width / 2 - 16,
child: FlatButton(
padding: EdgeInsets.all(14),
shape: RoundedRectangleBorder(
borderRadius:
new BorderRadius.circular(8.0)),
color: Colors.lightGreen,
onPressed: () {},
child: Text(
plot_action_harvest_process,
style: TextStyle(
color: Colors.white, fontSize: 16),
),
),
),
SizedBox(
width: Get.width / 2 - 16,
child: FlatButton(
padding: EdgeInsets.all(14),
shape: RoundedRectangleBorder(
borderRadius:
new BorderRadius.circular(8.0)),
color: Colors.lightGreen,
onPressed: () {
if (_harvest.id != null) {
Get.to(EditActionPackingScreen(
cropId: widget.cropId,
harvestId: _harvest.id,
));
} else {
Get.to(EditActionPackingScreen(
cropId: widget.cropId));
}
},
child: Text(
plot_action_packing,
style: TextStyle(
color: Colors.white, fontSize: 16),
),
),
)
],
),
SizedBox(
height: 8,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: Get.width / 2 - 16,
child: FlatButton(
padding: EdgeInsets.all(14),
shape: RoundedRectangleBorder(
borderRadius:
new BorderRadius.circular(8.0)),
color: Colors.lightGreen,
onPressed: () {},
child: Text(
plot_action_sell,
style: TextStyle(
color: Colors.white, fontSize: 16),
),
),
)
],
),
],
);
},

Loading…
Cancel
Save