added user page, pimpinan page, e signature

This commit is contained in:
kicap
2023-08-03 17:58:40 +08:00
parent 30131e5ffe
commit 914e24706b
35 changed files with 2341 additions and 327 deletions

View File

@ -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<PimpinanIndexTrackingViewModel>.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),
),
);
},
);
}
}

View File

@ -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<NavigationService>();
final _dialogService = locator<DialogService>();
final Future<SharedPreferences> _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<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
final List<String> _views = [
PimpinanIndexTrackingViewRoutes.dataSiswaView,
PimpinanIndexTrackingViewRoutes.danaSosialAdminView,
PimpinanIndexTrackingViewRoutes.profilView,
];
Future<void> 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();
}
});
}
}