Browse Source

update navigation from noti list

master
daivph 5 years ago
parent
commit
53a8ededdc
8 changed files with 134 additions and 89 deletions
  1. +1
    -1
      ios/Flutter/.last_build_id
  2. +3
    -7
      lib/main.dart
  3. +6
    -5
      lib/presentation/screens/notification/sc_notification.dart
  4. +1
    -7
      lib/presentation/screens/plot/sc_plot.dart
  5. +21
    -0
      lib/presentation/screens/plot_detail/bloc/plot_detail_bloc.dart
  6. +6
    -0
      lib/presentation/screens/plot_detail/bloc/plot_detail_event.dart
  7. +95
    -69
      lib/presentation/screens/plot_detail/sc_plot_detail.dart
  8. +1
    -0
      lib/presentation/screens/plot_detail/widget_tab.dart

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

dab672e712362fdbbfa98386624f95d6
440505e9ea1eee7043d2cbfeb318f6bc

+ 3
- 7
lib/main.dart View File

print("ok"); print("ok");
if (Get.isDialogOpen) Get.back(); if (Get.isDialogOpen) Get.back();
Get.to(PlotDetailScreen( Get.to(PlotDetailScreen(
cropId: value.tbCropDTO.id,
cropType: value.tbCropDTO.type,
initialIndex: 1,
code: value.tbCropDTO.code,
areaM2: value.tbCropDTO.areaM2,
suppliesName: value.tbCropDTO.suppliesName,
));
cropId: value.tbCropDTO.id,
cropType: value.tbCropDTO.type,
initialIndex: 0));
}).catchError((onError) { }).catchError((onError) {
Utils.showDialog( Utils.showDialog(
title: "Không tìm thấy lô", title: "Không tìm thấy lô",

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

Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) => PlotParameterScreen(
builder: (BuildContext context) => PlotDetailScreen(
cropType: item.type,
cropId: item.tbCropId, cropId: item.tbCropId,
isShowAppbar: true,
initialIndex: 0,
))).then((value) { ))).then((value) {
if (item.isRead == 0) { if (item.isRead == 0) {
_updateReadNotification( _updateReadNotification(
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) =>
PlotInformationScreen(
builder: (BuildContext context) => PlotDetailScreen(
cropType: item.type,
cropId: item.tbCropId, cropId: item.tbCropId,
isShowAppbar: true,
initialIndex: 1,
))).then((value) { ))).then((value) {
if (item.isRead == 0) { if (item.isRead == 0) {
_updateReadNotification( _updateReadNotification(

+ 1
- 7
lib/presentation/screens/plot/sc_plot.dart View File

context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) => PlotDetailScreen( builder: (BuildContext context) => PlotDetailScreen(
cropId: item.id,
initialIndex: 0,
cropType: item.type,
code: item.code,
areaM2: item.areaM2,
suppliesName: item.suppliesName,
)));
cropId: item.id, initialIndex: 0, cropType: item.type)));
}); });
} }
} }

+ 21
- 0
lib/presentation/screens/plot_detail/bloc/plot_detail_bloc.dart View File

