From 9690764cf4b7befbd8013aaf93023f4cad311e52 Mon Sep 17 00:00:00 2001 From: Khafidh Fuadi Date: Sat, 8 Mar 2025 14:13:59 +0700 Subject: [PATCH] Perbarui sintaks Dart dan perbaiki opacity warna - Ganti `Key? key` dengan `super.key` di berbagai tampilan - Gunakan `withAlpha()` sebagai pengganti `withOpacity()` untuk transparansi warna - Lakukan penyesuaian kecil pada tata letak dan styling komponen - Hapus impor yang tidak digunakan - Sederhanakan beberapa bagian kode dashboard --- lib/app/modules/auth/views/login_view.dart | 3 +- .../views/donatur_dashboard_view.dart | 6 +- .../views/petugas_desa_dashboard_view.dart | 111 ++++++++---------- .../petugas_verifikasi_dashboard_view.dart | 4 +- .../dashboard/views/warga_dashboard_view.dart | 4 +- lib/app/modules/home/views/home_view.dart | 2 +- 6 files changed, 58 insertions(+), 72 deletions(-) diff --git a/lib/app/modules/auth/views/login_view.dart b/lib/app/modules/auth/views/login_view.dart index b538bb9..72e92da 100644 --- a/lib/app/modules/auth/views/login_view.dart +++ b/lib/app/modules/auth/views/login_view.dart @@ -2,10 +2,9 @@ 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 { - const LoginView({Key? key}) : super(key: key); + const LoginView({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/app/modules/dashboard/views/donatur_dashboard_view.dart b/lib/app/modules/dashboard/views/donatur_dashboard_view.dart index f241343..0daa10e 100644 --- a/lib/app/modules/dashboard/views/donatur_dashboard_view.dart +++ b/lib/app/modules/dashboard/views/donatur_dashboard_view.dart @@ -3,7 +3,7 @@ import 'package:get/get.dart'; import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_controller.dart'; class DonaturDashboardView extends GetView { - const DonaturDashboardView({Key? key}) : super(key: key); + const DonaturDashboardView({super.key}); @override Widget build(BuildContext context) { @@ -145,8 +145,8 @@ class DonaturDashboardView extends GetView { onPressed: () { // Navigasi ke halaman penitipan bantuan baru }, - child: const Icon(Icons.add), tooltip: 'Titipkan Bantuan Baru', + child: const Icon(Icons.add), ), ); } @@ -187,7 +187,7 @@ class DonaturDashboardView extends GetView { Container( padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( - color: color.withOpacity(0.1), + color: color.withAlpha(26), borderRadius: BorderRadius.circular(8.0), ), child: Icon( diff --git a/lib/app/modules/dashboard/views/petugas_desa_dashboard_view.dart b/lib/app/modules/dashboard/views/petugas_desa_dashboard_view.dart index 27ca8e8..25652c5 100644 --- a/lib/app/modules/dashboard/views/petugas_desa_dashboard_view.dart +++ b/lib/app/modules/dashboard/views/petugas_desa_dashboard_view.dart @@ -5,20 +5,20 @@ import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_contr import 'package:google_fonts/google_fonts.dart'; class PetugasDesaDashboardView extends GetView { - const PetugasDesaDashboardView({Key? key}) : super(key: key); + const PetugasDesaDashboardView({super.key}); @override Widget build(BuildContext context) { final TextTheme textTheme = GoogleFonts.dmSansTextTheme(Theme.of(context).textTheme); - final GlobalKey _scaffoldKey = GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); return Theme( data: Theme.of(context).copyWith( textTheme: textTheme, ), child: Scaffold( - key: _scaffoldKey, + key: scaffoldKey, drawer: Drawer( child: ListView( padding: EdgeInsets.zero, @@ -67,7 +67,6 @@ class PetugasDesaDashboardView extends GetView { 'assets/icons/home-icon.svg', width: 24, height: 24, - color: Colors.grey[700], ), title: const Text('Beranda'), onTap: () { @@ -120,7 +119,7 @@ class PetugasDesaDashboardView extends GetView { children: [ // add drawer button IconButton( - onPressed: () => _scaffoldKey.currentState?.openDrawer(), + onPressed: () => scaffoldKey.currentState?.openDrawer(), icon: const Icon(Icons.menu), ), // Header dengan greeting @@ -221,7 +220,7 @@ class PetugasDesaDashboardView extends GetView { borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( - color: Colors.grey.withOpacity(0.1), + color: Colors.grey.withAlpha(26), // 0.1 * 255 ≈ 26 spreadRadius: 1, blurRadius: 3, offset: const Offset(0, 1), @@ -277,7 +276,7 @@ class PetugasDesaDashboardView extends GetView { title, style: textTheme.bodyMedium?.copyWith( fontSize: 14, - color: Colors.white.withOpacity(0.8), + color: Colors.white.withAlpha(204), // 0.8 * 255 ≈ 204 ), ), const SizedBox(height: 8), @@ -341,7 +340,7 @@ class PetugasDesaDashboardView extends GetView { title, style: textTheme.bodyMedium?.copyWith( fontSize: 14, - color: Colors.white.withOpacity(0.8), + color: Colors.white.withAlpha(204), // 0.8 * 255 ≈ 204 ), ), Text( @@ -366,60 +365,48 @@ class PetugasDesaDashboardView extends GetView { } Widget _buildProgressSection(TextTheme textTheme) { - return Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - gradient: const LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [Color(0xFF2E5077), Color(0xFF5882B1)], - transform: GradientRotation(96.93 * 3.14159 / 180), + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Progress Penyaluran', + style: textTheme.titleMedium?.copyWith( + fontSize: 16, + fontWeight: FontWeight.bold, + ), ), - borderRadius: BorderRadius.circular(12), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Progress Penyaluran', - style: textTheme.bodyMedium?.copyWith( - fontSize: 14, - color: Colors.white.withOpacity(0.8), - ), + const SizedBox(height: 10), + ClipRRect( + borderRadius: BorderRadius.circular(8), + child: LinearProgressIndicator( + value: 0.7, + minHeight: 10, + backgroundColor: Colors.grey[300], + valueColor: const AlwaysStoppedAnimation(Color(0xFF2E5077)), ), - const SizedBox(height: 10), - ClipRRect( - borderRadius: BorderRadius.circular(8), - child: LinearProgressIndicator( - value: 0.7, - minHeight: 10, - backgroundColor: Colors.white.withOpacity(0.3), - valueColor: const AlwaysStoppedAnimation(Colors.white), - ), + ), + const SizedBox(height: 10), + Text( + '70% Selesai', + style: textTheme.bodyMedium?.copyWith( + fontSize: 14, + fontWeight: FontWeight.bold, + color: const Color(0xFF2E5077), ), - const SizedBox(height: 10), - Text( - '70% Selesai', - style: textTheme.bodyMedium?.copyWith( - fontSize: 16, - fontWeight: FontWeight.bold, - color: Colors.white, - ), + ), + const SizedBox(height: 10), + _buildProgressDetailRow('Telah Menerima', 70, textTheme), + _buildProgressDetailRow('Dijedwalkan', 20, textTheme), + _buildProgressDetailRow('Belum Dijadwalkan', 10, textTheme), + const SizedBox(height: 5), + Text( + 'Total : 100 Penerima, Telah Disalurkan : 70 Penerima, Belum Disalurkan : 30', + style: textTheme.bodySmall?.copyWith( + fontSize: 12, + color: Colors.grey[600], ), - const SizedBox(height: 10), - _buildProgressDetailRow('Telah Menerima', 70, textTheme), - _buildProgressDetailRow('Dijedwalkan', 20, textTheme), - _buildProgressDetailRow('Belum Dijadwalkan', 10, textTheme), - const SizedBox(height: 5), - Text( - 'Total : 100 Penerima, Telah Disalurkan : 70 Penerima, Belum Disalurkan : 30', - style: textTheme.bodySmall?.copyWith( - fontSize: 12, - color: Colors.white.withOpacity(0.8), - ), - ), - ], - ), + ), + ], ); } @@ -455,7 +442,7 @@ class PetugasDesaDashboardView extends GetView { 0.7 * (value / 100), decoration: BoxDecoration( - color: const Color(0xFFE4F1AC), + color: const Color(0xFF2E5077), borderRadius: BorderRadius.circular(4), ), ), @@ -552,7 +539,7 @@ class PetugasDesaDashboardView extends GetView { borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( - color: Colors.grey.withOpacity(0.1), + color: Colors.grey.withAlpha(26), // 0.1 * 255 ≈ 26 spreadRadius: 1, blurRadius: 3, offset: const Offset(0, 1), @@ -662,7 +649,7 @@ class PetugasDesaDashboardView extends GetView { borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( - color: Colors.grey.withOpacity(0.1), + color: Colors.grey.withAlpha(26), // 0.1 * 255 ≈ 26 spreadRadius: 1, blurRadius: 3, offset: const Offset(0, 1), @@ -686,7 +673,7 @@ class PetugasDesaDashboardView extends GetView { Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), decoration: BoxDecoration( - color: Colors.green.withOpacity(0.1), + color: Colors.green.withAlpha(26), // 0.1 * 255 ≈ 26 borderRadius: BorderRadius.circular(12), ), child: Text( diff --git a/lib/app/modules/dashboard/views/petugas_verifikasi_dashboard_view.dart b/lib/app/modules/dashboard/views/petugas_verifikasi_dashboard_view.dart index b7cd07b..2dc3916 100644 --- a/lib/app/modules/dashboard/views/petugas_verifikasi_dashboard_view.dart +++ b/lib/app/modules/dashboard/views/petugas_verifikasi_dashboard_view.dart @@ -3,7 +3,7 @@ import 'package:get/get.dart'; import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_controller.dart'; class PetugasVerifikasiDashboardView extends GetView { - const PetugasVerifikasiDashboardView({Key? key}) : super(key: key); + const PetugasVerifikasiDashboardView({super.key}); @override Widget build(BuildContext context) { @@ -174,7 +174,7 @@ class PetugasVerifikasiDashboardView extends GetView { Container( padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( - color: color.withOpacity(0.1), + color: color.withAlpha(26), borderRadius: BorderRadius.circular(8.0), ), child: Icon( diff --git a/lib/app/modules/dashboard/views/warga_dashboard_view.dart b/lib/app/modules/dashboard/views/warga_dashboard_view.dart index a58ce3b..c82d61b 100644 --- a/lib/app/modules/dashboard/views/warga_dashboard_view.dart +++ b/lib/app/modules/dashboard/views/warga_dashboard_view.dart @@ -4,7 +4,7 @@ import 'package:penyaluran_app/app/modules/dashboard/controllers/dashboard_contr import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart'; class WargaDashboardView extends GetView { - const WargaDashboardView({Key? key}) : super(key: key); + const WargaDashboardView({super.key}); @override Widget build(BuildContext context) { @@ -253,7 +253,7 @@ class WargaDashboardView extends GetView { Container( padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( - color: color.withOpacity(0.1), + color: color.withAlpha(26), borderRadius: BorderRadius.circular(8.0), ), child: Icon( diff --git a/lib/app/modules/home/views/home_view.dart b/lib/app/modules/home/views/home_view.dart index 631e693..86028a5 100644 --- a/lib/app/modules/home/views/home_view.dart +++ b/lib/app/modules/home/views/home_view.dart @@ -3,7 +3,7 @@ import 'package:get/get.dart'; import 'package:penyaluran_app/app/modules/home/controllers/home_controller.dart'; class HomeView extends GetView { - const HomeView({Key? key}) : super(key: key); + const HomeView({super.key}); @override Widget build(BuildContext context) {