Browse Source

Add tab qr management

phase2
Đại Võ 1 year ago
parent
commit
355f1f76f6
5 changed files with 155 additions and 126 deletions
  1. +17
    -0
      assets/svg/ic_qr_manage.svg
  2. +2
    -2
      lib/data/api/dio_provider.dart
  3. +103
    -105
      lib/presentation/screens/plot_detail/sc_plot_information.dart
  4. +32
    -19
      lib/presentation/screens/tabbar/tabbar.dart
  5. +1
    -0
      lib/utils/const_icons.dart

+ 17
- 0
assets/svg/ic_qr_manage.svg View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 28 28" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<title>grid</title>
<desc>Created with Sketch Beta.</desc>
<defs>

</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="Icon-Set" sketch:type="MSLayerGroup" transform="translate(-102.000000, -933.000000)" fill="#000000">
<path d="M128,941 C128,942.104 127.104,943 126,943 L122,943 C120.896,943 120,942.104 120,941 L120,937 C120,935.896 120.896,935 122,935 L126,935 C127.104,935 128,935.896 128,937 L128,941 L128,941 Z M126,933 L122,933 C119.791,933 118,934.791 118,937 L118,941 C118,943.209 119.791,945 122,945 L126,945 C128.209,945 130,943.209 130,941 L130,937 C130,934.791 128.209,933 126,933 L126,933 Z M128,957 C128,958.104 127.104,959 126,959 L122,959 C120.896,959 120,958.104 120,957 L120,953 C120,951.896 120.896,951 122,951 L126,951 C127.104,951 128,951.896 128,953 L128,957 L128,957 Z M126,949 L122,949 C119.791,949 118,950.791 118,953 L118,957 C118,959.209 119.791,961 122,961 L126,961 C128.209,961 130,959.209 130,957 L130,953 C130,950.791 128.209,949 126,949 L126,949 Z M112,941 C112,942.104 111.104,943 110,943 L106,943 C104.896,943 104,942.104 104,941 L104,937 C104,935.896 104.896,935 106,935 L110,935 C111.104,935 112,935.896 112,937 L112,941 L112,941 Z M110,933 L106,933 C103.791,933 102,934.791 102,937 L102,941 C102,943.209 103.791,945 106,945 L110,945 C112.209,945 114,943.209 114,941 L114,937 C114,934.791 112.209,933 110,933 L110,933 Z M112,957 C112,958.104 111.104,959 110,959 L106,959 C104.896,959 104,958.104 104,957 L104,953 C104,951.896 104.896,951 106,951 L110,951 C111.104,951 112,951.896 112,953 L112,957 L112,957 Z M110,949 L106,949 C103.791,949 102,950.791 102,953 L102,957 C102,959.209 103.791,961 106,961 L110,961 C112.209,961 114,959.209 114,957 L114,953 C114,950.791 112.209,949 110,949 L110,949 Z" id="grid" sketch:type="MSShapeGroup">

</path>
</g>
</g>
</svg>

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