yield PlotDetailFailure(errorString: errorString); yield PlotDetailFailure(errorString: errorString);
} }
} }
if (event is CheckInfo) {
try {
yield PlotDetailLoading();
var response;
if (event.cropId != null) {
response = await repository.getPlotDetail(event.cropId,
page: 0, size: pageSize);
} else {
response = await repository.getPlotDetailByCode(event.cropCode,
page: 0, size: pageSize);
}
CropPlot cropPlot = response as CropPlot;
yield PlotDetailSuccess(
ownerItem: cropPlot,
page: 0,
hasReachedMax:
response.activities.length < pageSize ? true : false);
} catch (e) {
yield PlotDetailFailure(errorString: AppException.handleError(e));
}
}
if (event is OnRefresh) { if (event is OnRefresh) {
try { try {
yield PlotDetailLoading(); yield PlotDetailLoading();

+ 6
- 0
lib/presentation/screens/plot_detail/bloc/plot_detail_event.dart View File

List<Object> get props => []; List<Object> get props => [];
} }


class CheckInfo extends PlotDetailEvent {
final int cropId;
final String cropCode;
CheckInfo({this.cropId, this.cropCode});
}

class DataFetched extends PlotDetailEvent { class DataFetched extends PlotDetailEvent {
final int cropId; final int cropId;
final String cropCode; final String cropCode;

+ 95
- 69
lib/presentation/screens/plot_detail/sc_plot_detail.dart View File

import 'package:farm_tpf/custom_model/CropPlot.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/app_bar_widget.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/bloc/plot_detail_bloc.dart';
import 'package:farm_tpf/presentation/screens/plot_detail/widget_tab.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_assets.dart';
import 'package:farm_tpf/utils/formatter.dart'; import 'package:farm_tpf/utils/formatter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';


class PlotDetailScreen extends StatefulWidget { class PlotDetailScreen extends StatefulWidget {
int cropId; int cropId;
String cropCode; String cropCode;
int cropType; int cropType;
int initialIndex; int initialIndex;
String code;
num areaM2;
String suppliesName;
PlotDetailScreen(
{this.cropId,
this.initialIndex = 0,
this.cropCode,
@required this.cropType,
@required this.code,
@required this.areaM2,
@required this.suppliesName});
PlotDetailScreen({
this.cropId,
this.initialIndex = 0,
this.cropCode,
@required this.cropType,
});
@override @override
_PlotDetailScreenState createState() => _PlotDetailScreenState(); _PlotDetailScreenState createState() => _PlotDetailScreenState();
} }


class _PlotDetailScreenState extends State<PlotDetailScreen> { class _PlotDetailScreenState extends State<PlotDetailScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBarWidget(),
body: Column(
children: [
Container(
padding: EdgeInsets.all(8),
width: double.infinity,
color: Colors.white,
child: Row(
children: [
SizedBox(
width: 12,
),
Expanded(
child: Container(
height: 75,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text('${widget.suppliesName ?? ''}',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18)),
Expanded(
child: SizedBox(),
),
Row(
children: [
Text('Mã lô: ${widget.code ?? ''}',
style: TextStyle(color: Colors.grey)),
SizedBox(
width: 16,
),
Text(
'Diện tích: ${widget.areaM2.formatNumtoStringDecimal() ?? '0'} m\u00B2',
style: TextStyle(color: Colors.grey))
],
)
],
),
Widget content({String suppliesName, String code, num areaM2}) {
return Column(
children: [
Container(
padding: EdgeInsets.all(8),
width: double.infinity,
color: Colors.white,
child: Row(
children: [
SizedBox(
width: 12,
),
Expanded(
child: Container(
height: 75,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text('${suppliesName ?? ''}',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18)),
Expanded(
child: SizedBox(),
),
Row(
children: [
Text('Mã lô: ${code ?? ''}',
style: TextStyle(color: Colors.grey)),
SizedBox(
width: 16,
),
Text(
'Diện tích: ${areaM2.formatNumtoStringDecimal() ?? '0'} m\u00B2',
style: TextStyle(color: Colors.grey))
],
)
],
), ),
), ),
Image.asset(
AppAssets.tempImage,
width: 75,
height: 75,
)
],
),
),
Image.asset(
AppAssets.tempImage,
width: 75,
height: 75,
)
],
), ),
Expanded(
child: HomeTabbarWidget(
cropType: widget.cropType,
cropId: widget.cropId,
cropCode: widget.cropCode,
initialIndex: widget.initialIndex,
))
],
),
),
Expanded(
child: HomeTabbarWidget(
cropType: widget.cropType,
cropId: widget.cropId,
cropCode: widget.cropCode,
initialIndex: widget.initialIndex,
))
],
); );
} }

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBarWidget(),
body: BlocProvider(
create: (context) => PlotDetailBloc(repository: Repository())
..add(CheckInfo(cropId: widget.cropId, cropCode: widget.cropCode)),
child: BlocConsumer<PlotDetailBloc, PlotDetailState>(
listener: (context, state) {
if (state is PlotDetailLoading) {
LoadingDialog.showLoadingDialog(context);
} else if (state is PlotDetailFailure) {
LoadingDialog.hideLoadingDialog(context);
} else {
LoadingDialog.hideLoadingDialog(context);
}
}, builder: (context, state) {
if (state is PlotDetailSuccess) {
var cropPlot = state.ownerItem as CropPlot;
return content(
suppliesName: cropPlot.tbCropDTO.suppliesName,
code: cropPlot.tbCropDTO.code,
areaM2: cropPlot.tbCropDTO.areaM2);
} else {
return content(suppliesName: '', code: '', areaM2: 0);
}
}),
));
}
} }

+ 1
- 0
lib/presentation/screens/plot_detail/widget_tab.dart View File

super.initState(); super.initState();
homeTabSelected.init(); homeTabSelected.init();
tabbarController = TabController(vsync: this, length: 4); tabbarController = TabController(vsync: this, length: 4);
tabbarController.animateTo(widget.initialIndex);
tabbarController.addListener(() { tabbarController.addListener(() {
homeTabSelected.changeTab(tabbarController.index); homeTabSelected.changeTab(tabbarController.index);
}); });

Loading…
Cancel
Save