Commit 297a0bd5 authored by qorri_di's avatar qorri_di

fixing login

- delete variabel yang tidak digunain.
parent 163106e3
...@@ -8,21 +8,19 @@ void setPageTitle(String title, BuildContext context) { ...@@ -8,21 +8,19 @@ void setPageTitle(String title, BuildContext context) {
)); ));
} }
class login extends StatefulWidget { class SignIn extends StatefulWidget {
const login({Key? key}) : super(key: key); const SignIn({Key? key}) : super(key: key);
@override @override
State<login> createState() => _loginState(); State<SignIn> createState() => _SignInState();
} }
class _loginState extends State<login> { class _SignInState extends State<SignIn> {
bool _isObscure = true; bool _isObscure = true;
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
String _usmail = ''; final TextEditingController _usernamecontroller = TextEditingController();
String _uspswd = ''; final TextEditingController _passwordcontroller = TextEditingController();
final TextEditingController _editingController = TextEditingController();
final TextEditingController _editingController2 = TextEditingController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -123,7 +121,7 @@ class _loginState extends State<login> { ...@@ -123,7 +121,7 @@ class _loginState extends State<login> {
height: 40, height: 40,
width: screenSize.width * 0.2, width: screenSize.width * 0.2,
child: TextFormField( child: TextFormField(
controller: _editingController, controller: _usernamecontroller,
textAlign: TextAlign.start, textAlign: TextAlign.start,
decoration: InputDecoration( decoration: InputDecoration(
labelText: "Enter Your Email", labelText: "Enter Your Email",
...@@ -134,7 +132,7 @@ class _loginState extends State<login> { ...@@ -134,7 +132,7 @@ class _loginState extends State<login> {
), ),
validator: (value) { validator: (value) {
if (value == null || value.trim().isEmpty) { if (value == null || value.trim().isEmpty) {
_editingController.clear(); _usernamecontroller.clear();
return "please enter your email address"; return "please enter your email address";
} else if (!RegExp(r'\S+@\S+\.\S+') } else if (!RegExp(r'\S+@\S+\.\S+')
.hasMatch(value)) { .hasMatch(value)) {
...@@ -143,7 +141,6 @@ class _loginState extends State<login> { ...@@ -143,7 +141,6 @@ class _loginState extends State<login> {
return null; return null;
} }
}, },
onChanged: (value) => _usmail = value,
), ),
), ),
const Spacer( const Spacer(
...@@ -169,7 +166,7 @@ class _loginState extends State<login> { ...@@ -169,7 +166,7 @@ class _loginState extends State<login> {
height: 40, height: 40,
width: screenSize.width * 0.2, width: screenSize.width * 0.2,
child: TextFormField( child: TextFormField(
controller: _editingController2, controller: _passwordcontroller,
textAlign: TextAlign.start, textAlign: TextAlign.start,
obscureText: _isObscure, obscureText: _isObscure,
decoration: InputDecoration( decoration: InputDecoration(
...@@ -192,14 +189,13 @@ class _loginState extends State<login> { ...@@ -192,14 +189,13 @@ class _loginState extends State<login> {
), ),
validator: (value) { validator: (value) {
if (value == null || value.trim().isEmpty) { if (value == null || value.trim().isEmpty) {
_editingController2.clear(); _passwordcontroller.clear();
return 'This field is required'; return 'This field is required';
} else if (value.trim().length < 8) { } else if (value.trim().length < 8) {
return 'Password must be at least 8 characters in length'; return 'Password must be at least 8 characters in length';
} }
return null; return null;
}, },
onChanged: (value) => _uspswd = value,
), ),
), ),
const Spacer( const Spacer(
...@@ -225,8 +221,8 @@ class _loginState extends State<login> { ...@@ -225,8 +221,8 @@ class _loginState extends State<login> {
width: screenSize.width * 0.08, width: screenSize.width * 0.08,
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
if (_usmail == 'admin@admin.com' && if (_usernamecontroller.value.text == 'admin@admin.com' &&
_uspswd != 'administrator') { _passwordcontroller.value.text != 'administrator') {
showDialog<String>( showDialog<String>(
context: context, context: context,
builder: (BuildContext context) => builder: (BuildContext context) =>
...@@ -243,8 +239,8 @@ class _loginState extends State<login> { ...@@ -243,8 +239,8 @@ class _loginState extends State<login> {
], ],
), ),
); );
} else if (_usmail == 'client@client.com' && } else if (_usernamecontroller.value.text == 'client@client.com' &&
_uspswd != 'clientpage') { _passwordcontroller.value.text != 'clientpage') {
showDialog<String>( showDialog<String>(
context: context, context: context,
builder: (BuildContext context) => builder: (BuildContext context) =>
...@@ -261,11 +257,11 @@ class _loginState extends State<login> { ...@@ -261,11 +257,11 @@ class _loginState extends State<login> {
], ],
), ),
); );
} else if (_usmail == 'admin@admin.com' && } else if (_usernamecontroller.value.text == 'admin@admin.com' &&
_uspswd == 'administrator') { _passwordcontroller.value.text == 'administrator') {
Navigator.pushNamed(context, '/admin'); Navigator.pushNamed(context, '/admin');
} else if (_usmail == 'client@client.com' && } else if (_usernamecontroller.value.text == 'client@client.com' &&
_uspswd == 'clientpage') { _passwordcontroller.value.text == 'clientpage') {
Navigator.pushNamed(context, '/client'); Navigator.pushNamed(context, '/client');
} else { } else {
showDialog<String>( showDialog<String>(
......
...@@ -25,7 +25,7 @@ class MyApp extends StatelessWidget { ...@@ -25,7 +25,7 @@ class MyApp extends StatelessWidget {
'/about': (context) => const HomePage(), '/about': (context) => const HomePage(),
'/solutions': (context) => const Solutions(), '/solutions': (context) => const Solutions(),
'/contact': (context) => const ContactUs(), '/contact': (context) => const ContactUs(),
'/login': (context) => const login(), '/login': (context) => const SignIn(),
'/register': (context) => const Register(), '/register': (context) => const Register(),
'/dashboard': (context) => const DashboardAdmin(), '/dashboard': (context) => const DashboardAdmin(),
'/reset_password': (context) => const ForgotPassword(), '/reset_password': (context) => const ForgotPassword(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment