membuat tampilan lebih menarik

This commit is contained in:
Khafidh Fuadi
2025-03-27 22:31:14 +07:00
parent f6d3eef2cf
commit c008020705
44 changed files with 6260 additions and 3195 deletions

View File

@ -4,7 +4,7 @@ import 'package:syncfusion_flutter_calendar/calendar.dart';
import 'package:penyaluran_app/app/data/models/penyaluran_bantuan_model.dart';
import 'package:penyaluran_app/app/modules/petugas_desa/controllers/jadwal_penyaluran_controller.dart';
import 'package:penyaluran_app/app/theme/app_theme.dart';
import 'package:penyaluran_app/app/utils/date_time_helper.dart';
import 'package:penyaluran_app/app/utils/format_helper.dart';
class CalendarViewWidget extends StatelessWidget {
final JadwalPenyaluranController controller;
@ -25,30 +25,48 @@ class CalendarViewWidget extends StatelessWidget {
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 3,
offset: const Offset(0, 1),
blurRadius: 5,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
Container(
padding: const EdgeInsets.all(16.0),
child: Text(
'Kalender Penyaluran Bulan Ini',
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
decoration: BoxDecoration(
gradient: AppTheme.primaryGradient,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
),
child: Row(
children: [
const Icon(
Icons.calendar_month_rounded,
color: Colors.white,
size: 28,
),
const SizedBox(width: 12),
Text(
'Kalender Penyaluran',
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
padding: const EdgeInsets.all(12.0),
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.65,
child: Obx(() {
@ -64,7 +82,7 @@ class CalendarViewWidget extends StatelessWidget {
MonthAppointmentDisplayMode.indicator,
showAgenda: true,
agendaViewHeight: MediaQuery.of(context).size.height * 0.3,
agendaItemHeight: 60,
agendaItemHeight: 70,
dayFormat: 'EEE',
numberOfWeeksInView: 6,
appointmentDisplayCount: 3,
@ -82,19 +100,19 @@ class CalendarViewWidget extends StatelessWidget {
color: Colors.grey.withOpacity(0.7),
),
),
agendaStyle: const AgendaStyle(
backgroundColor: Colors.white,
appointmentTextStyle: TextStyle(
agendaStyle: AgendaStyle(
backgroundColor: Colors.grey.shade50,
appointmentTextStyle: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white,
),
dateTextStyle: TextStyle(
dateTextStyle: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
color: AppTheme.primaryColor,
),
dayTextStyle: TextStyle(
dayTextStyle: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: AppTheme.primaryColor,
@ -106,7 +124,7 @@ class CalendarViewWidget extends StatelessWidget {
selectionDecoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(color: AppTheme.primaryColor, width: 2),
borderRadius: const BorderRadius.all(Radius.circular(4)),
borderRadius: const BorderRadius.all(Radius.circular(8)),
shape: BoxShape.rectangle,
),
headerStyle: const CalendarHeaderStyle(
@ -163,6 +181,13 @@ class CalendarViewWidget extends StatelessWidget {
? BoxDecoration(
shape: BoxShape.circle,
color: AppTheme.primaryColor,
boxShadow: [
BoxShadow(
color: AppTheme.primaryColor.withOpacity(0.3),
blurRadius: 4,
offset: const Offset(0, 2),
)
],
)
: null,
child: Column(
@ -179,7 +204,7 @@ class CalendarViewWidget extends StatelessWidget {
details.date.year == DateTime.now().year
? Colors.white
: AppTheme.primaryColor,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
),
),
),
@ -201,12 +226,19 @@ class CalendarViewWidget extends StatelessWidget {
),
if (hasAppointments && details.appointments.isEmpty)
Container(
width: 6,
height: 6,
width: 8,
height: 8,
margin: const EdgeInsets.only(bottom: 2),
decoration: const BoxDecoration(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppTheme.primaryColor,
boxShadow: [
BoxShadow(
color: AppTheme.primaryColor.withOpacity(0.3),
blurRadius: 2,
spreadRadius: 0.5,
)
],
),
),
],
@ -322,131 +354,245 @@ class CalendarViewWidget extends StatelessWidget {
showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
backgroundColor: Colors.transparent,
builder: (context) => Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: Container(
padding: const EdgeInsets.all(20),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 10,
spreadRadius: 0,
offset: Offset(0, -2),
),
],
),
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.7,
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
appointment.subject,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Handle bar
Center(
child: Container(
width: 40,
height: 5,
margin: const EdgeInsets.only(bottom: 20),
decoration: BoxDecoration(
color: Colors.grey.shade300,
borderRadius: BorderRadius.circular(30),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
appointment.subject,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
if (status != null) _buildStatusBadge(status),
],
),
const SizedBox(width: 8),
if (status != null) _buildStatusBadge(status),
],
),
const SizedBox(height: 16),
// Date, time and location info
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade200),
),
const SizedBox(height: 10),
if (status != null) ...[
Row(
children: [
Icon(
_getStatusIcon(status),
size: 16,
color: _getStatusColor(status),
),
const SizedBox(width: 8),
Text(
'Status: ${_getStatusText(status)}',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: _getStatusColor(status),
child: Column(
children: [
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppTheme.primaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(
Icons.calendar_today,
size: 16,
color: AppTheme.primaryColor,
),
),
const SizedBox(width: 12),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Tanggal',
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 2),
Text(
formattedDate,
style: const TextStyle(
fontSize: 14, fontWeight: FontWeight.w600),
),
],
),
],
),
const SizedBox(height: 12),
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppTheme.primaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(
Icons.access_time,
size: 16,
color: AppTheme.primaryColor,
),
),
const SizedBox(width: 12),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Waktu',
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 2),
Text(
'${appointment.startTime.hour}:${appointment.startTime.minute.toString().padLeft(2, '0')} - ${appointment.endTime.hour}:${appointment.endTime.minute.toString().padLeft(2, '0')} WIB',
style: const TextStyle(
fontSize: 14, fontWeight: FontWeight.w600),
),
],
),
],
),
if (appointment.location != null &&
appointment.location!.isNotEmpty) ...[
const SizedBox(height: 12),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppTheme.primaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(
Icons.location_on,
size: 16,
color: AppTheme.primaryColor,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Lokasi',
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 2),
Text(
appointment.location!,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600),
),
],
),
),
],
),
],
),
const SizedBox(height: 8),
],
Row(
children: [
const Icon(Icons.calendar_today, size: 16),
const SizedBox(width: 8),
Text(
formattedDate,
style: const TextStyle(fontSize: 16),
),
],
),
),
if (appointment.notes != null &&
appointment.notes!.isNotEmpty) ...[
const SizedBox(height: 20),
Text(
'Deskripsi',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.grey.shade800,
),
),
const SizedBox(height: 8),
Row(
children: [
const Icon(Icons.access_time, size: 16),
const SizedBox(width: 8),
Text(
'${appointment.startTime.hour}:${appointment.startTime.minute.toString().padLeft(2, '0')} - ${appointment.endTime.hour}:${appointment.endTime.minute.toString().padLeft(2, '0')} WIB',
style: const TextStyle(fontSize: 16),
),
],
),
if (appointment.location != null &&
appointment.location!.isNotEmpty) ...[
const SizedBox(height: 8),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Icon(Icons.location_on, size: 16),
const SizedBox(width: 8),
Expanded(
child: Text(
appointment.location!,
style: const TextStyle(fontSize: 16),
),
),
],
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade200),
),
],
if (appointment.notes != null &&
appointment.notes!.isNotEmpty) ...[
const SizedBox(height: 16),
const Text(
'Deskripsi:',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8),
Text(
child: Text(
appointment.notes!,
style: const TextStyle(fontSize: 16),
),
],
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.primaryColor,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
style: TextStyle(
fontSize: 14,
color: Colors.grey.shade800,
height: 1.5,
),
child: const Text('Tutup'),
),
),
],
),
const SizedBox(height: 24),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.primaryColor,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 0,
),
child: const Text(
'Tutup',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
),
),
],
),
),
),

