mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 17:48:54 +03:30
Improve back button function in all screens
This commit is contained in:
@@ -49,244 +49,229 @@ class _TestResultAddScreenState extends State<TestResultAddScreen> {
|
||||
// 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);
|
||||
// Navigator.pushReplacementNamed(
|
||||
// context,
|
||||
// Routes.testResultScreen,
|
||||
// );
|
||||
// return true;
|
||||
},
|
||||
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,
|
||||
),
|
||||
// padding: EdgeInsets.all(0),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.popAndPushNamed(Routes.testResultScreen),
|
||||
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'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 20, vertical: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: 10,
|
||||
),
|
||||
child: Text(
|
||||
'Add a Test Result',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
color: Colors.white,
|
||||
size: 35,
|
||||
),
|
||||
// padding: EdgeInsets.all(0),
|
||||
onPressed: () =>
|
||||
Navigator.of(context).popAndPushNamed(Routes.testResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView(
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 20, vertical: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: 10,
|
||||
),
|
||||
child: Text(
|
||||
'Add a Test Result',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 5, bottom: 30),
|
||||
padding: EdgeInsets.all(10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'PLease Scan The Test Barcode',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 5, bottom: 30),
|
||||
padding: EdgeInsets.all(10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'PLease Scan The Test Barcode',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).testCode = result;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: result,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 70 * _deviceBlockSize,
|
||||
child: TestResultAddSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
dataCTRL: testTypeCTRL,
|
||||
dataVals: testTypeVals,
|
||||
label: 'Choose a Test Type',
|
||||
),
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).testCode = result;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: result,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 70 * _deviceBlockSize,
|
||||
child: TestResultAddSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
dataCTRL: testTypeCTRL,
|
||||
dataVals: testTypeVals,
|
||||
label: 'Choose a Test Type',
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'OR',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 7 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'OR',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 7 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 8 * _deviceBlockSize,
|
||||
),
|
||||
Container(
|
||||
width: 50 * _deviceBlockSize,
|
||||
child: TextFormField(
|
||||
onChanged: (val) {
|
||||
if (val != '') {
|
||||
setState(
|
||||
() {
|
||||
testTypeCTRL.text = '';
|
||||
},
|
||||
);
|
||||
} else {
|
||||
setState(
|
||||
() {
|
||||
testTypeCTRL.text =
|
||||
testTypeVals[0];
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
controller: testCodeCTRL,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons
|
||||
.sortNumericDown,
|
||||
),
|
||||
labelText: 'Enter a Test Code',
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
contentPadding: EdgeInsets.only(
|
||||
bottom: 5,
|
||||
top: 5,
|
||||
),
|
||||
),
|
||||
keyboardType:
|
||||
TextInputType.visiblePassword,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 40.0,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
width: 50 * _deviceBlockSize,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
SizedBox(
|
||||
width: 8 * _deviceBlockSize,
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: TextButton(
|
||||
child: Text(
|
||||
'Select',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (testCodeCTRL.text != '') {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).testCode = testCodeCTRL.text;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: testCodeCTRL.text,
|
||||
Container(
|
||||
width: 50 * _deviceBlockSize,
|
||||
child: TextFormField(
|
||||
onChanged: (val) {
|
||||
if (val != '') {
|
||||
setState(
|
||||
() {
|
||||
testTypeCTRL.text = '';
|
||||
},
|
||||
);
|
||||
} else if (testTypeCTRL.text !=
|
||||
'') {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).testType = testTypeCTRL.text;
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: testTypeCTRL.text,
|
||||
} else {
|
||||
setState(
|
||||
() {
|
||||
testTypeCTRL.text =
|
||||
testTypeVals[0];
|
||||
},
|
||||
);
|
||||
}
|
||||
// print(testCode);
|
||||
},
|
||||
controller: testCodeCTRL,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
),
|
||||
labelText: 'Enter a Test Code',
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
contentPadding: EdgeInsets.only(
|
||||
bottom: 5,
|
||||
top: 5,
|
||||
),
|
||||
),
|
||||
keyboardType:
|
||||
TextInputType.visiblePassword,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 40.0,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 5 * _deviceBlockSize,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
width: 50 * _deviceBlockSize,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: TextButton(
|
||||
child: Text(
|
||||
'Select',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (testCodeCTRL.text != '') {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).testCode = testCodeCTRL.text;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: testCodeCTRL.text,
|
||||
);
|
||||
} else if (testTypeCTRL.text != '') {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).testType = testTypeCTRL.text;
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: testTypeCTRL.text,
|
||||
);
|
||||
}
|
||||
// print(testCode);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 5 * _deviceBlockSize,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user