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
@@ -52,58 +52,51 @@ class _MyItemsDetailScreenState extends State<MyItemsDetailScreen> {
final _media = MediaQuery.of(context);
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(
'My Items',
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(
'My Items',
style: TextStyle(
color: Colors.white,
),
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? isInit
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: isEmpty
? Center(
child: Text('This Item does\'nt exists!'),
)
: MyItemsDetailsDataBox(
datas: datas!,
deviceBlockSize: _deviceBlockSize,
push: () {
Navigator.pushNamed(
context, Routes.itemsTransferScreen,
arguments: datas);
},
)
: ConnectionErrorBox();
},
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'
? isInit
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: isEmpty
? Center(
child: Text('This Item does\'nt exists!'),
)
: MyItemsDetailsDataBox(
datas: datas!,
deviceBlockSize: _deviceBlockSize,
push: () {
Navigator.pushNamed(
context, Routes.itemsTransferScreen,
arguments: datas);
},
)
: ConnectionErrorBox();
},
),
),
);
}
+301 -313
View File
@@ -53,323 +53,311 @@ class _MyItemsFilterScreenState extends State<MyItemsFilterScreen> {
final _media = MediaQuery.of(context);
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.myItemsResultScreen,
// );
// return true;
},
child: SafeArea(
child: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'My Items',
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)
.pushReplacementNamed(Routes.myItemsResultScreen),
return SafeArea(
child: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'My Items',
style: TextStyle(
color: Colors.white,
),
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? isInit
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: Padding(
padding: EdgeInsets.all(20),
child: ListView(
children: <Widget>[
Text(
'Filter My Items',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
),
SizedBox(
height: 20,
),
Row(
children: [
Flexible(
flex: 8,
child: TextFormField(
controller: idCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.sortNumericDown,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Item ID',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemNameFocusNode);
},
),
),
// Spacer(),
Flexible(
flex: 1,
child: InkWell(
onTap: () {
scan().then(
(String result) {
if (result == 'cancel') {
print('cancel');
} else if (result == 'error') {
print('error');
} else if (result == 'access') {
print('access');
} else {
print(result);
idCTRL.text = result;
}
},
);
},
child: Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Icon(
Icons.qr_code_scanner,
size: 5 * _deviceBlockSize,
color: Colors.white,
),
),
),
),
],
),
SizedBox(
height: 30,
),
TextFormField(
controller: nameCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Item Name',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemNameFocusNode,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemUdiFocusNode);
},
),
SizedBox(
height: 30,
),
Row(
children: [
Flexible(
flex: 8,
child: TextFormField(
controller: udiCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'UDI',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemUdiFocusNode,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemSizeFocusNode);
},
),
),
Flexible(
flex: 1,
child: InkWell(
onTap: () {
scan().then(
(String result) {
if (result == 'cancel') {
print('cancel');
} else if (result == 'error') {
print('error');
} else if (result == 'access') {
print('access');
} else {
print(result);
idCTRL.text = result;
}
},
);
},
child: Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Icon(
Icons.qr_code_scanner,
size: 5 * _deviceBlockSize,
color: Colors.white,
),
),
),
),
],
),
SizedBox(
height: 30.0,
),
TextFormField(
controller: sizeCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.sortNumericDown,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Size',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemSizeFocusNode,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemSpecificFocusNode);
},
),
SizedBox(
height: 30,
),
TextFormField(
controller: specificCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Specific',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemSpecificFocusNode,
keyboardType: TextInputType.visiblePassword,
textInputAction: TextInputAction.next,
),
SizedBox(
height: 90,
),
MyItemFilterSaveButton(
idCTRL: idCTRL,
nameCTRL: nameCTRL,
udiCTRL: udiCTRL,
sizeCTRL: sizeCTRL,
specificCTRL: specificCTRL,
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
push: Routes.myItemsResultScreen,
),
SizedBox(
height: 100,
),
],
),
)
: ConnectionErrorBox();
},
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context)
.pushReplacementNamed(Routes.myItemsResultScreen),
),
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? isInit
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: Padding(
padding: EdgeInsets.all(20),
child: ListView(
children: <Widget>[
Text(
'Filter My Items',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
),
SizedBox(
height: 20,
),
Row(
children: [
Flexible(
flex: 8,
child: TextFormField(
controller: idCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.sortNumericDown,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Item ID',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemNameFocusNode);
},
),
),
// Spacer(),
Flexible(
flex: 1,
child: InkWell(
onTap: () {
scan().then(
(String result) {
if (result == 'cancel') {
print('cancel');
} else if (result == 'error') {
print('error');
} else if (result == 'access') {
print('access');
} else {
print(result);
idCTRL.text = result;
}
},
);
},
child: Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Icon(
Icons.qr_code_scanner,
size: 5 * _deviceBlockSize,
color: Colors.white,
),
),
),
),
],
),
SizedBox(
height: 30,
),
TextFormField(
controller: nameCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Item Name',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemNameFocusNode,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemUdiFocusNode);
},
),
SizedBox(
height: 30,
),
Row(
children: [
Flexible(
flex: 8,
child: TextFormField(
controller: udiCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'UDI',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemUdiFocusNode,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemSizeFocusNode);
},
),
),
Flexible(
flex: 1,
child: InkWell(
onTap: () {
scan().then(
(String result) {
if (result == 'cancel') {
print('cancel');
} else if (result == 'error') {
print('error');
} else if (result == 'access') {
print('access');
} else {
print(result);
idCTRL.text = result;
}
},
);
},
child: Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Icon(
Icons.qr_code_scanner,
size: 5 * _deviceBlockSize,
color: Colors.white,
),
),
),
),
],
),
SizedBox(
height: 30.0,
),
TextFormField(
controller: sizeCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.sortNumericDown,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Size',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemSizeFocusNode,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemSpecificFocusNode);
},
),
SizedBox(
height: 30,
),
TextFormField(
controller: specificCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Specific',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemSpecificFocusNode,
keyboardType: TextInputType.visiblePassword,
textInputAction: TextInputAction.next,
),
SizedBox(
height: 90,
),
MyItemFilterSaveButton(
idCTRL: idCTRL,
nameCTRL: nameCTRL,
udiCTRL: udiCTRL,
sizeCTRL: sizeCTRL,
specificCTRL: specificCTRL,
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
push: Routes.myItemsResultScreen,
),
SizedBox(
height: 100,
),
],
),
)
: ConnectionErrorBox();
},
),
),
),
);
+150 -157
View File
@@ -26,181 +26,174 @@ class _MyItemsScanScreenState extends State<MyItemsScanScreen> {
// 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: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'My Items',
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: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'My Items',
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 an Item?',
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 an Item?',
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 Item 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/Item/$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 Item Barcode',
style: TextStyle(
color: Colors.black,
fontSize: 5 * _deviceBlockSize,
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Or enter an Item 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/Item/$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/Item/${idCTRL.text}',
);
// Navigator.of(context).pushNamed(
// Routes.cycleDetailScreen,
// arguments: 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: [kDarkBlue, kDarkBlueSub],
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Or enter an Item 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/Item/${idCTRL.text}',
);
// Navigator.of(context).pushNamed(
// Routes.cycleDetailScreen,
// arguments: idCTRL.text,
// );
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 5 * _deviceBlockSize,
vertical: 10,
),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [kDarkBlue, kDarkBlueSub],
),
borderRadius: BorderRadius.circular(7),
),
child: Align(
alignment: Alignment.center,
child: Text(
'Search',
style: TextStyle(
color: Colors.white,
fontSize: 5 * _deviceBlockSize,
),
),
),
),
],
)
: ConnectionErrorBox();
},
),
),
],
)
: ConnectionErrorBox();
},
),
),
),
@@ -79,250 +79,240 @@ class _ItemsTransferScreenState extends State<ItemsTransferScreen> {
final _media = MediaQuery.of(context);
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: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'Item Details',
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: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'Item Details',
style: TextStyle(
color: Colors.white,
),
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? Padding(
padding: EdgeInsets.only(
top: 20,
right: 20,
bottom: 40,
left: 20,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ResultBanner(
deviceBlockSize: _deviceBlockSize,
text: 'Transfer to',
hasFilterObject: false,
push: Routes.myItemsFilterScreen,
),
SizedBox(
height: 20.0,
),
ResultSearchBox(
searchCTRL: searchCTRL,
text: 'user',
text2: 'name or ID',
deviceBlockSize: _deviceBlockSize,
textInputType: TextInputType.visiblePassword,
onChanged: (value) {
Provider.of<UsersProvider>(context,
listen: false)
.searchUsers(value);
},
),
SizedBox(
height: 20,
),
Expanded(
child: Consumer<UsersProvider>(
builder: (context, userResults, _) {
return userResults.isLoading
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: userResults.usersBox?.length != null
? ListView.builder(
controller: sc,
itemBuilder: (context, index) {
return TransferDataBox(
deviceBlockSize:
_deviceBlockSize,
user: userResults
.usersBox?[index],
clickColor: kDarkBlue,
isClicked: userResults
.selectedUserIndex ==
index,
onTap: (userId) {
Provider.of<UsersProvider>(
context,
listen: false,
).selectUser(index);
print(userId);
Provider.of<UsersProvider>(
context,
listen: false)
.saveUserId = userId;
Provider.of<UsersProvider>(
context,
listen: false)
.selectedUserForItems =
userResults
.usersBox?[index];
},
);
},
itemCount:
userResults.usersBox?.length,
shrinkWrap: true,
)
: Container(
child: Center(
child: Text(
"There is no user to show."),
),
);
},
),
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to transfer this Item?',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
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'
? Padding(
padding: EdgeInsets.only(
top: 20,
right: 20,
bottom: 40,
left: 20,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ResultBanner(
deviceBlockSize: _deviceBlockSize,
text: 'Transfer to',
hasFilterObject: false,
push: Routes.myItemsFilterScreen,
),
SizedBox(
height: 20.0,
),
ResultSearchBox(
searchCTRL: searchCTRL,
text: 'user',
text2: 'name or ID',
deviceBlockSize: _deviceBlockSize,
textInputType: TextInputType.visiblePassword,
onChanged: (value) {
Provider.of<UsersProvider>(context, listen: false)
.searchUsers(value);
},
),
SizedBox(
height: 20,
),
Expanded(
child: Consumer<UsersProvider>(
builder: (context, userResults, _) {
return userResults.isLoading
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 320,
child: Column(
children: [
Text(
'By approving, your item will be transferred the specified user. It can be undone unless the user reject the transfer.',
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
),
SizedBox(
height: 10.0,
),
ItemCard(
_deviceBlockSize, itemData!),
SizedBox(
height: 5.0,
),
Row(
children: [
Spacer(),
Text('To'),
SizedBox(
width: 5.0,
),
TransferDataBox(
deviceBlockSize:
_deviceBlockSize,
user: Provider.of<
UsersProvider>(
context)
.selectedUserForItems,
)
],
),
SizedBox(
height: 20.0,
),
Consumer<MyItemProvider>(
builder:
(context, myItemProvider, _) {
return TransferDestroyButton(
deviceBlockSize:
_deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
onTap: () async {
myItemProvider
.setLoadingButton();
await Provider.of<
MyItemProvider>(
context,
listen: false,
).transferItems(
itemData!.id,
await Provider.of<
UsersProvider>(
)
: userResults.usersBox?.length != null
? ListView.builder(
controller: sc,
itemBuilder: (context, index) {
return TransferDataBox(
deviceBlockSize:
_deviceBlockSize,
user: userResults
.usersBox?[index],
clickColor: kDarkBlue,
isClicked: userResults
.selectedUserIndex ==
index,
onTap: (userId) {
Provider.of<UsersProvider>(
context,
listen: false,
).selectUser(index);
print(userId);
Provider.of<UsersProvider>(
context,
listen: false)
.saveUserId = userId;
Provider.of<UsersProvider>(
context,
listen: false)
.saveUserId!,
);
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
myItemProvider
.resetLoadingButton();
Fluttertoast.showToast(
msg:
"The item is transferred.",
toastLength:
Toast.LENGTH_SHORT,
gravity:
ToastGravity.BOTTOM,
);
},
text: 'Transfer',
isLoadingButton:
myItemProvider
.isloadingButton,
);
},
.selectedUserForItems =
userResults
.usersBox?[index];
},
);
},
itemCount:
userResults.usersBox?.length,
shrinkWrap: true,
)
: Container(
child: Center(
child: Text(
"There is no user to show."),
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kPink,
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
);
},
text: 'Transfer',
),
],
),
)
: ConnectionErrorBox();
},
),
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to transfer this Item?',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 320,
child: Column(
children: [
Text(
'By approving, your item will be transferred the specified user. It can be undone unless the user reject the transfer.',
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
),
SizedBox(
height: 10.0,
),
ItemCard(_deviceBlockSize, itemData!),
SizedBox(
height: 5.0,
),
Row(
children: [
Spacer(),
Text('To'),
SizedBox(
width: 5.0,
),
TransferDataBox(
deviceBlockSize:
_deviceBlockSize,
user:
Provider.of<UsersProvider>(
context)
.selectedUserForItems,
)
],
),
SizedBox(
height: 20.0,
),
Consumer<MyItemProvider>(
builder:
(context, myItemProvider, _) {
return TransferDestroyButton(
deviceBlockSize:
_deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
onTap: () async {
myItemProvider
.setLoadingButton();
await Provider.of<
MyItemProvider>(
context,
listen: false,
).transferItems(
itemData!.id,
await Provider.of<
UsersProvider>(
context,
listen: false)
.saveUserId!,
);
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
myItemProvider
.resetLoadingButton();
Fluttertoast.showToast(
msg:
"The item is transferred.",
toastLength:
Toast.LENGTH_SHORT,
gravity:
ToastGravity.BOTTOM,
);
},
text: 'Transfer',
isLoadingButton: myItemProvider
.isloadingButton,
);
},
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kPink,
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
},
text: 'Transfer',
),
],
),
)
: ConnectionErrorBox();
},
),
),
),