import 'package:flutter/material.dart'; import 'register_screen.dart'; import 'dashboard_screen.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({super.key}); @override LoginScreenState createState() => LoginScreenState(); } class LoginScreenState extends State { final _emailController = TextEditingController(); final _passwordController = TextEditingController(); bool _obscurePassword = true; void _login() { String email = _emailController.text.trim(); String password = _passwordController.text.trim(); if (email.isEmpty || password.isEmpty) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text("Email dan password tidak boleh kosong!")), ); return; } // Simulasi login berhasil → langsung ke Dashboard Navigator.pushReplacement( context, MaterialPageRoute(builder: (_) => const DashboardScreen()), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.blue.shade50, body: Center( child: SingleChildScrollView( padding: const EdgeInsets.all(28), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ // ── Logo / Icon ────────────────────────────── Container( padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.blue, shape: BoxShape.circle, boxShadow: [ BoxShadow( color: Colors.blue.shade200, blurRadius: 20, spreadRadius: 4, ) ], ), child: const Icon(Icons.set_meal, size: 60, color: Colors.white), ), const SizedBox(height: 24), const Text( "Pengering Ikan", style: TextStyle( fontSize: 26, fontWeight: FontWeight.bold, color: Colors.blue, ), ), const Text( "Masuk ke akun Anda", style: TextStyle(fontSize: 14, color: Colors.grey), ), const SizedBox(height: 32), // ── Card Form ──────────────────────────────── Card( elevation: 6, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), child: Padding( padding: const EdgeInsets.all(24), child: Column( children: [ // Email TextField( controller: _emailController, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( labelText: "Email", prefixIcon: const Icon(Icons.email_outlined), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), ), ), ), const SizedBox(height: 16), // Password TextField( controller: _passwordController, obscureText: _obscurePassword, decoration: InputDecoration( labelText: "Password", prefixIcon: const Icon(Icons.lock_outline), suffixIcon: IconButton( icon: Icon( _obscurePassword ? Icons.visibility_off : Icons.visibility, ), onPressed: () => setState( () => _obscurePassword = !_obscurePassword), ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), ), ), ), const SizedBox(height: 24), // Tombol Login SizedBox( width: double.infinity, height: 48, child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: Colors.blue, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), onPressed: _login, child: const Text( "Masuk", style: TextStyle(fontSize: 16, color: Colors.white), ), ), ), ], ), ), ), const SizedBox(height: 20), // ── Link ke Register ───────────────────────── Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text("Belum punya akun? "), GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (_) => const RegisterScreen()), ); }, child: const Text( "Daftar", style: TextStyle( color: Colors.blue, fontWeight: FontWeight.bold, ), ), ), ], ), ], ), ), ), ); } }