Set progress & toast for some other events

This commit is contained in:
fhkhd
2024-01-31 22:24:31 +03:30
parent 86feef9a38
commit 725b8dc30b
6 changed files with 526 additions and 358 deletions
@@ -12,7 +12,8 @@ class ItemDetailsDataBox extends StatelessWidget {
Key? key,
required this.datas,
required double deviceBlockSize,
}) : _deviceBlockSize = deviceBlockSize,
})
: _deviceBlockSize = deviceBlockSize,
super(key: key);
final ItemDetailObject datas;
@@ -336,10 +337,14 @@ class ItemDetailsDataBox extends StatelessWidget {
Container(
width: 45 * _deviceBlockSize,
child: Text(
datas.status == 'approved' ? 'Confirmed' : 'Rejected',
datas.status == 'approved' ? 'Confirmed' :
datas
.status == 'rejected' ? 'Rejected' : 'Pending..',
style: TextStyle(
fontWeight: FontWeight.w700,
color: datas.status == 'approved' ? kBlue : kPink,
color: datas.status == 'approved' ? kBlue :
datas
.status == 'rejected' ? kPink : Colors.grey,
),
overflow: TextOverflow.clip,
),
@@ -364,10 +369,12 @@ class ItemDetailsDataBox extends StatelessWidget {
),
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) => PinchZoom(
child: Image.network(datas.filePath![index])
),
context: context,
builder: (BuildContext context) =>
PinchZoom(
child: Image.network(
datas.filePath![index])
),
);
},
);
@@ -375,7 +382,7 @@ class ItemDetailsDataBox extends StatelessWidget {
itemCount: datas.filePath!.length,
options: CarouselOptions(
enlargeCenterPage: true,
aspectRatio: 16/8,
aspectRatio: 16 / 8,
viewportFraction: datas.filePath?.length == 1 ? 1 : 0.6,
padEnds: false,
pauseAutoPlayOnTouch: true,
@@ -383,7 +390,7 @@ class ItemDetailsDataBox extends StatelessWidget {
autoPlay: false,
enlargeFactor: 0.5,
enableInfiniteScroll:
datas.filePath?.length == 1 ? false : true,
datas.filePath?.length == 1 ? false : true,
),
),
),
@@ -394,7 +401,8 @@ class ItemDetailsDataBox extends StatelessWidget {
height: 20,
),
InkWell(
onTap: () async => await launch(
onTap: () async =>
await launch(
'https://cssd-doc.com/Show/Item/${datas.id.toString()}',
),
child: Container(
+190 -118
View File
@@ -3,6 +3,7 @@ import 'package:cssd/models/item_model.dart';
import 'package:cssd/providers/auth.dart';
import 'package:cssd/providers/items.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
@@ -51,7 +52,9 @@ class ItemItemBox extends StatelessWidget {
// width: 3 * _deviceBlockSize,
// ),
// Spacer(),
SizedBox(width: 4,),
SizedBox(
width: 4,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@@ -219,126 +222,193 @@ class ItemItemBox extends StatelessWidget {
SizedBox(
width: 5.0,
),
userData['roles']?.contains('User') ?? false
(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(
'Are you Reject this item?'
: item?.status == "suspended"
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Reject this item?'),
actions: <Widget>[
Consumer<ItemProvider>(
builder: (context,
itemProvider, _) {
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed:
() async {
itemProvider
.setLoadingButton();
await Provider.of<
ItemProvider>(
context,
listen:
false)
.changeStatus(
item!.id,
"rejected")
.then(
(value) {
if (value) {
print(
'true');
}
Navigator.of(
context)
.pop();
Navigator.of(
context)
.popAndPushNamed(
Routes
.itemResultScreen);
Fluttertoast
.showToast(
msg:
"Item 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: kPink),
child: Icon(
Icons.close,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
),
actions: <Widget>[
TextButton(
onPressed: () {
Provider.of<ItemProvider>(context,
listen: false)
.changeStatus(item!.id, "rejected")
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(context).pop();
// Navigator.of(context)
// .popAndPushNamed(Routes
// .itemResultScreen);
},
);
},
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.close ,
size: 4 * _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?',
SizedBox(
width: 5,
),
actions: <Widget>[
TextButton(
onPressed: () {
Provider.of<ItemProvider>(context,
listen: false)
.changeStatus(item!.id, "approved")
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(context).pop();
// Navigator.of(context)
// .popAndPushNamed(Routes
// .itemResultScreen);
},
);
},
child: Text('Yes'),
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Confirm this item?',
),
actions: <Widget>[
Consumer<ItemProvider>(builder:
(context, itemProvider, _) {
return itemProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
itemProvider
.setLoadingButton();
await Provider.of<
ItemProvider>(
context,
listen:
false)
.changeStatus(
item!.id,
"approved")
.then(
(value) {
if (value) {
print('true');
}
Navigator.of(
context)
.pop();
Navigator.of(
context)
.popAndPushNamed(
Routes
.itemResultScreen);
Fluttertoast
.showToast(
msg:
"Item is Confirmed.",
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: kBlue,
),
child: Icon(
Icons.check,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
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,
),
),
),
],
),
),
],
)
: Container(),
SizedBox(
width: 5.0,
),
@@ -368,7 +438,9 @@ class ItemItemBox extends StatelessWidget {
),
],
),
SizedBox(width: 4,)
SizedBox(
width: 4,
)
],
),
),
@@ -2,6 +2,7 @@ import 'package:cssd/models/package_model.dart';
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';
@@ -129,195 +130,243 @@ class PackageItemBox extends StatelessWidget {
userData['roles']?.contains('User') ?? false
? Container()
: 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?',
? 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);
},
),
TextButton(
child: Text('No'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
child: Icon(
Icons.delete,
size: 5 * _deviceBlockSize,
color: Colors.black,
),
),
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();
},
),
],
);
},
);
},
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?'
item?.status == "suspended"
? Row(
children: [
SizedBox(
width: 5.0,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Are you Reject this item?'),
actions: <Widget>[
Consumer<
PackageProvider>(
builder: (context,
packageProvider,
_) {
return packageProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors
.black,
)
: TextButton(
onPressed:
() async {
packageProvider
.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,
);
packageProvider.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: kPink),
child: Icon(
Icons.close,
size: 4 * _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>[
Consumer<
PackageProvider>(
builder: (context,
packageProvider,
_) {
return packageProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors
.black,
)
: TextButton(
onPressed:
() async {
packageProvider
.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 Confirmed.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
packageProvider.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: kBlue,
),
child: Icon(
Icons.check,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
),
],
)
: Container(),
SizedBox(
width: 5,
),
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'),
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,
),
),
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.close ,
size: 4 * _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,
),
),
),
],
),
],
),
],
),
],