Improve back button function in all screens

This commit is contained in:
hanie.khodkari
2025-03-19 18:38:40 +03:30
parent d99ecb2783
commit 58cd3d9f3f
35 changed files with 4715 additions and 5007 deletions
+142 -149
View File
@@ -27,173 +27,166 @@ class _TestScanScreenState extends State<TestScanScreen> {
// final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5);
final double _devicewidth = _media.size.width;
final double _deviceBlockSize = _devicewidth / 100;
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
if (didPop) return;
Navigator.of(context).pushNamed(Routes.homePage);
},
child: SafeArea(
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'Test Results',
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(),
return SafeArea(
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'Test Results',
style: TextStyle(
color: Colors.white,
),
),
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 Test Result?',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: 5.5 * _deviceBlockSize,
fontWeight: FontWeight.w700,
letterSpacing: 3,
),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
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 Test Result?',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: 5.5 * _deviceBlockSize,
fontWeight: FontWeight.w700,
letterSpacing: 3,
),
),
GestureDetector(
child: Container(
margin: EdgeInsets.symmetric(vertical: 10),
height: 200,
decoration: BoxDecoration(border: Border.all()),
child: Center(
child: Text(
'Please Scan The Test Result Barcode',
style: TextStyle(
color: Colors.black,
fontSize: 5 * _deviceBlockSize,
fontWeight: FontWeight.w100,
letterSpacing: 3,
),
textAlign: TextAlign.center,
),
),
),
onTap: () {
scan().then(
(String result) {
if (result == 'cancel') {
print('cancel');
} else if (result == 'error') {
print('error');
} else if (result == 'access') {
print('access');
} else {
launch(
'https://cssd-doc.com/Show/TestResult/$result',
);
// Navigator.of(context).pushNamed(
// Routes.cycleDetailScreen,
// arguments: result,
// );
}
},
);
},
),
SizedBox(
height: 10.0,
),
Form(
key: _form,
child: TextFormField(
validator: (val) {
if (val!.isEmpty) {
return 'Id required!!';
}
return null;
},
controller: idCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.sortNumericDown,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
),
GestureDetector(
child: Container(
margin: EdgeInsets.symmetric(vertical: 10),
height: 200,
decoration: BoxDecoration(border: Border.all()),
child: Center(
child: Text(
'Please Scan The Test Result Barcode',
style: TextStyle(
color: Colors.black,
fontSize: 5 * _deviceBlockSize,
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Or enter a Test Result ID',
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
focusedBorder: UnderlineInputBorder(
// borderRadius: BorderRadius.only(Radius.circular(4)),
borderSide: BorderSide(
color: Colors.grey,
),
letterSpacing: 3,
),
textAlign: TextAlign.center,
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.number,
),
),
SizedBox(
height: 70,
),
InkWell(
onTap: () {
if (!_form.currentState!.validate()) {
return;
onTap: () {
scan().then(
(String result) {
if (result == 'cancel') {
print('cancel');
} else if (result == 'error') {
print('error');
} else if (result == 'access') {
print('access');
} else {
launch(
'https://cssd-doc.com/Show/TestResult/$result',
);
// Navigator.of(context).pushNamed(
// Routes.cycleDetailScreen,
// arguments: result,
// );
}
},
);
},
),
SizedBox(
height: 10.0,
),
Form(
key: _form,
child: TextFormField(
validator: (val) {
if (val!.isEmpty) {
return 'Id required!!';
}
launch(
'https://cssd-doc.com/Show/TestResult/${idCTRL.text}',
);
return null;
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 5 * _deviceBlockSize,
vertical: 10,
controller: idCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.sortNumericDown,
size: 6 * _deviceBlockSize,
),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.black, Colors.black87],
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Or enter a Test Result ID',
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
focusedBorder: UnderlineInputBorder(
// borderRadius: BorderRadius.only(Radius.circular(4)),
borderSide: BorderSide(
color: Colors.grey,
),
borderRadius: BorderRadius.circular(7),
),
child: Align(
alignment: Alignment.center,
child: Text(
'Search',
style: TextStyle(
color: Colors.white,
fontSize: 5 * _deviceBlockSize,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.number,
),
),
SizedBox(
height: 70,
),
InkWell(
onTap: () {
if (!_form.currentState!.validate()) {
return;
}
launch(
'https://cssd-doc.com/Show/TestResult/${idCTRL.text}',
);
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 5 * _deviceBlockSize,
vertical: 10,
),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.black, Colors.black87],
),
borderRadius: BorderRadius.circular(7),
),
child: Align(
alignment: Alignment.center,
child: Text(
'Search',
style: TextStyle(
color: Colors.white,
fontSize: 5 * _deviceBlockSize,
),
),
),
),
],
)
: ConnectionErrorBox();
},
),
),
],
)
: ConnectionErrorBox();
},
),
),
);