mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-12 23:08:55 +03:30
fix bugs and set progress and toast for my items server events
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:cssd/providers/my_items.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:pinch_zoom/pinch_zoom.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -466,25 +467,39 @@ class MyItemsDetailsDataBox extends StatelessWidget {
|
||||
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,
|
||||
Consumer<ItemProvider>(
|
||||
builder: (context, itemProvider, child) {
|
||||
return TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kPink,
|
||||
secondColor: kPinkSub,
|
||||
isLoadingButton:
|
||||
itemProvider.isloadingButton,
|
||||
onTap: () async {
|
||||
itemProvider.setLoadingButton();
|
||||
await Provider.of<ItemProvider>(context,
|
||||
listen: false)
|
||||
.removeItems(datas.id)
|
||||
.then(
|
||||
(value) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.myItemsResultScreen,
|
||||
);
|
||||
itemProvider.resetLoadingButton();
|
||||
Fluttertoast.showToast(
|
||||
msg: "The item is destroyed.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Destroy',
|
||||
);
|
||||
},
|
||||
text: 'Destroy',
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
@@ -603,7 +618,7 @@ class MyItemsDetailsDataBox extends StatelessWidget {
|
||||
),
|
||||
content: SizedBox(
|
||||
width: _deviceBlockSize,
|
||||
height: 220,
|
||||
height: 240,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
@@ -619,25 +634,34 @@ class MyItemsDetailsDataBox extends StatelessWidget {
|
||||
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,
|
||||
Consumer<ItemProvider>(
|
||||
builder: (context, itemProvider, child) {
|
||||
return TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: Colors.black,
|
||||
secondColor: Colors.black87,
|
||||
isLoadingButton: itemProvider.isloadingButton,
|
||||
onTap: () async {
|
||||
itemProvider.setLoadingButton();
|
||||
await Provider.of<MyItemProvider>(context,
|
||||
listen: false)
|
||||
.repairItems(datas.id, 'approved')
|
||||
.then(
|
||||
(value) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
itemProvider.resetLoadingButton();
|
||||
Fluttertoast.showToast(
|
||||
msg: "The item is repaired.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Repair',
|
||||
);
|
||||
},
|
||||
text: 'Repair',
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
@@ -824,7 +848,7 @@ class MyItemsDetailsDataBox extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 30 * _deviceBlockSize,
|
||||
width: 40 * _deviceBlockSize,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
|
||||
@@ -9,6 +9,7 @@ class TransferDestroyButton extends StatelessWidget {
|
||||
required this.onTap,
|
||||
required this.text,
|
||||
this.fontSize = 5.0,
|
||||
this.isLoadingButton = false,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
final double _deviceBlockSize;
|
||||
@@ -17,6 +18,7 @@ class TransferDestroyButton extends StatelessWidget {
|
||||
final String text;
|
||||
final VoidCallback onTap;
|
||||
final double fontSize;
|
||||
final bool isLoadingButton;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -33,16 +35,22 @@ class TransferDestroyButton extends StatelessWidget {
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: fontSize * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: isLoadingButton
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: fontSize * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user