Improve navigation back

This commit is contained in:
fhkhd
2024-03-13 19:20:21 +03:30
parent 3db8ae3cfe
commit 92e02cc84e
10 changed files with 308 additions and 284 deletions
+40 -32
View File
@@ -77,7 +77,12 @@ class _CycleResultScreenState extends State<CycleResultScreen> {
),
appBar: AppBar(
titleSpacing: -10,
title: Text('Home', style: TextStyle(color: Colors.white,),),
title: Text(
'Home',
style: TextStyle(
color: Colors.white,
),
),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
@@ -85,7 +90,7 @@ class _CycleResultScreenState extends State<CycleResultScreen> {
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context).pushNamed(Routes.homePage),
),
),
body: Consumer<ConnectivityProvider>(
@@ -198,37 +203,40 @@ class _CycleResultScreenState extends State<CycleResultScreen> {
color: Colors.black,
),
)
:
cycleResults.items?.length != 0 ?
ListView.builder(
controller: sc,
itemBuilder: (context, index) {
String labels = '';
for (var label in cycleResults
.items![index].label) {
labels += label;
labels += ' , ';
}
if (labels.length >= 3) {
labels = labels.substring(
0,
labels.length -
3); // remove extra ,
}
return CycleItemBox(
deviceBlockSize: _deviceBlockSize,
item: cycleResults.items?[index],
labels: labels,
: cycleResults.items?.length != 0
? ListView.builder(
controller: sc,
itemBuilder: (context, index) {
String labels = '';
for (var label in cycleResults
.items![index].label) {
labels += label;
labels += ' , ';
}
if (labels.length >= 3) {
labels = labels.substring(
0,
labels.length -
3); // remove extra ,
}
return CycleItemBox(
deviceBlockSize:
_deviceBlockSize,
item:
cycleResults.items?[index],
labels: labels,
);
},
itemCount:
cycleResults.items?.length,
shrinkWrap: true,
)
: Container(
child: Center(
child: Text(
"There is no item to show."),
),
);
},
itemCount: cycleResults.items?.length,
shrinkWrap: true,
) :
Container(
child: Center(
child: Text("There is no item to show."),
),
);
},
),
),
+21 -18
View File
@@ -122,7 +122,7 @@ class _ItemResultScreenState extends State<ItemResultScreen> {
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context).pushNamed(Routes.homePage),
),
),
body: Consumer<ConnectivityProvider>(
@@ -251,24 +251,27 @@ class _ItemResultScreenState extends State<ItemResultScreen> {
color: Colors.black,
),
)
: itemResults.items?.length != 0 ?
ListView.builder(
controller: sc,
itemBuilder: (context, index) {
// remove extra ,
return ItemItemBox(
deviceBlockSize: _deviceBlockSize,
item: itemResults.items?[index],
: itemResults.items?.length != 0
? ListView.builder(
controller: sc,
itemBuilder: (context, index) {
// remove extra ,
return ItemItemBox(
deviceBlockSize:
_deviceBlockSize,
item: itemResults.items?[index],
);
},
itemCount:
itemResults.items?.length,
shrinkWrap: true,
)
: Container(
child: Center(
child: Text(
"There is no item to show."),
),
);
},
itemCount: itemResults.items?.length,
shrinkWrap: true,
) :
Container(
child: Center(
child: Text("There is no item to show."),
),
);
},
),
),
@@ -85,7 +85,7 @@ class _LabelResultScreenState extends State<LabelResultScreen> {
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context).pushNamed(Routes.homePage),
),
),
body: Consumer<ConnectivityProvider>(
@@ -55,7 +55,8 @@ class _MyItemsResultScreenState extends State<MyItemsResultScreen>
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () =>
Navigator.of(context).pushNamed(Routes.homePage),
),
// bottom: TabBar(
// controller: _tabController,
@@ -55,7 +55,8 @@ class _MyPackagesResultScreenState extends State<MyPackagesResultScreen>
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () =>
Navigator.of(context).pushNamed(Routes.homePage),
),
// bottom: TabBar(
// controller: _tabController,
@@ -117,13 +117,13 @@ class _PackageResultScreenState extends State<PackageResultScreen> {
),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
),
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () =>
Navigator.of(context).pushNamed(Routes.homePage)),
),
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
return connection.conStatus != 'offline'
+1 -1
View File
@@ -96,7 +96,7 @@ class _TestResultScreenState extends State<TestResultScreen> {
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context).pushNamed(Routes.homePage),
),
),
body: Consumer<ConnectivityProvider>(
+161 -149
View File
@@ -25,6 +25,7 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
ScrollController? sc;
bool _isInit = true;
// List<TestResult> _data = [];
@override
@@ -90,7 +91,7 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context).pushNamed(Routes.homePage),
),
),
body: Padding(
@@ -285,6 +286,7 @@ class TestItemBox extends StatelessWidget {
super(key: key);
final Map<String, dynamic> userData;
final double _deviceBlockSize;
// final String _id;
@override
@@ -355,161 +357,171 @@ class TestItemBox extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
item.verified == 'None' ?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
onTap: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('Verify'),
content: Text(
'Are you sure for verify this test?'),
actions: <Widget>[
Consumer<TestResultsProvider>(builder:
(context, testResultsProvider, child) {
return testResultsProvider.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
testResultsProvider
.setLoadingButton();
await Provider.of<
TestResultsProvider>(
context,
listen: false)
.changeVerification(
item.id, 'Verified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
Navigator.of(context)
.popAndPushNamed(Routes
.testVerifyScreen);
Fluttertoast.showToast(
msg: "Test is verified.",
toastLength:
Toast.LENGTH_SHORT,
gravity:
ToastGravity.BOTTOM,
item.verified == 'None'
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
onTap: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('Verify'),
content: Text(
'Are you sure for verify this test?'),
actions: <Widget>[
Consumer<TestResultsProvider>(builder:
(context, testResultsProvider,
child) {
return testResultsProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
testResultsProvider
.setLoadingButton();
await Provider.of<
TestResultsProvider>(
context,
listen: false)
.changeVerification(
item.id,
'Verified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
Navigator.of(context)
.popAndPushNamed(Routes
.testVerifyScreen);
Fluttertoast.showToast(
msg:
"Test is verified.",
toastLength: Toast
.LENGTH_SHORT,
gravity: ToastGravity
.BOTTOM,
);
testResultsProvider
.resetLoadingButton();
});
},
child: Text('Yes'),
);
testResultsProvider
.resetLoadingButton();
});
},
child: Text('Yes'),
);
}),
TextButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('No'),
}),
TextButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('No'),
),
],
),
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 10 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kBlue,
),
],
child: Icon(
Icons.check,
size: 6 * _deviceBlockSize,
color: Colors.white,
),
),
),
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 10 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kBlue,
),
child: Icon(
Icons.check,
size: 6 * _deviceBlockSize,
color: Colors.white,
),
),
),
SizedBox(
width: 3,
),
InkWell(
onTap: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('Reject'),
content: Text(
'Are you sure for reject this test?'),
actions: <Widget>[
Consumer<TestResultsProvider>(
builder:
(context, testResultsProvider, _) {
return testResultsProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
testResultsProvider
.setLoadingButton();
await Provider.of<
TestResultsProvider>(
context,
listen: false)
.changeVerification(
item.id,
'NotVerified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
Navigator.of(context)
.popAndPushNamed(Routes
.testVerifyScreen);
Fluttertoast.showToast(
msg: "Test is rejected.",
toastLength:
Toast.LENGTH_SHORT,
gravity:
ToastGravity.BOTTOM,
SizedBox(
width: 3,
),
InkWell(
onTap: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('Reject'),
content: Text(
'Are you sure for reject this test?'),
actions: <Widget>[
Consumer<TestResultsProvider>(
builder: (context,
testResultsProvider, _) {
return testResultsProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
testResultsProvider
.setLoadingButton();
await Provider.of<
TestResultsProvider>(
context,
listen: false)
.changeVerification(
item.id,
'NotVerified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx)
.pop();
Navigator.of(context)
.popAndPushNamed(
Routes
.testVerifyScreen);
Fluttertoast
.showToast(
msg:
"Test is rejected.",
toastLength: Toast
.LENGTH_SHORT,
gravity:
ToastGravity
.BOTTOM,
);
testResultsProvider
.resetLoadingButton();
});
},
child: Text('Yes'),
);
testResultsProvider
.resetLoadingButton();
});
},
child: Text('Yes'),
);
},
},
),
TextButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('No'),
),
],
),
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 10 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kPink,
),
TextButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('No'),
child: Icon(
Icons.close,
size: 6 * _deviceBlockSize,
color: Colors.white,
),
],
),
),
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 10 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kPink,
),
child: Icon(
Icons.close,
size: 6 * _deviceBlockSize,
color: Colors.white,
),
),
),
],
) : Container(),
],
)
: Container(),
SizedBox(
width: _deviceBlockSize,
),
+5 -4
View File
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../config/routes.dart';
import '../providers/auth.dart';
class MyInfoScreen extends StatefulWidget {
@@ -63,7 +64,7 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
onPressed: () => Navigator.of(context).pushNamed(Routes.homePage),
),
),
body: Consumer<ConnectivityProvider>(
@@ -174,9 +175,9 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
Navigator.of(context).pop();
auth.resetLoading();
Fluttertoast.showToast(
msg: "Info changed successfully.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
msg: "Info changed successfully.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
},
);
@@ -337,80 +337,78 @@ class MyPackageDetailsDataBox extends StatelessWidget {
SizedBox(
height: 10.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
text: 'Back Items to Item List',
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to destroy this Package?',
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
text: 'Back Items to Item List',
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to destroy this Package?',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 220,
child: Column(
children: [
Text(
'By approving, your package will be removed and it can not be used any more.',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
fontSize: 3 * _deviceBlockSize,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 220,
child: Column(
children: [
Text(
'By approving, your package will be removed and it can not be used any more.',
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
),
SizedBox(
height: 10.0,
),
PackageCard(_deviceBlockSize),
SizedBox(
height: 20.0,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
onTap: () {
Provider.of<PackageProvider>(context,
listen: false)
.removePackages(datas.id)
.then(
(value) {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(
context,
Routes.myPackagesResultScreen,
);
},
);
},
text: 'Destroy',
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kDarkPurple,
onTap: () {
Navigator.pop(context);
},
),
],
),
SizedBox(
height: 10.0,
),
);
},
);
},
),
PackageCard(_deviceBlockSize),
SizedBox(
height: 20.0,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
onTap: () {
Provider.of<PackageProvider>(context,
listen: false)
.removePackages(datas.id)
.then(
(value) {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(
context,
Routes.myPackagesResultScreen,
);
},
);
},
text: 'Destroy',
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kDarkPurple,
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
},
),
SizedBox(
height: 20,
),