Perbarui DonaturController dan tampilan terkait untuk mendukung stok bantuan
- Tambahkan metode fetchStokBantuan di DonaturController untuk mengambil data stok bantuan - Perbarui tampilan DaftarDonaturView untuk navigasi ke detail donatur - Tambahkan rute dan tampilan detail donatur - Ganti beberapa warna ikon dan teks untuk konsistensi tampilan - Gunakan dialog DetailPenitipanDialog untuk menampilkan detail penitipan
This commit is contained in:
@ -5,6 +5,7 @@ import 'package:penyaluran_app/app/data/models/penitipan_bantuan_model.dart';
|
||||
import 'package:penyaluran_app/app/modules/petugas_desa/controllers/penitipan_bantuan_controller.dart';
|
||||
import 'package:penyaluran_app/app/theme/app_theme.dart';
|
||||
import 'package:penyaluran_app/app/utils/date_formatter.dart';
|
||||
import 'package:penyaluran_app/app/widgets/detail_penitipan_dialog.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class PenitipanView extends GetView<PenitipanBantuanController> {
|
||||
@ -694,198 +695,18 @@ class PenitipanView extends GetView<PenitipanBantuanController> {
|
||||
final kategoriSatuan = item.kategoriBantuan?.satuan ??
|
||||
controller.getKategoriSatuan(item.stokBantuanId);
|
||||
|
||||
// Cek apakah penitipan berbentuk uang
|
||||
final isUang = item.isUang ?? false;
|
||||
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text('Detail Penitipan'),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildDetailItem('Donatur', donaturNama),
|
||||
_buildDetailItem('Status', item.status ?? 'Tidak diketahui'),
|
||||
_buildDetailItem('Kategori Bantuan', kategoriNama),
|
||||
_buildDetailItem(
|
||||
'Jumlah',
|
||||
isUang
|
||||
? 'Rp ${DateFormatter.formatNumber(item.jumlah)}'
|
||||
: '${DateFormatter.formatNumber(item.jumlah)} $kategoriSatuan'),
|
||||
if (isUang) _buildDetailItem('Jenis Bantuan', 'Uang (Rupiah)'),
|
||||
_buildDetailItem(
|
||||
'Deskripsi', item.deskripsi ?? 'Tidak ada deskripsi'),
|
||||
_buildDetailItem(
|
||||
'Tanggal Penitipan',
|
||||
DateFormatter.formatDateTime(item.tanggalPenitipan,
|
||||
defaultValue: 'Tidak ada tanggal'),
|
||||
),
|
||||
if (item.tanggalVerifikasi != null)
|
||||
_buildDetailItem(
|
||||
'Tanggal Verifikasi',
|
||||
DateFormatter.formatDateTime(item.tanggalVerifikasi),
|
||||
),
|
||||
if (item.status == 'TERVERIFIKASI' && item.petugasDesaId != null)
|
||||
_buildDetailItem(
|
||||
'Diverifikasi Oleh',
|
||||
controller.getPetugasDesaNama(item.petugasDesaId),
|
||||
),
|
||||
_buildDetailItem('Tanggal Dibuat',
|
||||
DateFormatter.formatDateTime(item.createdAt)),
|
||||
if (item.alasanPenolakan != null &&
|
||||
item.alasanPenolakan!.isNotEmpty)
|
||||
_buildDetailItem('Alasan Penolakan', item.alasanPenolakan!),
|
||||
|
||||
// Foto Bantuan
|
||||
if (!isUang &&
|
||||
item.fotoBantuan != null &&
|
||||
item.fotoBantuan!.isNotEmpty)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Foto Bantuan:',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: item.fotoBantuan!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
_showFullScreenImage(
|
||||
context, item.fotoBantuan![index]);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.network(
|
||||
item.fotoBantuan![index],
|
||||
height: 100,
|
||||
width: 100,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Container(
|
||||
height: 100,
|
||||
width: 100,
|
||||
color: Colors.grey.shade300,
|
||||
child: const Icon(Icons.error),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Bukti Transfer (untuk bantuan uang)
|
||||
if (isUang &&
|
||||
item.fotoBantuan != null &&
|
||||
item.fotoBantuan!.isNotEmpty)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Bukti Transfer:',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: item.fotoBantuan!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
_showFullScreenImage(
|
||||
context, item.fotoBantuan![index]);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.network(
|
||||
item.fotoBantuan![index],
|
||||
height: 100,
|
||||
width: 100,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Container(
|
||||
height: 100,
|
||||
width: 100,
|
||||
color: Colors.grey.shade300,
|
||||
child: const Icon(Icons.error),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Bukti Serah Terima
|
||||
if (item.fotoBuktiSerahTerima != null &&
|
||||
item.fotoBuktiSerahTerima!.isNotEmpty)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Bukti Serah Terima:',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
_showFullScreenImage(
|
||||
context, item.fotoBuktiSerahTerima!);
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.network(
|
||||
item.fotoBuktiSerahTerima!,
|
||||
height: 200,
|
||||
width: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Container(
|
||||
height: 200,
|
||||
width: double.infinity,
|
||||
color: Colors.grey.shade300,
|
||||
child: const Icon(Icons.error),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
child: const Text('Tutup'),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Gunakan dialog yang sudah dibuat
|
||||
DetailPenitipanDialog.show(
|
||||
context: context,
|
||||
item: item,
|
||||
donaturNama: donaturNama,
|
||||
kategoriNama: kategoriNama,
|
||||
kategoriSatuan: kategoriSatuan,
|
||||
getPetugasDesaNama: (String? id) =>
|
||||
controller.getPetugasDesaNama(id) ?? 'Tidak diketahui',
|
||||
showFullScreenImage: (String imageUrl) {
|
||||
DetailPenitipanDialog.showFullScreenImage(context, imageUrl);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user