This commit is contained in:
erfan
2021-06-21 14:14:54 +04:30
parent 2c045f43f1
commit e2b8fab7d9
60 changed files with 4078 additions and 3928 deletions
+191 -189
View File
@@ -1,4 +1,4 @@
import 'package:barcode_scan/platform_wrapper.dart';
import 'package:barcode_scan2/platform_wrapper.dart';
import 'package:double_back_to_close_app/double_back_to_close_app.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -6,13 +6,13 @@ import 'package:flutter_phoenix/flutter_phoenix.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import './my_info_screen.dart';
import '../providers/auth.dart';
import '../providers/connectivity.dart';
import '../widgets/Global/drawer.dart';
import '../widgets/Global/internet_error.dart';
import 'cycle_result_screen.dart';
import 'label_result_screen.dart';
import 'my_info_screen.dart';
import 'test_result_screen.dart';
import 'test_verify_screen.dart';
@@ -25,195 +25,197 @@ class HomePage extends StatelessWidget {
final userData = Provider.of<Auth>(context, listen: false).user;
// print(userData['roles']);
return Scaffold(
resizeToAvoidBottomPadding: false,
drawer: Selector<ConnectivityProvider, String>(
builder: (ctx, value, _) =>
value != 'offline' ? AppDrawer() : Container(),
selector: (_, connctivity) => connctivity.conStatus,
)
// Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
// return connection.conStatus != 'offline' ? AppDrawer() : Container();
// })
,
appBar: AppBar(
centerTitle: true,
title: Text('CSSD'),
actions: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: IconButton(
icon: Icon(
Icons.power_settings_new,
),
onPressed: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('LogOut'),
content: Text('Are you sure for logout?'),
actions: <Widget>[
FlatButton(
child: Text('Yes'),
onPressed: () {
Navigator.of(ctx).pop();
Provider.of<Auth>(context, listen: false).logout();
Phoenix.rebirth(context);
},
),
FlatButton(
child: Text('No'),
onPressed: () {
Navigator.of(ctx).pop();
},
),
],
),
);
},
),
)
],
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? DoubleBackToCloseApp(
snackBar: SnackBar(
duration: Duration(seconds: 2),
backgroundColor: Colors.black,
content: Text(
'Double tap for exit . . .',
style: TextStyle(color: Colors.white),
),
),
child: Container(
margin: EdgeInsets.only(
top: 0, bottom: 10, left: 20, right: 20),
child: ListView(
// crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 20, bottom: 10),
child: Text(
'WELCOME HOME',
style: TextStyle(
color: Colors.black,
fontSize: 20,
letterSpacing: 3.5,
fontWeight: FontWeight.w700,
),
),
return SafeArea(
child: Scaffold(
// resizeToAvoidBottomPadding: false,
drawer: Selector<ConnectivityProvider, String>(
builder: (ctx, value, _) =>
value != 'offline' ? AppDrawer() : Container(),
selector: (_, connctivity) => connctivity.conStatus,
)
// Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
// return connection.conStatus != 'offline' ? AppDrawer() : Container();
// })
,
appBar: AppBar(
centerTitle: true,
title: Text('CSSD'),
actions: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: IconButton(
icon: Icon(
Icons.power_settings_new,
),
onPressed: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('LogOut'),
content: Text('Are you sure for logout?'),
actions: <Widget>[
TextButton(
child: Text('Yes'),
onPressed: () {
Navigator.of(ctx).pop();
Provider.of<Auth>(context, listen: false).logout();
Phoenix.rebirth(context);
},
),
SelectionItem(
startColor: Color(0xFFFCB8A2),
endColor: Color(0xFFFFECD2),
firstLine: 'My INFO',
secondLine: 'List, Details & Add a one',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return MyInfoScreen();
},
);
},
),
),
TextButton(
child: Text('No'),
onPressed: () {
Navigator.of(ctx).pop();
},
),
SelectionItem(
startColor: Color(0xFFD5F5FD),
endColor: Color(0xFFE9FFF7),
firstLine: 'TEST RESULTS',
secondLine: 'List, Details & Add a one',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return TestResultScreen();
},
);
},
),
),
// MyTestResult(
// isAdmin: false,
// ),
),
SelectionItem(
startColor: Color(0xFFE2D2C4),
endColor: Color(0xFFFAF7F5),
firstLine: 'LABELS',
secondLine: 'List, Details & Add a one',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return LabelResultScreen();
},
);
},
),
),
),
SelectionItem(
startColor: Color(0xFFA7CCE1),
endColor: Color(0xFFECF7ED),
firstLine: 'CYCLES',
secondLine: 'List, Details & Add a one',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return CycleResultScreen();
},
);
},
),
),
),
// SelectionItem(
// startColor: Color(0xFFA7CCE1),
// endColor: Color(0xFFECF7ED),
// firstLine: 'image',
// secondLine: 'image',
// onTap: CaptureImage(),
// ),
userData['roles'].contains('User')
? Container()
: SelectionItem(
startColor: Color(0xFFA7CCE1),
endColor: Color(0xFFECF7ED),
firstLine: 'TEST TO VERIFY',
secondLine: 'Verify and reject Test Results',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return TestVerifyScreen();
},
);
},
),
),
),
BarcodeSelectionItem(),
],
),
),
)
: ConnectionErrorBox();
},
);
},
),
)
],
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? DoubleBackToCloseApp(
snackBar: SnackBar(
duration: Duration(seconds: 2),
backgroundColor: Colors.black,
content: Text(
'Double tap for exit . . .',
style: TextStyle(color: Colors.white),
),
),
child: Container(
margin: EdgeInsets.only(
top: 0, bottom: 10, left: 20, right: 20),
child: ListView(
// crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 20, bottom: 10),
child: Text(
'WELCOME HOME',
style: TextStyle(
color: Colors.black,
fontSize: 20,
letterSpacing: 3.5,
fontWeight: FontWeight.w700,
),
),
),
SelectionItem(
startColor: Color(0xFFFCB8A2),
endColor: Color(0xFFFFECD2),
firstLine: 'My INFO',
secondLine: 'List, Details & Add a one',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return MyInfoScreen();
},
);
},
),
),
),
SelectionItem(
startColor: Color(0xFFD5F5FD),
endColor: Color(0xFFE9FFF7),
firstLine: 'TEST RESULTS',
secondLine: 'List, Details & Add a one',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return TestResultScreen();
},
);
},
),
),
// MyTestResult(
// isAdmin: false,
// ),
),
SelectionItem(
startColor: Color(0xFFE2D2C4),
endColor: Color(0xFFFAF7F5),
firstLine: 'LABELS',
secondLine: 'List, Details & Add a one',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return LabelResultScreen();
},
);
},
),
),
),
SelectionItem(
startColor: Color(0xFFA7CCE1),
endColor: Color(0xFFECF7ED),
firstLine: 'CYCLES',
secondLine: 'List, Details & Add a one',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return CycleResultScreen();
},
);
},
),
),
),
// SelectionItem(
// startColor: Color(0xFFA7CCE1),
// endColor: Color(0xFFECF7ED),
// firstLine: 'image',
// secondLine: 'image',
// onTap: CaptureImage(),
// ),
userData['roles'].contains('User')
? Container()
: SelectionItem(
startColor: Color(0xFFA7CCE1),
endColor: Color(0xFFECF7ED),
firstLine: 'TEST TO VERIFY',
secondLine: 'Verify and reject Test Results',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Consumer<Auth>(
builder: (ctx, auth, _) {
return TestVerifyScreen();
},
);
},
),
),
),
BarcodeSelectionItem(),
],
),
),
)
: ConnectionErrorBox();
},
),
),
);
}
@@ -359,7 +361,7 @@ class BarcodeSelectionItem extends StatelessWidget {
print(result);
showDialog(
context: context,
child: AlertDialog(
builder: (_) => AlertDialog(
title: Text(
'نتیجه ی اسکن',
textDirection: TextDirection.rtl,
@@ -376,7 +378,7 @@ class BarcodeSelectionItem extends StatelessWidget {
),
),
actions: <Widget>[
FlatButton(
TextButton(
onPressed: () async {
await launch(result);
Navigator.of(context).pop();