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
+81 -45
View File
@@ -273,6 +273,7 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
class TestItemBox extends StatelessWidget {
final TestResultObject item;
const TestItemBox({
Key? key,
required String id,
@@ -354,6 +355,7 @@ class TestItemBox extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
item.verified == 'None' ?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
@@ -366,29 +368,44 @@ class TestItemBox extends StatelessWidget {
content: Text(
'Are you sure for verify this test?'),
actions: <Widget>[
TextButton(
onPressed: () async {
Provider.of<TestResultsProvider>(
context,
listen: false)
.changeVerification(
item.id, 'Verified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
Navigator.of(context).popAndPushNamed(
Routes.testVerifyScreen);
Fluttertoast.showToast(
msg: "Test is verified.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
});
},
child: Text('Yes'),
),
Consumer<TestResultsProvider>(builder:
(context, testResultsProvider, child) {
return testResultsProvider.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
testResultsProvider
.setLoadingButton();
await Provider.of<
TestResultsProvider>(
context,
listen: false)
.changeVerification(
item.id, 'Verified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
Navigator.of(context)
.popAndPushNamed(Routes
.testVerifyScreen);
Fluttertoast.showToast(
msg: "Test is verified.",
toastLength:
Toast.LENGTH_SHORT,
gravity:
ToastGravity.BOTTOM,
);
testResultsProvider
.resetLoadingButton();
});
},
child: Text('Yes'),
);
}),
TextButton(
onPressed: () {
Navigator.of(ctx).pop();
@@ -425,28 +442,47 @@ class TestItemBox extends StatelessWidget {
content: Text(
'Are you sure for reject this test?'),
actions: <Widget>[
TextButton(
onPressed: () async {
await Provider.of<TestResultsProvider>(
context,
listen: false)
.changeVerification(
item.id, 'NotVerified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
Navigator.of(context).popAndPushNamed(
Routes.testVerifyScreen);
Fluttertoast.showToast(
msg: "Test is rejected.",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
);
});
Consumer<TestResultsProvider>(
builder:
(context, testResultsProvider, _) {
return testResultsProvider
.isloadingButton
? CircularProgressIndicator(
color: Colors.black,
)
: TextButton(
onPressed: () async {
testResultsProvider
.setLoadingButton();
await Provider.of<
TestResultsProvider>(
context,
listen: false)
.changeVerification(
item.id,
'NotVerified')
.then((result) {
if (result) {
print('true');
}
Navigator.of(ctx).pop();
Navigator.of(context)
.popAndPushNamed(Routes
.testVerifyScreen);
Fluttertoast.showToast(
msg: "Test is rejected.",
toastLength:
Toast.LENGTH_SHORT,
gravity:
ToastGravity.BOTTOM,
);
testResultsProvider
.resetLoadingButton();
});
},
child: Text('Yes'),
);
},
child: Text('Yes'),
),
TextButton(
onPressed: () {
@@ -473,7 +509,7 @@ class TestItemBox extends StatelessWidget {
),
),
],
),
) : Container(),
SizedBox(
width: _deviceBlockSize,
),