marco.pms.mobile/lib/view/auth/login_screen.dart

90 lines
2.8 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:maxdash/controller/auth/login_controller.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
late LoginController controller;
@override
void initState() {
controller = Get.put(LoginController());
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: controller.basicValidator.formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Welcome Back!',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
Text(
'Please login to your account.',
style: TextStyle(fontSize: 16, color: Colors.grey),
),
SizedBox(height: 20),
TextFormField(
controller: controller.basicValidator.getController('username'),
decoration: InputDecoration(
labelText: 'Username',
border: OutlineInputBorder(),
),
),
SizedBox(height: 10),
TextFormField(
controller: controller.basicValidator.getController('password'),
decoration: InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
obscureText: true,
),
SizedBox(height: 20),
ElevatedButton(
onPressed: controller.onLogin,
child: Text('Login'),
style: ElevatedButton.styleFrom(
minimumSize: Size(double.infinity, 50),
),
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Dont have an account?'),
TextButton(
onPressed: () {
Get.toNamed('/auth/register_account'); // Navigate to the register screen
},
child: Text('Sign Up'),
),
],
),
TextButton(
onPressed: () {
Get.toNamed('/auth/forgot_password'); // Navigate to the forgot password screen
},
child: Text('Forgot Password?'),
),
],
),
),
),
);
}
}