You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
6.9 KiB
Dart
170 lines
6.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:tangheem/classes/const.dart';
|
|
import 'package:tangheem/classes/utils.dart';
|
|
import 'package:tangheem/ui/screens/forgot_password_screen.dart';
|
|
import 'package:tangheem/ui/screens/registration_screen.dart';
|
|
import 'package:tangheem/widgets/common_textfield_widget.dart';
|
|
|
|
import 'home_screen.dart';
|
|
|
|
class LoginScreen extends StatefulWidget {
|
|
static const String routeName = "/";
|
|
LoginScreen({Key key}) : super(key: key);
|
|
|
|
@override
|
|
_LoginScreenState createState() {
|
|
return _LoginScreenState();
|
|
}
|
|
}
|
|
|
|
class _LoginScreenState extends State<LoginScreen> {
|
|
TextEditingController _usernameController = TextEditingController();
|
|
TextEditingController _passwordController = TextEditingController();
|
|
bool _isRemember = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Const.secondaryWhite,
|
|
body: SafeArea(
|
|
child: Directionality(
|
|
textDirection: TextDirection.rtl,
|
|
child: SingleChildScrollView(
|
|
padding: EdgeInsets.all(32.0),
|
|
physics: BouncingScrollPhysics(),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8.0), color: Colors.white),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 24, bottom: 24),
|
|
child: SvgPicture.asset("assets/logos/tangheem_logo.svg", width: 100, height: 100),
|
|
),
|
|
Text(
|
|
"تسجيل الدخول",
|
|
style: TextStyle(fontSize: 22, color: Const.primaryBlue),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 16),
|
|
width: double.infinity,
|
|
padding: EdgeInsets.all(32.0),
|
|
color: Const.primaryBlue,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CommonTextFieldWidget(hint: "اسم المستخدم", controller: _usernameController, prefixIcon: "assets/icons/user.svg"),
|
|
SizedBox(height: 16),
|
|
CommonTextFieldWidget(hint: "كلمة المرور", controller: _passwordController, isPassword: true, prefixIcon: "assets/icons/password.svg"),
|
|
SizedBox(height: 16),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 50,
|
|
child: TextButton(
|
|
onPressed: () {
|
|
if (_usernameController.text.length < 1) {
|
|
Utils.showToast("Username is empty.");
|
|
return;
|
|
}
|
|
if (_passwordController.text.length < 1) {
|
|
Utils.showToast("Password is empty.");
|
|
return;
|
|
}
|
|
Navigator.pushNamed(context, HomeScreen.routeName);
|
|
},
|
|
style: TextButton.styleFrom(
|
|
primary: Colors.white,
|
|
backgroundColor: Const.secondaryPink,
|
|
textStyle: TextStyle(fontSize: 16, fontFamily: "DroidKufi"),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(6.0),
|
|
),
|
|
),
|
|
child: Text("تسجيل الدخول"),
|
|
),
|
|
),
|
|
SizedBox(height: 8),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
"تذكرني",
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
SizedBox(width: 8),
|
|
InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_isRemember = !_isRemember;
|
|
});
|
|
},
|
|
child: SvgPicture.asset(_isRemember ? "assets/icons/checkOn.svg" : "assets/icons/checkOff.svg", width: 16, height: 16))
|
|
],
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, ForgotPasswordScreen.routeName);
|
|
},
|
|
child: Text(
|
|
"نسيت كلمة المرور؟",
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.pushNamed(context, RegistrationScreen.routeName);
|
|
},
|
|
child: Container(
|
|
height: 50,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Const.tertiaryPurple,
|
|
borderRadius: BorderRadius.only(
|
|
bottomLeft: Radius.circular(8),
|
|
bottomRight: Radius.circular(8),
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
"انشاء حساب جديد",
|
|
style: TextStyle(fontSize: 14, color: Colors.white),
|
|
),
|
|
Icon(Icons.arrow_forward_ios, color: Colors.white, size: 12),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|