Fix status of package in detail screens

This commit is contained in:
fhkhd
2024-01-31 19:55:57 +03:30
parent 2dc4c6b416
commit 86feef9a38
8 changed files with 415 additions and 161 deletions
@@ -264,6 +264,33 @@ class PackageDetailsDataBox extends StatelessWidget {
],
),
Divider(),
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Container(
width: 35 * _deviceBlockSize,
child: Text(
'Status',
style: TextStyle(
color: Colors.grey,
),
),
),
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.status == 'approved' ? 'Confirmed' : 'Rejected',
style: TextStyle(
fontWeight: FontWeight.w700,
color: datas.status == 'approved' ? kBlue : kPink,
),
overflow: TextOverflow.clip,
),
),
],
),
SizedBox(
height: 30,
),
@@ -6,6 +6,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../../../config/colors.dart';
import '../../../config/routes.dart';
class PackageItemBox extends StatelessWidget {
@@ -127,70 +128,196 @@ class PackageItemBox extends StatelessWidget {
// ),
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Delete'),
content: Text(
'Are you sure you want delete this Package?',
: userData['roles']?.contains('User') ?? false
? Container()
: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Delete'),
content: Text(
'Are you sure you want delete this Package?',
),
actions: <Widget>[
TextButton(
child: Text('Yes'),
onPressed: () {
Navigator.of(context).pop();
Provider.of<PackageProvider>(
context,
listen: false)
.removePackages(item!.id);
},
),
actions: <Widget>[
TextButton(
child: Text('Yes'),
onPressed: () {
Navigator.of(context).pop();
Provider.of<PackageProvider>(
context,
listen: false)
.removePackages(item!.id);
},
),
TextButton(
child: Text('No'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
TextButton(
child: Text('No'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
child: Icon(
Icons.delete,
size: 5 * _deviceBlockSize,
color: Colors.black,
),
),
SizedBox(
width: 5.0,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Reject this item?'
),
actions: <Widget>[
TextButton(
onPressed: () {
Provider.of<PackageProvider>(context,
listen: false)
.changeStatus(item!.id, "rejected")
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(context).pop();
// Navigator.of(context)
// .popAndPushNamed(Routes
// .packageResultScreen);
},
);
},
child: Text('Yes'),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('No'),
),
],
);
},
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kPink
),
child: Icon(
Icons.delete,
size: 5 * _deviceBlockSize,
color: Colors.black,
Icons.close ,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
SizedBox(
width: 5.0,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
Navigator.of(context).pushNamed(
Routes.packageDetailScreen,
arguments: item!.id,
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 9 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Icon(
FontAwesomeIcons.fileAlt,
size: 5 * _deviceBlockSize,
color: Colors.white,
SizedBox(
width: 5,
),
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Confirm this item?',
),
actions: <Widget>[
TextButton(
onPressed: () {
Provider.of<PackageProvider>(context,
listen: false)
.changeStatus(item!.id, "approved")
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(context).pop();
// Navigator.of(context)
// .popAndPushNamed(Routes
// .packageResultScreen);
},
);
},
child: Text('Yes'),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('No'),
),
],
);
},
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kBlue,
),
child: Icon(
Icons.check,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
),
SizedBox(
width: 5,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
Navigator.of(context).pushNamed(
Routes.packageDetailScreen,
arguments: item!.id,
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 9 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Icon(
FontAwesomeIcons.fileAlt,
size: 5 * _deviceBlockSize,
color: Colors.white,
),
),
),
],
),
],
),
],