Browse Source

update flow screen from notification screen

master
daivph 5 years ago
parent
commit
dc7281f7c5
5 changed files with 84 additions and 76 deletions
  1. +5
    -2
      lib/presentation/screens/notification/sc_notification.dart
  2. +6
    -2
      lib/presentation/screens/plot/sc_plot.dart
  3. +12
    -8
      lib/presentation/screens/plot_detail/sc_plot_detail.dart
  4. +9
    -25
      lib/presentation/screens/plot_detail/sc_plot_information.dart
  5. +52
    -39
      lib/presentation/screens/plot_detail/sc_plot_parameter.dart

+ 5
- 2
lib/presentation/screens/notification/sc_notification.dart View File

@@ -6,6 +6,7 @@ import 'package:farm_tpf/presentation/custom_widgets/dash_line_widget.dart';
import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_information.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_parameter.dart';
import 'package:farm_tpf/utils/const_icons.dart';
import 'package:farm_tpf/utils/pref.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
@@ -59,6 +60,7 @@ class HoldInfinityWidget extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
backgroundColor: Colors.white,
appBar: AppBarWidget(
isBack: false,
),
@@ -264,9 +266,9 @@ class ItemInfinityWidget extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => PlotDetailScreen(
builder: (BuildContext context) => PlotParameterScreen(
cropId: item.tbCropId,
cropType: item.type,
isShowAppbar: true,
))).then((value) {
if (item.isRead == 0) {
_updateReadNotification(
@@ -286,6 +288,7 @@ class ItemInfinityWidget extends StatelessWidget {
builder: (BuildContext context) =>
PlotInformationScreen(
cropId: item.tbCropId,
isShowAppbar: true,
))).then((value) {
if (item.isRead == 0) {
_updateReadNotification(

+ 6
- 2
lib/presentation/screens/plot/sc_plot.dart View File

@@ -12,6 +12,7 @@ import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart';
import 'package:farm_tpf/presentation/screens/plot/widget_search.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_information.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_parameter.dart';
import 'package:farm_tpf/utils/const_assets.dart';
import 'package:farm_tpf/utils/const_color.dart';
import 'package:farm_tpf/utils/const_common.dart';
@@ -111,9 +112,9 @@ class _PlotListScreenState extends State<PlotListScreen> {
noti = NotificationDTO.fromJson(message);
}
if (noti.contents == "ENV_UPDATE") {
Get.to(PlotDetailScreen(
Get.to(PlotParameterScreen(
cropId: noti.tbCropId,
cropType: noti.type,
isShowAppbar: true,
));
} else if (noti.contents == "PIC_UPDATE") {
Get.to(PlotInformationScreen(
@@ -343,6 +344,9 @@ class ItemInfinityWidget extends StatelessWidget {
cropId: item.id,
initialIndex: 0,
cropType: item.type,
code: item.code,
areaM2: item.areaM2,
suppliesName: item.suppliesName,
)));
});
}

+ 12
- 8
lib/presentation/screens/plot_detail/sc_plot_detail.dart View File

@@ -1,7 +1,7 @@
import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/widget_tab.dart';
import 'package:farm_tpf/utils/const_assets.dart';
import 'package:farm_tpf/utils/const_color.dart';
import 'package:farm_tpf/utils/formatter.dart';
import 'package:flutter/material.dart';

class PlotDetailScreen extends StatefulWidget {
@@ -9,11 +9,17 @@ class PlotDetailScreen extends StatefulWidget {
String cropCode;
int cropType;
int initialIndex;
String code;
num areaM2;
String suppliesName;
PlotDetailScreen(
{this.cropId,
this.initialIndex = 0,
this.cropCode,
@required this.cropType});
@required this.cropType,
@required this.code,
@required this.areaM2,
@required this.suppliesName});
@override
_PlotDetailScreenState createState() => _PlotDetailScreenState();
}
@@ -41,7 +47,7 @@ class _PlotDetailScreenState extends State<PlotDetailScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text('Rau muống trắng 6 sạch, 3 an toàn',
Text('${widget.suppliesName ?? ''}',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18)),
Expanded(
@@ -49,15 +55,13 @@ class _PlotDetailScreenState extends State<PlotDetailScreen> {
),
Row(
children: [
SizedBox(
width: 4,
),
Text('item.startDate',
Text('Mã lô: ${widget.code ?? ''}',
style: TextStyle(color: Colors.grey)),
SizedBox(
width: 16,
),
Text('item.startDate',
Text(
'Diện tích: ${widget.areaM2.formatNumtoStringDecimal() ?? '0'} m\u00B2',
style: TextStyle(color: Colors.grey))
],
)

+ 9
- 25
lib/presentation/screens/plot_detail/sc_plot_information.dart View File

@@ -1,6 +1,7 @@
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/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';
@@ -16,7 +17,8 @@ import 'package:farm_tpf/utils/formatter.dart';

class PlotInformationScreen extends StatefulWidget {
final int cropId;
PlotInformationScreen({@required this.cropId});
final bool isShowAppbar;
PlotInformationScreen({@required this.cropId, this.isShowAppbar});
@override
_PlotInformationScreenState createState() => _PlotInformationScreenState();
}
@@ -96,30 +98,6 @@ class _PlotInformationScreenState extends State<PlotInformationScreen>
);
}

_actionAppBar() {
return <Widget>[
GetBuilder<DescriptionChangeControler>(
builder: (_) {
return IconButton(
icon: Icon(
Icons.done,
),
disabledColor: Colors.grey,
onPressed: controller.isChanged == false
? null
: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
_validateInputs();
},
);
},
)
];
}

@override
Widget build(BuildContext context) => KeyboardDismisser(
gestures: [
@@ -132,6 +110,12 @@ class _PlotInformationScreenState extends State<PlotInformationScreen>
top: false,
bottom: true,
child: Scaffold(
appBar: widget.isShowAppbar
? AppBarWidget()
: PreferredSize(
preferredSize: Size(0, 0),
child: SizedBox(),
),
key: _scaffoldKey,
body: KeyboardDismisser(
child: StreamBuilder(

+ 52
- 39
lib/presentation/screens/plot_detail/sc_plot_parameter.dart View File

@@ -2,6 +2,7 @@ import 'dart:async';

import 'package:farm_tpf/custom_model/EnvironmentParameter.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/bottom_loader.dart';
import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart';
import 'package:farm_tpf/utils/const_color.dart';
@@ -14,7 +15,8 @@ import 'bloc/plot_parameter_bloc.dart';

class PlotParameterScreen extends StatefulWidget {
final int cropId;
PlotParameterScreen({@required this.cropId});
final bool isShowAppbar;
PlotParameterScreen({@required this.cropId, this.isShowAppbar = false});
@override
_PlotParameterScreenState createState() => _PlotParameterScreenState();
}
@@ -39,44 +41,55 @@ class _PlotParameterScreenState extends State<PlotParameterScreen>

@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Expanded(
child: BlocBuilder<PlotParameterBloc, PlotParameterState>(
cubit: plotParameterBloc,
builder: (context, state) {
if (state is PlotParameterFailure) {
return Center(child: Text(state.errorString));
}
if (state is PlotParameterSuccess) {
if (state.items.isEmpty) {
return Center(child: Text(label_list_empty));
}
return RefreshIndicator(
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2),
physics: AlwaysScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return index >= state.items.length
? BottomLoader()
: ItemInfinityWidget(item: state.items[index]);
},
itemCount: state.hasReachedMax
? state.items.length
: state.items.length + 1,
controller: _scrollController,
),
onRefresh: () async {
plotParameterBloc.add(OnRefresh(cropId: widget.cropId));
});
}
return Center(
child: LoadingListPage(),
);
},
))
],
return Scaffold(
backgroundColor: Colors.white,
appBar: widget.isShowAppbar
? AppBarWidget()
: PreferredSize(
preferredSize: Size(0, 0),
child: SizedBox(),
),
body: SafeArea(
child: Column(
children: <Widget>[
Expanded(
child: BlocBuilder<PlotParameterBloc, PlotParameterState>(
cubit: plotParameterBloc,
builder: (context, state) {
if (state is PlotParameterFailure) {
return Center(child: Text(state.errorString));
}
if (state is PlotParameterSuccess) {
if (state.items.isEmpty) {
return Center(child: Text(label_list_empty));
}
return RefreshIndicator(
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2),
physics: AlwaysScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return index >= state.items.length
? BottomLoader()
: ItemInfinityWidget(item: state.items[index]);
},
itemCount: state.hasReachedMax
? state.items.length
: state.items.length + 1,
controller: _scrollController,
),
onRefresh: () async {
plotParameterBloc.add(OnRefresh(cropId: widget.cropId));
});
}
return Center(
child: LoadingListPage(),
);
},
))
],
),
),
);
}


Loading…
Cancel
Save