mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 19:08:55 +03:30
beta commit
This commit is contained in:
+484
-462
@@ -1,462 +1,484 @@
|
||||
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';
|
||||
import 'package:flutter_phoenix/flutter_phoenix.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.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';
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
// 09338736511
|
||||
|
||||
// static const route = '/HomeScreen';
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
|
||||
// print(userData['roles']);
|
||||
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);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
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();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> scan() async {
|
||||
try {
|
||||
var barcode = await BarcodeScanner.scan();
|
||||
if (barcode.type.name == 'Cancelled') {
|
||||
return 'cancel';
|
||||
} else if (barcode.type.name == 'Failed') {
|
||||
return 'error';
|
||||
}
|
||||
try {
|
||||
var id = barcode.rawContent;
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'null';
|
||||
}
|
||||
} on PlatformException catch (_) {
|
||||
return 'access';
|
||||
} catch (_) {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
class SelectionItem extends StatelessWidget {
|
||||
final Color startColor;
|
||||
final Color endColor;
|
||||
final String firstLine;
|
||||
final String secondLine;
|
||||
final Function onTap;
|
||||
|
||||
SelectionItem(
|
||||
{this.startColor,
|
||||
this.endColor,
|
||||
this.firstLine,
|
||||
this.secondLine,
|
||||
this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _media = MediaQuery.of(context);
|
||||
// final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5);
|
||||
final double _devicewidth = _media.size.width;
|
||||
final double _deviceBlockSize = _devicewidth / 100;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [startColor, endColor],
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(3),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
splashColor: Colors.red,
|
||||
onTap: onTap,
|
||||
child: ListTile(
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
firstLine,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3.5,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
secondLine,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
// Column(
|
||||
// children: <Widget>[
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// firstLine,
|
||||
// textAlign: TextAlign.start,
|
||||
// style: TextStyle(color: Colors.black),
|
||||
// ),
|
||||
// ),
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// secondLine,
|
||||
// style: TextStyle(color: Colors.black, fontSize: 20),
|
||||
// ),
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward_ios,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BarcodeSelectionItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _media = MediaQuery.of(context);
|
||||
// final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5);
|
||||
final double _devicewidth = _media.size.width;
|
||||
final double _deviceBlockSize = _devicewidth / 100;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.black, Colors.black87],
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(3),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
splashColor: Colors.red,
|
||||
onTap: () => scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: Text(
|
||||
'نتیجه ی اسکن',
|
||||
textDirection: TextDirection.rtl,
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontSize: 2.75 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
result,
|
||||
textDirection: TextDirection.rtl,
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await launch(result);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(
|
||||
'بازکردن در مرورگر',
|
||||
style: TextStyle(
|
||||
fontFamily: 'montserrat',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.qr_code_scanner,
|
||||
color: Colors.white,
|
||||
size: 8 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'SCANNER',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3.5,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Scan a Bar or QR code',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
// Column(
|
||||
// children: <Widget>[
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// firstLine,
|
||||
// textAlign: TextAlign.start,
|
||||
// style: TextStyle(color: Colors.black),
|
||||
// ),
|
||||
// ),
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// secondLine,
|
||||
// style: TextStyle(color: Colors.black, fontSize: 20),
|
||||
// ),
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward_ios,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:barcode_scan2/platform_wrapper.dart';
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/pages/ItemPages/item_result_screen.dart';
|
||||
import 'package:cssd/pages/MyItemsPages/Result/my_items_result_screen.dart';
|
||||
import 'package:cssd/pages/MyPackagesPages/Result/my_packages_result_screen.dart';
|
||||
import 'package:cssd/pages/PackagePages/package_result_screen.dart';
|
||||
import 'package:double_back_to_close_app/double_back_to_close_app.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_phoenix/flutter_phoenix.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../providers/auth.dart';
|
||||
import '../providers/connectivity.dart';
|
||||
import '../widgets/Global/drawer.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
import 'CyclePages/cycle_result_screen.dart';
|
||||
import 'LabelPages/label_result_screen.dart';
|
||||
import 'my_info_screen.dart';
|
||||
import 'TestPages/test_result_screen.dart';
|
||||
import 'TestPages/test_verify_screen.dart';
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
drawer: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) =>
|
||||
value != 'offline' ? AppDrawer() : Container(),
|
||||
selector: (_, connectivity) => connectivity.conStatus,
|
||||
),
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
backgroundColor: Colors.black,
|
||||
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);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'MY INFO',
|
||||
secondLine: 'Personal Details',
|
||||
firstLineColor: Colors.black,
|
||||
secondLineColor: Colors.grey,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return MyInfoScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'TEST RESULTS',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: Colors.black,
|
||||
secondLineColor: Colors.grey,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return TestResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 2,
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'LABELS',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: kLightBlue,
|
||||
secondLineColor: kLightBlueSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return LabelResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'CYCLES',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: kPink,
|
||||
secondLineColor: kPinkSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return CycleResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 2,
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'PACKAGES',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: kPurple,
|
||||
secondLineColor: kPurpleSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return PackageResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'MY PACKAGES',
|
||||
secondLine: 'The Package that i possess',
|
||||
firstLineColor: kDarkPurple,
|
||||
secondLineColor: kDarkPurpleSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return MyPackagesResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 2,
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'ITEMS',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: kBlue,
|
||||
secondLineColor: kBlueSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return ItemResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'MY ITEMS',
|
||||
secondLine: 'The Items that i possess',
|
||||
firstLineColor: kDarkBlue,
|
||||
secondLineColor: kDarkBlueSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return MyItemsResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(height: 2),
|
||||
userData['roles']?.contains('User') ?? false
|
||||
? Container()
|
||||
: SelectionItem(
|
||||
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();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> scan() async {
|
||||
try {
|
||||
var barcode = await BarcodeScanner.scan();
|
||||
if (barcode.type.name == 'Cancelled') {
|
||||
return 'cancel';
|
||||
} else if (barcode.type.name == 'Failed') {
|
||||
return 'error';
|
||||
}
|
||||
try {
|
||||
var id = barcode.rawContent;
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'null';
|
||||
}
|
||||
} on PlatformException catch (_) {
|
||||
return 'access';
|
||||
} catch (_) {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
class SelectionItem extends StatelessWidget {
|
||||
final String? firstLine;
|
||||
final String? secondLine;
|
||||
final Color? firstLineColor;
|
||||
final Color? secondLineColor;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
SelectionItem({
|
||||
this.firstLine,
|
||||
this.secondLine,
|
||||
this.onTap,
|
||||
this.firstLineColor,
|
||||
this.secondLineColor,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _media = MediaQuery.of(context);
|
||||
final double _devicewidth = _media.size.width;
|
||||
final double _deviceBlockSize = _devicewidth / 100;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(3),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
splashColor: Colors.grey[350],
|
||||
onTap: onTap,
|
||||
child: ListTile(
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
firstLine!,
|
||||
style: TextStyle(
|
||||
color: firstLineColor,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3.5,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
secondLine!,
|
||||
style: TextStyle(
|
||||
color: secondLineColor,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BarcodeSelectionItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _media = MediaQuery.of(context);
|
||||
// final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5);
|
||||
final double _devicewidth = _media.size.width;
|
||||
final double _deviceBlockSize = _devicewidth / 100;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.black, Colors.black87],
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(3),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
splashColor: Colors.red,
|
||||
onTap: () => scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: Text(
|
||||
'نتیجه ی اسکن',
|
||||
textDirection: TextDirection.rtl,
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontSize: 2.75 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
result,
|
||||
textDirection: TextDirection.rtl,
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await launch(result);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(
|
||||
'بازکردن در مرورگر',
|
||||
style: TextStyle(
|
||||
fontFamily: 'montserrat',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.qr_code_scanner,
|
||||
color: Colors.white,
|
||||
size: 8 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'SCANNER',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3.5,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Scan a Bar or QR code',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user