Change some ui in package result

This commit is contained in:
hanie.khodkari
2025-04-23 19:10:52 +03:30
parent 7b0e10f796
commit 0a9ca94d05
3 changed files with 340 additions and 32 deletions
+17 -14
View File
@@ -6,12 +6,14 @@ class PackageResultObject extends Equatable {
final String createdAt;
final String name;
final String status;
final String userName;
PackageResultObject({
required this.id,
required this.createdAt,
required this.name,
required this.status
required this.status,
required this.userName,
});
@override
@@ -31,24 +33,24 @@ class PackageDetailObject extends Equatable {
final String description;
final String createDate;
final String hospitalName;
// final String udi;
final List<String> items;
final String userName;
final String userName;
final String userCreator;
final String status;
PackageDetailObject({
required this.id,
required this.name,
required this.description,
required this.createDate,
required this.hospitalName,
// required this.udi,
required this.items,
required this.userName,
required this.userCreator,
required this.status
});
PackageDetailObject(
{required this.id,
required this.name,
required this.description,
required this.createDate,
required this.hospitalName,
// required this.udi,
required this.items,
required this.userName,
required this.userCreator,
required this.status});
@override
List<Object> get props {
@@ -73,6 +75,7 @@ class PackageFilterObject extends Equatable {
final String id;
final String name;
final String hospital;
// final String udi;
PackageFilterObject({
+2 -1
View File
@@ -401,7 +401,8 @@ class PackageProvider extends ChangeNotifier {
createdAt: item['created_at'],
id: item['id'].toString(),
name: item['name'],
status: item['status']),
status: item['status'],
userName: item['user']['name']),
);
}
pageNumber += 1;
@@ -3,7 +3,6 @@ import 'package:cssd/providers/auth.dart';
import 'package:cssd/providers/packages.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
@@ -55,24 +54,81 @@ class PackageItemBox extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 30 * _deviceBlockSize,
child: Text(
item!.id,
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.grey,
),
width: 40 * _deviceBlockSize,
child: Row(
children: [
Text(
item!.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 3 * _deviceBlockSize,
),
),
if (item!.status != "approved")
Container(
margin: EdgeInsets.only(left: 5.0),
padding: EdgeInsets.symmetric(
vertical: 1, horizontal: 10),
decoration: BoxDecoration(
color: item!.status == "pending"
? Colors.grey.withOpacity(0.2)
: kPink.withOpacity(0.05),
borderRadius: BorderRadius.circular(2)),
alignment: Alignment.center,
child: Text(
item!.status,
style: TextStyle(
fontSize: 2 * _deviceBlockSize,
color: item!.status == "pending"
? Colors.black.withOpacity(0.5)
: kPink,
),
),
)
],
),
),
Container(
width: 40 * _deviceBlockSize,
child: Text(
item!.name,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 3 * _deviceBlockSize,
),
width: 50 * _deviceBlockSize,
child: Row(
children: [
Text(
"ID: ",
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.grey,
),
),
Text(
item!.id,
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.black87,
),
),
Text(
" | ",
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.grey,
),
),
Text(
"Owner: ",
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.grey,
),
),
Text(
item!.userName,
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.black87,
),
),
],
),
),
Container(
@@ -80,7 +136,7 @@ class PackageItemBox extends StatelessWidget {
child: Row(
children: <Widget>[
Text(
'Date:',
'Items: ',
style: TextStyle(
color: Colors.grey,
fontSize: 3 * _deviceBlockSize,
@@ -134,6 +190,254 @@ class PackageItemBox extends StatelessWidget {
: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
if (userData['roles']?.contains('Admin') ||
userData['roles']
?.contains('Supervisor'))
item?.status == "pending"
? Row(
children: [
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Confirm this item?',
),
actions: <Widget>[
Consumer<
PackageProvider>(
builder: (context,
itemProvider,
_) {
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors
.black,
)
: TextButton(
onPressed:
() async {
itemProvider
.setLoadingButton();
await 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);
Fluttertoast.showToast(
msg: "Package is Approved.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
itemProvider.resetLoadingButton();
},
);
},
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: kLightBlue,
),
child: Icon(
Icons.check,
size:
4 * _deviceBlockSize,
color: Colors.white,
),
),
),
SizedBox(
width: 5.0,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Reject this Package?'),
actions: <Widget>[
Consumer<
PackageProvider>(
builder: (context,
itemProvider,
_) {
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors
.black,
)
: TextButton(
onPressed:
() async {
itemProvider
.setLoadingButton();
await 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);
Fluttertoast.showToast(
msg: "Package is rejected.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
itemProvider.resetLoadingButton();
},
);
},
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: Colors.black),
child: Icon(
Icons.close,
size:
4 * _deviceBlockSize,
color: Colors.white,
),
),
),
],
)
: item?.status == "rejected"
? InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Confirm this Package?',
),
actions: <Widget>[
Consumer<
PackageProvider>(
builder: (context,
itemProvider,
_) {
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors
.black,
)
: TextButton(
onPressed:
() async {
itemProvider
.setLoadingButton();
await 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);
Fluttertoast.showToast(
msg: "Package is Approved.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
itemProvider.resetLoadingButton();
},
);
},
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: kLightBlue,
),
child: Icon(
Icons.check,
size:
4 * _deviceBlockSize,
color: Colors.white,
),
),
)
: Container(),
SizedBox(
width: 5.0,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {