h-1 lebaran
This commit is contained in:
@ -7,6 +7,7 @@ import 'package:penyaluran_app/app/data/models/penyaluran_bantuan_model.dart';
|
||||
import 'package:penyaluran_app/app/data/models/laporan_penyaluran_model.dart';
|
||||
import 'package:penyaluran_app/app/data/models/user_model.dart';
|
||||
import 'package:penyaluran_app/app/data/models/stok_bantuan_model.dart';
|
||||
import 'package:penyaluran_app/app/data/models/lokasi_penyaluran_model.dart';
|
||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
||||
import 'package:penyaluran_app/app/services/supabase_service.dart';
|
||||
import 'package:penyaluran_app/app/routes/app_pages.dart';
|
||||
@ -45,6 +46,10 @@ class DonaturDashboardController extends GetxController {
|
||||
// Data untuk stok bantuan yang tersedia
|
||||
final RxList<StokBantuanModel> stokBantuan = <StokBantuanModel>[].obs;
|
||||
|
||||
// Data untuk lokasi penyaluran
|
||||
final RxList<LokasiPenyaluranModel> lokasiPenyaluran =
|
||||
<LokasiPenyaluranModel>[].obs;
|
||||
|
||||
// Indikator loading
|
||||
final RxBool isLoading = false.obs;
|
||||
|
||||
@ -199,6 +204,9 @@ class DonaturDashboardController extends GetxController {
|
||||
// Ambil data stok bantuan
|
||||
await fetchStokBantuan();
|
||||
|
||||
// Ambil data lokasi penyaluran
|
||||
await fetchLokasiPenyaluran();
|
||||
|
||||
// Ambil data notifikasi
|
||||
await fetchNotifikasi();
|
||||
} catch (e) {
|
||||
@ -233,7 +241,7 @@ class DonaturDashboardController extends GetxController {
|
||||
.from('penyaluran_bantuan')
|
||||
.select(
|
||||
'*, lokasi_penyaluran:lokasi_penyaluran_id(*), kategori:kategori_bantuan_id(*), petugas:petugas_id(*)')
|
||||
.order('tanggal_penyaluran', ascending: true);
|
||||
.order('tanggal_penyaluran', ascending: false);
|
||||
|
||||
// Konversi ke model lalu filter di sisi client
|
||||
final allJadwal = response
|
||||
@ -243,9 +251,7 @@ class DonaturDashboardController extends GetxController {
|
||||
|
||||
// Filter jadwal yang tanggalnya lebih besar dari hari ini
|
||||
jadwalPenyaluran.value = allJadwal
|
||||
.where((jadwal) =>
|
||||
jadwal.tanggalPenyaluran != null &&
|
||||
jadwal.tanggalPenyaluran!.isAfter(now))
|
||||
.where((jadwal) => jadwal.tanggalPenyaluran != null)
|
||||
.toList();
|
||||
} catch (e) {
|
||||
print('Error fetching jadwal penyaluran: $e');
|
||||
@ -306,6 +312,23 @@ class DonaturDashboardController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// Ambil data lokasi penyaluran
|
||||
Future<void> fetchLokasiPenyaluran() async {
|
||||
try {
|
||||
final response = await _supabaseService.client
|
||||
.from('lokasi_penyaluran')
|
||||
.select()
|
||||
.eq('is_lokasi_titip', true)
|
||||
.order('nama');
|
||||
|
||||
lokasiPenyaluran.value = (response as List<dynamic>)
|
||||
.map((data) => LokasiPenyaluranModel.fromJson(data))
|
||||
.toList();
|
||||
} catch (e) {
|
||||
print('Error fetching lokasi penyaluran: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Ambil data notifikasi
|
||||
Future<void> fetchNotifikasi() async {
|
||||
try {
|
||||
@ -386,6 +409,7 @@ class DonaturDashboardController extends GetxController {
|
||||
double jumlah,
|
||||
String deskripsi,
|
||||
String? skemaBantuanId,
|
||||
String? lokasiPenyaluranId,
|
||||
) async {
|
||||
try {
|
||||
isLoading.value = true;
|
||||
@ -426,15 +450,25 @@ class DonaturDashboardController extends GetxController {
|
||||
'tanggal_penitipan': DateTime.now().toIso8601String(),
|
||||
'foto_bantuan': fotoBantuanUrls,
|
||||
'is_uang': selectedStokBantuan.isUang ?? false,
|
||||
'skema_bantuan_id': skemaBantuanId,
|
||||
'lokasi_penyaluran_id': lokasiPenyaluranId,
|
||||
};
|
||||
|
||||
// Tambahkan skema bantuan jika ada
|
||||
if (skemaBantuanId != null && skemaBantuanId.isNotEmpty) {
|
||||
data['skema_bantuan_id'] = skemaBantuanId;
|
||||
}
|
||||
|
||||
// Simpan ke database
|
||||
await _supabaseService.client.from('penitipan_bantuan').insert(data);
|
||||
final response = await _supabaseService.client
|
||||
.from('penitipan_bantuan')
|
||||
.insert(data)
|
||||
.select('id')
|
||||
.single();
|
||||
|
||||
// Tampilkan pesan sukses
|
||||
Get.snackbar(
|
||||
'Berhasil',
|
||||
'Penitipan bantuan berhasil diinput',
|
||||
backgroundColor: Colors.green,
|
||||
colorText: Colors.white,
|
||||
duration: const Duration(seconds: 3),
|
||||
);
|
||||
|
||||
// Reset foto bantuan setelah berhasil disimpan
|
||||
resetFotoBantuan();
|
||||
@ -442,19 +476,13 @@ class DonaturDashboardController extends GetxController {
|
||||
// Ambil data penitipan bantuan yang baru
|
||||
await fetchPenitipanBantuan();
|
||||
|
||||
// Tampilkan pesan sukses
|
||||
Get.snackbar(
|
||||
'Berhasil',
|
||||
'Penitipan bantuan berhasil dikirim dan akan diproses oleh petugas desa',
|
||||
backgroundColor: Colors.green,
|
||||
colorText: Colors.white,
|
||||
duration: const Duration(seconds: 3),
|
||||
);
|
||||
// Kembali ke halaman utama
|
||||
Get.back();
|
||||
} catch (e) {
|
||||
print('Error creating penitipan bantuan: $e');
|
||||
Get.snackbar(
|
||||
'Gagal',
|
||||
'Terjadi kesalahan saat mengirim penitipan bantuan: $e',
|
||||
'Terjadi kesalahan: $e',
|
||||
backgroundColor: Colors.red,
|
||||
colorText: Colors.white,
|
||||
duration: const Duration(seconds: 3),
|
||||
@ -475,7 +503,7 @@ class DonaturDashboardController extends GetxController {
|
||||
.eq('id', lokasiId)
|
||||
.single();
|
||||
|
||||
if (response != null && response['nama'] != null) {
|
||||
if (response['nama'] != null) {
|
||||
return response['nama'] as String;
|
||||
}
|
||||
return null;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:penyaluran_app/app/modules/donatur/controllers/donatur_dashboard_controller.dart';
|
||||
import 'package:penyaluran_app/app/routes/app_pages.dart';
|
||||
import 'package:penyaluran_app/app/utils/format_helper.dart';
|
||||
import 'package:penyaluran_app/app/widgets/section_header.dart';
|
||||
|
||||
class DonaturDashboardView extends GetView<DonaturDashboardController> {
|
||||
@ -36,13 +36,57 @@ class DonaturDashboardView extends GetView<DonaturDashboardController> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Header DisalurKita dengan logo dan slogan
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.blue.withOpacity(0.1),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/logo-disalurkita.png',
|
||||
width: 50,
|
||||
height: 50,
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'DisalurKita',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1565C0),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
Text(
|
||||
'Salurkan dengan Pasti, Pantau dengan Bukti',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_buildWelcomeSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildStatisticSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildUpcomingEvents(),
|
||||
const SizedBox(height: 24),
|
||||
_buildRecentPenitipan(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -101,14 +145,24 @@ class DonaturDashboardView extends GetView<DonaturDashboardController> {
|
||||
child: CircleAvatar(
|
||||
radius: 30,
|
||||
backgroundColor: Colors.blue.shade100,
|
||||
backgroundImage: controller.profilePhotoUrl != null
|
||||
backgroundImage: controller.profilePhotoUrl != null &&
|
||||
controller.profilePhotoUrl!.isNotEmpty
|
||||
? NetworkImage(controller.profilePhotoUrl!)
|
||||
: null,
|
||||
child: controller.profilePhotoUrl == null
|
||||
? Icon(
|
||||
Icons.person,
|
||||
color: Colors.blue.shade700,
|
||||
size: 30,
|
||||
child: (controller.profilePhotoUrl == null ||
|
||||
controller.profilePhotoUrl!.isEmpty)
|
||||
? Text(
|
||||
controller.nama.isNotEmpty
|
||||
? controller.nama
|
||||
.toString()
|
||||
.substring(0, 1)
|
||||
.toUpperCase()
|
||||
: '?',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue.shade700,
|
||||
fontSize: 24,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
@ -263,7 +317,7 @@ class DonaturDashboardView extends GetView<DonaturDashboardController> {
|
||||
child: _buildStatCard(
|
||||
title: 'Diterima',
|
||||
value:
|
||||
'${controller.penitipanBantuan.where((p) => p.status == 'DITERIMA').length}',
|
||||
'${controller.penitipanBantuan.where((p) => p.status == 'TERVERIFIKASI').length}',
|
||||
icon: Icons.check_circle_outline,
|
||||
color: Colors.green,
|
||||
),
|
||||
@ -284,125 +338,6 @@ class DonaturDashboardView extends GetView<DonaturDashboardController> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUpcomingEvents() {
|
||||
final upcomingEvents = controller.jadwalPenyaluran
|
||||
.where((event) =>
|
||||
event.tanggalPenyaluran != null &&
|
||||
event.tanggalPenyaluran!.isAfter(DateTime.now()))
|
||||
.take(3)
|
||||
.toList();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SectionHeader(
|
||||
title: 'Jadwal Penyaluran',
|
||||
),
|
||||
Text(
|
||||
'Jadwal penyaluran bantuan terdekat',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// Navigasi ke tab jadwal penyaluran
|
||||
controller.activeTabIndex.value = 2;
|
||||
},
|
||||
child: Text(
|
||||
'Lihat Semua',
|
||||
style: TextStyle(color: Colors.blue.shade700),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (upcomingEvents.isEmpty)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Tidak ada jadwal penyaluran dalam waktu dekat',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
...upcomingEvents.map((event) => _buildEventCard(event)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRecentPenitipan() {
|
||||
final recentPenitipan = controller.penitipanBantuan.take(3).toList();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SectionHeader(
|
||||
title: 'Bantuan Terakhir',
|
||||
),
|
||||
Text(
|
||||
'Riwayat penitipan bantuan terakhir',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// Navigasi ke tab riwayat penitipan
|
||||
controller.activeTabIndex.value = 3;
|
||||
},
|
||||
child: Text(
|
||||
'Lihat Semua',
|
||||
style: TextStyle(color: Colors.blue.shade700),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (recentPenitipan.isEmpty)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Belum ada riwayat penitipan bantuan',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
...recentPenitipan.map((penitipan) => _buildPenitipanCard(penitipan)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow({
|
||||
required IconData icon,
|
||||
required Color iconColor,
|
||||
@ -545,7 +480,7 @@ class DonaturDashboardView extends GetView<DonaturDashboardController> {
|
||||
|
||||
Widget _buildEventCard(dynamic event) {
|
||||
final formattedDate = event.tanggalPenyaluran != null
|
||||
? DateFormat('dd MMMM yyyy', 'id_ID').format(event.tanggalPenyaluran!)
|
||||
? FormatHelper.formatDateTime(event.tanggalPenyaluran!)
|
||||
: 'Tanggal tidak tersedia';
|
||||
|
||||
return Container(
|
||||
@ -588,7 +523,8 @@ class DonaturDashboardView extends GetView<DonaturDashboardController> {
|
||||
),
|
||||
Text(
|
||||
event.tanggalPenyaluran != null
|
||||
? DateFormat('dd').format(event.tanggalPenyaluran!)
|
||||
? FormatHelper.formatDateTime(
|
||||
event.tanggalPenyaluran!)
|
||||
: '--',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
@ -640,8 +576,7 @@ class DonaturDashboardView extends GetView<DonaturDashboardController> {
|
||||
|
||||
Widget _buildPenitipanCard(dynamic penitipan) {
|
||||
final formattedDate = penitipan.tanggalPenitipan != null
|
||||
? DateFormat('dd MMMM yyyy', 'id_ID')
|
||||
.format(penitipan.tanggalPenitipan!)
|
||||
? FormatHelper.formatDateTime(penitipan.tanggalPenitipan!)
|
||||
: 'Tanggal tidak tersedia';
|
||||
|
||||
Color statusColor;
|
||||
|
@ -1,12 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:penyaluran_app/app/modules/donatur/controllers/donatur_dashboard_controller.dart';
|
||||
import 'package:penyaluran_app/app/data/models/penyaluran_bantuan_model.dart';
|
||||
import 'package:penyaluran_app/app/widgets/section_header.dart';
|
||||
import 'package:penyaluran_app/app/utils/format_helper.dart';
|
||||
|
||||
class DonaturJadwalDetailView extends GetView<DonaturDashboardController> {
|
||||
const DonaturJadwalDetailView({Key? key}) : super(key: key);
|
||||
const DonaturJadwalDetailView({super.key});
|
||||
|
||||
@override
|
||||
DonaturDashboardController get controller {
|
||||
@ -35,7 +35,6 @@ class DonaturJadwalDetailView extends GetView<DonaturDashboardController> {
|
||||
_buildDetailSection(jadwal),
|
||||
_buildPelaksanaSection(jadwal),
|
||||
_buildStatusSection(jadwal),
|
||||
_buildActionSection(jadwal),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -126,8 +125,7 @@ class DonaturJadwalDetailView extends GetView<DonaturDashboardController> {
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
DateFormat('EEEE, dd MMMM yyyy', 'id_ID')
|
||||
.format(jadwal.tanggalPenyaluran!),
|
||||
FormatHelper.formatDateIndonesian(jadwal.tanggalPenyaluran),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
@ -204,11 +202,26 @@ class DonaturJadwalDetailView extends GetView<DonaturDashboardController> {
|
||||
CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundColor: Colors.blue.shade100,
|
||||
child: Icon(
|
||||
Icons.person,
|
||||
color: Colors.blue.shade700,
|
||||
size: 30,
|
||||
),
|
||||
backgroundImage: jadwal.fotoPetugas != null &&
|
||||
jadwal.fotoPetugas.toString().isNotEmpty
|
||||
? NetworkImage(jadwal.fotoPetugas as String)
|
||||
: null,
|
||||
child: (jadwal.fotoPetugas == null ||
|
||||
jadwal.fotoPetugas.toString().isEmpty)
|
||||
? Text(
|
||||
jadwal.namaPetugas != null
|
||||
? jadwal.namaPetugas
|
||||
.toString()
|
||||
.substring(0, 1)
|
||||
.toUpperCase()
|
||||
: '?',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue.shade700,
|
||||
fontSize: 20,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
@ -254,50 +267,87 @@ class DonaturJadwalDetailView extends GetView<DonaturDashboardController> {
|
||||
children: [
|
||||
const SectionHeader(title: 'Status Penyaluran'),
|
||||
const SizedBox(height: 16),
|
||||
_buildStatusTimeline(jadwal),
|
||||
_buildStatusCard(jadwal),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusTimeline(PenyaluranBantuanModel jadwal) {
|
||||
Widget _buildStatusCard(PenyaluranBantuanModel jadwal) {
|
||||
final status = jadwal.status;
|
||||
final bool isCompleted = status == 'SELESAI';
|
||||
final bool isCancelled = status == 'DIBATALKAN';
|
||||
final bool isInProgress = status == 'DALAM_PROSES';
|
||||
final bool isCompleted = status == 'TERLAKSANA';
|
||||
final bool isCancelled = status == 'BATALTERLAKSANA';
|
||||
final bool isInProgress = status == 'AKTIF';
|
||||
final bool isScheduled = status == 'Dijadwalkan';
|
||||
|
||||
Color statusColor = Colors.blue;
|
||||
IconData statusIcon = Icons.schedule;
|
||||
String statusText = 'Dijadwalkan';
|
||||
|
||||
if (isCompleted) {
|
||||
statusColor = Colors.green;
|
||||
statusIcon = Icons.check_circle;
|
||||
statusText = 'Terlaksana';
|
||||
} else if (isCancelled) {
|
||||
statusColor = Colors.red;
|
||||
statusIcon = Icons.cancel;
|
||||
statusText = 'Batal Terlaksana';
|
||||
} else if (isInProgress) {
|
||||
statusColor = Colors.blue;
|
||||
statusIcon = Icons.sync;
|
||||
statusText = 'Aktif';
|
||||
} else if (isScheduled) {
|
||||
statusColor = Colors.orange;
|
||||
statusIcon = Icons.schedule;
|
||||
statusText = 'Dijadwalkan';
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
_buildTimelineItem(
|
||||
title: 'Dijadwalkan',
|
||||
date: jadwal.createdAt != null
|
||||
? DateFormat('dd MMM yyyy', 'id_ID').format(jadwal.createdAt!)
|
||||
: '-',
|
||||
isCompleted: true,
|
||||
isFirst: true,
|
||||
),
|
||||
_buildTimelineItem(
|
||||
title: 'Dalam Proses',
|
||||
date: isInProgress || isCompleted
|
||||
? jadwal.tanggalPenyaluran != null
|
||||
? DateFormat('dd MMM yyyy', 'id_ID')
|
||||
.format(jadwal.tanggalPenyaluran!)
|
||||
: '-'
|
||||
: '-',
|
||||
isCompleted: isInProgress || isCompleted,
|
||||
isCancelled: isCancelled,
|
||||
),
|
||||
_buildTimelineItem(
|
||||
title: 'Selesai',
|
||||
date: isCompleted
|
||||
? jadwal.tanggalSelesai != null
|
||||
? DateFormat('dd MMM yyyy', 'id_ID')
|
||||
.format(jadwal.tanggalSelesai!)
|
||||
: '-'
|
||||
: '-',
|
||||
isCompleted: isCompleted,
|
||||
isCancelled: isCancelled,
|
||||
isLast: true,
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: statusColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: statusColor.withOpacity(0.3)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(statusIcon, color: statusColor, size: 28),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
statusText,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: statusColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildStatusDetailItem(
|
||||
title: 'Tanggal Dijadwalkan',
|
||||
value: FormatHelper.formatDateIndonesian(jadwal.createdAt),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildStatusDetailItem(
|
||||
title: 'Tanggal Penyaluran',
|
||||
value:
|
||||
FormatHelper.formatDateIndonesian(jadwal.tanggalPenyaluran),
|
||||
),
|
||||
if (isCompleted) ...[
|
||||
const SizedBox(height: 8),
|
||||
_buildStatusDetailItem(
|
||||
title: 'Tanggal Selesai',
|
||||
value:
|
||||
FormatHelper.formatDateIndonesian(jadwal.tanggalSelesai),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (isCancelled) ...[
|
||||
const SizedBox(height: 16),
|
||||
@ -333,7 +383,7 @@ class DonaturJadwalDetailView extends GetView<DonaturDashboardController> {
|
||||
const SizedBox(height: 8),
|
||||
if (jadwal.tanggalPembatalan != null)
|
||||
Text(
|
||||
'Dibatalkan pada: ${DateFormat('dd MMMM yyyy', 'id_ID').format(jadwal.tanggalPembatalan!)}',
|
||||
'Dibatalkan pada: ${FormatHelper.formatDateIndonesian(jadwal.tanggalPembatalan)}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.red.shade700,
|
||||
@ -347,159 +397,29 @@ class DonaturJadwalDetailView extends GetView<DonaturDashboardController> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTimelineItem({
|
||||
required String title,
|
||||
required String date,
|
||||
required bool isCompleted,
|
||||
bool isFirst = false,
|
||||
bool isLast = false,
|
||||
bool isCancelled = false,
|
||||
}) {
|
||||
Widget _buildStatusDetailItem(
|
||||
{required String title, required String value}) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 20,
|
||||
child: Column(
|
||||
children: [
|
||||
if (!isFirst)
|
||||
Container(
|
||||
width: 2,
|
||||
height: 20,
|
||||
color: isCompleted
|
||||
? Colors.green
|
||||
: isCancelled
|
||||
? Colors.red
|
||||
: Colors.grey.shade300,
|
||||
),
|
||||
Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: isCompleted
|
||||
? Colors.green
|
||||
: isCancelled
|
||||
? Colors.red
|
||||
: Colors.grey.shade300,
|
||||
border: Border.all(
|
||||
color: isCompleted
|
||||
? Colors.green
|
||||
: isCancelled
|
||||
? Colors.red
|
||||
: Colors.grey.shade300,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: isCompleted
|
||||
? const Icon(Icons.check, size: 12, color: Colors.white)
|
||||
: isCancelled
|
||||
? const Icon(Icons.close, size: 12, color: Colors.white)
|
||||
: null,
|
||||
),
|
||||
if (!isLast)
|
||||
Container(
|
||||
width: 2,
|
||||
height: 20,
|
||||
color: isCompleted && !isCancelled
|
||||
? Colors.green
|
||||
: Colors.grey.shade300,
|
||||
),
|
||||
],
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade700,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isCompleted
|
||||
? Colors.black
|
||||
: isCancelled
|
||||
? Colors.red
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
date,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isCompleted
|
||||
? Colors.grey.shade700
|
||||
: isCancelled
|
||||
? Colors.red.shade300
|
||||
: Colors.grey.shade400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionSection(PenyaluranBantuanModel jadwal) {
|
||||
if (jadwal.status == 'DIBATALKAN') {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SectionHeader(title: 'Tindakan'),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () => _hubungiPetugas(jadwal),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20, vertical: 12),
|
||||
backgroundColor: Colors.green,
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.chat_outlined),
|
||||
label: const Text('Hubungi Petugas'),
|
||||
),
|
||||
),
|
||||
if (jadwal.status == 'SELESAI') ...[
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () => _lihatLaporan(jadwal),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20, vertical: 12),
|
||||
foregroundColor: Colors.blue,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.description_outlined),
|
||||
label: const Text('Lihat Laporan'),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoItem({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:penyaluran_app/app/modules/donatur/controllers/donatur_dashboard_controller.dart';
|
||||
import 'package:penyaluran_app/app/utils/format_helper.dart';
|
||||
import 'package:penyaluran_app/app/widgets/section_header.dart';
|
||||
|
||||
class DonaturJadwalView extends GetView<DonaturDashboardController> {
|
||||
@ -97,7 +98,7 @@ class DonaturJadwalView extends GetView<DonaturDashboardController> {
|
||||
for (var jadwal in controller.jadwalPenyaluran) {
|
||||
if (jadwal.tanggalPenyaluran != null) {
|
||||
String monthYear =
|
||||
DateFormat('MMMM yyyy', 'id_ID').format(jadwal.tanggalPenyaluran!);
|
||||
FormatHelper.formatDate(jadwal.tanggalPenyaluran!, format: 'MMMM');
|
||||
|
||||
if (!groupedJadwal.containsKey(monthYear)) {
|
||||
groupedJadwal[monthYear] = [];
|
||||
@ -110,9 +111,14 @@ class DonaturJadwalView extends GetView<DonaturDashboardController> {
|
||||
// Urutkan kunci (bulan) secara kronologis
|
||||
List<String> sortedMonths = groupedJadwal.keys.toList()
|
||||
..sort((a, b) {
|
||||
DateTime dateA = DateFormat('MMMM yyyy', 'id_ID').parse(a);
|
||||
DateTime dateB = DateFormat('MMMM yyyy', 'id_ID').parse(b);
|
||||
return dateA.compareTo(dateB);
|
||||
try {
|
||||
DateTime dateA = DateFormat('MMMM yyyy', 'id_ID').parse(a);
|
||||
DateTime dateB = DateFormat('MMMM yyyy', 'id_ID').parse(b);
|
||||
return dateA.compareTo(dateB);
|
||||
} catch (e) {
|
||||
// Fallback sorting jika parse error
|
||||
return a.compareTo(b);
|
||||
}
|
||||
});
|
||||
|
||||
return ListView(
|
||||
@ -158,28 +164,27 @@ class DonaturJadwalView extends GetView<DonaturDashboardController> {
|
||||
|
||||
Widget _buildJadwalCard(dynamic jadwal) {
|
||||
final formattedDate = jadwal.tanggalPenyaluran != null
|
||||
? DateFormat('EEEE, dd MMMM yyyy', 'id_ID')
|
||||
.format(jadwal.tanggalPenyaluran!)
|
||||
? FormatHelper.formatDateTime(jadwal.tanggalPenyaluran!)
|
||||
: 'Tanggal tidak tersedia';
|
||||
|
||||
String statusText = 'Akan Datang';
|
||||
String statusText = 'Dijadwalkan';
|
||||
Color statusColor = Colors.blue;
|
||||
|
||||
switch (jadwal.status) {
|
||||
case 'SELESAI':
|
||||
statusText = 'Selesai';
|
||||
case 'TERLAKSANA':
|
||||
statusText = 'Terlaksana';
|
||||
statusColor = Colors.green;
|
||||
break;
|
||||
case 'DIBATALKAN':
|
||||
statusText = 'Dibatalkan';
|
||||
case 'BATALTERLAKSANA':
|
||||
statusText = 'Batal Terlaksana';
|
||||
statusColor = Colors.red;
|
||||
break;
|
||||
case 'DALAM_PROSES':
|
||||
statusText = 'Dalam Proses';
|
||||
statusColor = Colors.orange;
|
||||
case 'AKTIF':
|
||||
statusText = 'Aktif';
|
||||
statusColor = Colors.blue;
|
||||
break;
|
||||
default:
|
||||
statusText = 'Akan Datang';
|
||||
statusText = 'Dijadwalkan';
|
||||
statusColor = Colors.blue;
|
||||
}
|
||||
|
||||
@ -248,8 +253,9 @@ class DonaturJadwalView extends GetView<DonaturDashboardController> {
|
||||
),
|
||||
child: Text(
|
||||
jadwal.tanggalPenyaluran != null
|
||||
? DateFormat('MMM', 'id_ID')
|
||||
.format(jadwal.tanggalPenyaluran!)
|
||||
? FormatHelper.formatDate(
|
||||
jadwal.tanggalPenyaluran!,
|
||||
format: 'MMM')
|
||||
.toUpperCase()
|
||||
: 'TBD',
|
||||
style: const TextStyle(
|
||||
@ -265,8 +271,9 @@ class DonaturJadwalView extends GetView<DonaturDashboardController> {
|
||||
child: Center(
|
||||
child: Text(
|
||||
jadwal.tanggalPenyaluran != null
|
||||
? DateFormat('dd')
|
||||
.format(jadwal.tanggalPenyaluran!)
|
||||
? FormatHelper.formatDate(
|
||||
jadwal.tanggalPenyaluran!,
|
||||
format: 'dd')
|
||||
: '-',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
@ -459,11 +466,11 @@ class DonaturJadwalView extends GetView<DonaturDashboardController> {
|
||||
|
||||
IconData _getStatusIcon(String? status) {
|
||||
switch (status) {
|
||||
case 'SELESAI':
|
||||
case 'TERLAKSANA':
|
||||
return Icons.check_circle;
|
||||
case 'DIBATALKAN':
|
||||
case 'BATALTERLAKSANA':
|
||||
return Icons.cancel;
|
||||
case 'DALAM_PROSES':
|
||||
case 'AKTIF':
|
||||
return Icons.timelapse;
|
||||
default:
|
||||
return Icons.event_available;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:penyaluran_app/app/modules/donatur/controllers/donatur_dashboard_controller.dart';
|
||||
import 'package:penyaluran_app/app/utils/format_helper.dart';
|
||||
import 'package:penyaluran_app/app/widgets/widgets.dart';
|
||||
|
||||
class DonaturRiwayatPenitipanView extends GetView<DonaturDashboardController> {
|
||||
DonaturRiwayatPenitipanView({super.key});
|
||||
@ -60,8 +61,7 @@ class DonaturRiwayatPenitipanView extends GetView<DonaturDashboardController> {
|
||||
final kategoriNama = item.kategoriBantuan?.nama?.toLowerCase() ?? '';
|
||||
final deskripsi = item.deskripsi?.toLowerCase() ?? '';
|
||||
final tanggal = item.tanggalPenitipan != null
|
||||
? DateFormat('dd MMMM yyyy', 'id_ID')
|
||||
.format(item.tanggalPenitipan!)
|
||||
? FormatHelper.formatDateTime(item.tanggalPenitipan!)
|
||||
.toLowerCase()
|
||||
: '';
|
||||
|
||||
@ -214,8 +214,7 @@ class DonaturRiwayatPenitipanView extends GetView<DonaturDashboardController> {
|
||||
Widget _buildPenitipanCard(
|
||||
BuildContext context, dynamic penitipan, Color statusColor) {
|
||||
final formattedDate = penitipan.tanggalPenitipan != null
|
||||
? DateFormat('dd MMMM yyyy', 'id_ID')
|
||||
.format(penitipan.tanggalPenitipan!)
|
||||
? FormatHelper.formatDateTime(penitipan.tanggalPenitipan!)
|
||||
: 'Tanggal tidak tersedia';
|
||||
|
||||
IconData statusIcon;
|
||||
@ -435,61 +434,6 @@ class DonaturRiwayatPenitipanView extends GetView<DonaturDashboardController> {
|
||||
return id != null ? 'Petugas Desa' : 'Tidak ada petugas';
|
||||
}
|
||||
|
||||
void showFullScreenImage(String imageUrl) {
|
||||
Get.dialog(
|
||||
Dialog(
|
||||
insetPadding: EdgeInsets.zero,
|
||||
child: Container(
|
||||
color: Colors.black,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
InteractiveViewer(
|
||||
panEnabled: true,
|
||||
minScale: 0.5,
|
||||
maxScale: 4,
|
||||
child: Image.network(
|
||||
imageUrl,
|
||||
fit: BoxFit.contain,
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
value: loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded /
|
||||
loadingProgress.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 20,
|
||||
right: 20,
|
||||
child: GestureDetector(
|
||||
onTap: () => Get.back(),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text('Detail Penitipan'),
|
||||
@ -509,8 +453,7 @@ class DonaturRiwayatPenitipanView extends GetView<DonaturDashboardController> {
|
||||
_buildInfoRow(
|
||||
'Tanggal Penitipan',
|
||||
penitipan.tanggalPenitipan != null
|
||||
? DateFormat('dd MMMM yyyy', 'id_ID')
|
||||
.format(penitipan.tanggalPenitipan!)
|
||||
? FormatHelper.formatDateTime(penitipan.tanggalPenitipan!)
|
||||
: 'Tanggal tidak tersedia',
|
||||
),
|
||||
_buildInfoRow(
|
||||
@ -520,8 +463,7 @@ class DonaturRiwayatPenitipanView extends GetView<DonaturDashboardController> {
|
||||
if (penitipan.tanggalVerifikasi != null)
|
||||
_buildInfoRow(
|
||||
'Tanggal Verifikasi',
|
||||
DateFormat('dd MMMM yyyy HH:mm', 'id_ID')
|
||||
.format(penitipan.tanggalVerifikasi!),
|
||||
FormatHelper.formatDateTime(penitipan.tanggalVerifikasi!),
|
||||
),
|
||||
if (penitipan.deskripsi != null &&
|
||||
penitipan.deskripsi!.isNotEmpty)
|
||||
@ -543,8 +485,10 @@ class DonaturRiwayatPenitipanView extends GetView<DonaturDashboardController> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
onTap: () =>
|
||||
showFullScreenImage(penitipan.fotoBantuan!.first),
|
||||
onTap: () => ShowImageDialog.showFullScreen(
|
||||
context,
|
||||
penitipan.fotoBantuan!.first,
|
||||
),
|
||||
child: Container(
|
||||
height: 200,
|
||||
width: double.infinity,
|
||||
@ -572,8 +516,10 @@ class DonaturRiwayatPenitipanView extends GetView<DonaturDashboardController> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
onTap: () =>
|
||||
showFullScreenImage(penitipan.fotoBuktiSerahTerima!),
|
||||
onTap: () => ShowImageDialog.showFullScreen(
|
||||
context,
|
||||
penitipan.fotoBuktiSerahTerima!,
|
||||
),
|
||||
child: Container(
|
||||
height: 200,
|
||||
width: double.infinity,
|
||||
|
@ -4,7 +4,6 @@ import 'package:penyaluran_app/app/modules/donatur/controllers/donatur_dashboard
|
||||
import 'package:penyaluran_app/app/widgets/section_header.dart';
|
||||
import 'package:penyaluran_app/app/data/models/stok_bantuan_model.dart';
|
||||
import 'package:penyaluran_app/app/utils/format_helper.dart';
|
||||
import 'package:penyaluran_app/app/utils/date_helper.dart';
|
||||
|
||||
class DonaturSkemaView extends GetView<DonaturDashboardController> {
|
||||
const DonaturSkemaView({super.key});
|
||||
@ -549,14 +548,14 @@ class DonaturSkemaView extends GetView<DonaturDashboardController> {
|
||||
|
||||
int days = difference.inDays;
|
||||
if (days > 0) {
|
||||
return 'Batas waktu: ${days} hari lagi';
|
||||
return 'Batas waktu: $days hari lagi';
|
||||
} else {
|
||||
int hours = difference.inHours;
|
||||
if (hours > 0) {
|
||||
return 'Batas waktu: ${hours} jam lagi';
|
||||
return 'Batas waktu: $hours jam lagi';
|
||||
} else {
|
||||
int minutes = difference.inMinutes;
|
||||
return 'Batas waktu: ${minutes} menit lagi';
|
||||
return 'Batas waktu: $minutes menit lagi';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -597,20 +596,20 @@ class DonaturSkemaView extends GetView<DonaturDashboardController> {
|
||||
}
|
||||
}
|
||||
// Format nilai sebagai Rupiah menggunakan DateHelper
|
||||
return DateHelper.formatRupiah(nilai);
|
||||
return FormatHelper.formatRupiah(nilai);
|
||||
}
|
||||
|
||||
// Jika bukan uang, kembalikan nilai + satuan (jika ada)
|
||||
return '${jumlahDiterimaPerOrang} ${stokBantuan.satuan ?? ''}';
|
||||
return '$jumlahDiterimaPerOrang ${stokBantuan.satuan ?? ''}';
|
||||
}
|
||||
|
||||
String _formatRupiah(dynamic amount) {
|
||||
if (amount is num) {
|
||||
return DateHelper.formatRupiah(amount);
|
||||
return FormatHelper.formatRupiah(amount);
|
||||
} else if (amount is String) {
|
||||
try {
|
||||
double nilai = double.parse(amount);
|
||||
return DateHelper.formatRupiah(nilai);
|
||||
return FormatHelper.formatRupiah(nilai);
|
||||
} catch (e) {
|
||||
return 'Rp ${amount.replaceAllMapped(RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'), (Match m) => '${m[1]}.')}';
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class DonaturView extends GetView<DonaturDashboardController> {
|
||||
title: Obx(() {
|
||||
switch (controller.activeTabIndex.value) {
|
||||
case 0:
|
||||
return const Text('Dashboard Donatur');
|
||||
return const Text('Dashboard');
|
||||
case 1:
|
||||
return const Text('Skema Bantuan');
|
||||
case 2:
|
||||
@ -44,7 +44,7 @@ class DonaturView extends GetView<DonaturDashboardController> {
|
||||
case 4:
|
||||
return const Text('Laporan Penyaluran');
|
||||
default:
|
||||
return const Text('Dashboard Donatur');
|
||||
return const Text('Dashboard');
|
||||
}
|
||||
}),
|
||||
leading: IconButton(
|
||||
@ -201,12 +201,20 @@ class DonaturView extends GetView<DonaturDashboardController> {
|
||||
controller.profilePhotoUrl!.isNotEmpty
|
||||
? NetworkImage(controller.profilePhotoUrl!)
|
||||
: null,
|
||||
child: controller.profilePhotoUrl == null ||
|
||||
controller.profilePhotoUrl!.isEmpty
|
||||
? const Icon(
|
||||
Icons.person,
|
||||
color: Colors.white,
|
||||
size: 40,
|
||||
child: (controller.profilePhotoUrl == null ||
|
||||
controller.profilePhotoUrl!.isEmpty)
|
||||
? Text(
|
||||
controller.nama.isNotEmpty
|
||||
? controller.nama
|
||||
.toString()
|
||||
.substring(0, 1)
|
||||
.toUpperCase()
|
||||
: '?',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue.shade700,
|
||||
fontSize: 24,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
@ -284,44 +292,175 @@ class DonaturView extends GetView<DonaturDashboardController> {
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.person_outline),
|
||||
title: const Text('Profil'),
|
||||
_buildMenuCategory('Menu Utama'),
|
||||
Obx(() => _buildMenuItem(
|
||||
icon: Icons.dashboard_outlined,
|
||||
activeIcon: Icons.dashboard,
|
||||
title: 'Dashboard',
|
||||
isSelected: controller.activeTabIndex.value == 0,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
controller.activeTabIndex.value = 0;
|
||||
},
|
||||
)),
|
||||
Obx(() => _buildMenuItem(
|
||||
icon: Icons.description_outlined,
|
||||
activeIcon: Icons.description,
|
||||
title: 'Skema Bantuan',
|
||||
isSelected: controller.activeTabIndex.value == 1,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
controller.activeTabIndex.value = 1;
|
||||
},
|
||||
)),
|
||||
Obx(() => _buildMenuItem(
|
||||
icon: Icons.calendar_today_outlined,
|
||||
activeIcon: Icons.calendar_today,
|
||||
title: 'Jadwal Penyaluran',
|
||||
isSelected: controller.activeTabIndex.value == 2,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
controller.activeTabIndex.value = 2;
|
||||
},
|
||||
)),
|
||||
Obx(() => _buildMenuItem(
|
||||
icon: Icons.add_box_outlined,
|
||||
activeIcon: Icons.add_box,
|
||||
title: 'Penitipan Bantuan',
|
||||
isSelected: controller.activeTabIndex.value == 3,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
controller.activeTabIndex.value = 3;
|
||||
},
|
||||
)),
|
||||
Obx(() => _buildMenuItem(
|
||||
icon: Icons.assignment_outlined,
|
||||
activeIcon: Icons.assignment,
|
||||
title: 'Laporan Penyaluran',
|
||||
isSelected: controller.activeTabIndex.value == 4,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
controller.activeTabIndex.value = 4;
|
||||
},
|
||||
)),
|
||||
_buildMenuCategory('Pengaturan'),
|
||||
_buildMenuItem(
|
||||
icon: Icons.person_outline,
|
||||
activeIcon: Icons.person,
|
||||
title: 'Profil',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Get.toNamed('/profile');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.history),
|
||||
title: const Text('Riwayat Donasi'),
|
||||
_buildMenuItem(
|
||||
icon: Icons.info_outline,
|
||||
activeIcon: Icons.info,
|
||||
title: 'Tentang Kami',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// TODO: Implementasi riwayat donasi
|
||||
Get.toNamed('/about');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings_outlined),
|
||||
title: const Text('Pengaturan'),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
// TODO: Implementasi pengaturan
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout),
|
||||
title: const Text('Keluar'),
|
||||
_buildMenuItem(
|
||||
icon: Icons.logout,
|
||||
title: 'Keluar',
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
controller.logout();
|
||||
},
|
||||
isLogout: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Text(
|
||||
'© ${DateTime.now().year} DisalurKita',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuCategory(String title) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuItem({
|
||||
required IconData icon,
|
||||
IconData? activeIcon,
|
||||
required String title,
|
||||
bool isSelected = false,
|
||||
String? badge,
|
||||
required Function() onTap,
|
||||
bool isLogout = false,
|
||||
}) {
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? AppTheme.primaryColor.withOpacity(0.1)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
isSelected ? (activeIcon ?? icon) : icon,
|
||||
color: isSelected
|
||||
? AppTheme.primaryColor
|
||||
: (isLogout ? Colors.red : null),
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: isSelected
|
||||
? AppTheme.primaryColor
|
||||
: (isLogout ? Colors.red : null),
|
||||
fontWeight: isSelected ? FontWeight.bold : null,
|
||||
),
|
||||
),
|
||||
trailing: badge != null
|
||||
? Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 20,
|
||||
minHeight: 20,
|
||||
),
|
||||
child: Text(
|
||||
badge,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
onTap: onTap,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user