Fix some issue

This commit is contained in:
fhkhd
2024-02-13 17:17:42 +03:30
parent c448b695ec
commit d2b81bd4a6
9 changed files with 839 additions and 780 deletions
+238 -224
View File
@@ -21,6 +21,7 @@ class _PackageAddScreenState extends State<PackageAddScreen> {
final _packageUdiFocusNode = FocusNode();
final _descriptionFocusNode = FocusNode();
TextEditingController descriptionCTRL = new TextEditingController();
// TextEditingController udiCTRL = new TextEditingController();
TextEditingController nameCTRL = new TextEditingController();
TextEditingController dateCTRL = new TextEditingController();
@@ -30,6 +31,7 @@ class _PackageAddScreenState extends State<PackageAddScreen> {
PackageFilterObject? filters;
int curLabelVal = 1;
@override
void initState() {
descriptionCTRL.text = '';
@@ -62,234 +64,246 @@ class _PackageAddScreenState extends State<PackageAddScreen> {
final _media = MediaQuery.of(context);
final double _devicewidth = _media.size.width;
final double _deviceBlockSize = _devicewidth / 100;
return WillPopScope(
onWillPop: () async {
Navigator.pushReplacementNamed(
context,
Routes.packageResultScreen,
);
return true;
},
child: SafeArea(
child: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
return Consumer<PackageProvider>(
builder: (context, packageProvider, _) {
return WillPopScope(
onWillPop: () async {
packageProvider.resetLoadingButton();
Navigator.pushReplacementNamed(
context,
Routes.packageResultScreen,
);
return true;
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'Packages',
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.packageResultScreen),
),
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? isInit
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: Form(
key: _form,
child: Padding(
padding: EdgeInsets.all(20),
child: ListView(
children: <Widget>[
Text(
'Add a Package',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 6 * _deviceBlockSize,
letterSpacing: 3,
),
),
SizedBox(
height: 20,
),
TextFormField(
validator: (val) {
if (val!.isEmpty) {
return 'Name required!';
}
return null;
},
controller: nameCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 7 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Package Name',
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_packageUdiFocusNode);
},
),
SizedBox(
height: 30,
),
// TextFormField(
// validator: (val) {
// if (val!.isEmpty) {
// return 'UDI required!';
// }
// return null;
// },
// controller: udiCTRL,
// decoration: InputDecoration(
// icon: Icon(
// FontAwesomeIcons.alignLeft,
// size: 7 * _deviceBlockSize,
// ),
// labelStyle: TextStyle(
// fontWeight: FontWeight.w100,
// fontSize: 4 * _deviceBlockSize,
// ),
// isDense: true,
// labelText: 'UDI',
// contentPadding: EdgeInsets.symmetric(
// vertical: 2, horizontal: 3),
// ),
// style: TextStyle(
// fontWeight: FontWeight.w700,
// fontSize: 5 * _deviceBlockSize,
// ),
// focusNode: _packageUdiFocusNode,
// keyboardType: TextInputType.visiblePassword,
// textInputAction: TextInputAction.next,
// onFieldSubmitted: (_) {
// FocusScope.of(context)
// .requestFocus(_descriptionFocusNode);
// },
// ),
// SizedBox(
// height: 20,
// ),
Container(
margin: EdgeInsets.symmetric(vertical: 5),
child: Text(
'Items included',
style: TextStyle(
color: kPurple,
letterSpacing: 2,
fontSize: 5 * _deviceBlockSize,
),
),
),
Consumer<PackageProvider>(
builder: (ctx, packageProvider, _) =>
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (ctx, index) => AddItemBox(
text: 'Select Items Included',
iconColor: kPurpleSub,
deviceBlockSize: _deviceBlockSize,
values:
packageProvider.itemValues[index],
vals: packageProvider.itemVals,
initialItemValue:
packageProvider.initialItemValue,
index: index,
// filteredItems:
// packageProvider.filteredItems!,
hasRemoveButton:
packageProvider.itemValues.length >
1
? true
: false,
),
itemCount:
packageProvider.itemValues.length,
),
),
SizedBox(
height: 30,
),
TextFormField(
controller: descriptionCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 7 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Description',
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.multiline,
focusNode: _descriptionFocusNode,
minLines: 1,
maxLines: 5,
),
SizedBox(
height: 70,
),
PackageAddSaveButton(
form: _form,
itemValues: Provider.of<PackageProvider>(
context,
listen: false,
).itemValues,
nameCTRL: nameCTRL,
// udiCTRL: udiCTRL,
dateValue: dateCTRL.text,
descriptionCTRL: descriptionCTRL,
deviceBlockSize: _deviceBlockSize,
),
SizedBox(
height: 100,
),
],
),
),
)
: ConnectionErrorBox();
child: SafeArea(
child: GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text(
'Packages',
style: TextStyle(
color: Colors.white,
),
),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () {
packageProvider.resetLoadingButton();
Navigator.of(context)
.pushReplacementNamed(Routes.packageResultScreen);
},
),
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? isInit
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: Form(
key: _form,
child: Padding(
padding: EdgeInsets.all(20),
child: ListView(
children: <Widget>[
Text(
'Add a Package',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 6 * _deviceBlockSize,
letterSpacing: 3,
),
),
SizedBox(
height: 20,
),
TextFormField(
validator: (val) {
if (val!.isEmpty) {
return 'Name required!';
}
return null;
},
controller: nameCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 7 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Package Name',
contentPadding: EdgeInsets.symmetric(
vertical: 2,
horizontal: 3,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context).requestFocus(
_packageUdiFocusNode);
},
),
SizedBox(
height: 30,
),
// TextFormField(
// validator: (val) {
// if (val!.isEmpty) {
// return 'UDI required!';
// }
// return null;
// },
// controller: udiCTRL,
// decoration: InputDecoration(
// icon: Icon(
// FontAwesomeIcons.alignLeft,
// size: 7 * _deviceBlockSize,
// ),
// labelStyle: TextStyle(
// fontWeight: FontWeight.w100,
// fontSize: 4 * _deviceBlockSize,
// ),
// isDense: true,
// labelText: 'UDI',
// contentPadding: EdgeInsets.symmetric(
// vertical: 2, horizontal: 3),
// ),
// style: TextStyle(
// fontWeight: FontWeight.w700,
// fontSize: 5 * _deviceBlockSize,
// ),
// focusNode: _packageUdiFocusNode,
// keyboardType: TextInputType.visiblePassword,
// textInputAction: TextInputAction.next,
// onFieldSubmitted: (_) {
// FocusScope.of(context)
// .requestFocus(_descriptionFocusNode);
// },
// ),
// SizedBox(
// height: 20,
// ),
Container(
margin:
EdgeInsets.symmetric(vertical: 5),
child: Text(
'Items included',
style: TextStyle(
color: kPurple,
letterSpacing: 2,
fontSize: 5 * _deviceBlockSize,
),
),
),
Consumer<PackageProvider>(
builder: (ctx, packageProvider, _) =>
ListView.builder(
physics:
NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (ctx, index) =>
AddItemBox(
text: 'Select Items Included',
iconColor: kPurpleSub,
deviceBlockSize: _deviceBlockSize,
values: packageProvider
.itemValues[index],
vals: packageProvider.itemVals,
initialItemValue: packageProvider
.initialItemValue,
index: index,
// filteredItems:
// packageProvider.filteredItems!,
hasRemoveButton: packageProvider
.itemValues.length >
1
? true
: false,
),
itemCount:
packageProvider.itemValues.length,
),
),
SizedBox(
height: 30,
),
TextFormField(
controller: descriptionCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 7 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Description',
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.multiline,
focusNode: _descriptionFocusNode,
minLines: 1,
maxLines: 5,
),
SizedBox(
height: 70,
),
PackageAddSaveButton(
form: _form,
itemValues:
Provider.of<PackageProvider>(
context,
listen: false,
).itemValues,
nameCTRL: nameCTRL,
// udiCTRL: udiCTRL,
dateValue: dateCTRL.text,
descriptionCTRL: descriptionCTRL,
deviceBlockSize: _deviceBlockSize,
),
SizedBox(
height: 100,
),
],
),
),
)
: ConnectionErrorBox();
},
),
),
),
),
),
),
);
},
);
}
}