membuat tampilan lebih menarik
This commit is contained in:
@ -2,11 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:penyaluran_app/app/modules/warga/controllers/warga_dashboard_controller.dart';
|
||||
import 'package:penyaluran_app/app/routes/app_pages.dart';
|
||||
import 'package:penyaluran_app/app/widgets/bantuan_card.dart';
|
||||
import 'package:penyaluran_app/app/widgets/section_header.dart';
|
||||
import 'package:penyaluran_app/app/data/models/penerima_penyaluran_model.dart';
|
||||
import 'package:penyaluran_app/app/modules/warga/views/form_pengaduan_view.dart';
|
||||
|
||||
class WargaDashboardView extends GetView<WargaDashboardController> {
|
||||
const WargaDashboardView({super.key});
|
||||
@ -32,8 +28,6 @@ class WargaDashboardView extends GetView<WargaDashboardController> {
|
||||
_buildStatisticSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildPenerimaanSummary(),
|
||||
const SizedBox(height: 24),
|
||||
_buildRecentPenerimaan(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -588,285 +582,4 @@ class WargaDashboardView extends GetView<WargaDashboardController> {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRecentPenerimaan() {
|
||||
if (controller.penerimaPenyaluran.isEmpty) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade50,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
SectionHeader(
|
||||
title: 'Bantuan Terbaru',
|
||||
titleStyle: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue.shade800,
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: Colors.grey.shade200),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.info_outline,
|
||||
size: 48,
|
||||
color: Colors.grey.shade400,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Belum Ada Bantuan',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey.shade700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Data bantuan akan muncul di sini ketika Anda menerima bantuan.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final maxItems = controller.penerimaPenyaluran.length > 2
|
||||
? 2
|
||||
: controller.penerimaPenyaluran.length;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade50,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SectionHeader(
|
||||
title: 'Bantuan Terbaru',
|
||||
viewAllText: 'Lihat Semua',
|
||||
onViewAll: () {
|
||||
Get.toNamed(Routes.wargaPenerimaan);
|
||||
},
|
||||
titleStyle: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue.shade800,
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: maxItems,
|
||||
itemBuilder: (context, index) {
|
||||
final item = controller.penerimaPenyaluran[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: BantuanCard(
|
||||
item: item,
|
||||
isCompact: true,
|
||||
onTap: () {
|
||||
Get.toNamed('/warga/detail-penerimaan',
|
||||
arguments: {'id': item.id});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (controller.penerimaPenyaluran.length > 2)
|
||||
Center(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Get.toNamed(Routes.wargaPenerimaan);
|
||||
},
|
||||
icon: const Icon(Icons.list),
|
||||
label: const Text('Lihat Semua Bantuan'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: Colors.blue,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showBuatPengaduanDialog(BuildContext context) {
|
||||
// Daftar penerimaan bantuan yang dapat diadukan (status DITERIMA)
|
||||
final bantuanDiterima = controller.penerimaPenyaluran
|
||||
.where((item) => item.statusPenerimaan == 'DITERIMA')
|
||||
.toList();
|
||||
|
||||
// Jika tidak ada bantuan yang diterima
|
||||
if (bantuanDiterima.isEmpty) {
|
||||
Get.snackbar(
|
||||
'Informasi',
|
||||
'Tidak ada bantuan yang sudah diterima untuk dapat diajukan pengaduan',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
backgroundColor: Colors.orange,
|
||||
colorText: Colors.white,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Variabel untuk menyimpan pilihan penerimaan
|
||||
PenerimaPenyaluranModel? selectedPenerimaan = bantuanDiterima.first;
|
||||
|
||||
Get.dialog(
|
||||
Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.report_problem,
|
||||
color: Colors.orange.shade700,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
const Text(
|
||||
'Buat Pengaduan Baru',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
'Pilih Bantuan yang Ingin Diadukan:',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<PenerimaPenyaluranModel>(
|
||||
isExpanded: true,
|
||||
value: selectedPenerimaan,
|
||||
items: bantuanDiterima.map((item) {
|
||||
String displayText = item.namaPenyaluran ?? 'Bantuan';
|
||||
if (item.tanggalPenerimaan != null) {
|
||||
displayText +=
|
||||
' (${DateFormat('dd/MM/yyyy').format(item.tanggalPenerimaan!)})';
|
||||
}
|
||||
|
||||
return DropdownMenuItem<PenerimaPenyaluranModel>(
|
||||
value: item,
|
||||
child: Text(displayText),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
selectedPenerimaan = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
if (selectedPenerimaan != null) {
|
||||
Get.back();
|
||||
Get.to(
|
||||
() => FormPengaduanView(
|
||||
uidPenerimaan: selectedPenerimaan!.id.toString(),
|
||||
),
|
||||
transition: Transition.rightToLeft,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
);
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.orange.shade700,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Lanjutkan',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user