@@ -56,7 +56,7 @@ class AuthorizationInterceptor extends InterceptorsWrapper {
RequestInterceptorHandler handler,
) async {
final String? token = await LocalStorage.getString(LocalStorageKey.access_token);
if (token != null && options.path != 'token') {
if (token != null && !options.path.contains('authenticate')) {
options.headers.putIfAbsent('Authorization', () => 'Bearer $token');
}
return handler.next(options);
@@ -115,7 +115,7 @@ class UnauthorizedInterceptor extends InterceptorsWrapper {
ErrorInterceptorHandler handler,
) async {
final checkUnauthorized =
err.type == DioErrorType.response && err.response?.statusCode == HttpStatus.unauthorized && err.requestOptions.path != 'token';
err.type == DioErrorType.response && err.response?.statusCode == HttpStatus.unauthorized && !err.requestOptions.path.contains('authenticate');
if (checkUnauthorized) {
LocalStorage.clearUserInfo();
BlocProvider.of<AuthenticationBloc>(globalNavigator.currentContext!).add(

+ 103
- 105
lib/presentation/screens/plot_detail/sc_plot_information.dart View File

@@ -4,6 +4,7 @@ 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';
import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart';
@@ -104,113 +105,110 @@ class _PlotInformationScreenState extends State<PlotInformationScreen> with Auto

@override
Widget build(BuildContext context) => KeyboardDismisser(
gestures: [GestureType.onTap],
child: Container(
gestures: [GestureType.onTap],
child: Container(
color: AppColors.ITEM_BG,
child: SafeArea(
top: false,
bottom: true,
child: Scaffold(
appBar: widget.isShowAppbar ? AppBarWidget() : null,
// PreferredSize(
// preferredSize: Size(0, 0),
// child: SizedBox(),
// ),
key: _scaffoldKey,
body: KeyboardDismisser(
child: StreamBuilder(
stream: getPlotInfoBloc.actions,
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.hasData) {
return Form(
key: _formKey,
child: SingleChildScrollView(
padding: EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1), name: 'Mã lô', value: '${cropPlot.tbCropDTO?.code ?? ''}'),
WidgetRowPlotInfo(color: AppColors.DEFAULT.withOpacity(0.3), name: 'Trạng thái', value: '$statusCrop'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1),
name: 'Nhà màng',
value: '${cropPlot.tbCropDTO?.netHouseName ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3),
name: 'Giống',
value: '${cropPlot.tbCropDTO?.suppliesName ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1),
name: 'Ngày gieo trồng',
value: cropPlot.tbCropDTO?.tbCropTypeId == 0
? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}'
: '--'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3),
name: 'Ngày vô khây ươm',
value: cropPlot.tbCropDTO?.tbCropTypeId == 1
? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}'
: '--'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1),
name: 'Thời gian ngâm hạt',
value: '${cropPlot.seedIncubationTime ?? '--'} ngày'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3),
name: 'Số lượng cây trồng',
value: '${cropPlot.numberPlants ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1),
name: 'Số lượng cây hiện tại',
value: '${cropPlot.numberCurrentPlants ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3),
name: 'Ngày kết thúc canh tác',
value: '${cropPlot.tbCropDTO?.endDate?.format_DDMMYY_HHmm() ?? '--'}'),
WidgetRowPlotInfo(color: AppColors.DEFAULT.withOpacity(0.1), name: 'Kỹ sư trực tiếp', value: '$technicians'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3),
name: 'Diện tích (m\u00B2)',
value: '${cropPlot.tbCropDTO?.areaM2?.formatNumtoStringDecimal()}'),
SizedBox(
height: 8,
),
_descriptionField(),
SizedBox(
height: 16,
),
GetBuilder<DescriptionChangeControler>(
builder: (_) {
return SizedBox(
width: double.infinity,
height: 55,
child: TextButton(
onPressed: controller.isChanged == false
? () {}
: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
_validateInputs();
},
child: Text('Cập nhật'.toUpperCase(),
style: TextStyle(fontWeight: FontWeight.bold, color: AppColors.WHITE, fontSize: 18)),
),
);
},
)
],
),
));
} else if (snapshot.hasError) {
return Center(
child: Text(snapshot.error.toString()),
);
} else {
return LoadingListPage();
}
}))))));
top: false,
bottom: true,
child: Scaffold(
appBar: widget.isShowAppbar ? AppBarWidget() : null,
// PreferredSize(
// preferredSize: Size(0, 0),
// child: SizedBox(),
// ),
key: _scaffoldKey,
body: KeyboardDismisser(
child: StreamBuilder(
stream: getPlotInfoBloc.actions,
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.hasData) {
return Form(
key: _formKey,
child: SingleChildScrollView(
padding: EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1), name: 'Mã lô', value: '${cropPlot.tbCropDTO?.code ?? ''}'),
WidgetRowPlotInfo(color: AppColors.DEFAULT.withOpacity(0.3), name: 'Trạng thái', value: '$statusCrop'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1),
name: 'Nhà màng',
value: '${cropPlot.tbCropDTO?.netHouseName ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3), name: 'Giống', value: '${cropPlot.tbCropDTO?.suppliesName ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1),
name: 'Ngày gieo trồng',
value: cropPlot.tbCropDTO?.tbCropTypeId == 0
? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}'
: '--'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3),
name: 'Ngày vô khây ươm',
value: cropPlot.tbCropDTO?.tbCropTypeId == 1
? '${cropPlot.tbCropDTO?.startDate?.format_DDMMYY_HHmm() ?? '--'}'
: '--'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1),
name: 'Thời gian ngâm hạt',
value: '${cropPlot.seedIncubationTime ?? '--'} ngày'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3), name: 'Số lượng cây trồng', value: '${cropPlot.numberPlants ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.1),
name: 'Số lượng cây hiện tại',
value: '${cropPlot.numberCurrentPlants ?? '--'}'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3),
name: 'Ngày kết thúc canh tác',
value: '${cropPlot.tbCropDTO?.endDate?.format_DDMMYY_HHmm() ?? '--'}'),
WidgetRowPlotInfo(color: AppColors.DEFAULT.withOpacity(0.1), name: 'Kỹ sư trực tiếp', value: '$technicians'),
WidgetRowPlotInfo(
color: AppColors.DEFAULT.withOpacity(0.3),
name: 'Diện tích (m\u00B2)',
value: '${cropPlot.tbCropDTO?.areaM2?.formatNumtoStringDecimal()}'),
SizedBox(
height: 8,
),
_descriptionField(),
SizedBox(
height: 16,
),
GetBuilder<DescriptionChangeControler>(
builder: (_) {
return ButtonWidget(
title: 'CẬP NHẬT',
onPressed: controller.isChanged == false
? () {}
: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
_validateInputs();
},
);
},
)
],
),
));
} else if (snapshot.hasError) {
return Center(
child: Text(snapshot.error.toString()),
);
} else {
return LoadingListPage();
}
},
),
),
),
),
),
);

