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
+176 -174
View File
@@ -1,11 +1,12 @@
import 'package:cssd/config/routes.dart';
import 'package:cssd/providers/auth.dart';
import 'package:cssd/providers/connectivity.dart';
import 'package:cssd/widgets/Global/internet_error.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../config/routes.dart';
import '../providers/auth.dart';
import '../providers/connectivity.dart';
import '../widgets/Global/internet_error.dart';
class LoginScreen extends StatefulWidget {
// static const route = '/HomeScreen';
@@ -44,7 +45,7 @@ class _LoginScreenState extends State<LoginScreen> {
title: Text('Error'),
content: Text(message),
actions: <Widget>[
FlatButton(
TextButton(
child: Text('Ok'),
onPressed: () {
Navigator.of(ctx).pop();
@@ -110,186 +111,187 @@ class _LoginScreenState extends State<LoginScreen> {
// final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5);
final double _devicewidth = _media.size.width;
final double _deviceBlockSize = _devicewidth / 100;
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('CSSD'),
),
body: Selector<ConnectivityProvider, String>(
builder: (ctx, value, _) => value != 'offline'
? _isLoading
? Center(
child: CircularProgressIndicator(),
)
: Form(
key: _form,
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 20),
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(vertical: 20),
child: Text(
'LOGIN',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: 6 * _deviceBlockSize,
letterSpacing: 3,
fontWeight: FontWeight.w700,
),
),
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Cell number is required.';
}
RegExp regExp =
RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$');
if (!regExp.hasMatch(value)) {
return 'Enter a valid cell number';
}
return null;
},
controller: cellNumberController,
decoration: InputDecoration(
icon: Icon(
Icons.call,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Cell Number',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
return SafeArea(
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('CSSD'),
),
body: Selector<ConnectivityProvider, String>(
builder: (ctx, value, _) => value != 'offline'
? _isLoading
? Center(
child: CircularProgressIndicator(),
)
: Form(
key: _form,
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 20),
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(vertical: 20),
child: Text(
'LOGIN',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontSize: 6 * _deviceBlockSize,
letterSpacing: 3,
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.phone,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_passwordFocusNode);
},
onSaved: (value) {
map['cellNumber'] = value;
},
),
SizedBox(
height: 30,
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Password is required.';
}
if (value.length < 8) {
return 'Password at least is 8 characters.';
}
return null;
},
obscureText: _hidePass,
controller: passwordController,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.starOfLife,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Password',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
suffixIcon: InkWell(
child: Icon(FontAwesomeIcons.eye),
onTap: () {
setState(() {
_hidePass = !_hidePass;
});
},
),
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Cell number is required.';
}
RegExp regExp =
RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$');
if (!regExp.hasMatch(value)) {
return 'Enter a valid cell number';
}
return null;
},
controller: cellNumberController,
decoration: InputDecoration(
icon: Icon(
Icons.call,
size: 6 * _deviceBlockSize,
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
textInputAction: TextInputAction.done,
onFieldSubmitted: (_) {
_login();
},
keyboardType: TextInputType.visiblePassword,
focusNode: _passwordFocusNode,
onSaved: (value) {
map['password'] = value;
},
labelText: 'Cell Number',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
SizedBox(height: 40),
Row(
children: <Widget>[
InkWell(
onTap: () => _login(),
child: Container(
width: 40 * _deviceBlockSize,
padding: EdgeInsets.symmetric(
horizontal: 5 * _deviceBlockSize,
vertical: 10,
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.phone,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_passwordFocusNode);
},
onSaved: (value) {
map['cellNumber'] = value;
},
),
SizedBox(
height: 30,
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Password is required.';
}
if (value.length < 8) {
return 'Password at least is 8 characters.';
}
return null;
},
obscureText: _hidePass,
controller: passwordController,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.starOfLife,
size: 6 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
labelText: 'Password',
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
suffixIcon: InkWell(
child: Icon(FontAwesomeIcons.eye),
onTap: () {
setState(() {
_hidePass = !_hidePass;
});
},
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
textInputAction: TextInputAction.done,
onFieldSubmitted: (_) {
_login();
},
keyboardType: TextInputType.visiblePassword,
focusNode: _passwordFocusNode,
onSaved: (value) {
map['password'] = value;
},
),
SizedBox(height: 40),
Row(
children: <Widget>[
InkWell(
onTap: () => _login(),
child: Container(
width: 40 * _deviceBlockSize,
padding: EdgeInsets.symmetric(
horizontal: 5 * _deviceBlockSize,
vertical: 10,
),
// margin:
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.blue, Colors.green],
),
// margin:
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.blue, Colors.green],
borderRadius: BorderRadius.circular(7),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Spacer(),
Icon(
Icons.exit_to_app,
color: Colors.white,
),
borderRadius: BorderRadius.circular(7),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Spacer(),
Icon(
Icons.exit_to_app,
color: Colors.white,
),
Text(
'Login',
style: TextStyle(color: Colors.white),
),
Spacer()
],
)),
),
Spacer(),
],
),
SizedBox(height: 10),
FlatButton(
padding: EdgeInsets.all(0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Forgot Password ?',
style: TextStyle(
color: Colors.black54,
decoration: TextDecoration.underline,
),
Text(
'Login',
style: TextStyle(color: Colors.white),
),
Spacer()
],
)),
),
Spacer(),
],
),
SizedBox(height: 10),
TextButton(
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Forgot Password ?',
style: TextStyle(
color: Colors.black54,
decoration: TextDecoration.underline,
),
),
onPressed: () => Navigator.of(context)
.pushNamed(Routes.forgetPassScreen),
),
],
),
)
: ConnectionErrorBox(),
selector: (_, connectivity) => connectivity.conStatus,
));
onPressed: () => Navigator.of(context)
.pushNamed(Routes.forgetPassScreen),
),
],
),
)
: ConnectionErrorBox(),
selector: (_, connectivity) => connectivity.conStatus,
)),
);
}
}