This commit is contained in:
unknown
2023-12-09 17:52:53 +03:30
parent 6464557956
commit ede10a2efe
36 changed files with 2252 additions and 1821 deletions
@@ -168,7 +168,7 @@ class MyItemsDetailsDataBox extends StatelessWidget {
Container(
width: 35 * _deviceBlockSize,
child: Text(
'User',
'Owner',
style: TextStyle(
color: Colors.grey,
),
@@ -190,6 +190,33 @@ class MyItemsDetailsDataBox extends StatelessWidget {
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
width: 35 * _deviceBlockSize,
child: Text(
'Creator',
style: TextStyle(
color: Colors.grey,
),
),
),
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.userCreator.toString(),
style: TextStyle(
fontWeight: FontWeight.w700,
),
overflow: TextOverflow.clip,
),
),
],
),
Divider(),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
@@ -332,21 +359,32 @@ class MyItemsDetailsDataBox extends StatelessWidget {
SizedBox(
height: 20,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
text: 'Transfer',
onTap: () {
push();
},
),
userData['roles']?.contains('Admin') ?? false
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
text: 'Transfer',
onTap: () {
push();
},
)
: datas.packageId != null
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kDarkBlue,
secondColor: kDarkBlueSub,
text: 'Transfer',
onTap: () {
push();
},
)
: Container(),
SizedBox(
height: 10.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: TransferDestroyButton(
userData['roles']?.contains('Admin') ?? false
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
@@ -417,13 +455,88 @@ class MyItemsDetailsDataBox extends StatelessWidget {
},
);
},
),
)
: userData['roles'].contains('Supervisor')
? datas.packageId != null
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
text: 'Destroy',
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to destroy this Item?',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 220,
child: Column(
children: [
Text(
'By approving, your item will be removed and it can not be used any more.',
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
),
SizedBox(
height: 10.0,
),
ItemCard(_deviceBlockSize),
SizedBox(
height: 20.0,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: kPink,
secondColor: kPinkSub,
onTap: () {
Provider.of<ItemProvider>(context,
listen: false)
.removeItems(datas.id)
.then(
(value) {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(
context,
Routes.myItemsResultScreen,
);
},
);
},
text: 'Destroy',
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kDarkBlue,
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
},
)
: Container()
: Container(),
SizedBox(
height: 10.0,
),
userData['roles']?.contains('User') ?? false
? Container()
: TransferDestroyButton(
userData['roles']?.contains('Admin') ?? false
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: Colors.black,
secondColor: Colors.black87,
@@ -494,7 +607,84 @@ class MyItemsDetailsDataBox extends StatelessWidget {
},
);
},
),
)
: userData['roles'].contains('Supervisor')
? datas.packageId != null
? TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: Colors.black,
secondColor: Colors.black87,
text: 'Repair',
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you sure to repair this Item?',
style: TextStyle(
fontSize: 4 * _deviceBlockSize,
),
),
content: SizedBox(
width: _deviceBlockSize,
height: 220,
child: Column(
children: [
Text(
'By approving, your item will be set in repair mode and it can be use anymore unless you disable repair mode.',
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
),
SizedBox(
height: 10.0,
),
ItemCard(_deviceBlockSize),
SizedBox(
height: 20.0,
),
TransferDestroyButton(
deviceBlockSize: _deviceBlockSize,
firstColor: Colors.black,
secondColor: Colors.black87,
onTap: () {
Provider.of<MyItemProvider>(context,
listen: false)
.repairItems(
datas.id, 'approved')
.then(
(value) {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(
context,
Routes.myItemsResultScreen,
);
},
);
},
text: 'Repair',
),
SizedBox(
height: 5.0,
),
CancelTransferButton(
deviceBlockSize: _deviceBlockSize,
color: kDarkBlue,
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
},
)
: Container()
: Container(),
SizedBox(
height: 20.0,
),
@@ -8,6 +8,7 @@ class TransferDestroyButton extends StatelessWidget {
required this.secondColor,
required this.onTap,
required this.text,
this.fontSize = 5.0,
}) : _deviceBlockSize = deviceBlockSize,
super(key: key);
final double _deviceBlockSize;
@@ -15,6 +16,7 @@ class TransferDestroyButton extends StatelessWidget {
final Color secondColor;
final String text;
final VoidCallback onTap;
final double fontSize;
@override
Widget build(BuildContext context) {
@@ -37,7 +39,7 @@ class TransferDestroyButton extends StatelessWidget {
text,
style: TextStyle(
color: Colors.white,
fontSize: 5 * _deviceBlockSize,
fontSize: fontSize * _deviceBlockSize,
),
),
),
@@ -1,4 +1,3 @@
import 'package:cssd/providers/auth.dart';
import 'package:cssd/providers/my_items.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -32,7 +31,6 @@ class MyItemFilterChip extends StatelessWidget {
@override
Widget build(BuildContext context) {
final userData = Provider.of<Auth>(context, listen: false).user;
return Row(
children: <Widget>[
SizedBox(
@@ -61,19 +59,11 @@ class MyItemFilterChip extends StatelessWidget {
_specific,
);
itemProvider.setLoading();
if (userData['roles']?.contains('User')) {
itemProvider.getMyItems().then(
(_) {
itemProvider.resetLoading();
},
);
} else {
itemProvider.getHospitalItems().then(
(_) {
itemProvider.resetLoading();
},
);
}
itemProvider.getMyItems().then(
(_) {
itemProvider.resetLoading();
},
);
},
),
],