first commit
This commit is contained in:
144
lib/ui/views/caleg_index_tracking/area_tps/area_tps_view.dart
Normal file
144
lib/ui/views/caleg_index_tracking/area_tps/area_tps_view.dart
Normal file
@ -0,0 +1,144 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './area_tps_view_model.dart';
|
||||
|
||||
class AreaTpsView extends StatelessWidget {
|
||||
const AreaTpsView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<AreaTpsViewModel>.reactive(
|
||||
viewModelBuilder: () => AreaTpsViewModel(),
|
||||
onViewModelReady: (AreaTpsViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
AreaTpsViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: warningColor,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Jumlah Area TPS : ",
|
||||
style: italicTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${model.jumlahArea} TPS',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.location_on_outlined,
|
||||
color: fontColor,
|
||||
),
|
||||
// SizedBox(width: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: warningColor,
|
||||
),
|
||||
child: Column(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (model.isBusy)
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
if (!model.isBusy)
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
if (model.jumlahArea == 0)
|
||||
Center(
|
||||
child: model.status == true
|
||||
? const Text(
|
||||
'Belum ada area diinput')
|
||||
: const Text(
|
||||
'Gagal mengambil data'),
|
||||
),
|
||||
if (model.jumlahArea > 0)
|
||||
for (var i = 0;
|
||||
i < model.jumlahArea;
|
||||
i++)
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Text('${i + 1}'),
|
||||
title: Text(
|
||||
'${model.listAreaModel[i].namaArea}'),
|
||||
trailing: IconButton(
|
||||
// trash bin icon
|
||||
icon: const Icon(
|
||||
Icons.list_alt_outlined,
|
||||
color: mainColor,
|
||||
),
|
||||
onPressed: () {
|
||||
model.cekSuara(
|
||||
model.listAreaModel[i]);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
import '../../../../app/app.bottomsheets.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/area_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
|
||||
class AreaTpsViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('AreaTpsViewModel');
|
||||
|
||||
List<AreaModel> listAreaModel = [];
|
||||
int jumlahArea = 0;
|
||||
bool status = false;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
String? idCaleg = await mySharedPrefs.getString('id');
|
||||
await getData(idCaleg!);
|
||||
}
|
||||
|
||||
getData(String idCaleg) async {
|
||||
setBusy(true);
|
||||
|
||||
try {
|
||||
var response = await httpService.get('/area/cek_area_caleg/$idCaleg');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
AreaListModel areaListModel =
|
||||
AreaListModel.fromJson(myResponseModel.data);
|
||||
listAreaModel = areaListModel.area ?? [];
|
||||
log.i('listAreaModel: $listAreaModel');
|
||||
jumlahArea = listAreaModel.length;
|
||||
log.i('jumlahArea: $jumlahArea');
|
||||
status = true;
|
||||
} catch (e) {
|
||||
log.e(e.toString());
|
||||
status = false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
cekSuara(AreaModel areaModel) async {
|
||||
await bottomSheetService.showCustomSheet(
|
||||
data: areaModel.idArea,
|
||||
barrierDismissible: true,
|
||||
isScrollControlled: true,
|
||||
title: 'Detail Suara Area ${areaModel.namaArea}',
|
||||
description: 'Tim Survei',
|
||||
ignoreSafeArea: false,
|
||||
variant: BottomSheetType.detailSuaraBottomSheetView,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
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 './caleg_index_tracking_view_model.dart';
|
||||
|
||||
class CalegIndexTrackingView extends StatelessWidget {
|
||||
const CalegIndexTrackingView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<CalegIndexTrackingViewModel>.reactive(
|
||||
viewModelBuilder: () => CalegIndexTrackingViewModel(),
|
||||
onViewModelReady: (CalegIndexTrackingViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
CalegIndexTrackingViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
model.header,
|
||||
style: const TextStyle(
|
||||
color: fontColor,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
backgroundColor: warningColor,
|
||||
elevation: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
model.logout();
|
||||
},
|
||||
icon: const Icon(Icons.logout, color: fontColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
extendBody: false,
|
||||
body: ExtendedNavigator(
|
||||
router: CalegIndexTrackingViewRouter(),
|
||||
navigatorKey: StackedService.nestedNavigationKey(3),
|
||||
),
|
||||
bottomNavigationBar: StylishBottomBar(
|
||||
items: [
|
||||
for (var item in model.bottomNavBarList)
|
||||
BottomBarItem(
|
||||
icon: Icon(item['icon'],
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? warningColor
|
||||
: fontColor),
|
||||
title: Text(
|
||||
item['name'],
|
||||
style: regularTextStyle.copyWith(
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? warningColor
|
||||
: fontColor,
|
||||
),
|
||||
// textAlign: TextAlign.l,
|
||||
),
|
||||
backgroundColor: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? fontColor
|
||||
: fontColor,
|
||||
),
|
||||
],
|
||||
currentIndex: model.currentIndex,
|
||||
option: BubbleBarOptions(),
|
||||
hasNotch: true,
|
||||
backgroundColor: warningColor,
|
||||
onTap: (value) {
|
||||
model.handleNavigation(value);
|
||||
},
|
||||
// fabLocation: StylishBarFabLocation.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
import 'package:flutter/material.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';
|
||||
import '../../../services/global_var.dart';
|
||||
import '../../../services/shared_prefs.dart';
|
||||
|
||||
class CalegIndexTrackingViewModel extends IndexTrackingViewModel {
|
||||
final log = getLogger('CalegIndexTrackingViewModel');
|
||||
final mySharedPrefs = locator<MySharedPrefs>();
|
||||
final navigationService = locator<NavigationService>();
|
||||
final globalVar = locator<GlobalVar>();
|
||||
final snackbarService = locator<SnackbarService>();
|
||||
final dialogService = locator<DialogService>();
|
||||
|
||||
final _bottomNavBarList = [
|
||||
{
|
||||
'name': 'Area\nTPS',
|
||||
'icon': Icons.location_on_outlined,
|
||||
'header': 'Area TPS',
|
||||
},
|
||||
{
|
||||
'name': 'Hasil\nSuara',
|
||||
'icon': Icons.supervised_user_circle_outlined,
|
||||
'header': 'Hasil Suara',
|
||||
},
|
||||
{
|
||||
'name': 'Tim \nSurvei',
|
||||
'icon': Icons.history_edu_outlined,
|
||||
'header': 'History Survei',
|
||||
},
|
||||
{
|
||||
'name': 'Pengaturan',
|
||||
'icon': Icons.settings_outlined,
|
||||
'header': 'Pengaturan',
|
||||
},
|
||||
];
|
||||
|
||||
String header = 'Pengaturan';
|
||||
|
||||
List<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
|
||||
|
||||
final List<String> _views = [
|
||||
CalegIndexTrackingViewRoutes.areaTpsView,
|
||||
CalegIndexTrackingViewRoutes.logSuaraView,
|
||||
CalegIndexTrackingViewRoutes.timSurveiView,
|
||||
CalegIndexTrackingViewRoutes.pengaturanCaleg2View,
|
||||
];
|
||||
|
||||
Future<void> init() async {
|
||||
String? level = await mySharedPrefs.getString('level');
|
||||
log.i('level: $level');
|
||||
if (level != 'caleg') {
|
||||
mySharedPrefs.clear();
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Anda tidak memiliki akses',
|
||||
title: 'Akses Ditolak',
|
||||
duration: const Duration(milliseconds: 2500),
|
||||
);
|
||||
navigationService.clearStackAndShow(Routes.loginScreenView);
|
||||
}
|
||||
setIndex(3);
|
||||
}
|
||||
|
||||
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: 3,
|
||||
);
|
||||
}
|
||||
|
||||
logout() async {
|
||||
dialogService
|
||||
.showConfirmationDialog(
|
||||
title: 'Konfirmasi',
|
||||
description: 'Apakah anda yakin ingin keluar?',
|
||||
cancelTitle: 'Batal',
|
||||
confirmationTitle: 'Keluar',
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
await mySharedPrefs.clear();
|
||||
navigationService.clearStackAndShow(Routes.loginScreenView);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
161
lib/ui/views/caleg_index_tracking/log_suara/log_suara_view.dart
Normal file
161
lib/ui/views/caleg_index_tracking/log_suara/log_suara_view.dart
Normal file
@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './log_suara_view_model.dart';
|
||||
|
||||
class LogSuaraView extends StatelessWidget {
|
||||
const LogSuaraView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<LogSuaraViewModel>.reactive(
|
||||
viewModelBuilder: () => LogSuaraViewModel(),
|
||||
onViewModelReady: (LogSuaraViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
LogSuaraViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: warningColor,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Jumlah Suara : ",
|
||||
style: italicTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${model.counter} suara',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.people_alt_outlined,
|
||||
color: fontColor,
|
||||
),
|
||||
// SizedBox(width: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: model.isBusy
|
||||
? Alignment.center
|
||||
: model.status == true
|
||||
? model.counter > 0
|
||||
? Alignment.topCenter
|
||||
: Alignment.center
|
||||
: Alignment.center,
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: warningColor,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (model.isBusy)
|
||||
const Center(
|
||||
child: CircularProgressIndicator()),
|
||||
if (!model.isBusy &&
|
||||
model.status == true &&
|
||||
model.counter > 0)
|
||||
for (var i = 0; i < model.counter; i++)
|
||||
Card(
|
||||
child: ListTile(
|
||||
// leading is datetime dummy
|
||||
leading: Text(model.myFunction
|
||||
.convertDateTime2(model
|
||||
.listPemilih[i].createdAt!)),
|
||||
title: Text(
|
||||
model.listPemilih[i].namaPemilih!,
|
||||
style: boldTextStyle,
|
||||
),
|
||||
subtitle: Text(
|
||||
model.listPemilih[i].namaArea!,
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.info_outline,
|
||||
color: mainColor,
|
||||
),
|
||||
onPressed: () {
|
||||
model.showDetailPemilih(
|
||||
model.listPemilih[i],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!model.isBusy &&
|
||||
model.status == true &&
|
||||
model.counter == 0)
|
||||
const Center(
|
||||
child: Text(
|
||||
'Belum ada data',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
if (!model.isBusy && model.status == false)
|
||||
const Center(
|
||||
child: Text(
|
||||
'Error: Gagal mengambil data dari server',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
import '../../../../app/app.bottomsheets.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
import '../../../../model/pemilih_model.dart';
|
||||
|
||||
class LogSuaraViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('LogSuaraViewModel');
|
||||
int counter = 0;
|
||||
List<PemilihModel> listPemilih = [];
|
||||
bool status = false;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
String? idCaleg = await mySharedPrefs.getString('id');
|
||||
await getData(idCaleg!);
|
||||
}
|
||||
|
||||
getData(String idCaleg) async {
|
||||
setBusy(true);
|
||||
|
||||
try {
|
||||
var response = await httpService.get('caleg/suara/$idCaleg');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
PemilihDetailModel pemilihDetailModel =
|
||||
PemilihDetailModel.fromJson(myResponseModel.data);
|
||||
listPemilih = pemilihDetailModel.pemilihModel!;
|
||||
counter = listPemilih.length;
|
||||
|
||||
status = true;
|
||||
} catch (e) {
|
||||
log.e('error: $e');
|
||||
status = false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
showDetailPemilih(PemilihModel listPemilih) async {
|
||||
await bottomSheetService.showCustomSheet(
|
||||
variant: BottomSheetType.detailSuaraPemilihBottomSheetView,
|
||||
title: 'Detail Suara Pemilih',
|
||||
description: 'Detail Suara Pemilih',
|
||||
// isScrollControlled: true,
|
||||
data: listPemilih,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,191 @@
|
||||
import 'package:flutter/material.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 './ganti_password_dialog_view_model.dart';
|
||||
|
||||
class GantiPasswordDialogView extends StatelessWidget {
|
||||
final DialogRequest? request;
|
||||
final Function(DialogResponse)? completer;
|
||||
|
||||
const GantiPasswordDialogView({
|
||||
Key? key,
|
||||
this.request,
|
||||
this.completer,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<GantiPasswordDialogViewModel>.reactive(
|
||||
viewModelBuilder: () => GantiPasswordDialogViewModel(),
|
||||
onViewModelReady: (GantiPasswordDialogViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
GantiPasswordDialogViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Form(
|
||||
key: model.globalKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Ganti Password',
|
||||
style: boldTextStyle.copyWith(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MyTextFormField(
|
||||
labelText: 'Password Lama',
|
||||
hintText: 'Masukkan password lama',
|
||||
obscureText: model.isPasswordLamaObscure,
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {
|
||||
model.isPasswordLamaObscure =
|
||||
!model.isPasswordLamaObscure;
|
||||
model.notifyListeners();
|
||||
},
|
||||
icon: Icon(
|
||||
model.isPasswordLamaObscure
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
),
|
||||
controller: model.passwordLamaController,
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'Password lama tidak boleh kosong'),
|
||||
Validatorless.min(
|
||||
8, 'Password lama minimal 8 karakter'),
|
||||
Validatorless.compare(
|
||||
// compare with thePasswordLamaController
|
||||
model.thePasswordLamaController,
|
||||
'Password lama tidak sama',
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Password Baru',
|
||||
hintText: 'Masukkan password baru',
|
||||
obscureText: model.isPasswordBaruObscure,
|
||||
controller: model.passwordBaruController,
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {
|
||||
model.isPasswordBaruObscure =
|
||||
!model.isPasswordBaruObscure;
|
||||
model.notifyListeners();
|
||||
},
|
||||
icon: Icon(
|
||||
model.isPasswordBaruObscure
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
),
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'Password baru tidak boleh kosong'),
|
||||
Validatorless.min(
|
||||
8, 'Password baru minimal 8 karakter'),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Konfirmasi Password Baru',
|
||||
hintText: 'Masukkan konfirmasi password baru',
|
||||
obscureText: model.isKonfirmasiPasswordBaruObscure,
|
||||
controller: model.konfirmasiPasswordBaruController,
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {
|
||||
model.isKonfirmasiPasswordBaruObscure =
|
||||
!model.isKonfirmasiPasswordBaruObscure;
|
||||
model.notifyListeners();
|
||||
},
|
||||
icon: Icon(
|
||||
model.isKonfirmasiPasswordBaruObscure
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
),
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'Konfirmasi password baru tidak boleh kosong'),
|
||||
Validatorless.min(
|
||||
8, 'Konfirmasi password baru minimal 8 karakter'),
|
||||
Validatorless.compare(
|
||||
model.passwordBaruController,
|
||||
'Password baru tidak sama',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
if (model.globalKey.currentState!.validate()) {
|
||||
// remove keyboard
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
model.dialogService
|
||||
.showConfirmationDialog(
|
||||
title: 'Konfirmasi',
|
||||
description:
|
||||
'Apakah anda yakin ingin mengubah password?',
|
||||
cancelTitle: 'Batal',
|
||||
confirmationTitle: 'Ya',
|
||||
)
|
||||
.then(
|
||||
(response) async {
|
||||
if (response!.confirmed) {
|
||||
// completer!(DialogResponse(confirmed: true));
|
||||
// model.log.i('Password berhasil diubah');
|
||||
bool res = await model.gantiPassword();
|
||||
// model.log.i('res: $res');
|
||||
if (res) {
|
||||
completer!(DialogResponse(confirmed: true));
|
||||
model.log.i('Password berhasil diubah');
|
||||
}
|
||||
} else {
|
||||
model.log.i('Password gagal diubah');
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('Simpan'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
completer!(DialogResponse(confirmed: false)),
|
||||
child: const Text(
|
||||
'Batal',
|
||||
style: TextStyle(color: dangerColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class GantiPasswordDialogViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('GantiPasswordDialogViewModel');
|
||||
|
||||
// form variable
|
||||
final globalKey = GlobalKey<FormState>();
|
||||
TextEditingController passwordLamaController = TextEditingController();
|
||||
TextEditingController passwordBaruController = TextEditingController();
|
||||
TextEditingController konfirmasiPasswordBaruController =
|
||||
TextEditingController();
|
||||
|
||||
TextEditingController thePasswordLamaController = TextEditingController();
|
||||
|
||||
bool isPasswordLamaObscure = true;
|
||||
bool isPasswordBaruObscure = true;
|
||||
bool isKonfirmasiPasswordBaruObscure = true;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'normalBack';
|
||||
String? passwordLama = await mySharedPrefs.getString('password');
|
||||
thePasswordLamaController.text = passwordLama!;
|
||||
}
|
||||
|
||||
Future<bool> gantiPassword() async {
|
||||
setBusy(true);
|
||||
|
||||
try {
|
||||
String? idCaleg = await mySharedPrefs.getString('id');
|
||||
var formData = FormData.fromMap({
|
||||
'id_caleg': idCaleg,
|
||||
'password_lama': passwordLamaController.text,
|
||||
'password_baru': passwordBaruController.text,
|
||||
});
|
||||
await httpService.postWithFormData('login/ganti_pass_caleg', formData);
|
||||
return true;
|
||||
} catch (e) {
|
||||
log.e(e.toString());
|
||||
return false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../pengaturan_caleg_view.dart';
|
||||
import './pengaturan_caleg2_view_model.dart';
|
||||
|
||||
class PengaturanCaleg2View extends StatelessWidget {
|
||||
const PengaturanCaleg2View({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<PengaturanCaleg2ViewModel>.nonReactive(
|
||||
viewModelBuilder: () => PengaturanCaleg2ViewModel(),
|
||||
onViewModelReady: (PengaturanCaleg2ViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
PengaturanCaleg2ViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return const PengaturanCalegView();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class PengaturanCaleg2ViewModel extends CustomBaseViewModel {
|
||||
Future<void> init() async {}
|
||||
}
|
@ -0,0 +1,206 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import '../../../widgets/top_container.dart';
|
||||
import './pengaturan_caleg_view_model.dart';
|
||||
|
||||
class PengaturanCalegView extends StatelessWidget {
|
||||
const PengaturanCalegView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<PengaturanCalegViewModel>.reactive(
|
||||
viewModelBuilder: () => PengaturanCalegViewModel(),
|
||||
onViewModelReady: (PengaturanCalegViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
PengaturanCalegViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TopContainer(
|
||||
title: 'Jumlah Suara',
|
||||
value: '${model.suaraCounter} Suara',
|
||||
icon: Icons.people_alt_outlined,
|
||||
background: warningColor,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TopContainer(
|
||||
title: 'Area\nTPS',
|
||||
value: '${model.suaraCounter} TPS',
|
||||
icon: Icons.location_on_outlined,
|
||||
background: orangeColor,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TopContainer(
|
||||
title: 'Jumlah Tim Survei',
|
||||
value: '${model.timSurverCounter} Orang',
|
||||
icon: Icons.co_present_outlined,
|
||||
background: greenColor,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
if (model.isBusy)
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
if (!model.isBusy && model.status == true)
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Selamat Datang, ',
|
||||
style: regularTextStyle,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Caleg ${model.nama}\n\n',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Sila tekan menu',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: ' Hasil Suara ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'untuk mengetahui jumlah suara.\n\nDan sila tekan menu',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: ' Tim Survei ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'untuk mengetahui jumlah tim survei anda.\n\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Dan sila tekan menu',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: ' Area TPS ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'untuk mengetahui Area TPS anda.\n\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'Jika terjadi kesalahan pada data, silahkan hubungi admin.\n\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Aplikasi dibuat oleh :',
|
||||
style: italicTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: ' Kicap Karan\n',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'http://www.kicap-karan.com\n',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!model.isBusy && model.status == false)
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Selamat Datang, ',
|
||||
style: regularTextStyle,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${model.nama}\n',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Terjadi ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Error ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: redColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'pada saat mengambil data\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Silahkan coba lagi dengan menekan icon',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: ' Pengaturan\n',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'di pojok kanan bawah\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// with setting icon
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: warningColor,
|
||||
onPressed: () {
|
||||
model.gantiPassword();
|
||||
},
|
||||
child: const Icon(Icons.settings, color: fontColor),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
import '../../../../app/app.dialogs.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
|
||||
class PengaturanCalegViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('PengaturanCalegViewModel');
|
||||
|
||||
int timSurverCounter = 0;
|
||||
int suaraCounter = 0;
|
||||
int areaCounter = 0;
|
||||
bool status = false;
|
||||
String? nama;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
String? idCaleg = await mySharedPrefs.getString('id');
|
||||
nama = await mySharedPrefs.getString('nama');
|
||||
await getData(idCaleg!);
|
||||
}
|
||||
|
||||
getData(String idCaleg) async {
|
||||
setBusy(true);
|
||||
|
||||
try {
|
||||
var response = await httpService.get('caleg/detail/$idCaleg');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
timSurverCounter = myResponseModel.data['jumlah_tim_survei'];
|
||||
suaraCounter = myResponseModel.data['jumlah_suara'];
|
||||
areaCounter = myResponseModel.data['jumlah_area'];
|
||||
status = true;
|
||||
} catch (e) {
|
||||
log.e(e.toString());
|
||||
status = false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
gantiPassword() async {
|
||||
var res = await dialogService.showCustomDialog(
|
||||
variant: DialogType.gantiPasswordDialogView,
|
||||
title: 'Ganti Password',
|
||||
mainButtonTitle: 'Simpan',
|
||||
barrierDismissible: false,
|
||||
);
|
||||
|
||||
if (res!.confirmed) {
|
||||
snackbarService.showSnackbar(message: 'Password berhasil diubah');
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import '../../../widgets/top_container.dart';
|
||||
import './tim_survei_view_model.dart';
|
||||
|
||||
class TimSurveiView extends StatelessWidget {
|
||||
const TimSurveiView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<TimSurveiViewModel>.reactive(
|
||||
viewModelBuilder: () => TimSurveiViewModel(),
|
||||
onViewModelReady: (TimSurveiViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
TimSurveiViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
TopContainer(
|
||||
title: 'Tim\nSurvei',
|
||||
value: '${model.jumlahTimSurvei} Orang',
|
||||
icon: Icons.people_alt_outlined,
|
||||
background: orangeColor,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: model.isBusy
|
||||
? Alignment.center
|
||||
: (model.listTimSurveiModel.isNotEmpty
|
||||
? null
|
||||
: Alignment.center),
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: warningColor,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (model.isBusy)
|
||||
const Center(
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 5,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
if (!model.isBusy &&
|
||||
model.listTimSurveiModel.isNotEmpty)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// create 10 list of survei person using card
|
||||
for (int i = 0;
|
||||
i < model.jumlahTimSurvei;
|
||||
i++)
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Text('${i + 1}'),
|
||||
title: Text(
|
||||
model.listTimSurveiModel[i].nama!,
|
||||
),
|
||||
subtitle: Text(
|
||||
model.listTimSurveiModel[i].nik!,
|
||||
style: italicTextStyle,
|
||||
),
|
||||
trailing: IconButton(
|
||||
onPressed: () {
|
||||
model.checkSuara(model
|
||||
.listTimSurveiModel[i]);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.list_alt_outlined,
|
||||
color: mainColor,
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// if listTimSurveiModel is empty
|
||||
if (!model.isBusy &&
|
||||
model.listTimSurveiModel.isEmpty)
|
||||
Center(
|
||||
child: Text(
|
||||
model.status == true
|
||||
? 'Data Tim Survei Kosong\n'
|
||||
'Hubungi Admin Untuk\nTambahkan Tim Survei Baru'
|
||||
: 'Gagal Mengambil Data Tim Survei',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
import '../../../../app/app.bottomsheets.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
import '../../../../model/tim_survei_model.dart';
|
||||
|
||||
class TimSurveiViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('TimSurveiViewModel');
|
||||
|
||||
// variabel
|
||||
List<TimSurveiModel> listTimSurveiModel = [];
|
||||
int jumlahTimSurvei = 0;
|
||||
bool status = false;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
String? idCaleg = await mySharedPrefs.getString('id');
|
||||
// log.i('idCaleg: $idCaleg');
|
||||
await getData(idCaleg!);
|
||||
}
|
||||
|
||||
getData(String idCaleg) async {
|
||||
setBusy(true);
|
||||
// easyLoading.showLoading();
|
||||
// globalVar.backPressed = 'cantBack';
|
||||
try {
|
||||
var response = await httpService.get('survei/caleg/$idCaleg');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
// log.i('myResponseModel: ${myResponseModel.data}');
|
||||
TimSurveiListModel timSurveiListModel =
|
||||
TimSurveiListModel.fromJson(myResponseModel.data);
|
||||
// log.i('timSurveiListModel: ${timSurveiListModel.survei}');
|
||||
listTimSurveiModel = timSurveiListModel.survei ?? [];
|
||||
jumlahTimSurvei = timSurveiListModel.jumlah!;
|
||||
// log.i('listTimSurveiModel: $listTimSurveiModel');
|
||||
// log.i('jumlahTimSurvei: $jumlahTimSurvei');
|
||||
status = true;
|
||||
} catch (e) {
|
||||
log.e(e.toString());
|
||||
status = false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
// globalVar.backPressed = 'exitApp';
|
||||
// easyLoading.dismissLoading();
|
||||
}
|
||||
}
|
||||
|
||||
checkSuara(TimSurveiModel timSurveiModel) async {
|
||||
await bottomSheetService.showCustomSheet(
|
||||
data: timSurveiModel.nik,
|
||||
barrierDismissible: true,
|
||||
isScrollControlled: true,
|
||||
title: 'Detail Suara Tim Survei ${timSurveiModel.nama}',
|
||||
description: 'Tim Survei',
|
||||
ignoreSafeArea: false,
|
||||
variant: BottomSheetType.detailSuaraBottomSheetView,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
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 './detail_suara_bottom_sheet_view_model.dart';
|
||||
|
||||
class DetailSuaraBottomSheetView extends StatelessWidget {
|
||||
final SheetRequest? request;
|
||||
final Function(SheetResponse)? completer;
|
||||
|
||||
const DetailSuaraBottomSheetView({
|
||||
Key? key,
|
||||
this.request,
|
||||
this.completer,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<DetailSuaraBottomSheetViewModel>.reactive(
|
||||
viewModelBuilder: () => DetailSuaraBottomSheetViewModel(),
|
||||
onViewModelReady: (DetailSuaraBottomSheetViewModel model) async {
|
||||
await model.init(request!);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
DetailSuaraBottomSheetViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return SafeArea(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
padding: const EdgeInsets.all(20),
|
||||
alignment: Alignment.topCenter,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(20),
|
||||
topRight: Radius.circular(20),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
request!.title!,
|
||||
style: italicTextStyle.copyWith(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
color: warningColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Jumlah Suara: ${model.counter}',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (model.isBusy)
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
if (!model.isBusy &&
|
||||
model.status == true &&
|
||||
model.counter > 0)
|
||||
for (var i = 0; i < model.counter; i++)
|
||||
Card(
|
||||
child: ListTile(
|
||||
// leading is datetime dummy
|
||||
leading: Text(model.myFunction
|
||||
.convertDateTime2(
|
||||
model.listPemilih[i].createdAt!)),
|
||||
title: Text(
|
||||
model.listPemilih[i].namaPemilih!,
|
||||
style: boldTextStyle,
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (request!.description == 'Caleg')
|
||||
Text(
|
||||
model.listPemilih[i].namaTimSurvei!,
|
||||
style: italicTextStyle,
|
||||
),
|
||||
Text(
|
||||
model.listPemilih[i].namaArea!,
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.info_outline,
|
||||
color: mainColor,
|
||||
),
|
||||
onPressed: () {
|
||||
model.showDetailPemilih(
|
||||
model.listPemilih[i],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!model.isBusy &&
|
||||
model.status == true &&
|
||||
model.counter == 0)
|
||||
const Center(
|
||||
child: Text(
|
||||
'Belum ada data',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
if (!model.isBusy && model.status == false)
|
||||
const Center(
|
||||
child: Text(
|
||||
'Error: Gagal mengambil data dari server',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
import '../../../app/app.bottomsheets.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../model/my_response.model.dart';
|
||||
import '../../../model/pemilih_model.dart';
|
||||
|
||||
class DetailSuaraBottomSheetViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('DetailSuaraBottomSheetViewModel');
|
||||
bool status = false;
|
||||
|
||||
List<PemilihModel> listPemilih = [];
|
||||
int counter = 0;
|
||||
|
||||
Future<void> init(sheetRequest) async {
|
||||
String id = sheetRequest.data.toString();
|
||||
String status = sheetRequest.description;
|
||||
String? idCaleg = await mySharedPrefs.getString('id');
|
||||
await getData(id, status, idCaleg!);
|
||||
}
|
||||
|
||||
getData(String id, String status, String idCaleg) async {
|
||||
setBusy(true);
|
||||
|
||||
try {
|
||||
// var response = await httpService.get('caleg/suara/$id');
|
||||
String url = status == 'Tim Survei'
|
||||
? 'survei/suara/$id'
|
||||
: 'area/suara/$id/$idCaleg';
|
||||
|
||||
var response = await httpService.get(url);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
PemilihDetailModel pemilihDetailModel =
|
||||
PemilihDetailModel.fromJson(myResponseModel.data);
|
||||
|
||||
listPemilih = pemilihDetailModel.pemilihModel!;
|
||||
counter = pemilihDetailModel.jumlah!;
|
||||
this.status = true;
|
||||
} catch (e) {
|
||||
this.status = false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
showDetailPemilih(PemilihModel listPemilih) async {
|
||||
await bottomSheetService.showCustomSheet(
|
||||
variant: BottomSheetType.detailSuaraPemilihBottomSheetView,
|
||||
title: 'Detail Suara Pemilih',
|
||||
description: 'Detail Suara Pemilih',
|
||||
// isScrollControlled: true,
|
||||
data: listPemilih,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.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 './detail_suara_pemilih_bottom_sheet_view_model.dart';
|
||||
|
||||
class DetailSuaraPemilihBottomSheetView extends StatelessWidget {
|
||||
final SheetRequest request;
|
||||
final Function(SheetResponse)? completer;
|
||||
|
||||
const DetailSuaraPemilihBottomSheetView({
|
||||
Key? key,
|
||||
required this.request,
|
||||
this.completer,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<DetailSuaraPemilihBottomSheetViewModel>.reactive(
|
||||
viewModelBuilder: () => DetailSuaraPemilihBottomSheetViewModel(),
|
||||
onViewModelReady: (DetailSuaraPemilihBottomSheetViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
DetailSuaraPemilihBottomSheetViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return SafeArea(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
padding: const EdgeInsets.all(20),
|
||||
alignment: Alignment.topCenter,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(16.0),
|
||||
topRight: Radius.circular(16.0),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
request.title!,
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
color: fontColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Container(
|
||||
height: 100,
|
||||
width: 150,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
model.showImage(
|
||||
context,
|
||||
dotenv.env['url']! + request.data!.img!,
|
||||
);
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Image.network(
|
||||
dotenv.env['url']! + request.data!.img!,
|
||||
fit: BoxFit.fill,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return const Center(
|
||||
child: Icon(
|
||||
Icons.error,
|
||||
color: backgroundColor,
|
||||
size: 50,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Nama',
|
||||
value: request.data!.namaPemilih!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'No KTP /\nNo HP',
|
||||
value: request.data!.nikNomorHp!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Tanggal/\nWaktu',
|
||||
value: model.myFunction
|
||||
.convertDateTime2(request.data!.createdAt!),
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Caleg', value: request.data!.namaCaleg!),
|
||||
_DetailChildWidget(
|
||||
title: 'Tim Survei',
|
||||
value: request.data!.namaTimSurvei!,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DetailChildWidget extends StatelessWidget {
|
||||
const _DetailChildWidget({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.value,
|
||||
}) : super(key: key);
|
||||
final String title;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
title,
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
color: fontColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
' : ',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
color: fontColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 7,
|
||||
child: Text(
|
||||
value,
|
||||
style: italicTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
color: fontColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import 'package:easy_image_viewer/easy_image_viewer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class DetailSuaraPemilihBottomSheetViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('DetailSuaraPemilihBottomSheetViewModel');
|
||||
Future<void> init() async {}
|
||||
|
||||
showImage(BuildContext context, String? url) async {
|
||||
log.i(url);
|
||||
showImageViewer(
|
||||
context,
|
||||
Image.network(
|
||||
url!,
|
||||
fit: BoxFit.fill,
|
||||
).image,
|
||||
swipeDismissible: true,
|
||||
doubleTapZoomable: true,
|
||||
);
|
||||
}
|
||||
}
|
129
lib/ui/views/login_screen/login_screen_view.dart
Normal file
129
lib/ui/views/login_screen/login_screen_view.dart
Normal file
@ -0,0 +1,129 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import '../../../app/themes/app_colors.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 {
|
||||
const LoginScreenView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<LoginScreenViewModel>.reactive(
|
||||
viewModelBuilder: () => LoginScreenViewModel(),
|
||||
onViewModelReady: (LoginScreenViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
LoginScreenViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
backgroundColor: warningColor,
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'backNormal') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
Center(
|
||||
child: Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Text(
|
||||
'Halaman Login',
|
||||
),
|
||||
const Text(
|
||||
'(Caleg App)',
|
||||
style: italicTextStyle,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.usernameController,
|
||||
labelText: 'Username',
|
||||
hintText: 'Masukkan Username',
|
||||
suffixIcon: const Icon(Icons.person),
|
||||
validator: Validatorless.required(
|
||||
'Username tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.passwordController,
|
||||
hintText: 'Masukkan Password',
|
||||
labelText: 'Password',
|
||||
suffixIcon: GestureDetector(
|
||||
child: model.isPasswordVisible
|
||||
? const Icon(Icons.visibility)
|
||||
: const Icon(Icons.visibility_off),
|
||||
onTap: () {
|
||||
model.isPasswordVisible =
|
||||
!model.isPasswordVisible;
|
||||
model.log.i(
|
||||
'isPasswordVisible: ${model.isPasswordVisible}');
|
||||
model.notifyListeners();
|
||||
},
|
||||
),
|
||||
obscureText: !model.isPasswordVisible,
|
||||
validator: Validatorless.required(
|
||||
'Password tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: MyButton(
|
||||
// theBackgroundColor: lightColor,
|
||||
textColor: fontColor,
|
||||
text: 'Login',
|
||||
onPressed: () {
|
||||
if (model.formKey.currentState!.validate()) {
|
||||
model.login();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
64
lib/ui/views/login_screen/login_screen_view_model.dart
Normal file
64
lib/ui/views/login_screen/login_screen_view_model.dart
Normal file
@ -0,0 +1,64 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../model/caleg_model.dart';
|
||||
import '../../../model/my_response.model.dart';
|
||||
|
||||
class LoginScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('LoginScreenViewModel');
|
||||
|
||||
// variable
|
||||
final formKey = GlobalKey<FormState>();
|
||||
TextEditingController usernameController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
bool isPasswordVisible = false;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'backNormal';
|
||||
}
|
||||
|
||||
login() async {
|
||||
easyLoading.customLoading('Login..');
|
||||
globalVar.backPressed = 'cantBack';
|
||||
|
||||
try {
|
||||
var formData = FormData.fromMap({
|
||||
'username': usernameController.text,
|
||||
'password': passwordController.text,
|
||||
});
|
||||
var response =
|
||||
await httpService.postWithFormData('login/caleg', formData);
|
||||
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
var data = myResponseModel.data;
|
||||
CalegModel calegModel = CalegModel.fromJson(data);
|
||||
// log.i('calegModel: ${calegModel.toJson()}');
|
||||
await mySharedPrefs.setString('id', calegModel.idCaleg!.toString());
|
||||
await mySharedPrefs.setString('nama', calegModel.namaCaleg!);
|
||||
await mySharedPrefs.setString(
|
||||
'nomorUrut', calegModel.nomorUrutCaleg!.toString());
|
||||
await mySharedPrefs.setString('foto', calegModel.foto!);
|
||||
await mySharedPrefs.setString('level', 'caleg');
|
||||
await mySharedPrefs.setString('password', passwordController.text);
|
||||
|
||||
snackbarService.showSnackbar(
|
||||
message:
|
||||
'Selamat datang kembali Calon Legislatif ${calegModel.namaCaleg}',
|
||||
title: 'Login Berhasil',
|
||||
duration: const Duration(milliseconds: 2500),
|
||||
);
|
||||
navigationService.navigateToCalegIndexTrackingView();
|
||||
} catch (e) {
|
||||
log.e('error: $e');
|
||||
} finally {
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'backNormal';
|
||||
}
|
||||
|
||||
// navigationService.pushNamedAndRemoveUntil('/home-screen');
|
||||
// await navigationService.navigateToAdminIndexTrackingView();
|
||||
}
|
||||
}
|
92
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
92
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
@ -0,0 +1,92 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import './splash_screen_view_model.dart';
|
||||
|
||||
class SplashScreenView extends StatelessWidget {
|
||||
const SplashScreenView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<SplashScreenViewModel>.reactive(
|
||||
viewModelBuilder: () => SplashScreenViewModel(),
|
||||
onViewModelReady: (SplashScreenViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
SplashScreenViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
backgroundColor: warningColor,
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Expanded(
|
||||
flex: 1,
|
||||
child: SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
'SISTEM CEK SUARA',
|
||||
style: boldTextStyle.copyWith(
|
||||
// color: backgroundColor,
|
||||
fontSize: 20,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'(Survei App)',
|
||||
style: boldTextStyle.copyWith(
|
||||
// color: backgroundColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const Expanded(child: SizedBox()),
|
||||
Text(
|
||||
'Created By',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'Kicap Karan',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 13,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'www.kicap-karan.com',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
13
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
13
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
@ -0,0 +1,13 @@
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class SplashScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('SplashScreenViewModel');
|
||||
Future<void> init() async {
|
||||
// await 3 seconds then go to login
|
||||
await mySharedPrefs.clear();
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
await navigationService.navigateTo(Routes.loginScreenView);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user