import 'package:flutter/material.dart'; import 'package:finalproject/theme/colors.dart'; import 'package:finalproject/theme/text_styles.dart'; class SettingsScreen extends StatefulWidget { const SettingsScreen({Key? key}) : super(key: key); @override State createState() => _SettingsScreenState(); } class _SettingsScreenState extends State { int _selectedIndex = 5; // Settings tab void _showLogoutDialog() { showDialog( context: context, builder: (context) => AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), title: Text( 'Logout', style: AppTextStyles.headlineSmall.copyWith( color: AppColors.textPrimary, ), ), content: Text( 'Apakah Anda yakin ingin keluar dari aplikasi?', style: AppTextStyles.bodyMedium.copyWith( color: AppColors.textSecondary, ), ), actions: [ TextButton( onPressed: () => Navigator.pop(context), child: Text( 'Batal', style: AppTextStyles.labelLarge.copyWith( color: AppColors.textSecondary, ), ), ), ElevatedButton( onPressed: () { Navigator.pop(context); Navigator.of( context, ).pushNamedAndRemoveUntil('/login', (route) => false); }, style: ElevatedButton.styleFrom( backgroundColor: AppColors.statusError, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), ), child: Text( 'Logout', style: AppTextStyles.labelLarge.copyWith(color: Colors.white), ), ), ], ), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.bgLight, appBar: AppBar( backgroundColor: AppColors.primaryBrown, elevation: 0, title: Text( 'Pengaturan', style: AppTextStyles.headlineLarge.copyWith(color: Colors.white), ), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Account Section Text( 'Akun', style: AppTextStyles.headlineSmall.copyWith( color: AppColors.textPrimary, ), ), const SizedBox(height: 16), // User Profile Card Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: AppColors.bgWhite, borderRadius: BorderRadius.circular(16), boxShadow: [AppColors.shadowLight], ), child: Row( children: [ Container( width: 60, height: 60, decoration: BoxDecoration( color: AppColors.primaryBrown, borderRadius: BorderRadius.circular(12), ), child: const Icon( Icons.person, color: Colors.white, size: 32, ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Admin Sulastri', style: AppTextStyles.labelLarge.copyWith( color: AppColors.textPrimary, fontWeight: FontWeight.w700, ), ), const SizedBox(height: 4), Text( 'admin@sulastri.com', style: AppTextStyles.bodySmall.copyWith( color: AppColors.textSecondary, ), ), ], ), ), ], ), ), const SizedBox(height: 32), // General Settings Section Text( 'Umum', style: AppTextStyles.headlineSmall.copyWith( color: AppColors.textPrimary, ), ), const SizedBox(height: 16), // Settings Item: Language Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: AppColors.bgWhite, borderRadius: BorderRadius.circular(12), boxShadow: [AppColors.shadowLight], ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Icon( Icons.language, color: AppColors.primaryBrown, size: 24, ), const SizedBox(width: 12), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Bahasa', style: AppTextStyles.labelLarge.copyWith( color: AppColors.textPrimary, ), ), Text( 'Bahasa Indonesia', style: AppTextStyles.bodySmall.copyWith( color: AppColors.textSecondary, ), ), ], ), ], ), Icon(Icons.chevron_right, color: AppColors.textSecondary), ], ), ), const SizedBox(height: 12), // Settings Item: Notifikasi Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: AppColors.bgWhite, borderRadius: BorderRadius.circular(12), boxShadow: [AppColors.shadowLight], ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Icon( Icons.notifications_outlined, color: AppColors.primaryBrown, size: 24, ), const SizedBox(width: 12), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Notifikasi', style: AppTextStyles.labelLarge.copyWith( color: AppColors.textPrimary, ), ), Text( 'Aktifkan notifikasi penting', style: AppTextStyles.bodySmall.copyWith( color: AppColors.textSecondary, ), ), ], ), ], ), Switch( value: true, onChanged: (value) {}, activeColor: AppColors.primaryBrown, ), ], ), ), const SizedBox(height: 32), // Security Section Text( 'Keamanan', style: AppTextStyles.headlineSmall.copyWith( color: AppColors.textPrimary, ), ), const SizedBox(height: 16), // Settings Item: Change Password Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: AppColors.bgWhite, borderRadius: BorderRadius.circular(12), boxShadow: [AppColors.shadowLight], ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Icon( Icons.lock_outlined, color: AppColors.primaryBrown, size: 24, ), const SizedBox(width: 12), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Ubah Password', style: AppTextStyles.labelLarge.copyWith( color: AppColors.textPrimary, ), ), Text( 'Perbarui password akun Anda', style: AppTextStyles.bodySmall.copyWith( color: AppColors.textSecondary, ), ), ], ), ], ), Icon(Icons.chevron_right, color: AppColors.textSecondary), ], ), ), const SizedBox(height: 32), // Logout Button SizedBox( width: double.infinity, child: ElevatedButton.icon( onPressed: _showLogoutDialog, icon: const Icon(Icons.logout), label: const Text('Logout'), style: ElevatedButton.styleFrom( backgroundColor: AppColors.statusError, foregroundColor: Colors.white, padding: const EdgeInsets.symmetric(vertical: 14), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), ), ), const SizedBox(height: 32), // App Info Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: AppColors.bgLight, borderRadius: BorderRadius.circular(12), border: Border.all(color: AppColors.grey300), ), child: Column( children: [ Text( 'Prediksi Stok Bahan Kue', style: AppTextStyles.labelLarge.copyWith( color: AppColors.textPrimary, fontWeight: FontWeight.w700, ), ), const SizedBox(height: 8), Text( 'Version 1.0.0', style: AppTextStyles.bodySmall.copyWith( color: AppColors.textSecondary, ), ), const SizedBox(height: 12), Text( '© 2025 Toko Bahan Kue Sulastri', style: AppTextStyles.bodySmall.copyWith( color: AppColors.textTertiary, ), textAlign: TextAlign.center, ), ], ), ), ], ), ), ), bottomNavigationBar: BottomNavigationBar( currentIndex: _selectedIndex, onTap: (index) { setState(() => _selectedIndex = index); switch (index) { case 0: Navigator.of(context).pushNamed('/dashboard'); break; case 1: Navigator.of(context).pushNamed('/products'); break; case 2: Navigator.of(context).pushNamed('/transaction'); break; case 3: Navigator.of(context).pushNamed('/prediction'); break; case 4: Navigator.of(context).pushNamed('/reports'); break; case 5: break; } }, type: BottomNavigationBarType.fixed, backgroundColor: Colors.white, items: const [ BottomNavigationBarItem( icon: Icon(Icons.home_outlined), label: 'Dashboard', ), BottomNavigationBarItem( icon: Icon(Icons.shopping_bag_outlined), label: 'Produk', ), BottomNavigationBarItem( icon: Icon(Icons.shopping_cart_outlined), label: 'Transaksi', ), BottomNavigationBarItem( icon: Icon(Icons.trending_up_outlined), label: 'Prediksi', ), BottomNavigationBarItem( icon: Icon(Icons.description_outlined), label: 'Laporan', ), BottomNavigationBarItem( icon: Icon(Icons.settings_outlined), label: 'Pengaturan', ), ], ), ); } }