Tambahkan dependensi dan konfigurasi awal proyek
- Tambahkan dependensi utama: GetX, Supabase, SharedPreferences - Konfigurasi struktur awal aplikasi dengan GetX - Inisialisasi layanan Supabase - Perbarui konfigurasi plugin untuk berbagai platform - Ganti template default dengan struktur aplikasi baru
This commit is contained in:
11
lib/app/modules/auth/bindings/auth_binding.dart
Normal file
11
lib/app/modules/auth/bindings/auth_binding.dart
Normal file
@ -0,0 +1,11 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
||||
|
||||
class AuthBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<AuthController>(
|
||||
() => AuthController(),
|
||||
);
|
||||
}
|
||||
}
|
512
lib/app/modules/auth/controllers/auth_controller.dart
Normal file
512
lib/app/modules/auth/controllers/auth_controller.dart
Normal file
@ -0,0 +1,512 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/data/models/user_model.dart';
|
||||
import 'package:penyaluran_app/app/data/providers/auth_provider.dart';
|
||||
import 'package:penyaluran_app/app/routes/app_pages.dart';
|
||||
|
||||
class AuthController extends GetxController {
|
||||
static AuthController get to => Get.find();
|
||||
|
||||
final AuthProvider _authProvider = AuthProvider();
|
||||
|
||||
final Rx<UserModel?> _user = Rx<UserModel?>(null);
|
||||
UserModel? get user => _user.value;
|
||||
|
||||
final RxBool isLoading = false.obs;
|
||||
final RxBool isWargaProfileComplete = false.obs;
|
||||
|
||||
// Form controllers
|
||||
final TextEditingController emailController = TextEditingController();
|
||||
final TextEditingController passwordController = TextEditingController();
|
||||
final TextEditingController confirmPasswordController =
|
||||
TextEditingController();
|
||||
|
||||
// Form controllers untuk data warga
|
||||
final TextEditingController nikController = TextEditingController();
|
||||
final TextEditingController namaLengkapController = TextEditingController();
|
||||
final TextEditingController jenisKelaminController = TextEditingController();
|
||||
final TextEditingController noHpController = TextEditingController();
|
||||
final TextEditingController alamatController = TextEditingController();
|
||||
final TextEditingController tempatLahirController = TextEditingController();
|
||||
final TextEditingController tanggalLahirController = TextEditingController();
|
||||
final TextEditingController agamaController = TextEditingController();
|
||||
|
||||
// Form keys
|
||||
final GlobalKey<FormState> loginFormKey = GlobalKey<FormState>();
|
||||
final GlobalKey<FormState> registerFormKey = GlobalKey<FormState>();
|
||||
final GlobalKey<FormState> wargaProfileFormKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
// Tambahkan penundaan kecil untuk menghindari loop navigasi
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
checkAuthStatus();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// Pastikan semua controller dibersihkan sebelum dilepaskan
|
||||
clearAndDisposeControllers();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
// Metode untuk membersihkan dan melepaskan controller
|
||||
void clearAndDisposeControllers() {
|
||||
try {
|
||||
if (emailController.text.isNotEmpty) emailController.clear();
|
||||
if (passwordController.text.isNotEmpty) passwordController.clear();
|
||||
if (confirmPasswordController.text.isNotEmpty)
|
||||
confirmPasswordController.clear();
|
||||
if (nikController.text.isNotEmpty) nikController.clear();
|
||||
if (namaLengkapController.text.isNotEmpty) namaLengkapController.clear();
|
||||
if (jenisKelaminController.text.isNotEmpty)
|
||||
jenisKelaminController.clear();
|
||||
if (noHpController.text.isNotEmpty) noHpController.clear();
|
||||
if (alamatController.text.isNotEmpty) alamatController.clear();
|
||||
if (tempatLahirController.text.isNotEmpty) tempatLahirController.clear();
|
||||
if (tanggalLahirController.text.isNotEmpty)
|
||||
tanggalLahirController.clear();
|
||||
if (agamaController.text.isNotEmpty) agamaController.clear();
|
||||
|
||||
emailController.dispose();
|
||||
passwordController.dispose();
|
||||
confirmPasswordController.dispose();
|
||||
nikController.dispose();
|
||||
namaLengkapController.dispose();
|
||||
jenisKelaminController.dispose();
|
||||
noHpController.dispose();
|
||||
alamatController.dispose();
|
||||
tempatLahirController.dispose();
|
||||
tanggalLahirController.dispose();
|
||||
agamaController.dispose();
|
||||
} catch (e) {
|
||||
print('Error disposing controllers: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Memeriksa status autentikasi
|
||||
Future<void> checkAuthStatus() async {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
final currentUser = await _authProvider.getCurrentUser();
|
||||
if (currentUser != null) {
|
||||
_user.value = currentUser;
|
||||
|
||||
// Periksa apakah profil warga sudah lengkap
|
||||
await checkWargaProfileStatus();
|
||||
|
||||
// Hindari navigasi jika sudah berada di halaman yang sesuai
|
||||
final currentRoute = Get.currentRoute;
|
||||
|
||||
// Untuk semua role, arahkan ke dashboard masing-masing
|
||||
final targetRoute = _getTargetRouteForRole(currentUser.role);
|
||||
if (currentRoute != targetRoute) {
|
||||
navigateBasedOnRole(currentUser.role);
|
||||
}
|
||||
} else {
|
||||
// Jika tidak ada user yang login, arahkan ke halaman login
|
||||
if (Get.currentRoute != Routes.LOGIN) {
|
||||
// Bersihkan dependensi form sebelum navigasi
|
||||
clearFormDependencies();
|
||||
Get.offAllNamed(Routes.LOGIN);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error checking auth status: $e');
|
||||
// Jika terjadi error, arahkan ke halaman login
|
||||
if (Get.currentRoute != Routes.LOGIN) {
|
||||
// Bersihkan dependensi form sebelum navigasi
|
||||
clearFormDependencies();
|
||||
Get.offAllNamed(Routes.LOGIN);
|
||||
}
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Memeriksa status profil warga
|
||||
Future<void> checkWargaProfileStatus() async {
|
||||
try {
|
||||
if (_user.value?.role == 'WARGA') {
|
||||
final wargaData = await _authProvider.getWargaData();
|
||||
isWargaProfileComplete.value = wargaData != null;
|
||||
} else {
|
||||
isWargaProfileComplete.value = true;
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error checking warga profile: $e');
|
||||
isWargaProfileComplete.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Metode untuk membersihkan dependensi form
|
||||
void clearFormDependencies() {
|
||||
try {
|
||||
// Hapus fokus dari semua field
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
|
||||
// Reset form state jika ada
|
||||
loginFormKey.currentState?.reset();
|
||||
registerFormKey.currentState?.reset();
|
||||
wargaProfileFormKey.currentState?.reset();
|
||||
} catch (e) {
|
||||
print('Error clearing form dependencies: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Metode untuk navigasi berdasarkan peran
|
||||
void navigateBasedOnRole(String role) {
|
||||
// Bersihkan dependensi form sebelum navigasi
|
||||
clearFormDependencies();
|
||||
|
||||
switch (role) {
|
||||
case 'WARGA':
|
||||
Get.offAllNamed(Routes.WARGA_DASHBOARD);
|
||||
break;
|
||||
case 'PETUGASVERIFIKASI':
|
||||
Get.offAllNamed(Routes.PETUGAS_VERIFIKASI_DASHBOARD);
|
||||
break;
|
||||
case 'PETUGASDESA':
|
||||
Get.offAllNamed(Routes.PETUGAS_DESA_DASHBOARD);
|
||||
break;
|
||||
case 'DONATUR':
|
||||
Get.offAllNamed(Routes.DONATUR_DASHBOARD);
|
||||
break;
|
||||
default:
|
||||
Get.offAllNamed(Routes.HOME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Metode untuk login
|
||||
Future<void> login() async {
|
||||
if (!loginFormKey.currentState!.validate()) return;
|
||||
|
||||
// Simpan nilai dari controller sebelum melakukan operasi asinkron
|
||||
final email = emailController.text.trim();
|
||||
final password = passwordController.text;
|
||||
|
||||
try {
|
||||
isLoading.value = true;
|
||||
final user = await _authProvider.signIn(
|
||||
email,
|
||||
password,
|
||||
);
|
||||
|
||||
if (user != null) {
|
||||
_user.value = user;
|
||||
clearControllers();
|
||||
|
||||
// Periksa apakah profil warga sudah lengkap
|
||||
await checkWargaProfileStatus();
|
||||
|
||||
// Arahkan ke dashboard sesuai peran
|
||||
navigateBasedOnRole(user.role);
|
||||
|
||||
// Tampilkan notifikasi jika profil belum lengkap untuk warga
|
||||
if (user.role == 'WARGA' && !isWargaProfileComplete.value) {
|
||||
Get.snackbar(
|
||||
'Informasi',
|
||||
'Profil Anda belum lengkap. Silakan lengkapi profil Anda melalui menu Profil',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.blue,
|
||||
colorText: Colors.white,
|
||||
duration: const Duration(seconds: 5),
|
||||
);
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'Berhasil',
|
||||
'Login berhasil',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.green,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error login: $e');
|
||||
Get.snackbar(
|
||||
'Error',
|
||||
'Login gagal: ${e.toString()}',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.red,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Metode untuk register
|
||||
Future<void> register() async {
|
||||
if (!registerFormKey.currentState!.validate()) return;
|
||||
|
||||
// Simpan nilai dari controller sebelum melakukan operasi asinkron
|
||||
final email = emailController.text.trim();
|
||||
final password = passwordController.text;
|
||||
final confirmPassword = confirmPasswordController.text;
|
||||
|
||||
if (password != confirmPassword) {
|
||||
Get.snackbar(
|
||||
'Error',
|
||||
'Password dan konfirmasi password tidak sama',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.red,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
isLoading.value = true;
|
||||
final user = await _authProvider.signUp(
|
||||
email,
|
||||
password,
|
||||
);
|
||||
|
||||
if (user != null) {
|
||||
_user.value = user;
|
||||
clearControllers();
|
||||
|
||||
// Periksa status profil
|
||||
await checkWargaProfileStatus();
|
||||
|
||||
// Arahkan ke dashboard sesuai peran
|
||||
navigateBasedOnRole(user.role);
|
||||
|
||||
// Tampilkan notifikasi untuk melengkapi profil
|
||||
Get.snackbar(
|
||||
'Berhasil',
|
||||
'Registrasi berhasil. Silakan lengkapi profil Anda melalui menu Profil',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.green,
|
||||
colorText: Colors.white,
|
||||
duration: const Duration(seconds: 5),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar(
|
||||
'Error',
|
||||
'Registrasi gagal: ${e.toString()}',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.red,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Metode untuk melengkapi profil warga
|
||||
Future<void> completeWargaProfile() async {
|
||||
if (!wargaProfileFormKey.currentState!.validate()) return;
|
||||
|
||||
// Simpan nilai dari controller sebelum melakukan operasi asinkron
|
||||
final nik = nikController.text.trim();
|
||||
final namaLengkap = namaLengkapController.text.trim();
|
||||
final jenisKelamin = jenisKelaminController.text.trim();
|
||||
final noHp = noHpController.text.trim();
|
||||
final alamat = alamatController.text.trim();
|
||||
final tempatLahir = tempatLahirController.text.trim();
|
||||
final tanggalLahirText = tanggalLahirController.text;
|
||||
final agama = agamaController.text.trim();
|
||||
|
||||
try {
|
||||
isLoading.value = true;
|
||||
|
||||
DateTime? tanggalLahir;
|
||||
if (tanggalLahirText.isNotEmpty) {
|
||||
try {
|
||||
final parts = tanggalLahirText.split('-');
|
||||
if (parts.length == 3) {
|
||||
tanggalLahir = DateTime(
|
||||
int.parse(parts[2]), // tahun
|
||||
int.parse(parts[1]), // bulan
|
||||
int.parse(parts[0]), // hari
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error parsing date: $e');
|
||||
}
|
||||
}
|
||||
|
||||
await _authProvider.createWargaProfile(
|
||||
nik: nik,
|
||||
namaLengkap: namaLengkap,
|
||||
jenisKelamin: jenisKelamin,
|
||||
noHp: noHp,
|
||||
alamat: alamat,
|
||||
tempatLahir: tempatLahir,
|
||||
tanggalLahir: tanggalLahir,
|
||||
agama: agama,
|
||||
);
|
||||
|
||||
isWargaProfileComplete.value = true;
|
||||
|
||||
// Kembali ke halaman sebelumnya jika menggunakan Get.toNamed
|
||||
if (Get.previousRoute.isNotEmpty) {
|
||||
Get.back();
|
||||
Get.snackbar(
|
||||
'Berhasil',
|
||||
'Profil berhasil dilengkapi',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.green,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
} else {
|
||||
// Jika tidak ada halaman sebelumnya, navigasi ke dashboard warga
|
||||
Get.offAllNamed(Routes.WARGA_DASHBOARD);
|
||||
Get.snackbar(
|
||||
'Berhasil',
|
||||
'Profil berhasil dilengkapi',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.green,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar(
|
||||
'Error',
|
||||
'Gagal melengkapi profil: ${e.toString()}',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.red,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Metode untuk logout
|
||||
Future<void> logout() async {
|
||||
try {
|
||||
await _authProvider.signOut();
|
||||
_user.value = null;
|
||||
isWargaProfileComplete.value = false;
|
||||
|
||||
// Bersihkan dependensi form sebelum navigasi
|
||||
clearFormDependencies();
|
||||
|
||||
Get.offAllNamed(Routes.LOGIN);
|
||||
} catch (e) {
|
||||
Get.snackbar(
|
||||
'Error',
|
||||
'Logout gagal: ${e.toString()}',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.red,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Metode untuk membersihkan controller
|
||||
void clearControllers() {
|
||||
try {
|
||||
if (emailController.text.isNotEmpty) emailController.clear();
|
||||
if (passwordController.text.isNotEmpty) passwordController.clear();
|
||||
if (confirmPasswordController.text.isNotEmpty)
|
||||
confirmPasswordController.clear();
|
||||
} catch (e) {
|
||||
print('Error clearing controllers: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Validasi email
|
||||
String? validateEmail(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Email tidak boleh kosong';
|
||||
}
|
||||
if (!GetUtils.isEmail(value)) {
|
||||
return 'Email tidak valid';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Validasi password
|
||||
String? validatePassword(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Password tidak boleh kosong';
|
||||
}
|
||||
if (value.length < 6) {
|
||||
return 'Password minimal 6 karakter';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Validasi konfirmasi password
|
||||
String? validateConfirmPassword(String? value) {
|
||||
try {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Konfirmasi password tidak boleh kosong';
|
||||
}
|
||||
|
||||
// Ambil nilai password dari controller jika tersedia
|
||||
final password = passwordController.text;
|
||||
if (value != password) {
|
||||
return 'Password dan konfirmasi password tidak sama';
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
print('Error validating confirm password: $e');
|
||||
return 'Terjadi kesalahan saat validasi';
|
||||
}
|
||||
}
|
||||
|
||||
// Validasi NIK
|
||||
String? validateNIK(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'NIK tidak boleh kosong';
|
||||
}
|
||||
if (value.length != 16) {
|
||||
return 'NIK harus 16 digit';
|
||||
}
|
||||
if (!GetUtils.isNumericOnly(value)) {
|
||||
return 'NIK harus berupa angka';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Validasi nama lengkap
|
||||
String? validateNamaLengkap(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Nama lengkap tidak boleh kosong';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Validasi jenis kelamin
|
||||
String? validateJenisKelamin(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Jenis kelamin tidak boleh kosong';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Mendapatkan rute target berdasarkan peran
|
||||
String _getTargetRouteForRole(String role) {
|
||||
switch (role) {
|
||||
case 'WARGA':
|
||||
return Routes.WARGA_DASHBOARD;
|
||||
case 'PETUGASVERIFIKASI':
|
||||
return Routes.PETUGAS_VERIFIKASI_DASHBOARD;
|
||||
case 'PETUGASDESA':
|
||||
return Routes.PETUGAS_DESA_DASHBOARD;
|
||||
case 'DONATUR':
|
||||
return Routes.DONATUR_DASHBOARD;
|
||||
default:
|
||||
return Routes.HOME;
|
||||
}
|
||||
}
|
||||
|
||||
// Metode untuk navigasi ke halaman lengkapi profil
|
||||
void navigateToCompleteProfile() {
|
||||
// Bersihkan dependensi form sebelum navigasi
|
||||
clearFormDependencies();
|
||||
|
||||
// Gunakan preventDuplicates untuk mencegah navigasi berulang
|
||||
Get.toNamed(Routes.COMPLETE_PROFILE, preventDuplicates: true);
|
||||
}
|
||||
}
|
270
lib/app/modules/auth/views/complete_profile_view.dart
Normal file
270
lib/app/modules/auth/views/complete_profile_view.dart
Normal file
@ -0,0 +1,270 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
||||
|
||||
class CompleteProfileView extends GetView<AuthController> {
|
||||
const CompleteProfileView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Lengkapi Profil'),
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
key: controller.wargaProfileFormKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const Center(
|
||||
child: Text(
|
||||
'Lengkapi Data Diri Anda',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const Center(
|
||||
child: Text(
|
||||
'Data ini diperlukan untuk verifikasi',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// NIK Field
|
||||
TextFormField(
|
||||
controller: controller.nikController,
|
||||
keyboardType: TextInputType.number,
|
||||
maxLength: 16,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'NIK',
|
||||
prefixIcon: const Icon(Icons.credit_card),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
validator: controller.validateNIK,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// Nama Lengkap Field
|
||||
TextFormField(
|
||||
controller: controller.namaLengkapController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Nama Lengkap',
|
||||
prefixIcon: const Icon(Icons.person),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
validator: controller.validateNamaLengkap,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// Jenis Kelamin Field
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Jenis Kelamin',
|
||||
prefixIcon: const Icon(Icons.people),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: 'LAKI-LAKI',
|
||||
child: Text('Laki-laki'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'PEREMPUAN',
|
||||
child: Text('Perempuan'),
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
controller.jenisKelaminController.text = value ?? '';
|
||||
},
|
||||
validator: controller.validateJenisKelamin,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// No HP Field
|
||||
TextFormField(
|
||||
controller: controller.noHpController,
|
||||
keyboardType: TextInputType.phone,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'No. HP',
|
||||
prefixIcon: const Icon(Icons.phone),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// Alamat Field
|
||||
TextFormField(
|
||||
controller: controller.alamatController,
|
||||
maxLines: 3,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Alamat',
|
||||
prefixIcon: const Icon(Icons.home),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// Tempat Lahir Field
|
||||
TextFormField(
|
||||
controller: controller.tempatLahirController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Tempat Lahir',
|
||||
prefixIcon: const Icon(Icons.location_city),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// Tanggal Lahir Field
|
||||
TextFormField(
|
||||
controller: controller.tanggalLahirController,
|
||||
keyboardType: TextInputType.datetime,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Tanggal Lahir (DD-MM-YYYY)',
|
||||
prefixIcon: const Icon(Icons.calendar_today),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null) {
|
||||
controller.tanggalLahirController.text =
|
||||
'${picked.day.toString().padLeft(2, '0')}-'
|
||||
'${picked.month.toString().padLeft(2, '0')}-'
|
||||
'${picked.year}';
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// Agama Field
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Agama',
|
||||
prefixIcon: const Icon(Icons.church),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
value: 'ISLAM',
|
||||
child: Text('Islam'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'KRISTEN PROTESTAN',
|
||||
child: Text('Kristen Protestan'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'KRISTEN KATOLIK',
|
||||
child: Text('Kristen Katolik'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'HINDU',
|
||||
child: Text('Hindu'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'BUDHA',
|
||||
child: Text('Budha'),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'KONGHUCU',
|
||||
child: Text('Konghucu'),
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
controller.agamaController.text = value ?? '';
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Submit Button
|
||||
Obx(() => ElevatedButton(
|
||||
onPressed: controller.isLoading.value
|
||||
? null
|
||||
: controller.completeWargaProfile,
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: controller.isLoading.value
|
||||
? const SpinKitThreeBounce(
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
)
|
||||
: const Text(
|
||||
'SIMPAN',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
)),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
// Kembali Button
|
||||
OutlinedButton(
|
||||
onPressed: () => Get.back(),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'KEMBALI KE DASHBOARD',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
133
lib/app/modules/auth/views/login_view.dart
Normal file
133
lib/app/modules/auth/views/login_view.dart
Normal file
@ -0,0 +1,133 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
||||
import 'package:penyaluran_app/app/routes/app_pages.dart';
|
||||
|
||||
class LoginView extends GetView<AuthController> {
|
||||
const LoginView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
key: controller.loginFormKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
// Logo atau Judul
|
||||
const Center(
|
||||
child: Text(
|
||||
'Penyaluran App',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Center(
|
||||
child: Text(
|
||||
'Masuk ke akun Anda',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 50),
|
||||
|
||||
// Email Field
|
||||
TextFormField(
|
||||
controller: controller.emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Email',
|
||||
prefixIcon: const Icon(Icons.email),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
validator: controller.validateEmail,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Password Field
|
||||
TextFormField(
|
||||
controller: controller.passwordController,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
prefixIcon: const Icon(Icons.lock),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
validator: controller.validatePassword,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// Forgot Password
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
// Implementasi lupa password
|
||||
},
|
||||
child: const Text('Lupa Password?'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Login Button
|
||||
Obx(() => ElevatedButton(
|
||||
onPressed: controller.isLoading.value
|
||||
? null
|
||||
: controller.login,
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: controller.isLoading.value
|
||||
? const SpinKitThreeBounce(
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
)
|
||||
: const Text(
|
||||
'MASUK',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
)),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Register Link
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('Belum punya akun?'),
|
||||
TextButton(
|
||||
onPressed: () => Get.toNamed(Routes.REGISTER),
|
||||
child: const Text('Daftar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
140
lib/app/modules/auth/views/register_view.dart
Normal file
140
lib/app/modules/auth/views/register_view.dart
Normal file
@ -0,0 +1,140 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
||||
import 'package:penyaluran_app/app/routes/app_pages.dart';
|
||||
|
||||
class RegisterView extends GetView<AuthController> {
|
||||
const RegisterView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Daftar Akun'),
|
||||
elevation: 0,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
key: controller.registerFormKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
// Logo atau Judul
|
||||
const Center(
|
||||
child: Text(
|
||||
'Penyaluran App',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Center(
|
||||
child: Text(
|
||||
'Buat akun baru',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Email Field
|
||||
TextFormField(
|
||||
controller: controller.emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Email',
|
||||
prefixIcon: const Icon(Icons.email),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
validator: controller.validateEmail,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Password Field
|
||||
TextFormField(
|
||||
controller: controller.passwordController,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
prefixIcon: const Icon(Icons.lock),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
validator: controller.validatePassword,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Confirm Password Field
|
||||
TextFormField(
|
||||
controller: controller.confirmPasswordController,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Konfirmasi Password',
|
||||
prefixIcon: const Icon(Icons.lock_outline),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
validator: controller.validateConfirmPassword,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Register Button
|
||||
Obx(() => ElevatedButton(
|
||||
onPressed: controller.isLoading.value
|
||||
? null
|
||||
: controller.register,
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: controller.isLoading.value
|
||||
? const SpinKitThreeBounce(
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
)
|
||||
: const Text(
|
||||
'DAFTAR',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
)),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Login Link
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('Sudah punya akun?'),
|
||||
TextButton(
|
||||
onPressed: () => Get.offAllNamed(Routes.LOGIN),
|
||||
child: const Text('Masuk'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
11
lib/app/modules/dashboard/bindings/dashboard_binding.dart
Normal file
11
lib/app/modules/dashboard/bindings/dashboard_binding.dart
Normal file
@ -0,0 +1,11 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_controller.dart';
|
||||
|
||||
class DashboardBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<DashboardController>(
|
||||
() => DashboardController(),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/data/models/user_model.dart';
|
||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
||||
import 'package:penyaluran_app/app/services/supabase_service.dart';
|
||||
|
||||
class DashboardController extends GetxController {
|
||||
final AuthController _authController = Get.find<AuthController>();
|
||||
final SupabaseService _supabaseService = SupabaseService.to;
|
||||
|
||||
final RxBool isLoading = false.obs;
|
||||
final Rx<Map<String, dynamic>?> roleData = Rx<Map<String, dynamic>?>(null);
|
||||
|
||||
UserModel? get user => _authController.user;
|
||||
String get role => user?.role ?? 'WARGA';
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
loadRoleData();
|
||||
}
|
||||
|
||||
Future<void> loadRoleData() async {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
if (user != null) {
|
||||
final data = await _supabaseService.getRoleSpecificData(role);
|
||||
roleData.value = data;
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error loading role data: $e');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
void logout() {
|
||||
_authController.logout();
|
||||
}
|
||||
}
|
229
lib/app/modules/dashboard/views/donatur_dashboard_view.dart
Normal file
229
lib/app/modules/dashboard/views/donatur_dashboard_view.dart
Normal file
@ -0,0 +1,229 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_controller.dart';
|
||||
|
||||
class DonaturDashboardView extends GetView<DashboardController> {
|
||||
const DonaturDashboardView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Dashboard Donatur'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout),
|
||||
onPressed: controller.logout,
|
||||
tooltip: 'Logout',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Obx(() {
|
||||
if (controller.isLoading.value) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Greeting
|
||||
Text(
|
||||
'Halo, ${controller.roleData.value?['namaLengkap'] ?? controller.user?.email ?? 'Donatur'}!',
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const Text(
|
||||
'Selamat datang di Dashboard Donatur',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Donatur Data
|
||||
if (controller.roleData.value != null) ...[
|
||||
const Text(
|
||||
'Data Donatur',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
'NIK', controller.roleData.value?['NIK'] ?? '-'),
|
||||
_buildInfoRow('Nama',
|
||||
controller.roleData.value?['namaLengkap'] ?? '-'),
|
||||
_buildInfoRow('No. Telp',
|
||||
controller.roleData.value?['noTelp'] ?? '-'),
|
||||
_buildInfoRow('Email',
|
||||
controller.roleData.value?['email'] ?? '-'),
|
||||
_buildInfoRow(
|
||||
'Alamat',
|
||||
controller.roleData.value?['alamatLengkap'] ??
|
||||
'-'),
|
||||
_buildInfoRow('Desa',
|
||||
controller.roleData.value?['namaDesa'] ?? '-'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
const Center(
|
||||
child: Text(
|
||||
'Data donatur belum tersedia',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Menu
|
||||
const Text(
|
||||
'Menu',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Penitipan Bantuan',
|
||||
'Titipkan bantuan Anda',
|
||||
Icons.card_giftcard,
|
||||
Colors.blue,
|
||||
() {
|
||||
// Navigasi ke halaman penitipan bantuan
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Riwayat Penitipan',
|
||||
'Lihat riwayat penitipan bantuan',
|
||||
Icons.history,
|
||||
Colors.green,
|
||||
() {
|
||||
// Navigasi ke halaman riwayat penitipan
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Laporan Penyaluran',
|
||||
'Lihat laporan penyaluran bantuan',
|
||||
Icons.assessment,
|
||||
Colors.orange,
|
||||
() {
|
||||
// Navigasi ke halaman laporan penyaluran
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
// Navigasi ke halaman penitipan bantuan baru
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
tooltip: 'Titipkan Bantuan Baru',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(value),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuCard(String title, String subtitle, IconData icon,
|
||||
Color color, VoidCallback onTap) {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
220
lib/app/modules/dashboard/views/petugas_desa_dashboard_view.dart
Normal file
220
lib/app/modules/dashboard/views/petugas_desa_dashboard_view.dart
Normal file
@ -0,0 +1,220 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_controller.dart';
|
||||
|
||||
class PetugasDesaDashboardView extends GetView<DashboardController> {
|
||||
const PetugasDesaDashboardView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Dashboard Petugas Desa'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout),
|
||||
onPressed: controller.logout,
|
||||
tooltip: 'Logout',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Obx(() {
|
||||
if (controller.isLoading.value) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Greeting
|
||||
Text(
|
||||
'Halo, ${controller.roleData.value?['namaLengkap'] ?? controller.user?.email ?? 'Petugas'}!',
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
'Selamat datang di Dashboard Petugas Desa ${controller.roleData.value?['Desa'] ?? ''}',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Petugas Data
|
||||
if (controller.roleData.value != null) ...[
|
||||
const Text(
|
||||
'Data Petugas',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
'NIP', controller.roleData.value?['NIP'] ?? '-'),
|
||||
_buildInfoRow('Nama',
|
||||
controller.roleData.value?['namaLengkap'] ?? '-'),
|
||||
_buildInfoRow('Jabatan',
|
||||
controller.roleData.value?['jabatan'] ?? '-'),
|
||||
_buildInfoRow('Desa',
|
||||
controller.roleData.value?['Desa'] ?? '-'),
|
||||
_buildInfoRow('No. HP',
|
||||
controller.roleData.value?['noHP'] ?? '-'),
|
||||
_buildInfoRow('Email',
|
||||
controller.roleData.value?['email'] ?? '-'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
const Center(
|
||||
child: Text(
|
||||
'Data petugas belum tersedia',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Menu
|
||||
const Text(
|
||||
'Menu',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Penyaluran Bantuan',
|
||||
'Kelola penyaluran bantuan',
|
||||
Icons.local_shipping,
|
||||
Colors.blue,
|
||||
() {
|
||||
// Navigasi ke halaman penyaluran bantuan
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Pengaduan',
|
||||
'Kelola pengaduan warga',
|
||||
Icons.report_problem,
|
||||
Colors.orange,
|
||||
() {
|
||||
// Navigasi ke halaman pengaduan
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Laporan',
|
||||
'Lihat laporan penyaluran',
|
||||
Icons.assessment,
|
||||
Colors.green,
|
||||
() {
|
||||
// Navigasi ke halaman laporan
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(value),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuCard(String title, String subtitle, IconData icon,
|
||||
Color color, VoidCallback onTap) {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_controller.dart';
|
||||
|
||||
class PetugasVerifikasiDashboardView extends GetView<DashboardController> {
|
||||
const PetugasVerifikasiDashboardView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Dashboard Petugas Verifikasi'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout),
|
||||
onPressed: controller.logout,
|
||||
tooltip: 'Logout',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Obx(() {
|
||||
if (controller.isLoading.value) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Greeting
|
||||
Text(
|
||||
'Halo, ${controller.roleData.value?['namaLengkap'] ?? controller.user?.email ?? 'Petugas'}!',
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const Text(
|
||||
'Selamat datang di Dashboard Petugas Verifikasi',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Petugas Data
|
||||
if (controller.roleData.value != null) ...[
|
||||
const Text(
|
||||
'Data Petugas',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
'NIP', controller.roleData.value?['nip'] ?? '-'),
|
||||
_buildInfoRow('Nama',
|
||||
controller.roleData.value?['namaLengkap'] ?? '-'),
|
||||
_buildInfoRow('Jabatan',
|
||||
controller.roleData.value?['jabatan'] ?? '-'),
|
||||
_buildInfoRow('Email',
|
||||
controller.roleData.value?['email'] ?? '-'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
const Center(
|
||||
child: Text(
|
||||
'Data petugas belum tersedia',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Menu
|
||||
const Text(
|
||||
'Menu',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Verifikasi Data Warga',
|
||||
'Verifikasi data warga baru',
|
||||
Icons.verified_user,
|
||||
Colors.blue,
|
||||
() {
|
||||
// Navigasi ke halaman verifikasi data warga
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Verifikasi Pengajuan Bantuan',
|
||||
'Verifikasi pengajuan bantuan',
|
||||
Icons.fact_check,
|
||||
Colors.green,
|
||||
() {
|
||||
// Navigasi ke halaman verifikasi pengajuan bantuan
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Kelola Skema Bantuan',
|
||||
'Kelola skema bantuan yang tersedia',
|
||||
Icons.settings,
|
||||
Colors.orange,
|
||||
() {
|
||||
// Navigasi ke halaman kelola skema bantuan
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(value),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuCard(String title, String subtitle, IconData icon,
|
||||
Color color, VoidCallback onTap) {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
303
lib/app/modules/dashboard/views/warga_dashboard_view.dart
Normal file
303
lib/app/modules/dashboard/views/warga_dashboard_view.dart
Normal file
@ -0,0 +1,303 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_controller.dart';
|
||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
||||
|
||||
class WargaDashboardView extends GetView<DashboardController> {
|
||||
const WargaDashboardView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authController = Get.find<AuthController>();
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Dashboard Warga'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout),
|
||||
onPressed: controller.logout,
|
||||
tooltip: 'Logout',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Obx(() {
|
||||
if (controller.isLoading.value) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Greeting
|
||||
Text(
|
||||
'Halo, ${controller.user?.email ?? 'Pengguna'}!',
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const Text(
|
||||
'Selamat datang di Dashboard Warga',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Status Profil
|
||||
Obx(() => authController.isWargaProfileComplete.value
|
||||
? _buildProfileCompleteCard()
|
||||
: _buildProfileIncompleteCard(authController)),
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Warga Data
|
||||
if (controller.roleData.value != null) ...[
|
||||
const Text(
|
||||
'Data Pribadi',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInfoRow('NIK',
|
||||
controller.roleData.value?['NIK'] ?? '-'),
|
||||
_buildInfoRow(
|
||||
'Nama',
|
||||
controller.roleData.value?['namaLengkap'] ??
|
||||
'-'),
|
||||
_buildInfoRow(
|
||||
'Jenis Kelamin',
|
||||
controller.roleData.value?['jenisKelamin'] ??
|
||||
'-'),
|
||||
_buildInfoRow('No. HP',
|
||||
controller.roleData.value?['noHp'] ?? '-'),
|
||||
_buildInfoRow('Alamat',
|
||||
controller.roleData.value?['alamat'] ?? '-'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
const Center(
|
||||
child: Text(
|
||||
'Data warga belum tersedia',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Menu
|
||||
const Text(
|
||||
'Menu',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Pengajuan Bantuan',
|
||||
'Ajukan permohonan bantuan',
|
||||
Icons.request_page,
|
||||
Colors.blue,
|
||||
() {
|
||||
// Navigasi ke halaman pengajuan bantuan
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Pengaduan',
|
||||
'Sampaikan pengaduan Anda',
|
||||
Icons.report_problem,
|
||||
Colors.orange,
|
||||
() {
|
||||
// Navigasi ke halaman pengaduan
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildMenuCard(
|
||||
'Status Bantuan',
|
||||
'Lihat status bantuan Anda',
|
||||
Icons.info,
|
||||
Colors.green,
|
||||
() {
|
||||
// Navigasi ke halaman status bantuan
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Widget untuk menampilkan status profil lengkap
|
||||
Widget _buildProfileCompleteCard() {
|
||||
return Card(
|
||||
color: Colors.green.shade50,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.check_circle, color: Colors.green.shade700),
|
||||
const SizedBox(width: 10),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Profil Anda sudah lengkap',
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Widget untuk menampilkan status profil belum lengkap dengan tombol
|
||||
Widget _buildProfileIncompleteCard(AuthController authController) {
|
||||
return Card(
|
||||
color: Colors.orange.shade50,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.warning, color: Colors.orange.shade700),
|
||||
const SizedBox(width: 10),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Profil Anda belum lengkap',
|
||||
style: TextStyle(
|
||||
color: Colors.orange,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'Lengkapi profil Anda untuk mengakses semua fitur aplikasi',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ElevatedButton(
|
||||
onPressed: authController.navigateToCompleteProfile,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.orange,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('Lengkapi Profil'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 120,
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(value),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuCard(String title, String subtitle, IconData icon,
|
||||
Color color, VoidCallback onTap) {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_forward_ios, size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
11
lib/app/modules/home/bindings/home_binding.dart
Normal file
11
lib/app/modules/home/bindings/home_binding.dart
Normal file
@ -0,0 +1,11 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/home/controllers/home_controller.dart';
|
||||
|
||||
class HomeBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<HomeController>(
|
||||
() => HomeController(),
|
||||
);
|
||||
}
|
||||
}
|
14
lib/app/modules/home/controllers/home_controller.dart
Normal file
14
lib/app/modules/home/controllers/home_controller.dart
Normal file
@ -0,0 +1,14 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
||||
|
||||
class HomeController extends GetxController {
|
||||
final AuthController _authController = Get.find<AuthController>();
|
||||
|
||||
// Getter untuk mendapatkan user dari auth controller
|
||||
get user => _authController.user;
|
||||
|
||||
// Metode untuk logout
|
||||
void logout() {
|
||||
_authController.logout();
|
||||
}
|
||||
}
|
63
lib/app/modules/home/views/home_view.dart
Normal file
63
lib/app/modules/home/views/home_view.dart
Normal file
@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:penyaluran_app/app/modules/home/controllers/home_controller.dart';
|
||||
|
||||
class HomeView extends GetView<HomeController> {
|
||||
const HomeView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Penyaluran App'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout),
|
||||
onPressed: controller.logout,
|
||||
tooltip: 'Logout',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Greeting
|
||||
Text(
|
||||
'Halo, ${controller.user?.email ?? 'Pengguna'}!',
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const Text(
|
||||
'Selamat datang di Penyaluran App',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Dashboard Content
|
||||
const Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Halaman Dashboard',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user