@override
void dispose() {

+ 32
- 19
lib/presentation/screens/tabbar/tabbar.dart View File

@@ -19,6 +19,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';

import '../qr_scan/qr_scan_page.dart';

class TabbarScreen extends StatefulWidget {
static Route route() {
return MaterialPageRoute<void>(builder: (_) => TabbarScreen());
@@ -40,7 +42,8 @@ class _TabbarScreenState extends State<TabbarScreen> {
final changeTabbar = Get.put(TabbarSelected());
List<TabbarItem> itemsTabbar = [
TabbarItem(icon: AppIcons.icPlot, title: 'Lô trồng', index: TabBarIndex.plot),
TabbarItem(icon: AppIcons.icDevice, title: 'Thiết bị', index: TabBarIndex.device),
// TabbarItem(icon: AppIcons.icDevice, title: 'Thiết bị', index: TabBarIndex.device),
TabbarItem(icon: AppIcons.icQrManage, title: 'Quản lý QR', index: TabBarIndex.qrManage),
TabbarItem(icon: AppIcons.icQr, title: 'Quét QR', index: TabBarIndex.qr),
TabbarItem(icon: AppIcons.icNotification, title: 'Thông báo', index: TabBarIndex.notification),
TabbarItem(icon: AppIcons.icPerson, title: 'Cá nhân', index: TabBarIndex.account)
@@ -204,11 +207,14 @@ class _TabbarScreenState extends State<TabbarScreen> {
case TabBarIndex.plot:
return PlotListScreen();
break;
case TabBarIndex.device:
return ControlDeviceScreen();
// case TabBarIndex.device:
// return ControlDeviceScreen();
// break;
case TabBarIndex.qrManage:
return CodePage();
break;
case TabBarIndex.qr:
return CodePage();
return Container();
break;
case TabBarIndex.notification:
return NotificationScreen();
@@ -271,20 +277,20 @@ class _TabbarScreenState extends State<TabbarScreen> {
)),
onTap: () {
//Open scan qr code when tap icon in tabbar
// if (index == 2) {
// changeTabbar.changeIndex(changeTabbar.index ?? TabBarIndex.plot);
// // scan(context);
// Get.to(
// QrCodeScannerScreen(),
// ).then((value) {
// if (value != null) {
// _showAlertCheckCropCode(value);
// }
// });
// } else {
// changeTabbar.changeIndex(itemsTabbar[index].index);
// }
changeTabbar.changeIndex(itemsTabbar[index].index);
if (index == 2) {
changeTabbar.changeIndex(changeTabbar.index ?? TabBarIndex.plot);
// scan(context);
Get.to(
QrCodeScannerScreen(),
).then((value) {
if (value != null) {
_showAlertCheckCropCode(value);
}
});
} else {
changeTabbar.changeIndex(itemsTabbar[index].index);
}
// changeTabbar.changeIndex(itemsTabbar[index].index);
},
);
}),
@@ -339,7 +345,14 @@ class TabbarSelected extends GetxController {
}
}

enum TabBarIndex { plot, device, qr, notification, account }
enum TabBarIndex {
plot,
// device,
qrManage,
qr,
notification,
account,
}

class TabbarItem {
TabBarIndex index;

+ 1
- 0
lib/utils/const_icons.dart View File

@@ -15,4 +15,5 @@ class AppIcons {
static const icHarvestProcess = baseAssets + 'ic_harvest_process.svg';
static const icPacking = baseAssets + 'ic_packing.svg';
static const icSell = baseAssets + 'ic_sell.svg';
static const icQrManage = baseAssets + 'ic_qr_manage.svg';
}

Loading…
Cancel
Save