206 lines
6.9 KiB
Dart
206 lines
6.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import '../controllers/login_controller.dart';
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
class LoginView extends GetView<LoginController> {
|
|
const LoginView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
body: SafeArea(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Title
|
|
RichText(
|
|
text: const TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: 'Hello, ',
|
|
style: TextStyle(
|
|
fontSize: 26,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black87,
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: 'Selamat Datang',
|
|
style: TextStyle(
|
|
fontSize: 26,
|
|
fontWeight: FontWeight.bold,
|
|
color: Color(0xFF5B9BD5),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
// Blue label
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
decoration: BoxDecoration(
|
|
gradient: const LinearGradient(
|
|
colors: [Color(0xFF5B9BD5), Color(0xFF7BB3E0)],
|
|
),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: const Center(
|
|
child: Text(
|
|
'Masuk ke akun Anda',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 15,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
// Email
|
|
_buildTextField(
|
|
controller: controller.emailController,
|
|
hint: 'Email',
|
|
icon: Icons.email_outlined,
|
|
keyboardType: TextInputType.emailAddress,
|
|
),
|
|
const SizedBox(height: 14),
|
|
|
|
// Password
|
|
Obx(
|
|
() => _buildTextField(
|
|
controller: controller.passwordController,
|
|
hint: 'Password',
|
|
icon: Icons.lock_outline,
|
|
obscureText: !controller.isPasswordVisible.value,
|
|
suffixIcon: IconButton(
|
|
icon: Icon(
|
|
controller.isPasswordVisible.value
|
|
? Icons.visibility_outlined
|
|
: Icons.visibility_off_outlined,
|
|
color: Colors.grey,
|
|
),
|
|
onPressed: controller.togglePasswordVisibility,
|
|
),
|
|
),
|
|
),
|
|
|
|
// ← Lupa Password rata kanan, tepat di bawah input password
|
|
const SizedBox(height: 8),
|
|
Align(
|
|
alignment: Alignment.centerRight,
|
|
child: GestureDetector(
|
|
onTap: controller.lupaPassword,
|
|
child: const Text(
|
|
'Lupa Password?',
|
|
style: TextStyle(
|
|
color: Color(0xFF5B9BD5),
|
|
fontWeight: FontWeight.w500,
|
|
fontSize: 13,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 24),
|
|
|
|
// Login Button
|
|
Obx(
|
|
() => GestureDetector(
|
|
onTap: controller.isLoading.value ? null : controller.login,
|
|
child: Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.symmetric(vertical: 18),
|
|
decoration: BoxDecoration(
|
|
color: controller.isLoading.value
|
|
? Colors.grey
|
|
: const Color(0xFF5B9BD5),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Center(
|
|
child: controller.isLoading.value
|
|
? const CircularProgressIndicator(color: Colors.white)
|
|
: const Text(
|
|
'Login',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
// Belum punya akun? Register
|
|
Center(
|
|
child: RichText(
|
|
text: TextSpan(
|
|
children: [
|
|
const TextSpan(
|
|
text: 'Belum punya akun? ',
|
|
style: TextStyle(color: Colors.black54, fontSize: 14),
|
|
),
|
|
TextSpan(
|
|
text: 'Register',
|
|
style: const TextStyle(
|
|
color: Color(0xFF5B9BD5),
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 14,
|
|
),
|
|
recognizer: TapGestureRecognizer()
|
|
..onTap = controller.goToRegister,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildTextField({
|
|
required TextEditingController controller,
|
|
required String hint,
|
|
required IconData icon,
|
|
bool obscureText = false,
|
|
Widget? suffixIcon,
|
|
TextInputType keyboardType = TextInputType.text,
|
|
}) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF2F2F2),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: TextField(
|
|
controller: controller,
|
|
obscureText: obscureText,
|
|
keyboardType: keyboardType,
|
|
decoration: InputDecoration(
|
|
hintText: hint,
|
|
hintStyle: const TextStyle(color: Colors.grey, fontSize: 14),
|
|
prefixIcon: Icon(icon, color: Colors.grey, size: 20),
|
|
suffixIcon: suffixIcon,
|
|
border: InputBorder.none,
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
vertical: 16,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|