View File

@ -3,7 +3,7 @@ import 'package:get/get.dart';
import 'package:penyaluran_app/app/data/models/penyaluran_bantuan_model.dart';
import 'package:penyaluran_app/app/modules/petugas_desa/controllers/jadwal_penyaluran_controller.dart';
import 'package:penyaluran_app/app/routes/app_pages.dart';
import 'package:penyaluran_app/app/utils/date_time_helper.dart';
import 'package:penyaluran_app/app/utils/format_helper.dart';
import 'package:penyaluran_app/app/theme/app_theme.dart';
class JadwalSectionWidget extends StatelessWidget {
@ -43,32 +43,56 @@ class JadwalSectionWidget extends StatelessWidget {
),
],
),
const SizedBox(height: 12),
const SizedBox(height: 16),
Obx(() {
final currentJadwalList = _getCurrentJadwalList();
if (currentJadwalList.isEmpty) {
return Container(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.grey.withAlpha(20),
borderRadius: BorderRadius.circular(12),
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.grey.shade200),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.03),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Center(
child: Column(
children: [
Icon(
_getEmptyIcon(),
size: 40,
color: Colors.grey.shade400,
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.grey.shade100,
shape: BoxShape.circle,
),
child: Icon(
_getEmptyIcon(),
size: 48,
color: Colors.grey.shade400,
),
),
const SizedBox(height: 8),
const SizedBox(height: 16),
Text(
'Tidak ada jadwal $title',
style: textTheme.titleMedium?.copyWith(
color: Colors.grey.shade600,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
Text(
'Jadwal akan muncul di sini saat tersedia',
style: textTheme.bodySmall?.copyWith(
color: Colors.grey.shade500,
),
textAlign: TextAlign.center,
),
],
),
),
@ -192,17 +216,18 @@ class JadwalSectionWidget extends StatelessWidget {
controller.getKategoriBantuanName(jadwal.kategoriBantuanId);
return Card(
margin: const EdgeInsets.only(bottom: 12),
elevation: 2,
margin: const EdgeInsets.only(bottom: 16),
elevation: 3,
shadowColor: Colors.black.withOpacity(0.1),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(16),
side: BorderSide(
color: statusColor.withOpacity(0.3),
width: 1,
width: 1.5,
),
),
child: InkWell(
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(16),
onTap: () {
if (jadwal.id != null) {
Get.toNamed(Routes.detailPenyaluran,
@ -223,19 +248,19 @@ class JadwalSectionWidget extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Container(
// padding: const EdgeInsets.all(10),
// decoration: BoxDecoration(
// color: statusColor.withOpacity(0.1),
// borderRadius: BorderRadius.circular(10),
// ),
// child: Icon(
// _getStatusIcon(),
// color: statusColor,
// size: 24,
// ),
// ),
// const SizedBox(width: 12),
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: statusColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
),
child: Icon(
_getStatusIcon(),
color: statusColor,
size: 24,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -254,12 +279,16 @@ class JadwalSectionWidget extends StatelessWidget {
),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
horizontal: 10,
vertical: 6,
),
decoration: BoxDecoration(
color: statusColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
color: statusColor.withOpacity(0.15),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: statusColor.withOpacity(0.3),
width: 1,
),
),
child: Text(
statusText,
@ -273,10 +302,12 @@ class JadwalSectionWidget extends StatelessWidget {
),
if (jadwal.deskripsi != null &&
jadwal.deskripsi!.isNotEmpty) ...[
const SizedBox(height: 4),
const SizedBox(height: 6),
Text(
jadwal.deskripsi!,
style: textTheme.bodyMedium,
style: textTheme.bodyMedium?.copyWith(
color: Colors.grey.shade700,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
@ -287,47 +318,18 @@ class JadwalSectionWidget extends StatelessWidget {
],
),
const Divider(height: 24),
_buildInfoItem(
Icons.location_on_outlined,
'Lokasi',
lokasiName,
_buildInfoSection(
textTheme,
lokasiName,
kategoriName,
formattedDateTime,
jadwal.jumlahPenerima,
),
const SizedBox(height: 8),
Row(
children: [
Expanded(
child: _buildInfoItem(
Icons.category_outlined,
'Kategori',
kategoriName,
textTheme,
),
),
Expanded(
child: _buildInfoItem(
Icons.event,
'Jadwal',
formattedDateTime,
textTheme,
),
),
],
),
if (jadwal.jumlahPenerima != null) ...[
const SizedBox(height: 8),
_buildInfoItem(
Icons.people_outline,
'Jumlah Penerima',
'${jadwal.jumlahPenerima}',
textTheme,
),
],
const SizedBox(height: 16),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton.icon(
ElevatedButton.icon(
onPressed: () {
if (jadwal.id != null) {
Get.toNamed(Routes.detailPenyaluran,
@ -340,10 +342,19 @@ class JadwalSectionWidget extends StatelessWidget {
);
}
},
icon: const Icon(Icons.visibility_outlined),
icon: const Icon(Icons.visibility_outlined, size: 18),
label: const Text('Lihat Detail'),
style: TextButton.styleFrom(
foregroundColor: statusColor,
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: statusColor,
elevation: 0,
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
],
@ -355,6 +366,66 @@ class JadwalSectionWidget extends StatelessWidget {
);
}
Widget _buildInfoSection(
TextTheme textTheme,
String lokasiName,
String kategoriName,
String formattedDateTime,
int? jumlahPenerima,
) {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.grey.shade200,
width: 1,
),
),
child: Column(
children: [
_buildInfoItem(
Icons.location_on_outlined,
'Lokasi',
lokasiName,
textTheme,
),
const SizedBox(height: 10),
Row(
children: [
Expanded(
child: _buildInfoItem(
Icons.category_outlined,
'Kategori',
kategoriName,
textTheme,
),
),
Expanded(
child: _buildInfoItem(
Icons.event,
'Jadwal',
formattedDateTime,
textTheme,
),
),
],
),
if (jumlahPenerima != null) ...[
const SizedBox(height: 10),
_buildInfoItem(
Icons.people_outline,
'Jumlah Penerima',
'$jumlahPenerima',
textTheme,
),
],
],
),
);
}
Widget _buildInfoItem(
IconData icon,
String label,
@ -364,12 +435,19 @@ class JadwalSectionWidget extends StatelessWidget {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
icon,
size: 16,
color: Colors.grey.shade600,
Container(
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
color: Colors.grey.shade200,
borderRadius: BorderRadius.circular(6),
),
child: Icon(
icon,
size: 14,
color: Colors.grey.shade700,
),
),
const SizedBox(width: 4),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -378,11 +456,15 @@ class JadwalSectionWidget extends StatelessWidget {
label,
style: textTheme.bodySmall?.copyWith(
color: Colors.grey.shade600,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 2),
Text(
value,
style: textTheme.bodyMedium,
style: textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),