1
- import 'package:amalyot_uchun/providers/appProvider.dart' ;
2
- import 'package:amalyot_uchun/widget/wait.dart' ;
3
1
import 'package:flutter/material.dart' ;
4
2
import 'package:provider/provider.dart' ;
5
3
import 'package:qr_code_scanner/qr_code_scanner.dart' ;
6
4
5
+ import '../providers/appProvider.dart' ;
6
+ import '../widget/wait.dart' ;
7
+
7
8
class ScannerScreen extends StatefulWidget {
8
9
const ScannerScreen ({super .key});
9
10
@@ -30,7 +31,6 @@ class _ScannerScreenState extends State<ScannerScreen> {
30
31
var user =
31
32
await Provider .of <AppProvider >(ctx, listen: false ).getUser (userId);
32
33
33
-
34
34
// ignore: use_build_context_synchronously
35
35
Navigator .of (ctx).pop ();
36
36
if (user['status' ] != 200 ) {
@@ -47,7 +47,10 @@ class _ScannerScreenState extends State<ScannerScreen> {
47
47
isScanned = false ;
48
48
});
49
49
},
50
- child: const Text ("Close" ),
50
+ child: const Text (
51
+ "Close" ,
52
+ style: TextStyle (color: Colors .red),
53
+ ),
51
54
),
52
55
],
53
56
),
@@ -57,12 +60,13 @@ class _ScannerScreenState extends State<ScannerScreen> {
57
60
String access = "" ;
58
61
user['msg' ]['access' ] == null ? access = "yo'q" : access = "bor" ;
59
62
var userData =
60
- "${ user [ 'msg' ][ 'comes' ]}! \n Ishtrokch : ${user ['msg' ]['name' ]} ${user ['msg' ]['surname' ]}\n Jamo : ${user ['msg' ]['firm' ]}\n Ruxsat $access " ;
63
+ "Ishtrokch : ${user ['msg' ]['name' ]} ${user ['msg' ]['surname' ]}\n Firma : ${user ['msg' ]['firm' ]}\n Ruxsat $access " ;
61
64
// ignore: use_build_context_synchronously
62
65
showDialog (
63
66
context: ctx,
64
67
builder: (ctx1) => AlertDialog (
65
68
content: Text (userData),
69
+ actionsAlignment: MainAxisAlignment .center,
66
70
actions: [
67
71
ElevatedButton (
68
72
onPressed: () {
@@ -71,36 +75,36 @@ class _ScannerScreenState extends State<ScannerScreen> {
71
75
isScanned = false ;
72
76
});
73
77
},
74
- child: const Text ("Close" ),
78
+ child: const Text ("Close" , style : TextStyle (color : Colors .red) ),
75
79
),
76
- ElevatedButton (
77
- onPressed: () {
78
- Navigator .of (ctx1).pop ();
79
- WaitWidget (ctx);
80
-
81
- Provider .of <AppProvider >(ctx1, listen: false )
82
- .acceptUser (userId)
83
- .then ((value) => ScaffoldMessenger .of (context).showSnackBar (
84
- const SnackBar (
85
- content: Text ("Successful" ),
86
- ),
87
- )
88
-
89
-
80
+ if (access != "bor" )
81
+ ElevatedButton (
82
+ onPressed: () {
83
+ Navigator .of (ctx1).pop ();
84
+ WaitWidget (ctx);
90
85
91
- ).onError ((error, stackTrace) => ScaffoldMessenger .of (context).showSnackBar (
92
- const SnackBar (
93
- content: Text ("Bad! 404 error" ),
94
- ),
95
- ));
86
+ Provider .of <AppProvider >(ctx1, listen: false )
87
+ .acceptUser (userId)
88
+ .then ((value) => ScaffoldMessenger .of (context).showSnackBar (
89
+ const SnackBar (
90
+ content: Text ("Successful" ),
91
+ ),
92
+ ))
93
+ .onError ((error, stackTrace) =>
94
+ ScaffoldMessenger .of (context).showSnackBar (
95
+ const SnackBar (
96
+ content: Text ("Bad! 404 error" ),
97
+ ),
98
+ ));
96
99
97
- setState (() {
98
- isScanned = false ;
99
- });
100
- Navigator .of (ctx).pop ();
101
- },
102
- child: const Text ("Accept" ),
103
- ),
100
+ setState (() {
101
+ isScanned = false ;
102
+ });
103
+ Navigator .of (ctx).pop ();
104
+ },
105
+ child:
106
+ const Text ("Access" , style: TextStyle (color: Colors .green)),
107
+ ),
104
108
],
105
109
),
106
110
);
@@ -123,24 +127,25 @@ class _ScannerScreenState extends State<ScannerScreen> {
123
127
@override
124
128
Widget build (BuildContext context) {
125
129
return Scaffold (
126
- appBar: AppBar (
127
- title: const Text ("QR scanner" ),
128
- centerTitle: true ,
130
+ appBar: AppBar (
131
+ title: const Text ("QR scanner" ),
132
+ centerTitle: true ,
133
+ ),
134
+ body: Center (
135
+ child: Column (
136
+ mainAxisSize: MainAxisSize .min,
137
+ children: [
138
+ SizedBox (
139
+ width: 250 ,
140
+ height: 250 ,
141
+ child: QRView (
142
+ key: qrKey,
143
+ onQRViewCreated: (c) => qr (c, context),
144
+ ),
145
+ )
146
+ ],
129
147
),
130
- body: Center (
131
- child: Column (
132
- mainAxisSize: MainAxisSize .min,
133
- children: [
134
- SizedBox (
135
- width: 250 ,
136
- height: 250 ,
137
- child: QRView (
138
- key: qrKey,
139
- onQRViewCreated: (c) => qr (c, context),
140
- ),
141
- )
142
- ],
143
- ),
144
- ));
148
+ ),
149
+ );
145
150
}
146
151
}
0 commit comments