diff --git a/assets/qrcode.png b/assets/qrcode.png new file mode 100644 index 0000000..0afc160 Binary files /dev/null and b/assets/qrcode.png differ diff --git a/lib/app/app.dart b/lib/app/app.dart index 0a4cbfa..b75ecce 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -1,8 +1,9 @@ -import 'package:panti_asuhan/ui/views/admin_index_tracking/admin_index/admin_index_view.dart'; import 'package:panti_asuhan/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view.dart'; import 'package:panti_asuhan/ui/views/admin_index_tracking/data_siswa/data_siswa_view.dart'; import 'package:panti_asuhan/ui/views/admin_index_tracking/edit_siswa/edit_siswa_view.dart'; import 'package:panti_asuhan/ui/views/admin_index_tracking/profil/profil_view.dart'; +import 'package:panti_asuhan/ui/views/detail_dana_sosial/detail_dana_sosial_view.dart'; +import 'package:panti_asuhan/ui/views/pimpinan_index_tracking/pimpinan_index_tracking/pimpinan_index_tracking_view.dart'; import 'package:panti_asuhan/ui/views/tambah_dana_sosial/tambah_dana_sosial_view.dart'; import 'package:stacked_services/stacked_services.dart'; import 'package:stacked/stacked_annotations.dart'; @@ -11,11 +12,13 @@ import '../services/http_services.dart'; import '../services/my_easyloading.dart'; import '../ui/views/admin_index_tracking/add_siswa_dialog/add_siswa_dialog/add_siswa_dialog_view.dart'; import '../ui/views/admin_index_tracking/admin_index_tracking_view.dart'; +import '../ui/views/admin_index_tracking/filter_dialog/filter_dialog_view.dart'; import '../ui/views/admin_index_tracking/sejarah/sejarah_view.dart'; import '../ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view.dart'; import '../ui/views/admin_index_tracking/visi_misi/visi_misi_view.dart'; import '../ui/views/login_screen/login_screen_view.dart'; import '../ui/views/splash_screen/splash_screen_view.dart'; +import '../ui/views/user_index_tracking/user_index_tracking_view.dart'; @StackedApp( routes: [ @@ -24,7 +27,7 @@ import '../ui/views/splash_screen/splash_screen_view.dart'; MaterialRoute( page: AdminIndexTrackingView, children: [ - MaterialRoute(page: AdminIndexView, initial: true), + // MaterialRoute(page: AdminIndexView, initial: true), MaterialRoute(page: DanaSosialAdminView), MaterialRoute(page: DataSiswaView), MaterialRoute(page: ProfilView), @@ -34,10 +37,33 @@ import '../ui/views/splash_screen/splash_screen_view.dart'; ], ), MaterialRoute(page: TambahDanaSosialView), - MaterialRoute(page: EditSiswaView) + MaterialRoute(page: EditSiswaView), + MaterialRoute(page: DetailDanaSosialView), + MaterialRoute( + page: PimpinanIndexTrackingView, + children: [ + // MaterialRoute(page: AdminIndexView, initial: true), + MaterialRoute(page: DanaSosialAdminView), + MaterialRoute(page: DataSiswaView), + MaterialRoute(page: ProfilView), + ], + ), + MaterialRoute( + page: UserIndexTrackingView, + children: [ + // MaterialRoute(page: AdminIndexView, initial: true), + MaterialRoute(page: DanaSosialAdminView), + MaterialRoute(page: DataSiswaView), + MaterialRoute(page: ProfilView), + MaterialRoute(page: VisiMisiView), + MaterialRoute(page: SejarahView), + MaterialRoute(page: StrukturOrganisasiView), + ], + ), ], dialogs: [ StackedDialog(classType: AddSiswaDialogView), + StackedDialog(classType: FilterDialogView), ], dependencies: [ LazySingleton(classType: NavigationService), diff --git a/lib/app/app.dialogs.dart b/lib/app/app.dialogs.dart index 0557da3..af3865d 100644 --- a/lib/app/app.dialogs.dart +++ b/lib/app/app.dialogs.dart @@ -8,9 +8,11 @@ import 'package:stacked_services/stacked_services.dart'; import 'app.locator.dart'; import '../ui/views/admin_index_tracking/add_siswa_dialog/add_siswa_dialog/add_siswa_dialog_view.dart'; +import '../ui/views/admin_index_tracking/filter_dialog/filter_dialog_view.dart'; enum DialogType { addSiswaDialogView, + filterDialogView, } void setupDialogUi() { @@ -19,6 +21,8 @@ void setupDialogUi() { final Map builders = { DialogType.addSiswaDialogView: (context, request, completer) => AddSiswaDialogView(request: request, completer: completer), + DialogType.filterDialogView: (context, request, completer) => + FilterDialogView(request: request, completer: completer), }; dialogService.registerCustomDialogBuilders(builders); diff --git a/lib/app/app.router.dart b/lib/app/app.router.dart index a4593ac..55da282 100644 --- a/lib/app/app.router.dart +++ b/lib/app/app.router.dart @@ -5,34 +5,38 @@ // ************************************************************************** // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:flutter/material.dart' as _i7; +import 'package:flutter/material.dart' as _i10; import 'package:flutter/material.dart'; -import 'package:panti_asuhan/ui/views/admin_index_tracking/admin_index/admin_index_view.dart' - as _i8; import 'package:panti_asuhan/ui/views/admin_index_tracking/admin_index_tracking_view.dart' as _i4; import 'package:panti_asuhan/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view.dart' - as _i9; + as _i11; import 'package:panti_asuhan/ui/views/admin_index_tracking/data_siswa/data_siswa_view.dart' - as _i10; + as _i12; import 'package:panti_asuhan/ui/views/admin_index_tracking/edit_siswa/edit_siswa_view.dart' as _i6; import 'package:panti_asuhan/ui/views/admin_index_tracking/profil/profil_view.dart' - as _i11; -import 'package:panti_asuhan/ui/views/admin_index_tracking/sejarah/sejarah_view.dart' as _i13; +import 'package:panti_asuhan/ui/views/admin_index_tracking/sejarah/sejarah_view.dart' + as _i15; import 'package:panti_asuhan/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view.dart' - as _i14; + as _i16; import 'package:panti_asuhan/ui/views/admin_index_tracking/visi_misi/visi_misi_view.dart' - as _i12; + as _i14; +import 'package:panti_asuhan/ui/views/detail_dana_sosial/detail_dana_sosial_view.dart' + as _i7; import 'package:panti_asuhan/ui/views/login_screen/login_screen_view.dart' as _i3; +import 'package:panti_asuhan/ui/views/pimpinan_index_tracking/pimpinan_index_tracking/pimpinan_index_tracking_view.dart' + as _i8; import 'package:panti_asuhan/ui/views/splash_screen/splash_screen_view.dart' as _i2; import 'package:panti_asuhan/ui/views/tambah_dana_sosial/tambah_dana_sosial_view.dart' as _i5; +import 'package:panti_asuhan/ui/views/user_index_tracking/user_index_tracking_view.dart' + as _i9; import 'package:stacked/stacked.dart' as _i1; -import 'package:stacked_services/stacked_services.dart' as _i15; +import 'package:stacked_services/stacked_services.dart' as _i17; class Routes { static const splashScreenView = '/'; @@ -45,12 +49,21 @@ class Routes { static const editSiswaView = '/edit-siswa-view'; + static const detailDanaSosialView = '/detail-dana-sosial-view'; + + static const pimpinanIndexTrackingView = '/pimpinan-index-tracking-view'; + + static const userIndexTrackingView = '/user-index-tracking-view'; + static const all = { splashScreenView, loginScreenView, adminIndexTrackingView, tambahDanaSosialView, editSiswaView, + detailDanaSosialView, + pimpinanIndexTrackingView, + userIndexTrackingView, }; } @@ -76,32 +89,44 @@ class StackedRouter extends _i1.RouterBase { Routes.editSiswaView, page: _i6.EditSiswaView, ), + _i1.RouteDef( + Routes.detailDanaSosialView, + page: _i7.DetailDanaSosialView, + ), + _i1.RouteDef( + Routes.pimpinanIndexTrackingView, + page: _i8.PimpinanIndexTrackingView, + ), + _i1.RouteDef( + Routes.userIndexTrackingView, + page: _i9.UserIndexTrackingView, + ), ]; final _pagesMap = { _i2.SplashScreenView: (data) { - return _i7.MaterialPageRoute( + return _i10.MaterialPageRoute( builder: (context) => const _i2.SplashScreenView(), settings: data, maintainState: false, ); }, _i3.LoginScreenView: (data) { - return _i7.MaterialPageRoute( + return _i10.MaterialPageRoute( builder: (context) => const _i3.LoginScreenView(), settings: data, maintainState: false, ); }, _i4.AdminIndexTrackingView: (data) { - return _i7.MaterialPageRoute( + return _i10.MaterialPageRoute( builder: (context) => const _i4.AdminIndexTrackingView(), settings: data, maintainState: false, ); }, _i5.TambahDanaSosialView: (data) { - return _i7.MaterialPageRoute( + return _i10.MaterialPageRoute( builder: (context) => const _i5.TambahDanaSosialView(), settings: data, maintainState: false, @@ -109,13 +134,36 @@ class StackedRouter extends _i1.RouterBase { }, _i6.EditSiswaView: (data) { final args = data.getArgs(nullOk: false); - return _i7.MaterialPageRoute( + return _i10.MaterialPageRoute( builder: (context) => _i6.EditSiswaView(idSiswa: args.idSiswa, key: args.key), settings: data, maintainState: false, ); }, + _i7.DetailDanaSosialView: (data) { + final args = data.getArgs(nullOk: false); + return _i10.MaterialPageRoute( + builder: (context) => + _i7.DetailDanaSosialView(key: args.key, id: args.id), + settings: data, + maintainState: false, + ); + }, + _i8.PimpinanIndexTrackingView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i8.PimpinanIndexTrackingView(), + settings: data, + maintainState: false, + ); + }, + _i9.UserIndexTrackingView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i9.UserIndexTrackingView(), + settings: data, + maintainState: false, + ); + }, }; @override @@ -132,7 +180,7 @@ class EditSiswaViewArguments { final int idSiswa; - final _i7.Key? key; + final _i10.Key? key; @override String toString() { @@ -140,9 +188,23 @@ class EditSiswaViewArguments { } } -class AdminIndexTrackingViewRoutes { - static const adminIndexView = ''; +class DetailDanaSosialViewArguments { + const DetailDanaSosialViewArguments({ + this.key, + required this.id, + }); + final _i10.Key? key; + + final int id; + + @override + String toString() { + return '{"key": "$key", "id": "$id"}'; + } +} + +class AdminIndexTrackingViewRoutes { static const danaSosialAdminView = 'dana-sosial-admin-view'; static const dataSiswaView = 'data-siswa-view'; @@ -156,7 +218,6 @@ class AdminIndexTrackingViewRoutes { static const strukturOrganisasiView = 'struktur-organisasi-view'; static const all = { - adminIndexView, danaSosialAdminView, dataSiswaView, profilView, @@ -168,82 +229,71 @@ class AdminIndexTrackingViewRoutes { class AdminIndexTrackingViewRouter extends _i1.RouterBase { final _routes = <_i1.RouteDef>[ - _i1.RouteDef( - AdminIndexTrackingViewRoutes.adminIndexView, - page: _i8.AdminIndexView, - ), _i1.RouteDef( AdminIndexTrackingViewRoutes.danaSosialAdminView, - page: _i9.DanaSosialAdminView, + page: _i11.DanaSosialAdminView, ), _i1.RouteDef( AdminIndexTrackingViewRoutes.dataSiswaView, - page: _i10.DataSiswaView, + page: _i12.DataSiswaView, ), _i1.RouteDef( AdminIndexTrackingViewRoutes.profilView, - page: _i11.ProfilView, + page: _i13.ProfilView, ), _i1.RouteDef( AdminIndexTrackingViewRoutes.visiMisiView, - page: _i12.VisiMisiView, + page: _i14.VisiMisiView, ), _i1.RouteDef( AdminIndexTrackingViewRoutes.sejarahView, - page: _i13.SejarahView, + page: _i15.SejarahView, ), _i1.RouteDef( AdminIndexTrackingViewRoutes.strukturOrganisasiView, - page: _i14.StrukturOrganisasiView, + page: _i16.StrukturOrganisasiView, ), ]; final _pagesMap = { - _i8.AdminIndexView: (data) { - return _i7.MaterialPageRoute( - builder: (context) => const _i8.AdminIndexView(), + _i11.DanaSosialAdminView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i11.DanaSosialAdminView(), settings: data, maintainState: false, ); }, - _i9.DanaSosialAdminView: (data) { - return _i7.MaterialPageRoute( - builder: (context) => const _i9.DanaSosialAdminView(), + _i12.DataSiswaView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i12.DataSiswaView(), settings: data, maintainState: false, ); }, - _i10.DataSiswaView: (data) { - return _i7.MaterialPageRoute( - builder: (context) => const _i10.DataSiswaView(), + _i13.ProfilView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i13.ProfilView(), settings: data, maintainState: false, ); }, - _i11.ProfilView: (data) { - return _i7.MaterialPageRoute( - builder: (context) => const _i11.ProfilView(), + _i14.VisiMisiView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i14.VisiMisiView(), settings: data, maintainState: false, ); }, - _i12.VisiMisiView: (data) { - return _i7.MaterialPageRoute( - builder: (context) => _i12.VisiMisiView(), + _i15.SejarahView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i15.SejarahView(), settings: data, maintainState: false, ); }, - _i13.SejarahView: (data) { - return _i7.MaterialPageRoute( - builder: (context) => _i13.SejarahView(), - settings: data, - maintainState: false, - ); - }, - _i14.StrukturOrganisasiView: (data) { - return _i7.MaterialPageRoute( - builder: (context) => _i14.StrukturOrganisasiView(), + _i16.StrukturOrganisasiView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i16.StrukturOrganisasiView(), settings: data, maintainState: false, ); @@ -256,7 +306,169 @@ class AdminIndexTrackingViewRouter extends _i1.RouterBase { Map get pagesMap => _pagesMap; } -extension NavigatorStateExtension on _i15.NavigationService { +class PimpinanIndexTrackingViewRoutes { + static const danaSosialAdminView = 'dana-sosial-admin-view'; + + static const dataSiswaView = 'data-siswa-view'; + + static const profilView = 'profil-view'; + + static const all = { + danaSosialAdminView, + dataSiswaView, + profilView, + }; +} + +class PimpinanIndexTrackingViewRouter extends _i1.RouterBase { + final _routes = <_i1.RouteDef>[ + _i1.RouteDef( + PimpinanIndexTrackingViewRoutes.danaSosialAdminView, + page: _i11.DanaSosialAdminView, + ), + _i1.RouteDef( + PimpinanIndexTrackingViewRoutes.dataSiswaView, + page: _i12.DataSiswaView, + ), + _i1.RouteDef( + PimpinanIndexTrackingViewRoutes.profilView, + page: _i13.ProfilView, + ), + ]; + + final _pagesMap = { + _i11.DanaSosialAdminView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i11.DanaSosialAdminView(), + settings: data, + maintainState: false, + ); + }, + _i12.DataSiswaView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i12.DataSiswaView(), + settings: data, + maintainState: false, + ); + }, + _i13.ProfilView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i13.ProfilView(), + settings: data, + maintainState: false, + ); + }, + }; + + @override + List<_i1.RouteDef> get routes => _routes; + @override + Map get pagesMap => _pagesMap; +} + +class UserIndexTrackingViewRoutes { + static const danaSosialAdminView = 'dana-sosial-admin-view'; + + static const dataSiswaView = 'data-siswa-view'; + + static const profilView = 'profil-view'; + + static const visiMisiView = 'visi-misi-view'; + + static const sejarahView = 'sejarah-view'; + + static const strukturOrganisasiView = 'struktur-organisasi-view'; + + static const all = { + danaSosialAdminView, + dataSiswaView, + profilView, + visiMisiView, + sejarahView, + strukturOrganisasiView, + }; +} + +class UserIndexTrackingViewRouter extends _i1.RouterBase { + final _routes = <_i1.RouteDef>[ + _i1.RouteDef( + UserIndexTrackingViewRoutes.danaSosialAdminView, + page: _i11.DanaSosialAdminView, + ), + _i1.RouteDef( + UserIndexTrackingViewRoutes.dataSiswaView, + page: _i12.DataSiswaView, + ), + _i1.RouteDef( + UserIndexTrackingViewRoutes.profilView, + page: _i13.ProfilView, + ), + _i1.RouteDef( + UserIndexTrackingViewRoutes.visiMisiView, + page: _i14.VisiMisiView, + ), + _i1.RouteDef( + UserIndexTrackingViewRoutes.sejarahView, + page: _i15.SejarahView, + ), + _i1.RouteDef( + UserIndexTrackingViewRoutes.strukturOrganisasiView, + page: _i16.StrukturOrganisasiView, + ), + ]; + + final _pagesMap = { + _i11.DanaSosialAdminView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i11.DanaSosialAdminView(), + settings: data, + maintainState: false, + ); + }, + _i12.DataSiswaView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i12.DataSiswaView(), + settings: data, + maintainState: false, + ); + }, + _i13.ProfilView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i13.ProfilView(), + settings: data, + maintainState: false, + ); + }, + _i14.VisiMisiView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i14.VisiMisiView(), + settings: data, + maintainState: false, + ); + }, + _i15.SejarahView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i15.SejarahView(), + settings: data, + maintainState: false, + ); + }, + _i16.StrukturOrganisasiView: (data) { + return _i10.MaterialPageRoute( + builder: (context) => const _i16.StrukturOrganisasiView(), + settings: data, + maintainState: false, + ); + }, + }; + + @override + List<_i1.RouteDef> get routes => _routes; + @override + Map get pagesMap => _pagesMap; +} + +extension NavigatorStateExtension on _i17.NavigationService { Future navigateToSplashScreenView([ int? routerId, bool preventDuplicates = true, @@ -315,7 +527,7 @@ extension NavigatorStateExtension on _i15.NavigationService { Future navigateToEditSiswaView({ required int idSiswa, - _i7.Key? key, + _i10.Key? key, int? routerId, bool preventDuplicates = true, Map? parameters, @@ -330,14 +542,45 @@ extension NavigatorStateExtension on _i15.NavigationService { transition: transition); } - Future navigateToNestedAdminIndexViewInAdminIndexTrackingViewRouter([ + Future navigateToDetailDanaSosialView({ + _i10.Key? key, + required int id, + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + }) async { + return navigateTo(Routes.detailDanaSosialView, + arguments: DetailDanaSosialViewArguments(key: key, id: id), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future navigateToPimpinanIndexTrackingView([ int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, ]) async { - return navigateTo(AdminIndexTrackingViewRoutes.adminIndexView, + return navigateTo(Routes.pimpinanIndexTrackingView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future navigateToUserIndexTrackingView([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo(Routes.userIndexTrackingView, id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, @@ -431,6 +674,138 @@ extension NavigatorStateExtension on _i15.NavigationService { transition: transition); } + Future + navigateToNestedDanaSosialAdminViewInPimpinanIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo( + PimpinanIndexTrackingViewRoutes.danaSosialAdminView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future + navigateToNestedDataSiswaViewInPimpinanIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo(PimpinanIndexTrackingViewRoutes.dataSiswaView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future navigateToNestedProfilViewInPimpinanIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo(PimpinanIndexTrackingViewRoutes.profilView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future + navigateToNestedDanaSosialAdminViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo(UserIndexTrackingViewRoutes.danaSosialAdminView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future navigateToNestedDataSiswaViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo(UserIndexTrackingViewRoutes.dataSiswaView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future navigateToNestedProfilViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo(UserIndexTrackingViewRoutes.profilView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future navigateToNestedVisiMisiViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo(UserIndexTrackingViewRoutes.visiMisiView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future navigateToNestedSejarahViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo(UserIndexTrackingViewRoutes.sejarahView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future + navigateToNestedStrukturOrganisasiViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return navigateTo( + UserIndexTrackingViewRoutes.strukturOrganisasiView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + Future replaceWithSplashScreenView([ int? routerId, bool preventDuplicates = true, @@ -489,7 +864,7 @@ extension NavigatorStateExtension on _i15.NavigationService { Future replaceWithEditSiswaView({ required int idSiswa, - _i7.Key? key, + _i10.Key? key, int? routerId, bool preventDuplicates = true, Map? parameters, @@ -504,15 +879,45 @@ extension NavigatorStateExtension on _i15.NavigationService { transition: transition); } - Future - replaceWithNestedAdminIndexViewInAdminIndexTrackingViewRouter([ + Future replaceWithDetailDanaSosialView({ + _i10.Key? key, + required int id, + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + }) async { + return replaceWith(Routes.detailDanaSosialView, + arguments: DetailDanaSosialViewArguments(key: key, id: id), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithPimpinanIndexTrackingView([ int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, ]) async { - return replaceWith(AdminIndexTrackingViewRoutes.adminIndexView, + return replaceWith(Routes.pimpinanIndexTrackingView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithUserIndexTrackingView([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(Routes.userIndexTrackingView, id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, @@ -606,4 +1011,136 @@ extension NavigatorStateExtension on _i15.NavigationService { parameters: parameters, transition: transition); } + + Future + replaceWithNestedDanaSosialAdminViewInPimpinanIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith( + PimpinanIndexTrackingViewRoutes.danaSosialAdminView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future + replaceWithNestedDataSiswaViewInPimpinanIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(PimpinanIndexTrackingViewRoutes.dataSiswaView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithNestedProfilViewInPimpinanIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(PimpinanIndexTrackingViewRoutes.profilView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future + replaceWithNestedDanaSosialAdminViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(UserIndexTrackingViewRoutes.danaSosialAdminView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithNestedDataSiswaViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(UserIndexTrackingViewRoutes.dataSiswaView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithNestedProfilViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(UserIndexTrackingViewRoutes.profilView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithNestedVisiMisiViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(UserIndexTrackingViewRoutes.visiMisiView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future replaceWithNestedSejarahViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith(UserIndexTrackingViewRoutes.sejarahView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } + + Future + replaceWithNestedStrukturOrganisasiViewInUserIndexTrackingViewRouter([ + int? routerId, + bool preventDuplicates = true, + Map? parameters, + Widget Function(BuildContext, Animation, Animation, Widget)? + transition, + ]) async { + return replaceWith( + UserIndexTrackingViewRoutes.strukturOrganisasiView, + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); + } } diff --git a/lib/app/core/custom_base_view_model.dart b/lib/app/core/custom_base_view_model.dart index 29abcee..f57e713 100755 --- a/lib/app/core/custom_base_view_model.dart +++ b/lib/app/core/custom_base_view_model.dart @@ -1,3 +1,4 @@ +import 'package:shared_preferences/shared_preferences.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; @@ -8,6 +9,7 @@ class CustomBaseViewModel extends BaseViewModel { final navigationService = locator(); final bottomSheetService = locator(); final snackbarService = locator(); + final Future prefs = SharedPreferences.getInstance(); void back() { navigationService.back(); diff --git a/lib/app/mycd b/lib/app/mycd deleted file mode 100755 index 66f5995..0000000 --- a/lib/app/mycd +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -ffmpeg -i "rtsp://admin:admin123@192.168.2.109/cam/realmonitor?channel=1&subtype=1" -acodec copy -vcodec copy abcd.mp4 -y diff --git a/lib/model/dana_sosial_model.dart b/lib/model/dana_sosial_model.dart index d59026d..4313bc6 100644 --- a/lib/model/dana_sosial_model.dart +++ b/lib/model/dana_sosial_model.dart @@ -3,6 +3,9 @@ class DanaSosialModel { String? nama; String? jumlah; String? tanggal; + String? keterangan; + String? jenisDonasi; + String? status; String? createdAt; String? updatedAt; @@ -12,6 +15,9 @@ class DanaSosialModel { this.nama, this.jumlah, this.tanggal, + this.keterangan, + this.jenisDonasi, + this.status, this.createdAt, this.updatedAt}); @@ -20,6 +26,10 @@ class DanaSosialModel { nama = json['nama']; jumlah = json['jumlah']; tanggal = json['tanggal']; + keterangan = json['ket']; + jenisDonasi = json['jenis']; + status = + json['status'] == '0' ? 'Belum Dikonfirmasi' : 'Sudah Dikonfirmasi'; createdAt = json['created_at']; updatedAt = json['updated_at']; } @@ -30,6 +40,9 @@ class DanaSosialModel { data['nama'] = nama; data['jumlah'] = jumlah; data['tanggal'] = tanggal; + data['ket'] = keterangan; + data['jenis'] = jenisDonasi; + data['status'] = status; data['created_at'] = createdAt; data['updated_at'] = updatedAt; return data; diff --git a/lib/services/other_function.dart b/lib/services/other_function.dart index f58ea3e..73af85c 100644 --- a/lib/services/other_function.dart +++ b/lib/services/other_function.dart @@ -15,4 +15,35 @@ class OtherFunction { final formatter = NumberFormat('#,###'); return formatter.format(number); } + + String changeMonth(String month) { + switch (month) { + case 'Januari': + return '01'; + case 'Februari': + return '02'; + case 'Maret': + return '03'; + case 'April': + return '04'; + case 'Mei': + return '05'; + case 'Juni': + return '06'; + case 'Juli': + return '07'; + case 'Agustus': + return '08'; + case 'September': + return '09'; + case 'Oktober': + return '10'; + case 'November': + return '11'; + case 'Desember': + return '12'; + default: + return ''; + } + } } diff --git a/lib/ui/views/admin_index_tracking/add_siswa_dialog/add_siswa_dialog/add_siswa_dialog_view.dart b/lib/ui/views/admin_index_tracking/add_siswa_dialog/add_siswa_dialog/add_siswa_dialog_view.dart index 0b4fa6a..1295c9d 100644 --- a/lib/ui/views/admin_index_tracking/add_siswa_dialog/add_siswa_dialog/add_siswa_dialog_view.dart +++ b/lib/ui/views/admin_index_tracking/add_siswa_dialog/add_siswa_dialog/add_siswa_dialog_view.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:panti_asuhan/app/themes/app_text.dart'; -import 'package:panti_asuhan/ui/widgets/my_textformfield.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; import 'package:validatorless/validatorless.dart'; import '../../../../../app/themes/app_colors.dart'; +import '../../../../../app/themes/app_text.dart'; +import '../../../../widgets/my_textformfield.dart'; import './add_siswa_dialog_view_model.dart'; class DataSiswa { diff --git a/lib/ui/views/admin_index_tracking/admin_index_tracking_view.dart b/lib/ui/views/admin_index_tracking/admin_index_tracking_view.dart index ff118a9..c878df3 100644 --- a/lib/ui/views/admin_index_tracking/admin_index_tracking_view.dart +++ b/lib/ui/views/admin_index_tracking/admin_index_tracking_view.dart @@ -36,12 +36,21 @@ class AdminIndexTrackingView extends StatelessWidget { backgroundColor: mainColor, elevation: 0, automaticallyImplyLeading: false, + actions: [ + IconButton( + onPressed: () { + model.logout(); + }, + icon: const Icon(Icons.logout, color: Colors.white), + ), + ], ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), child: ExtendedNavigator( navigatorKey: StackedService.nestedNavigationKey(3), router: AdminIndexTrackingViewRouter(), + initialRoute: AdminIndexTrackingViewRoutes.danaSosialAdminView, ), ), bottomNavigationBar: StylishBottomBar( diff --git a/lib/ui/views/admin_index_tracking/admin_index_tracking_view_model.dart b/lib/ui/views/admin_index_tracking/admin_index_tracking_view_model.dart index 1fa1e6c..e3e570d 100644 --- a/lib/ui/views/admin_index_tracking/admin_index_tracking_view_model.dart +++ b/lib/ui/views/admin_index_tracking/admin_index_tracking_view_model.dart @@ -1,14 +1,17 @@ import 'package:flutter/material.dart'; -import 'package:panti_asuhan/app/app.router.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; import '../../../app/app.locator.dart'; import '../../../app/app.logger.dart'; +import '../../../app/app.router.dart'; class AdminIndexTrackingViewModel extends IndexTrackingViewModel { final log = getLogger('AdminIndexTrackingViewModel'); final _navigationService = locator(); + final _dialogService = locator(); + final Future _prefs = SharedPreferences.getInstance(); final _bottomNavBarList = [ { @@ -47,11 +50,11 @@ class AdminIndexTrackingViewModel extends IndexTrackingViewModel { Future init() async { setIndex(1); // await 2 seconds to make sure the view is loaded - await Future.delayed(const Duration(milliseconds: 500)); - _navigationService.navigateTo( - _views[1], - id: 3, - ); + // await Future.delayed(const Duration(milliseconds: 500)); + // _navigationService.navigateTo( + // _views[1], + // id: 3, + // ); } void handleNavigation(int index) { @@ -67,4 +70,26 @@ class AdminIndexTrackingViewModel extends IndexTrackingViewModel { id: 3, ); } + + logout() { + _dialogService + .showConfirmationDialog( + title: 'Logout', + description: 'Apakah anda yakin ingin logout?', + cancelTitle: 'Ya', + confirmationTitle: 'Tidak', + // barrierDismissible: true, + ) + .then((value) { + if (!value!.confirmed) { + _prefs.then((SharedPreferences prefs) { + prefs.setBool('isLogin', false); + prefs.remove('role'); + _navigationService.clearStackAndShow(Routes.loginScreenView); + }); + } else { + _navigationService.back(); + } + }); + } } diff --git a/lib/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view.dart b/lib/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view.dart index d94f879..73c91b1 100644 --- a/lib/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view.dart +++ b/lib/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:panti_asuhan/app/themes/app_colors.dart'; -import 'package:panti_asuhan/services/other_function.dart'; import 'package:stacked/stacked.dart'; +import '../../../../app/themes/app_colors.dart'; import '../../../../app/themes/app_text.dart'; +import '../../../../services/other_function.dart'; import './dana_sosial_admin_view_model.dart'; class DanaSosialAdminView extends StatelessWidget { @@ -24,54 +24,80 @@ class DanaSosialAdminView extends StatelessWidget { return Scaffold( body: Column( children: [ - Container( - padding: - const EdgeInsets.symmetric(horizontal: 15, vertical: 10), - width: double.infinity, - decoration: BoxDecoration( - color: mainColor, - borderRadius: BorderRadius.circular(10), - boxShadow: [ - BoxShadow( - color: mainGrey.withOpacity(0.5), - spreadRadius: 5, - blurRadius: 7, - offset: const Offset(0, 3), // changes position of shadow - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Dana Sosial Bulan Ini', - style: boldTextStyle.copyWith( - color: Colors.white, - fontSize: 20, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 15, vertical: 10), + width: double.infinity, + decoration: BoxDecoration( + color: mainColor, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: mainGrey.withOpacity(0.5), + spreadRadius: 5, + blurRadius: 7, + offset: const Offset( + 0, 3), // changes position of shadow + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Dana Sosial Bulan Ini', + style: boldTextStyle.copyWith( + color: Colors.white, + fontSize: 20, + ), + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Total Dana Sosial', + style: regularTextStyle.copyWith( + color: Colors.white, + fontSize: 15, + ), + ), + Text( + 'Rp. 1.000.000', + style: regularTextStyle.copyWith( + color: Colors.white, + fontSize: 15, + ), + ), + ], + ), + ], ), ), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Total Dana Sosial', - style: regularTextStyle.copyWith( - color: Colors.white, - fontSize: 15, - ), - ), - Text( - 'Rp. 1.000.000', - style: regularTextStyle.copyWith( - color: Colors.white, - fontSize: 15, - ), - ), - ], + ), + const SizedBox(width: 10), + Container( + width: 50, + height: 50, + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: mainColor, ), - ], - ), + child: IconButton( + icon: const Icon( + Icons.filter_list, + color: Colors.white, + ), + onPressed: () { + model.filterDialog(context); + }, + ), + ), + ], ), const SizedBox(height: 25), Expanded( @@ -98,65 +124,93 @@ class DanaSosialAdminView extends StatelessWidget { ), ), ) - : ListView.builder( - padding: const EdgeInsets.symmetric( - horizontal: 15, vertical: 10), - itemCount: model.danaSosialModelList.length, - itemBuilder: (context, index) { - String jumlahDonasi = OtherFunction().commaFormat( - int.parse( - model.danaSosialModelList[index].jumlah ?? - '0')); - return Card( - child: ListTile( - title: Text( - model.danaSosialModelList[index].tanggal ?? - '', - style: boldTextStyle.copyWith( - fontSize: 13, color: mainColor)), - subtitle: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - model.danaSosialModelList[index].nama ?? - '', - style: regularTextStyle.copyWith( - fontSize: 13, color: mainColor)), - Text('Rp. $jumlahDonasi', - style: regularTextStyle.copyWith( - fontSize: 13, color: mainColor)), - ], - ), - trailing: Container( - width: 50, - height: 50, - decoration: BoxDecoration( - color: mainColor, - borderRadius: BorderRadius.circular(50), - ), - child: IconButton( - onPressed: () { - // model.goToTambahDanaSosial(); - }, - icon: const Icon( - Icons.edit, - color: Colors.white, - ), - ), - ), - ), - ); - }, - ), + : const TheData(), ), ), ], ), - floatingActionButton: FloatingActionButton( - onPressed: () { - model.goToTambahDanaSosial(); - }, - child: const Icon(Icons.add), + floatingActionButton: model.role == 'admin' + ? FloatingActionButton( + onPressed: () { + model.goToTambahDanaSosial(); + }, + child: const Icon(Icons.add), + ) + : null, + ); + }, + ); + } +} + +class TheData extends ViewModelWidget { + const TheData({ + super.key, + }); + + @override + Widget build(BuildContext context, DanaSosialAdminViewModel viewModel) { + return ListView.builder( + padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), + itemCount: viewModel.danaSosialModelList.length, + itemBuilder: (context, index) { + String jumlahDonasi = viewModel + .danaSosialModelList[index].jenisDonasi != + 'Barang' + ? OtherFunction().commaFormat( + int.parse(viewModel.danaSosialModelList[index].jumlah ?? '0')) + : '0'; + return Card( + child: ListTile( + title: Text(viewModel.danaSosialModelList[index].tanggal ?? '', + style: boldTextStyle.copyWith(fontSize: 13, color: mainColor)), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(viewModel.danaSosialModelList[index].nama ?? '', + style: regularTextStyle.copyWith( + fontSize: 13, color: mainColor)), + Text( + viewModel.danaSosialModelList[index].jenisDonasi == 'Uang' + ? (viewModel.isLogin == true ? 'Rp. $jumlahDonasi' : '-') + : 'Donasi Barang', + style: + regularTextStyle.copyWith(fontSize: 13, color: mainColor), + ), + Text( + viewModel.danaSosialModelList[index].status ?? '', + style: regularTextStyle.copyWith( + fontSize: 13, + color: viewModel.danaSosialModelList[index].status == + 'Belum Dikonfirmasi' + ? Colors.red + : Colors.green, + ), + ), + ], + ), + trailing: viewModel.isLogin == null + ? null + : (viewModel.isLogin == true + ? Container( + width: 50, + height: 50, + decoration: BoxDecoration( + color: mainColor, + borderRadius: BorderRadius.circular(50), + ), + child: IconButton( + onPressed: () { + viewModel.goToEditDanaSosial(int.parse(viewModel + .danaSosialModelList[index].idDanaSosial!)); + }, + icon: const Icon( + Icons.edit, + color: Colors.white, + ), + ), + ) + : null), ), ); }, diff --git a/lib/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view_model.dart b/lib/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view_model.dart index 9b680bf..09476c4 100644 --- a/lib/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view_model.dart +++ b/lib/ui/views/admin_index_tracking/dana_sosial_admin/dana_sosial_admin_view_model.dart @@ -1,3 +1,8 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../../../../app/app.dialogs.dart'; import '../../../../app/app.locator.dart'; import '../../../../app/app.logger.dart'; import '../../../../app/app.router.dart'; @@ -5,6 +10,7 @@ import '../../../../app/core/custom_base_view_model.dart'; import '../../../../model/dana_sosial_model.dart'; import '../../../../services/http_services.dart'; import '../../../../services/my_easyloading.dart'; +import '../../../../services/other_function.dart'; class DanaSosialAdminViewModel extends CustomBaseViewModel { final log = getLogger('DanaSosialAdminViewModel'); @@ -13,8 +19,15 @@ class DanaSosialAdminViewModel extends CustomBaseViewModel { List danaSosialModelList = []; + String? role; + bool? isLogin; + Future init() async { await getData(); + prefs.then((SharedPreferences prefs) { + role = prefs.getString('role'); + isLogin = prefs.getBool('isLogin'); + }); } getData() async { @@ -47,4 +60,93 @@ class DanaSosialAdminViewModel extends CustomBaseViewModel { goToTambahDanaSosial() { navigationService.navigateTo(Routes.tambahDanaSosialView); } + + getFilter(String sql) async { + setBusy(true); + easyLoading.showLoading(); + FormData formData = FormData.fromMap({ + 'sql': sql, + }); + try { + var response = await _httpService.postWithFormData( + 'filter_dana', + formData, + ); + log.i(response.data); + danaSosialModelList = []; + + var datanya = response.data['data']; + // log.i(datanya.length); + if (datanya.length > 0) { + for (var item in datanya) { + danaSosialModelList.add(DanaSosialModel.fromJson(item)); + } + } + + setBusy(false); + notifyListeners(); + log.i(danaSosialModelList); + } catch (e) { + log.e(e); + setBusy(false); + } finally { + easyLoading.dismissLoading(); + } + } + + filterDialog(BuildContext context) async { + // create a dialog + final res = await dialogService.showCustomDialog( + variant: DialogType.filterDialogView, + ); + + if (res!.confirmed) { + String jenisDonasi = res.data['jenisDonasi'] == 'Semua' + ? '' + : "jenis = '${res.data['jenisDonasi']}' and "; + String bulan = res.data['bulan'] == 'Semua' + ? '' + : "tanggal like '%-${OtherFunction().changeMonth(res.data['bulan'])}-%' and "; + String tahun = res.data['tahun'] == 'Semua' + ? '' + : 'tanggal like "%${res.data['tahun']}-%" and '; + String status = res.data['status'] == 'Semua' + ? '' + : (res.data['status'] == 'Belum Dikonfirmasi') + ? 'status = 0' + : 'status = 1'; + + if (jenisDonasi == 'Semua' && + bulan == 'Semua' && + tahun == 'Semua' && + status == 'Semua') { + getData(); + return; + } + + String sql = + 'Select * from tb_dana_sosial where $jenisDonasi$bulan$tahun$status'; + + // check the last 3 character if it is 'or ' then remove it + // if (sql.substring(sql.length - 3) == 'or ') { + // sql = sql.substring(0, sql.length - 3); + // } + if (sql.substring(sql.length - 4) == 'and ') { + sql = sql.substring(0, sql.length - 4); + } + + log.i(sql); + + getFilter(sql); + } + } + + goToEditDanaSosial(int id) async { + navigationService.navigateTo( + Routes.detailDanaSosialView, + arguments: DetailDanaSosialViewArguments( + id: id, + ), + ); + } } diff --git a/lib/ui/views/admin_index_tracking/data_siswa/data_siswa_view.dart b/lib/ui/views/admin_index_tracking/data_siswa/data_siswa_view.dart index c22f1b5..10e367e 100644 --- a/lib/ui/views/admin_index_tracking/data_siswa/data_siswa_view.dart +++ b/lib/ui/views/admin_index_tracking/data_siswa/data_siswa_view.dart @@ -127,12 +127,14 @@ class DataSiswaView extends StatelessWidget { ), ], ), - floatingActionButton: FloatingActionButton( - onPressed: () { - model.addSiswa(); - }, - child: const Icon(Icons.add), - ), + floatingActionButton: model.role == 'admin' + ? FloatingActionButton( + onPressed: () { + model.addSiswa(); + }, + child: const Icon(Icons.add), + ) + : null, ); }, ); diff --git a/lib/ui/views/admin_index_tracking/data_siswa/data_siswa_view_model.dart b/lib/ui/views/admin_index_tracking/data_siswa/data_siswa_view_model.dart index 98808d9..e6417b0 100644 --- a/lib/ui/views/admin_index_tracking/data_siswa/data_siswa_view_model.dart +++ b/lib/ui/views/admin_index_tracking/data_siswa/data_siswa_view_model.dart @@ -1,4 +1,5 @@ import 'package:panti_asuhan/ui/views/admin_index_tracking/edit_siswa/edit_siswa_view.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../../../../app/app.dialogs.dart'; import '../../../../app/app.locator.dart'; @@ -16,8 +17,13 @@ class DataSiswaViewModel extends CustomBaseViewModel { List siswaModelList = []; + String? role; + Future init() async { await getData(); + prefs.then((SharedPreferences prefs) { + role = prefs.getString('role'); + }); } getData() async { diff --git a/lib/ui/views/admin_index_tracking/filter_dialog/filter_dialog_view.dart b/lib/ui/views/admin_index_tracking/filter_dialog/filter_dialog_view.dart new file mode 100644 index 0000000..d546c38 --- /dev/null +++ b/lib/ui/views/admin_index_tracking/filter_dialog/filter_dialog_view.dart @@ -0,0 +1,284 @@ +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; + +import '../../../../app/themes/app_colors.dart'; +import '../../../../app/themes/app_text.dart'; +import './filter_dialog_view_model.dart'; + +class FilterDialogView extends StatelessWidget { + final DialogRequest? request; + final Function(DialogResponse)? completer; + + const FilterDialogView({ + Key? key, + this.request, + this.completer, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return ViewModelBuilder.reactive( + viewModelBuilder: () => FilterDialogViewModel(), + onViewModelReady: (FilterDialogViewModel model) async { + await model.init(); + }, + builder: ( + BuildContext context, + FilterDialogViewModel model, + Widget? child, + ) { + return Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + ), + padding: const EdgeInsets.all(10), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "FILTER LAPORAN", + style: boldTextStyle.copyWith( + fontSize: 16, + ), + ), + const SizedBox(height: 10), + Align( + alignment: Alignment.centerLeft, + child: Text( + "Jenis Dana Sosial", + style: regularTextStyle.copyWith(color: mainColor), + textAlign: TextAlign.left, + ), + ), + Container( + width: double.infinity, + height: 60, + padding: const EdgeInsets.all(15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + border: Border.all( + color: mainColor, + ), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: model.jenisDonasi, + onChanged: (String? newValue) { + // model.setSelectedjenisDonasi(newValue!); + model.log.i(newValue); + model.jenisDonasi = newValue!; + model.notifyListeners(); + }, + items: model.jenisDonasiList.map((String value) { + return DropdownMenuItem( + value: value, + child: Text( + value, + style: regularTextStyle.copyWith( + fontSize: 16, + ), + ), + ); + }).toList(), + ), + ), + ), + const SizedBox(height: 10), + Align( + alignment: Alignment.centerLeft, + child: Text( + "Filter Bulan", + style: regularTextStyle.copyWith(color: mainColor), + textAlign: TextAlign.left, + ), + ), + Container( + width: double.infinity, + height: 60, + padding: const EdgeInsets.all(15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + border: Border.all( + color: mainColor, + ), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: model.bulan, + onChanged: (String? newValue) { + // model.setSelectedbulan(newValue!); + model.log.i(newValue); + model.bulan = newValue!; + model.notifyListeners(); + }, + items: model.bulanList.map((String value) { + return DropdownMenuItem( + value: value, + child: Text( + value, + style: regularTextStyle.copyWith( + fontSize: 16, + ), + ), + ); + }).toList(), + ), + ), + ), + const SizedBox(height: 10), + Align( + alignment: Alignment.centerLeft, + child: Text( + "Filter Tahun", + style: regularTextStyle.copyWith(color: mainColor), + textAlign: TextAlign.left, + ), + ), + Container( + width: double.infinity, + height: 60, + padding: const EdgeInsets.all(15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + border: Border.all( + color: mainColor, + ), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: model.tahun, + onChanged: (String? newValue) { + // model.setSelectedtahun(newValue!); + model.log.i(newValue); + model.tahun = newValue!; + model.notifyListeners(); + }, + items: model.tahunList.map((String value) { + return DropdownMenuItem( + value: value, + child: Text( + value, + style: regularTextStyle.copyWith( + fontSize: 16, + ), + ), + ); + }).toList(), + ), + ), + ), + const SizedBox(height: 10), + Align( + alignment: Alignment.centerLeft, + child: Text( + "Filter Status", + style: regularTextStyle.copyWith(color: mainColor), + textAlign: TextAlign.left, + ), + ), + Container( + width: double.infinity, + height: 60, + padding: const EdgeInsets.all(15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + border: Border.all( + color: mainColor, + ), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: model.status, + onChanged: (String? newValue) { + // model.setSelectedstatus(newValue!); + model.log.i(newValue); + model.status = newValue!; + model.notifyListeners(); + }, + items: model.statusList.map((String value) { + return DropdownMenuItem( + value: value, + child: Text( + value, + style: regularTextStyle.copyWith( + fontSize: 16, + ), + ), + ); + }).toList(), + ), + ), + ), + const SizedBox(height: 15), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Expanded( + child: TextButton( + onPressed: () { + // model.filter(); + // model.filter(); + completer!( + DialogResponse( + confirmed: true, + data: { + 'jenisDonasi': model.jenisDonasi, + 'bulan': model.bulan, + 'tahun': model.tahun, + 'status': model.status, + }, + ), + ); + }, + style: TextButton.styleFrom( + backgroundColor: mainColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25), + ), + ), + child: Text( + "Filter", + style: boldTextStyle.copyWith( + fontSize: 16, + color: Colors.white, + ), + ), + ), + ), + const SizedBox(width: 10), + Expanded( + child: TextButton( + onPressed: () { + completer!(DialogResponse(confirmed: false)); + }, + style: TextButton.styleFrom( + backgroundColor: mainGrey, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25), + ), + ), + child: Text( + "Close", + style: boldTextStyle.copyWith( + fontSize: 16, + color: Colors.white, + ), + ), + ), + ), + ], + ) + ], + ), + ), + ); + }, + ); + } +} diff --git a/lib/ui/views/admin_index_tracking/filter_dialog/filter_dialog_view_model.dart b/lib/ui/views/admin_index_tracking/filter_dialog/filter_dialog_view_model.dart new file mode 100644 index 0000000..7714d26 --- /dev/null +++ b/lib/ui/views/admin_index_tracking/filter_dialog/filter_dialog_view_model.dart @@ -0,0 +1,41 @@ +import '../../../../app/app.logger.dart'; +import '../../../../app/core/custom_base_view_model.dart'; + +class FilterDialogViewModel extends CustomBaseViewModel { + final log = getLogger('FilterDialogViewModel'); + + String jenisDonasi = 'Semua'; + List jenisDonasiList = ['Semua', 'Uang', 'Barang']; + + String bulan = 'Semua'; + List bulanList = [ + 'Semua', + 'Januari', + 'Februari', + 'Maret', + 'April', + 'Mei', + 'Juni', + 'Agustus', + 'September', + 'Oktober', + 'November', + 'Desember' + ]; + + String tahun = 'Semua'; + List tahunList = [ + 'Semua', + '2023', + '2022', + ]; + + String status = 'Semua'; + List statusList = [ + 'Semua', + 'Belum Dikonfirmasi', + 'Sudah Dikonfirmasi', + ]; + + Future init() async {} +} diff --git a/lib/ui/views/admin_index_tracking/sejarah/sejarah_view.dart b/lib/ui/views/admin_index_tracking/sejarah/sejarah_view.dart index 6cfecd6..a8405d1 100644 --- a/lib/ui/views/admin_index_tracking/sejarah/sejarah_view.dart +++ b/lib/ui/views/admin_index_tracking/sejarah/sejarah_view.dart @@ -4,11 +4,13 @@ import 'package:stacked/stacked.dart'; import './sejarah_view_model.dart'; class SejarahView extends StatelessWidget { + const SejarahView({super.key}); + @override Widget build(BuildContext context) { return ViewModelBuilder.nonReactive( viewModelBuilder: () => SejarahViewModel(), - onModelReady: (SejarahViewModel model) async { + onViewModelReady: (SejarahViewModel model) async { await model.init(); }, builder: ( @@ -29,9 +31,9 @@ class SejarahView extends StatelessWidget { height: 150, ), ), - SizedBox(height: 20), + const SizedBox(height: 20), Text( - model.isi1 + '\n\n' + model.isi2, + '${model.isi1}\n\n${model.isi2}', style: const TextStyle(fontSize: 18), textAlign: TextAlign.justify, ), diff --git a/lib/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view.dart b/lib/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view.dart index 5335aa5..aefad19 100644 --- a/lib/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view.dart +++ b/lib/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view.dart @@ -4,11 +4,13 @@ import 'package:stacked/stacked.dart'; import './struktur_organisasi_view_model.dart'; class StrukturOrganisasiView extends StatelessWidget { + const StrukturOrganisasiView({super.key}); + @override Widget build(BuildContext context) { return ViewModelBuilder.nonReactive( viewModelBuilder: () => StrukturOrganisasiViewModel(), - onModelReady: (StrukturOrganisasiViewModel model) async { + onViewModelReady: (StrukturOrganisasiViewModel model) async { await model.init(); }, builder: ( @@ -43,7 +45,7 @@ class StrukturOrganisasiView extends StatelessWidget { height: 2, ), Text( - model.Ketua, + model.ketua, style: const TextStyle( fontSize: 20, ), @@ -62,7 +64,7 @@ class StrukturOrganisasiView extends StatelessWidget { height: 2, ), Text( - model.Sekretaris, + model.sekretaris, style: const TextStyle( fontSize: 20, ), @@ -81,7 +83,7 @@ class StrukturOrganisasiView extends StatelessWidget { height: 2, ), Text( - model.Bendahara, + model.bendahara, style: const TextStyle( fontSize: 20, ), @@ -100,7 +102,7 @@ class StrukturOrganisasiView extends StatelessWidget { height: 2, ), Text( - '${model.SeksiPengasuh1}\n${model.SeksiPengasuh2}\n${model.SeksiPengasuh3}\n${model.SeksiPengasuh4}', + '${model.seksiPengasuh1}\n${model.seksiPengasuh2}\n${model.seksiPengasuh3}\n${model.seksiPengasuh4}', style: const TextStyle( fontSize: 20, ), @@ -119,7 +121,7 @@ class StrukturOrganisasiView extends StatelessWidget { height: 2, ), Text( - '${model.SeksiIbadah1}\n${model.SeksiIbadah2}\n${model.SeksiIbadah3}\n${model.SeksiIbadah4}', + '${model.seksiIbadah1}\n${model.seksiIbadah2}\n${model.seksiIbadah3}\n${model.seksiIbadah4}', style: const TextStyle( fontSize: 20, ), @@ -138,7 +140,7 @@ class StrukturOrganisasiView extends StatelessWidget { height: 2, ), Text( - '${model.SeksiPendidikan1}\n${model.SeksiPendidikan2}', + '${model.seksiPendidikan1}\n${model.seksiPendidikan2}', style: const TextStyle( fontSize: 20, ), @@ -157,7 +159,7 @@ class StrukturOrganisasiView extends StatelessWidget { height: 2, ), Text( - model.SeksiKesehatan, + model.seksiKesehatan, style: const TextStyle( fontSize: 20, ), @@ -176,7 +178,7 @@ class StrukturOrganisasiView extends StatelessWidget { height: 2, ), Text( - model.SeksiKebersihan, + model.seksiKebersihan, style: const TextStyle( fontSize: 20, ), @@ -192,7 +194,7 @@ class StrukturOrganisasiView extends StatelessWidget { ), ), Text( - model.SeksiKeterampilan1, + model.seksiKeterampilan1, style: const TextStyle( fontSize: 20, ), @@ -208,7 +210,7 @@ class StrukturOrganisasiView extends StatelessWidget { ), ), Text( - model.SeksiSaranaPrasarana1, + model.seksiSaranaPrasarana1, style: const TextStyle( fontSize: 20, ), @@ -224,7 +226,7 @@ class StrukturOrganisasiView extends StatelessWidget { ), ), Text( - '${model.SeksiKonsumsi1}\n${model.SeksiKonsumsi2}', + '${model.seksiKonsumsi1}\n${model.seksiKonsumsi2}', style: const TextStyle( fontSize: 20, ), @@ -240,7 +242,7 @@ class StrukturOrganisasiView extends StatelessWidget { ), ), Text( - '${model.SeksiKeamanan1}\n${model.SeksiKeamanan2}', + '${model.seksiKeamanan1}\n${model.seksiKeamanan2}', style: const TextStyle( fontSize: 20, ), @@ -256,7 +258,7 @@ class StrukturOrganisasiView extends StatelessWidget { ), ), Text( - '${model.SeksiGedung1}\n${model.SeksiGedung2}\n${model.SeksiGedung3}\n${model.SeksiGedung4}', + '${model.seksiGedung1}\n${model.seksiGedung2}\n${model.seksiGedung3}\n${model.seksiGedung4}', style: const TextStyle( fontSize: 20, ), @@ -272,7 +274,7 @@ class StrukturOrganisasiView extends StatelessWidget { ), ), Text( - '${model.SeksiWisma1}\n${model.SeksiWisma2}\n${model.SeksiWisma3}\n${model.SeksiWisma4}\n${model.SeksiWisma5}', + '${model.seksiWisma1}\n${model.seksiWisma2}\n${model.seksiWisma3}\n${model.seksiWisma4}\n${model.seksiWisma5}', style: const TextStyle( fontSize: 20, ), @@ -288,7 +290,7 @@ class StrukturOrganisasiView extends StatelessWidget { ), ), Text( - '${model.KelompokPutri1}\n${model.KelompokPutri2}\n${model.KelompokPutri3}', + '${model.kelompokPutri1}\n${model.kelompokPutri2}\n${model.kelompokPutri3}', style: const TextStyle( fontSize: 20, ), @@ -304,7 +306,7 @@ class StrukturOrganisasiView extends StatelessWidget { ), ), Text( - '${model.KelompokPutra1}\n${model.KelompokPutra2}\n${model.KelompokPutra3}', + '${model.kelompokPutra1}\n${model.kelompokPutra2}\n${model.kelompokPutra3}', style: const TextStyle( fontSize: 20, ), diff --git a/lib/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view_model.dart b/lib/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view_model.dart index 3fd4d42..73f7748 100644 --- a/lib/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view_model.dart +++ b/lib/ui/views/admin_index_tracking/struktur_organisasi/struktur_organisasi_view_model.dart @@ -1,54 +1,54 @@ import 'package:panti_asuhan/app/core/custom_base_view_model.dart'; class StrukturOrganisasiViewModel extends CustomBaseViewModel { - String Ketua = "Dr. Andi Fitriani D, S.Ag, M.Pd"; - String Sekretaris = "Fitriana Buyanus, S.Si ., M.Kes"; - String Bendahara = "Hj. Djaliah, A.Ma"; + String ketua = "Dr. Andi Fitriani D, S.Ag, M.Pd"; + String sekretaris = "Fitriana Buyanus, S.Si ., M.Kes"; + String bendahara = "Hj. Djaliah, A.Ma"; - String SeksiPengasuh1 = "Dra Hj, CIA"; - String SeksiPengasuh2 = "Dahang, S.Ag"; - String SeksiPengasuh3 = "Sumadin, S.Pd.I"; - String SeksiPengasuh4 = "Darwan"; + String seksiPengasuh1 = "Dra Hj, CIA"; + String seksiPengasuh2 = "Dahang, S.Ag"; + String seksiPengasuh3 = "Sumadin, S.Pd.I"; + String seksiPengasuh4 = "Darwan"; - String SeksiIbadah1 = "Drs. Najib La'ady"; - String SeksiIbadah2 = "Sumadin, S.Pd.I"; - String SeksiIbadah3 = "Ahmad"; - String SeksiIbadah4 = "Darwan"; + String seksiIbadah1 = "Drs. Najib La'ady"; + String seksiIbadah2 = "Sumadin, S.Pd.I"; + String seksiIbadah3 = "Ahmad"; + String seksiIbadah4 = "Darwan"; - String SeksiPendidikan1 = "Dra. Hj. CIA"; - String SeksiPendidikan2 = "Hj. Djaliah, A.Ma"; + String seksiPendidikan1 = "Dra. Hj. CIA"; + String seksiPendidikan2 = "Hj. Djaliah, A.Ma"; - String SeksiKesehatan = "Haerul, SKM"; - String SeksiKebersihan = "Bd. Lina Sutomo"; + String seksiKesehatan = "Haerul, SKM"; + String seksiKebersihan = "Bd. Lina Sutomo"; - String SeksiKeterampilan1 = "Yuslihudriani, S.Pd"; + String seksiKeterampilan1 = "Yuslihudriani, S.Pd"; - String SeksiSaranaPrasarana1 = "Muh.Adham, ST"; + String seksiSaranaPrasarana1 = "Muh.Adham, ST"; - String SeksiKonsumsi1 = "Fatmawati"; - String SeksiKonsumsi2 = "Rasnaya"; + String seksiKonsumsi1 = "Fatmawati"; + String seksiKonsumsi2 = "Rasnaya"; - String SeksiKeamanan1 = "Firdaus"; - String SeksiKeamanan2 = "Ahmad"; + String seksiKeamanan1 = "Firdaus"; + String seksiKeamanan2 = "Ahmad"; - String SeksiGedung1 = "Dra. Bangsuari"; - String SeksiGedung2 = "Hidayani"; - String SeksiGedung3 = "Dahang. S,Ag"; - String SeksiGedung4 = "Saharia"; + String seksiGedung1 = "Dra. Bangsuari"; + String seksiGedung2 = "Hidayani"; + String seksiGedung3 = "Dahang. S,Ag"; + String seksiGedung4 = "Saharia"; - String SeksiWisma1 = "Drs. Muh, Yasmin"; - String SeksiWisma2 = "Hj. Hadilah"; - String SeksiWisma3 = "Muh.Adham, ST"; - String SeksiWisma4 = "Ahmad"; - String SeksiWisma5 = "Dahang, S.Ag"; + String seksiWisma1 = "Drs. Muh, Yasmin"; + String seksiWisma2 = "Hj. Hadilah"; + String seksiWisma3 = "Muh.Adham, ST"; + String seksiWisma4 = "Ahmad"; + String seksiWisma5 = "Dahang, S.Ag"; - String KelompokPutri1 = "St. Khadijah"; - String KelompokPutri2 = "St. Aisyah"; - String KelompokPutri3 = "St. Fatimah"; + String kelompokPutri1 = "St. Khadijah"; + String kelompokPutri2 = "St. Aisyah"; + String kelompokPutri3 = "St. Fatimah"; - String KelompokPutra1 = "Ahmad Dahlan"; - String KelompokPutra2 = "Ar. Fahruddin"; - String KelompokPutra3 = "Amin Rais"; + String kelompokPutra1 = "Ahmad Dahlan"; + String kelompokPutra2 = "Ar. Fahruddin"; + String kelompokPutra3 = "Amin Rais"; Future init() async {} } diff --git a/lib/ui/views/admin_index_tracking/visi_misi/visi_misi_view.dart b/lib/ui/views/admin_index_tracking/visi_misi/visi_misi_view.dart index 18757a4..c54c024 100644 --- a/lib/ui/views/admin_index_tracking/visi_misi/visi_misi_view.dart +++ b/lib/ui/views/admin_index_tracking/visi_misi/visi_misi_view.dart @@ -4,11 +4,13 @@ import 'package:stacked/stacked.dart'; import './visi_misi_view_model.dart'; class VisiMisiView extends StatelessWidget { + const VisiMisiView({super.key}); + @override Widget build(BuildContext context) { return ViewModelBuilder.nonReactive( viewModelBuilder: () => VisiMisiViewModel(), - onModelReady: (VisiMisiViewModel model) async { + onViewModelReady: (VisiMisiViewModel model) async { await model.init(); }, builder: ( @@ -29,36 +31,28 @@ class VisiMisiView extends StatelessWidget { height: 150, ), ), - Center( + const Center( child: Text( 'Visi', - style: const TextStyle(fontSize: 20), + style: TextStyle(fontSize: 20), ), ), - SizedBox(height: 10), + const SizedBox(height: 10), Text( model.visi, style: const TextStyle(fontSize: 18), textAlign: TextAlign.justify, ), - SizedBox(height: 30), - Center( + const SizedBox(height: 30), + const Center( child: Text( 'Misi', - style: const TextStyle(fontSize: 20), + style: TextStyle(fontSize: 20), ), ), - SizedBox(height: 10), + const SizedBox(height: 10), Text( - model.misi1 + - '\n\n' + - model.misi2 + - '\n\n' + - model.misi3 + - '\n\n' + - model.misi4 + - '\n\n' + - model.misi5, + '${model.misi1}\n\n${model.misi2}\n\n${model.misi3}\n\n${model.misi4}\n\n${model.misi5}', style: const TextStyle(fontSize: 18), textAlign: TextAlign.justify, ), diff --git a/lib/ui/views/detail_dana_sosial/detail_dana_sosial_view.dart b/lib/ui/views/detail_dana_sosial/detail_dana_sosial_view.dart new file mode 100644 index 0000000..0015027 --- /dev/null +++ b/lib/ui/views/detail_dana_sosial/detail_dana_sosial_view.dart @@ -0,0 +1,213 @@ +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; + +import '../../../app/themes/app_colors.dart'; +import '../../../app/themes/app_text.dart'; +import '../../widgets/my_textformfield.dart'; +import './detail_dana_sosial_view_model.dart'; + +class DetailDanaSosialView extends StatelessWidget { + final int id; + + const DetailDanaSosialView({Key? key, required this.id}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ViewModelBuilder.reactive( + viewModelBuilder: () => DetailDanaSosialViewModel(), + onViewModelReady: (DetailDanaSosialViewModel model) async { + await model.init(id); + }, + builder: ( + BuildContext context, + DetailDanaSosialViewModel model, + Widget? child, + ) { + return Scaffold( + appBar: AppBar( + title: const Text('Detail Dana Sosial', + style: TextStyle(color: Colors.white)), + backgroundColor: mainColor, + iconTheme: const IconThemeData(color: Colors.white), + ), + body: Padding( + padding: const EdgeInsets.all(15), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Align( + alignment: Alignment.centerLeft, + child: Text( + "Nama Donator", + style: regularTextStyle.copyWith(color: mainColor), + ), + ), + MyTextFormField( + controller: model.namaController, + maxLines: 1, + readOnly: true, + ), + const SizedBox( + height: 15, + ), + Align( + alignment: Alignment.centerLeft, + child: Text( + "Tanggal", + style: regularTextStyle.copyWith(color: mainColor), + ), + ), + MyTextFormField( + controller: model.tanggalController, + maxLines: 1, + readOnly: true, + ), + const SizedBox( + height: 15, + ), + Align( + alignment: Alignment.centerLeft, + child: Text( + "Jenis", + style: regularTextStyle.copyWith(color: mainColor), + ), + ), + MyTextFormField( + controller: model.jenisController, + maxLines: 1, + readOnly: true, + ), + Visibility( + visible: model.jenisBool, + child: const SizedBox( + height: 15, + ), + ), + Visibility( + visible: model.jenisBool, + child: Align( + alignment: Alignment.centerLeft, + child: Text( + "Jumlah", + style: regularTextStyle.copyWith(color: mainColor), + ), + ), + ), + Visibility( + visible: model.jenisBool, + child: MyTextFormField( + controller: model.jumlahController, + maxLines: 1, + readOnly: true, + ), + ), + Visibility( + visible: !model.jenisBool, + child: const SizedBox( + height: 15, + ), + ), + Visibility( + visible: !model.jenisBool, + child: Align( + alignment: Alignment.centerLeft, + child: Text( + "Keterangan", + style: regularTextStyle.copyWith(color: mainColor), + ), + ), + ), + Visibility( + visible: !model.jenisBool, + child: MyTextFormField( + controller: model.keteranganController, + maxLines: 2, + readOnly: true, + ), + ), + const SizedBox( + height: 15, + ), + Expanded( + child: Align( + alignment: Alignment.centerRight, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "Tanda Tangan", + style: regularTextStyle.copyWith(color: mainColor), + ), + SizedBox( + height: 150, + width: 150, + child: model.danaSosialModel == null + ? Container( + decoration: BoxDecoration( + border: Border.all(color: mainColor), + ), + ) + : (model.danaSosialModel!.status! == + 'Belum Dikonfirmasi' + ? const TtdWidget() + : Image.asset( + 'assets/qrcode.png', + fit: BoxFit.cover, + )), + ), + const SizedBox( + height: 10, + ), + Text( + "Dr. Andi Fitriani D, S.Ag, M.Pd", + style: regularTextStyle.copyWith( + color: mainColor, + fontWeight: FontWeight.bold, + ), + ), + // create a horizontal line + ], + ), + ), + ), + ], + ), + ), + ); + }, + ); + } +} + +class TtdWidget extends ViewModelWidget { + const TtdWidget({ + super.key, + }); + + @override + Widget build(BuildContext context, DetailDanaSosialViewModel viewModel) { + return Container( + decoration: BoxDecoration( + border: Border.all(color: mainColor), + ), + child: viewModel.role == 'pimpinan' + ? InkWell( + onTap: () { + viewModel.handleTtd(); + }, + child: Center( + child: Text( + "Tanda Tangan", + style: regularTextStyle.copyWith( + color: mainColor, + fontStyle: FontStyle.italic, + ), + ), + ), + ) + : null, + ); + } +} diff --git a/lib/ui/views/detail_dana_sosial/detail_dana_sosial_view_model.dart b/lib/ui/views/detail_dana_sosial/detail_dana_sosial_view_model.dart new file mode 100644 index 0000000..342f928 --- /dev/null +++ b/lib/ui/views/detail_dana_sosial/detail_dana_sosial_view_model.dart @@ -0,0 +1,105 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../../../app/app.locator.dart'; +import '../../../app/app.logger.dart'; +import '../../../app/core/custom_base_view_model.dart'; +import '../../../model/dana_sosial_model.dart'; +import '../../../services/http_services.dart'; +import '../../../services/my_easyloading.dart'; +import '../../../services/other_function.dart'; + +class DetailDanaSosialViewModel extends CustomBaseViewModel { + final log = getLogger('DetailDanaSosialViewModel'); + final _httpService = locator(); + final easyLoading = locator(); + + int? idDanaSosial; + DanaSosialModel? danaSosialModel; + bool jenisBool = true; + + String? role; + + TextEditingController namaController = TextEditingController(); + TextEditingController tanggalController = TextEditingController(); + TextEditingController jumlahController = TextEditingController(); + TextEditingController jenisController = TextEditingController(); + TextEditingController keteranganController = TextEditingController(); + + Future init(int id) async { + log.i('init and id: $id'); + getData(id); + idDanaSosial = id; + prefs.then((SharedPreferences prefs) { + role = prefs.getString('role'); + }); + } + + getData(int id) async { + setBusy(true); + easyLoading.showLoading(); + try { + var response = await _httpService.get('dana_sosial_detail?id=$id'); + log.i(response.data); + danaSosialModel = DanaSosialModel.fromJson(response.data['data']); + namaController.text = danaSosialModel!.nama!; + tanggalController.text = danaSosialModel!.tanggal!; + jumlahController.text = + "Rp. ${OtherFunction().commaFormat(danaSosialModel!.jumlah != null ? int.parse(danaSosialModel!.jumlah!) : 0)}"; + jenisController.text = danaSosialModel!.jenisDonasi!; + keteranganController.text = danaSosialModel!.keterangan!; + + if (danaSosialModel!.jenisDonasi == 'Uang') { + jenisBool = true; + } else { + jenisBool = false; + } + log.i('status: ${danaSosialModel!.status}'); + setBusy(false); + notifyListeners(); + } catch (e) { + log.e(e); + setBusy(false); + } finally { + easyLoading.dismissLoading(); + } + } + + void handleTtd() { + dialogService + .showConfirmationDialog( + title: 'Konfirmasi', + description: 'Apakah anda yakin ingin mengkonfirmasi tanda tangan ini?', + cancelTitle: 'Tidak', + confirmationTitle: 'Ya', + ) + .then((value) async { + if (value!.confirmed) { + setBusy(true); + easyLoading.showLoading(); + try { + FormData formData = FormData.fromMap({ + 'id': idDanaSosial, + }); + var response = + await _httpService.postWithFormData('dana_sosial_ttd', formData); + log.i(response.data); + getData(idDanaSosial!); + + setBusy(false); + notifyListeners(); + } catch (e) { + log.e(e); + setBusy(false); + dialogService.showDialog( + title: 'Error', + description: e.toString(), + ); + } finally { + easyLoading.dismissLoading(); + } + } + }); + } +} diff --git a/lib/ui/views/login_screen/login_screen_view.dart b/lib/ui/views/login_screen/login_screen_view.dart index d0f8ad3..6a36e9f 100644 --- a/lib/ui/views/login_screen/login_screen_view.dart +++ b/lib/ui/views/login_screen/login_screen_view.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:panti_asuhan/ui/widgets/my_button.dart'; -import 'package:panti_asuhan/ui/widgets/my_textformfield.dart'; import 'package:stacked/stacked.dart'; +import 'package:validatorless/validatorless.dart'; +import '../../../app/app.router.dart'; import '../../../app/themes/app_text.dart'; +import '../../widgets/my_button.dart'; +import '../../widgets/my_textformfield.dart'; import './login_screen_view_model.dart'; class LoginScreenView extends StatelessWidget { @@ -25,59 +27,77 @@ class LoginScreenView extends StatelessWidget { body: Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), child: SingleChildScrollView( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - height: MediaQuery.of(context).size.height * 0.2, - ), - // show the logo.png - const Center( - child: Image( - image: AssetImage("assets/logo.png"), - width: 150, - height: 150, + child: Form( + key: model.formKey, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height * 0.2, ), - ), - const SizedBox(height: 10), - Text( - "SILAHKAN LOGIN", - style: boldTextStyle.copyWith( - fontSize: 18, + // show the logo.png + const Center( + child: Image( + image: AssetImage("assets/logo.png"), + width: 150, + height: 150, + ), ), - ), - const SizedBox( - height: 10, - ), - const MyTextFormField( - hintText: "Username", - prefixIcon: Icon(Icons.person), - // controller: model.usernameController, - ), - const SizedBox( - height: 10, - ), - const MyTextFormField( - hintText: "Password", - prefixIcon: Icon(Icons.lock), - // controller: model.passwordController, - obscureText: true, - ), - const SizedBox( - height: 10, - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.5, - child: MyButton( - text: "LOGIN", + const SizedBox(height: 10), + Text( + "SILAHKAN LOGIN", + style: boldTextStyle.copyWith( + fontSize: 18, + ), + ), + const SizedBox( + height: 10, + ), + MyTextFormField( + hintText: "Username", + prefixIcon: const Icon(Icons.person), + controller: model.usernameController, + validator: + Validatorless.required("Username tidak boleh kosong"), + ), + const SizedBox( + height: 10, + ), + MyTextFormField( + hintText: "Password", + prefixIcon: const Icon(Icons.lock), + controller: model.passwordController, + obscureText: true, + validator: + Validatorless.required("Password tidak boleh kosong"), + ), + const SizedBox( + height: 10, + ), + SizedBox( + width: MediaQuery.of(context).size.width * 0.5, + child: MyButton( + text: "LOGIN", + onPressed: () { + if (model.formKey.currentState!.validate()) { + model.login(); + } + }, + ), + ), + TextButton( onPressed: () { - model.goToAdmin(); + model.navigationService + .navigateTo(Routes.userIndexTrackingView); }, - ), - ), - ], + child: const Text( + "Kembali ke beranda", + ), + ) + ], + ), ), ), ), diff --git a/lib/ui/views/login_screen/login_screen_view_model.dart b/lib/ui/views/login_screen/login_screen_view_model.dart index b4759fb..d1e4a01 100644 --- a/lib/ui/views/login_screen/login_screen_view_model.dart +++ b/lib/ui/views/login_screen/login_screen_view_model.dart @@ -1,13 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + import '../../../app/app.logger.dart'; import '../../../app/app.router.dart'; import '../../../app/core/custom_base_view_model.dart'; class LoginScreenViewModel extends CustomBaseViewModel { final log = getLogger('LoginScreenViewModel'); + final Future _prefs = SharedPreferences.getInstance(); Future init() async {} - goToAdmin() { - log.d('goToAdmin'); - navigationService.navigateTo(Routes.adminIndexTrackingView); + final formKey = GlobalKey(); + TextEditingController usernameController = TextEditingController(); + TextEditingController passwordController = TextEditingController(); + + login() { + if (usernameController.text == 'admin' && + passwordController.text == 'admin') { + _prefs.then((SharedPreferences prefs) { + prefs.setBool('isLogin', true); + prefs.setString('role', 'admin'); + }); + log.d('goToAdmin'); + navigationService.navigateTo(Routes.adminIndexTrackingView); + } else if (usernameController.text == 'pimpinan' && + passwordController.text == 'pimpinan') { + _prefs.then((SharedPreferences prefs) { + prefs.setBool('isLogin', true); + prefs.setString('role', 'pimpinan'); + }); + log.d('goToPimpinan'); + navigationService.navigateTo(Routes.pimpinanIndexTrackingView); + } else { + dialogService.showDialog( + title: 'Gagal', + description: 'Username atau password salah', + ); + _prefs.then((SharedPreferences prefs) { + prefs.setBool('isLogin', false); + prefs.remove('role'); + }); + } } } diff --git a/lib/ui/views/pimpinan_index_tracking/pimpinan_index_tracking/pimpinan_index_tracking_view.dart b/lib/ui/views/pimpinan_index_tracking/pimpinan_index_tracking/pimpinan_index_tracking_view.dart new file mode 100644 index 0000000..9744cf7 --- /dev/null +++ b/lib/ui/views/pimpinan_index_tracking/pimpinan_index_tracking/pimpinan_index_tracking_view.dart @@ -0,0 +1,99 @@ +import 'package:flutter/material.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; +import 'package:stylish_bottom_bar/model/bar_items.dart'; +import 'package:stylish_bottom_bar/stylish_bottom_bar.dart'; + +import '../../../../app/app.router.dart'; +import '../../../../app/themes/app_colors.dart'; +import '../../../../app/themes/app_text.dart'; +import './pimpinan_index_tracking_view_model.dart'; + +class PimpinanIndexTrackingView extends StatelessWidget { + const PimpinanIndexTrackingView({super.key}); + + @override + Widget build(BuildContext context) { + return ViewModelBuilder.reactive( + viewModelBuilder: () => PimpinanIndexTrackingViewModel(), + onViewModelReady: (PimpinanIndexTrackingViewModel model) async { + await model.init(); + }, + builder: ( + BuildContext context, + PimpinanIndexTrackingViewModel model, + Widget? child, + ) { + return Scaffold( + appBar: AppBar( + title: Text( + model.header, + style: const TextStyle( + color: Colors.white, + fontSize: 20, + ), + ), + backgroundColor: mainColor, + elevation: 0, + automaticallyImplyLeading: false, + actions: [ + IconButton( + onPressed: () { + // model.navigationService.navigateTo(Routes.loginScreenView); + model.logout(); + }, + icon: const Icon( + Icons.logout, + color: Colors.white, + ), + ), + ], + ), + body: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), + child: ExtendedNavigator( + navigatorKey: StackedService.nestedNavigationKey(4), + router: PimpinanIndexTrackingViewRouter(), + initialRoute: PimpinanIndexTrackingViewRoutes.danaSosialAdminView, + ), + ), + bottomNavigationBar: StylishBottomBar( + items: [ + for (var item in model.bottomNavBarList) + BottomBarItem( + icon: Icon(item['icon'], + color: model.currentIndex == + model.bottomNavBarList.indexOf(item) + ? sixthGrey + : backgroundColor), + title: Text( + item['name'], + style: regularTextStyle.copyWith( + color: model.currentIndex == + model.bottomNavBarList.indexOf(item) + ? sixthGrey + : Colors.grey, + ), + ), + backgroundColor: + model.currentIndex == model.bottomNavBarList.indexOf(item) + ? Colors.white + : Colors.grey, + ), + ], + currentIndex: model.currentIndex, + hasNotch: true, + backgroundColor: mainColor, + onTap: (value) { + model.handleNavigation(value); + }, + option: BubbleBarOptions( + barStyle: BubbleBarStyle.horizotnal, + bubbleFillStyle: BubbleFillStyle.fill, + opacity: 0.3), + ), + ); + }, + ); + } +} diff --git a/lib/ui/views/pimpinan_index_tracking/pimpinan_index_tracking/pimpinan_index_tracking_view_model.dart b/lib/ui/views/pimpinan_index_tracking/pimpinan_index_tracking/pimpinan_index_tracking_view_model.dart new file mode 100644 index 0000000..74ec8bf --- /dev/null +++ b/lib/ui/views/pimpinan_index_tracking/pimpinan_index_tracking/pimpinan_index_tracking_view_model.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; + +import '../../../../app/app.locator.dart'; +import '../../../../app/app.logger.dart'; +import '../../../../app/app.router.dart'; + +class PimpinanIndexTrackingViewModel extends IndexTrackingViewModel { + final log = getLogger('PimpinanIndexTrackingViewModel'); + final _navigationService = locator(); + final _dialogService = locator(); + + final Future _prefs = SharedPreferences.getInstance(); + + String header = 'Dana Sosial'; + + final _bottomNavBarList = [ + { + 'name': 'Siswa', + 'icon': Icons.people_alt_outlined, + 'header': 'List Siswa' + }, + {'name': 'Dana', 'icon': Icons.money, 'header': 'Dana Sosial'}, + { + 'name': 'Profil', + 'icon': Icons.person_4_outlined, + 'header': 'Profil Panti Asuhan' + }, + ]; + + List> get bottomNavBarList => _bottomNavBarList; + final List _views = [ + PimpinanIndexTrackingViewRoutes.dataSiswaView, + PimpinanIndexTrackingViewRoutes.danaSosialAdminView, + PimpinanIndexTrackingViewRoutes.profilView, + ]; + Future init() async { + _prefs.then((SharedPreferences prefs) { + if (prefs.getString('role') == 'pimpinan') { + setIndex(1); + // // await 2 seconds to make sure the view is loaded + // Future.delayed(const Duration(milliseconds: 500)); + } else { + prefs.setBool('isLogin', false); + prefs.remove('role'); + _navigationService.clearStackAndShow(Routes.loginScreenView); + } + }); + } + + void handleNavigation(int index) { + log.d("handleNavigation: $index"); + log.d("currentIndex: $currentIndex"); + + if (currentIndex == index) return; + + setIndex(index); + header = _bottomNavBarList[index]['header'] as String; + _navigationService.navigateTo( + _views[index], + id: 4, + ); + } + + logout() { + _dialogService + .showConfirmationDialog( + title: 'Logout', + description: 'Apakah anda yakin ingin logout?', + cancelTitle: 'Ya', + confirmationTitle: 'Tidak', + // barrierDismissible: true, + ) + .then((value) { + if (!value!.confirmed) { + _prefs.then((SharedPreferences prefs) { + prefs.setBool('isLogin', false); + prefs.remove('role'); + _navigationService.clearStackAndShow(Routes.loginScreenView); + }); + } else { + _navigationService.back(); + } + }); + } +} diff --git a/lib/ui/views/splash_screen/splash_screen_view_model.dart b/lib/ui/views/splash_screen/splash_screen_view_model.dart index 9fd48a2..8d8e05b 100644 --- a/lib/ui/views/splash_screen/splash_screen_view_model.dart +++ b/lib/ui/views/splash_screen/splash_screen_view_model.dart @@ -1,3 +1,5 @@ +import 'package:shared_preferences/shared_preferences.dart'; + import '../../../app/app.logger.dart'; import '../../../app/app.router.dart'; import '../../../app/core/custom_base_view_model.dart'; @@ -7,8 +9,29 @@ class SplashScreenViewModel extends CustomBaseViewModel { Future init() async { // wait 2 seconds then navigate to login await Future.delayed(const Duration(seconds: 2)); - await navigationService.navigateTo( - Routes.loginScreenView, - ); + prefs.then((SharedPreferences prefs) { + if (prefs.getBool('isLogin') != true) { + return navigationService.navigateTo( + Routes.userIndexTrackingView, + ); + } + + if (prefs.getString('role') == 'admin') { + return navigationService.navigateTo( + Routes.adminIndexTrackingView, + ); + } + + if (prefs.getString('role') == 'pimpinan') { + return navigationService.navigateTo( + Routes.pimpinanIndexTrackingView, + ); + } + }); + + // await navigationService.navigateTo( + // // Routes.loginScreenView, + // Routes.userIndexTrackingView, + // ); } } diff --git a/lib/ui/views/tambah_dana_sosial/tambah_dana_sosial_view.dart b/lib/ui/views/tambah_dana_sosial/tambah_dana_sosial_view.dart index 08f835c..3c3987f 100644 --- a/lib/ui/views/tambah_dana_sosial/tambah_dana_sosial_view.dart +++ b/lib/ui/views/tambah_dana_sosial/tambah_dana_sosial_view.dart @@ -58,18 +58,68 @@ class TambahDanaSosialView extends StatelessWidget { ), const SizedBox(height: 20), Text( - "Jumlah (Rp. )", + "Jenis Donasi", style: regularTextStyle.copyWith(color: mainColor), ), - MyTextFormField( - hintText: "Jumlah (Rp. )", - keyboardType: TextInputType.number, - controller: model.jumlahController, - validator: Validatorless.multiple( - [ - Validatorless.required('Jumlah tidak boleh kosong'), - Validatorless.number('Jumlah harus angka'), - ], + Container( + width: double.infinity, + height: 60, + padding: const EdgeInsets.symmetric(horizontal: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + border: Border.all( + color: mainColor, + ), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: model.jenisDonasi, + onChanged: (String? newValue) { + // model.setSelectedjenisDonasi(newValue!); + model.log.i(newValue); + model.jenisDonasi = newValue!; + model.notifyListeners(); + }, + items: model.jenisDonasiList.map((String value) { + return DropdownMenuItem( + value: value, + child: Text( + value, + style: regularTextStyle.copyWith( + fontSize: 16, + ), + ), + ); + }).toList(), + ), + ), + ), + Visibility( + visible: model.jenisDonasi == 'Uang', + child: const SizedBox(height: 20), + ), + Visibility( + visible: model.jenisDonasi == 'Uang', + child: Text( + "Jumlah (Rp. )", + style: regularTextStyle.copyWith(color: mainColor), + ), + ), + Visibility( + visible: model.jenisDonasi == 'Uang', + child: MyTextFormField( + hintText: "Jumlah (Rp. ) Donasi", + keyboardType: TextInputType.number, + controller: model.jumlahController, + validator: model.jenisDonasi == 'Uang' + ? Validatorless.multiple( + [ + Validatorless.required( + 'Jumlah tidak boleh kosong'), + Validatorless.number('Jumlah harus angka'), + ], + ) + : null, ), ), const SizedBox(height: 20), @@ -78,7 +128,7 @@ class TambahDanaSosialView extends StatelessWidget { style: regularTextStyle.copyWith(color: mainColor), ), MyTextFormField( - hintText: 'Tanggal', + hintText: ' Pilih Tanggal', readOnly: true, controller: model.tanggalController, validator: Validatorless.required( @@ -88,6 +138,30 @@ class TambahDanaSosialView extends StatelessWidget { }, ), const SizedBox(height: 20), + Visibility( + visible: model.jenisDonasi == 'Barang', + child: Text( + "Keterangan", + style: regularTextStyle.copyWith(color: mainColor), + ), + ), + Visibility( + visible: model.jenisDonasi == 'Barang', + child: MyTextFormField( + hintText: 'Masukkan Keterangan', + maxLines: 3, + controller: model.keteranganController, + validator: model.jenisDonasi == 'Barang' + ? Validatorless.multiple( + [ + Validatorless.required( + 'Keterangan tidak boleh kosong'), + ], + ) + : null, + ), + ), + const SizedBox(height: 20), MyButton( text: "Simpan Data", onPressed: () { diff --git a/lib/ui/views/tambah_dana_sosial/tambah_dana_sosial_view_model.dart b/lib/ui/views/tambah_dana_sosial/tambah_dana_sosial_view_model.dart index a2cec6c..d8707b5 100644 --- a/lib/ui/views/tambah_dana_sosial/tambah_dana_sosial_view_model.dart +++ b/lib/ui/views/tambah_dana_sosial/tambah_dana_sosial_view_model.dart @@ -13,14 +13,15 @@ class TambahDanaSosialViewModel extends CustomBaseViewModel { final _httpService = locator(); final easyLoading = locator(); - String jenisDana = 'Pemasukan'; - List jenisDanaList = ['Pemasukan', 'Pengeluaran']; + String jenisDonasi = 'Uang'; + List jenisDonasiList = ['Uang', 'Barang']; final formKey = GlobalKey(); TextEditingController namaController = TextEditingController(); TextEditingController jumlahController = TextEditingController(); TextEditingController tanggalController = TextEditingController(); + TextEditingController keteranganController = TextEditingController(); Future init() async {} @@ -47,6 +48,8 @@ class TambahDanaSosialViewModel extends CustomBaseViewModel { 'nama': namaController.text, 'jumlah': jumlahController.text, 'tanggal': tanggalController.text, + 'ket': keteranganController.text, + 'jenis': jenisDonasi, }); var response = await _httpService.postWithFormData('dana_sosial', formData); diff --git a/lib/ui/views/user_index_tracking/user_index_tracking_view.dart b/lib/ui/views/user_index_tracking/user_index_tracking_view.dart new file mode 100644 index 0000000..25de6d6 --- /dev/null +++ b/lib/ui/views/user_index_tracking/user_index_tracking_view.dart @@ -0,0 +1,95 @@ +import 'package:flutter/material.dart'; +import 'package:panti_asuhan/app/app.router.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; +import 'package:stylish_bottom_bar/model/bar_items.dart'; +import 'package:stylish_bottom_bar/stylish_bottom_bar.dart'; + +import '../../../app/themes/app_colors.dart'; +import '../../../app/themes/app_text.dart'; +import './user_index_tracking_view_model.dart'; + +class UserIndexTrackingView extends StatelessWidget { + const UserIndexTrackingView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ViewModelBuilder.reactive( + viewModelBuilder: () => UserIndexTrackingViewModel(), + onViewModelReady: (UserIndexTrackingViewModel model) async { + await model.init(); + }, + builder: ( + BuildContext context, + UserIndexTrackingViewModel model, + Widget? child, + ) { + return Scaffold( + appBar: AppBar( + title: Text( + model.header, + style: const TextStyle( + color: Colors.white, + fontSize: 20, + ), + ), + backgroundColor: mainColor, + elevation: 0, + automaticallyImplyLeading: false, + actions: [ + IconButton( + onPressed: () { + model.login(); + }, + icon: const Icon(Icons.login, color: Colors.white), + ), + ], + ), + body: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), + child: ExtendedNavigator( + navigatorKey: StackedService.nestedNavigationKey(5), + router: UserIndexTrackingViewRouter(), + initialRoute: UserIndexTrackingViewRoutes.danaSosialAdminView, + ), + ), + bottomNavigationBar: StylishBottomBar( + items: [ + for (var item in model.bottomNavBarList) + BottomBarItem( + icon: Icon(item['icon'], + color: model.currentIndex == + model.bottomNavBarList.indexOf(item) + ? sixthGrey + : backgroundColor), + title: Text( + item['name'], + style: regularTextStyle.copyWith( + color: model.currentIndex == + model.bottomNavBarList.indexOf(item) + ? sixthGrey + : Colors.grey, + ), + ), + backgroundColor: + model.currentIndex == model.bottomNavBarList.indexOf(item) + ? Colors.white + : Colors.grey, + ), + ], + currentIndex: model.currentIndex, + hasNotch: true, + backgroundColor: mainColor, + onTap: (value) { + model.handleNavigation(value); + }, + option: BubbleBarOptions( + barStyle: BubbleBarStyle.horizotnal, + bubbleFillStyle: BubbleFillStyle.fill, + opacity: 0.3), + ), + ); + }, + ); + } +} diff --git a/lib/ui/views/user_index_tracking/user_index_tracking_view_model.dart b/lib/ui/views/user_index_tracking/user_index_tracking_view_model.dart new file mode 100644 index 0000000..be379d3 --- /dev/null +++ b/lib/ui/views/user_index_tracking/user_index_tracking_view_model.dart @@ -0,0 +1,71 @@ +import 'package:flutter/material.dart'; +import 'package:panti_asuhan/app/app.router.dart'; +import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; + +import '../../../app/app.locator.dart'; +import '../../../app/app.logger.dart'; + +class UserIndexTrackingViewModel extends IndexTrackingViewModel { + final log = getLogger('PimpinanIndexTrackingViewModel'); + final _navigationService = locator(); + // final _dialogService = locator(); + + String header = 'Dana Sosial'; + + final _bottomNavBarList = [ + { + 'name': 'Siswa', + 'icon': Icons.people_alt_outlined, + 'header': 'List Siswa' + }, + {'name': 'Dana', 'icon': Icons.money, 'header': 'Dana Sosial'}, + { + 'name': 'Profil', + 'icon': Icons.person_4_outlined, + 'header': 'Profil Panti Asuhan' + }, + {'name': 'V & M', 'icon': Icons.list_alt_rounded, 'header': 'Visi & Misi'}, + {'name': 'Sejarah', 'icon': Icons.list_outlined, 'header': 'Sejarah'}, + { + 'name': 'S O', + 'icon': Icons.people_alt_outlined, + 'header': 'Struktur Organisasi' + }, + ]; + + List> get bottomNavBarList => _bottomNavBarList; + + final List _views = [ + UserIndexTrackingViewRoutes.dataSiswaView, + UserIndexTrackingViewRoutes.danaSosialAdminView, + UserIndexTrackingViewRoutes.profilView, + UserIndexTrackingViewRoutes.visiMisiView, + UserIndexTrackingViewRoutes.sejarahView, + UserIndexTrackingViewRoutes.strukturOrganisasiView + ]; + + Future init() async { + setIndex(1); + } + + void handleNavigation(int index) { + log.d("handleNavigation: $index"); + log.d("currentIndex: $currentIndex"); + + if (currentIndex == index) return; + + setIndex(index); + header = _bottomNavBarList[index]['header'] as String; + _navigationService.navigateTo( + _views[index], + id: 5, + ); + } + + void login() { + _navigationService.navigateTo( + Routes.loginScreenView, + ); + } +} diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 627db36..93e0730 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,8 +7,10 @@ import Foundation import location import path_provider_foundation +import shared_preferences_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index e404172..ae91aac 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -688,6 +688,62 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: "0344316c947ffeb3a529eac929e1978fcd37c26be4e8468628bac399365a3ca1" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: fe8401ec5b6dcd739a0fe9588802069e608c3fdbfd3c3c93e546cf2f90438076 + url: "https://pub.dev" + source: hosted + version: "2.2.0" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: f39696b83e844923b642ce9dd4bd31736c17e697f6731a5adf445b1274cf3cd4 + url: "https://pub.dev" + source: hosted + version: "2.3.2" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "71d6806d1449b0a9d4e85e0c7a917771e672a3d5dc61149cc9fac871115018e1" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "23b052f17a25b90ff2b61aad4cc962154da76fb62848a9ce088efe30d7c50ab1" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: "7347b194fb0bbeb4058e6a4e87ee70350b6b2b90f8ac5f8bd5b3a01548f6d33a" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: f95e6a43162bce43c9c3405f3eb6f39e5b5d11f65fab19196cf8225e2777624d + url: "https://pub.dev" + source: hosted + version: "2.3.0" shelf: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0c7fd9f..da1b457 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,6 +50,7 @@ dependencies: flutter_holo_date_picker: ^1.1.0 validatorless: ^1.2.3 intl: + shared_preferences: dev_dependencies: flutter_test: @@ -79,6 +80,7 @@ flutter: assets: - .env - assets/logo.png + - assets/qrcode.png # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see