Back button of other pages navigate to home

This commit is contained in:
fhkhd
2024-04-20 22:16:35 +04:30
parent 34e3f76845
commit c99cf569cf
20 changed files with 1455 additions and 1279 deletions
+11 -8
View File
@@ -77,14 +77,17 @@ class _LabelAddScreenState extends State<LabelAddScreen> {
// String initialLabelValue;
return Consumer<LabelsProvider>(
builder: (context, labelsProvider, _) {
return WillPopScope(
onWillPop: () async {
labelsProvider.resetLoadingButton();
Navigator.pushReplacementNamed(
context,
Routes.labelResultScreen,
);
return true;
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
if (didPop) return;
Navigator.of(context).pushNamed(Routes.homePage);
// labelsProvider.resetLoadingButton();
// Navigator.pushReplacementNamed(
// context,
// Routes.labelResultScreen,
// );
// return true;
},
child: SafeArea(
child: GestureDetector(
+17 -8
View File
@@ -31,6 +31,7 @@ class _LabelFilterScreenState extends State<LabelFilterScreen> {
List<Map<String, String>> hospitalVals = [];
bool isInit = true;
LabelFilterObject? filters;
@override
void initState() {
filters = Provider.of<LabelsProvider>(context, listen: false).filters;
@@ -79,13 +80,16 @@ class _LabelFilterScreenState extends State<LabelFilterScreen> {
final _media = MediaQuery.of(context);
final double _devicewidth = _media.size.width;
final double _deviceBlockSize = _devicewidth / 100;
return WillPopScope(
onWillPop: () async {
Navigator.pushReplacementNamed(
context,
Routes.labelResultScreen,
);
return true;
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
if (didPop) return;
Navigator.of(context).pushNamed(Routes.homePage);
// Navigator.pushReplacementNamed(
// context,
// Routes.labelResultScreen,
// );
// return true;
},
child: SafeArea(
child: GestureDetector(
@@ -95,7 +99,12 @@ class _LabelFilterScreenState extends State<LabelFilterScreen> {
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text('Labels', style: TextStyle(color: Colors.white,),),
title: Text(
'Labels',
style: TextStyle(
color: Colors.white,
),
),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
+68 -54
View File
@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../config/routes.dart';
import '../../providers/connectivity.dart';
import '../../widgets/Global/internet_error.dart';
import '../../widgets/LabelScreens/Scan/input_box.dart';
import '../../widgets/LabelScreens/Scan/save_button.dart';
import '../../widgets/LabelScreens/Scan/scan_box.dart';
// import 'package:flutter/services.dart';
// import 'package:barcode_scan2/barcode_scan2.dart';
@@ -28,67 +30,79 @@ class _LabelScanScreenState extends State<LabelScanScreen> {
// final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5);
final double _devicewidth = _media.size.width;
final double _deviceBlockSize = _devicewidth / 100;
return SafeArea(
child: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text('Labels', style: TextStyle(color: Colors.white,),),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
if (didPop) return;
Navigator.of(context).pushNamed(Routes.homePage);
},
child: SafeArea(
child: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'Labels',
style: TextStyle(
color: Colors.white,
),
),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
),
onPressed: () => Navigator.of(context).pop(),
),
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? ListView(
padding: EdgeInsets.symmetric(horizontal: 20),
children: <Widget>[
Container(
padding: EdgeInsets.only(top: 30),
child: Text(
'Looking for a Label?',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: 5.5 * _deviceBlockSize,
fontWeight: FontWeight.w700,
letterSpacing: 3,
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? ListView(
padding: EdgeInsets.symmetric(horizontal: 20),
children: <Widget>[
Container(
padding: EdgeInsets.only(top: 30),
child: Text(
'Looking for a Label?',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: 5.5 * _deviceBlockSize,
fontWeight: FontWeight.w700,
letterSpacing: 3,
),
),
),
),
LabelScanBox(),
SizedBox(
height: 10,
),
Form(
key: _form,
child: LabelScanInputBox(
LabelScanBox(),
SizedBox(
height: 10,
),
Form(
key: _form,
child: LabelScanInputBox(
idCTRL: idCTRL,
deviceBlockSize: _deviceBlockSize,
),
),
SizedBox(
height: 70,
),
FilterScanSaveButton(
form: _form,
idCTRL: idCTRL,
deviceBlockSize: _deviceBlockSize,
),
),
SizedBox(
height: 70,
),
FilterScanSaveButton(
form: _form,
idCTRL: idCTRL,
deviceBlockSize: _deviceBlockSize,
),
],
)
: ConnectionErrorBox();
},
],
)
: ConnectionErrorBox();
},
),
),
),
),