mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 00:58:56 +03:30
253 lines
8.8 KiB
Dart
253 lines
8.8 KiB
Dart
import 'package:cssd/pages/cycle_result_screen.dart';
|
|
import 'package:cssd/pages/label_result_screen.dart';
|
|
// import 'package:cssd/pages/my_test_result.dart';
|
|
import 'package:cssd/pages/test_result_screen.dart';
|
|
import 'package:cssd/providers/auth.dart';
|
|
import 'package:cssd/providers/connectivity.dart';
|
|
import 'package:cssd/widgets/Global/drawer.dart';
|
|
import 'package:cssd/widgets/Global/splash_screen%20copy.dart';
|
|
import 'package:double_back_to_close_app/double_back_to_close_app.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_phoenix/flutter_phoenix.dart';
|
|
import 'package:provider/provider.dart';
|
|
import './my_info_screen.dart';
|
|
|
|
class HomePage extends StatelessWidget {
|
|
// 09338736511
|
|
|
|
// static const route = '/HomeScreen';
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final userData = Provider.of<Auth>(context).user;
|
|
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).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: Column(
|
|
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: Consumer<Auth>(
|
|
builder: (ctx, auth, _) {
|
|
return MyInfoScreen();
|
|
},
|
|
),
|
|
),
|
|
SelectionItem(
|
|
startColor: Color(0xFFD5F5FD),
|
|
endColor: Color(0xFFE9FFF7),
|
|
firstLine: 'TEST RESULTS',
|
|
secondLine: 'List, Details & Add a one',
|
|
onTap: TestResultScreen()
|
|
// MyTestResult(
|
|
// isAdmin: false,
|
|
// ),
|
|
),
|
|
SelectionItem(
|
|
startColor: Color(0xFFE2D2C4),
|
|
endColor: Color(0xFFFAF7F5),
|
|
firstLine: 'LABELS',
|
|
secondLine: 'List, Details & Add a one',
|
|
onTap: LabelResultScreen(),
|
|
),
|
|
SelectionItem(
|
|
startColor: Color(0xFFA7CCE1),
|
|
endColor: Color(0xFFECF7ED),
|
|
firstLine: 'CYCLES',
|
|
secondLine: 'List, Details & Add a one',
|
|
onTap: CycleResultScreen(),
|
|
),
|
|
userData['roles'].contains('Admin')
|
|
? Container()
|
|
// SelectionItem(
|
|
// startColor: Color(0xFFA7CCE1),
|
|
// endColor: Color(0xFFECF7ED),
|
|
// firstLine: 'TEST TO VERIFY',
|
|
// secondLine: 'List, Details & Add a one',
|
|
// onTap: TestVerifyScreen(),
|
|
// )
|
|
: Container(),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
: ConnectionErrorBox();
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class SelectionItem extends StatelessWidget {
|
|
final Color startColor;
|
|
final Color endColor;
|
|
final String firstLine;
|
|
final String secondLine;
|
|
final Widget 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: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) {
|
|
return 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,
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
),
|
|
);
|
|
}
|
|
}
|