repair back button
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import 'package:reza_app/ui/views/meja_detail/meja_detail_view.dart';
|
import 'package:reza_app/services/global_var.dart';
|
||||||
import 'package:reza_app/ui/views/user_ui/pesanan_list/keranjang_saya/keranjang_saya_view.dart';
|
import 'package:reza_app/services/other_function.dart';
|
||||||
import 'package:stacked_services/stacked_services.dart';
|
import 'package:stacked_services/stacked_services.dart';
|
||||||
import 'package:stacked/stacked_annotations.dart';
|
import 'package:stacked/stacked_annotations.dart';
|
||||||
|
|
||||||
@ -9,10 +9,12 @@ import '../ui/views/daftar_user_ui/input_informasi_diri/input_informasi_diri_vie
|
|||||||
import '../ui/views/daftar_user_ui/masukan_no_hp/masukan_no_hp_view.dart';
|
import '../ui/views/daftar_user_ui/masukan_no_hp/masukan_no_hp_view.dart';
|
||||||
import '../ui/views/daftar_user_ui/verifikasi_no_hp/verifikasi_no_hp_view.dart';
|
import '../ui/views/daftar_user_ui/verifikasi_no_hp/verifikasi_no_hp_view.dart';
|
||||||
import '../ui/views/login_user/login_user_view.dart';
|
import '../ui/views/login_user/login_user_view.dart';
|
||||||
|
import '../ui/views/meja_detail/meja_detail_view.dart';
|
||||||
import '../ui/views/splash_screen/splash_screen_view.dart';
|
import '../ui/views/splash_screen/splash_screen_view.dart';
|
||||||
import '../ui/views/user_ui/akun_user/akun_user_view.dart';
|
import '../ui/views/user_ui/akun_user/akun_user_view.dart';
|
||||||
import '../ui/views/user_ui/makanan_list/detail_makanan/detail_makanan_view.dart';
|
import '../ui/views/user_ui/makanan_list/detail_makanan/detail_makanan_view.dart';
|
||||||
import '../ui/views/user_ui/makanan_list/makanan_list_view.dart';
|
import '../ui/views/user_ui/makanan_list/makanan_list_view.dart';
|
||||||
|
import '../ui/views/user_ui/pesanan_list/keranjang_saya/keranjang_saya_view.dart';
|
||||||
import '../ui/views/user_ui/pesanan_list/pesanan_list_view.dart';
|
import '../ui/views/user_ui/pesanan_list/pesanan_list_view.dart';
|
||||||
import '../ui/views/user_ui/reservasi_meja/reservasi_meja_view.dart';
|
import '../ui/views/user_ui/reservasi_meja/reservasi_meja_view.dart';
|
||||||
import '../ui/views/user_ui/user_index_tracking/user_index_tracking_view.dart';
|
import '../ui/views/user_ui/user_index_tracking/user_index_tracking_view.dart';
|
||||||
@ -50,6 +52,8 @@ import '../ui/views/user_ui/user_index_tracking/user_index_tracking_view.dart';
|
|||||||
|
|
||||||
LazySingleton(classType: MyEasyLoading),
|
LazySingleton(classType: MyEasyLoading),
|
||||||
LazySingleton(classType: MyHttpServices),
|
LazySingleton(classType: MyHttpServices),
|
||||||
|
LazySingleton(classType: OtherFunction),
|
||||||
|
LazySingleton(classType: GlobalVar),
|
||||||
],
|
],
|
||||||
logger: StackedLogger(),
|
logger: StackedLogger(),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -12,8 +12,10 @@ import 'package:stacked_services/src/navigation/navigation_service.dart';
|
|||||||
import 'package:stacked_services/src/snackbar/snackbar_service.dart';
|
import 'package:stacked_services/src/snackbar/snackbar_service.dart';
|
||||||
import 'package:stacked_shared/stacked_shared.dart';
|
import 'package:stacked_shared/stacked_shared.dart';
|
||||||
|
|
||||||
|
import '../services/global_var.dart';
|
||||||
import '../services/http_services.dart';
|
import '../services/http_services.dart';
|
||||||
import '../services/my_easyloading.dart';
|
import '../services/my_easyloading.dart';
|
||||||
|
import '../services/other_function.dart';
|
||||||
|
|
||||||
final locator = StackedLocator.instance;
|
final locator = StackedLocator.instance;
|
||||||
|
|
||||||
@ -32,4 +34,6 @@ Future<void> setupLocator({
|
|||||||
locator.registerLazySingleton(() => BottomSheetService());
|
locator.registerLazySingleton(() => BottomSheetService());
|
||||||
locator.registerLazySingleton(() => MyEasyLoading());
|
locator.registerLazySingleton(() => MyEasyLoading());
|
||||||
locator.registerLazySingleton(() => MyHttpServices());
|
locator.registerLazySingleton(() => MyHttpServices());
|
||||||
|
locator.registerLazySingleton(() => OtherFunction());
|
||||||
|
locator.registerLazySingleton(() => GlobalVar());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,10 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
import 'package:stacked_services/stacked_services.dart';
|
import 'package:stacked_services/stacked_services.dart';
|
||||||
|
|
||||||
|
import '../../services/global_var.dart';
|
||||||
import '../../services/http_services.dart';
|
import '../../services/http_services.dart';
|
||||||
import '../../services/my_easyloading.dart';
|
import '../../services/my_easyloading.dart';
|
||||||
|
import '../../services/other_function.dart';
|
||||||
import '../app.locator.dart';
|
import '../app.locator.dart';
|
||||||
import '../themes/app_colors.dart';
|
import '../themes/app_colors.dart';
|
||||||
|
|
||||||
@ -15,6 +17,8 @@ class CustomBaseViewModel extends BaseViewModel {
|
|||||||
final snackbarService = locator<SnackbarService>();
|
final snackbarService = locator<SnackbarService>();
|
||||||
final easyLoading = locator<MyEasyLoading>();
|
final easyLoading = locator<MyEasyLoading>();
|
||||||
final httpService = locator<MyHttpServices>();
|
final httpService = locator<MyHttpServices>();
|
||||||
|
final otherFunction = locator<OtherFunction>();
|
||||||
|
final globalVar = locator<GlobalVar>();
|
||||||
|
|
||||||
// late bool backPressed;
|
// late bool backPressed;
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class MyApp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Panti Asuhan Aisyiyah Abadi',
|
title: 'Reza Restaurant App',
|
||||||
theme: appTheme,
|
theme: appTheme,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
navigatorKey: StackedService.navigatorKey,
|
navigatorKey: StackedService.navigatorKey,
|
||||||
|
|||||||
3
lib/services/global_var.dart
Normal file
3
lib/services/global_var.dart
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class GlobalVar {
|
||||||
|
String backPressed = 'backNormal';
|
||||||
|
}
|
||||||
@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
|
|
||||||
class MyEasyLoading {
|
class MyEasyLoading {
|
||||||
int backPressed = 1;
|
|
||||||
|
|
||||||
showLoading() {
|
showLoading() {
|
||||||
EasyLoading.show(
|
EasyLoading.show(
|
||||||
status: 'loading...',
|
status: 'loading...',
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class InputInformasiDiriView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
body: WillPopScope(
|
body: WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
if (model.easyLoading.backPressed == 1) {
|
if (model.globalVar.backPressed == 'backNormal') {
|
||||||
model.navigationService.navigateToMasukanNoHpView();
|
model.navigationService.navigateToMasukanNoHpView();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -33,13 +33,13 @@ class InputInformasiDiriViewModel extends CustomBaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goToLogin() async {
|
goToLogin() async {
|
||||||
easyLoading.backPressed = 0;
|
globalVar.backPressed = 'cantBack';
|
||||||
easyLoading.customLoading("Mendaftarkan Akun Anda");
|
easyLoading.customLoading("Mendaftarkan Akun Anda");
|
||||||
await Future.delayed(const Duration(seconds: 2));
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
easyLoading.customLoading("Ke Halaman Login");
|
easyLoading.customLoading("Ke Halaman Login");
|
||||||
await Future.delayed(const Duration(seconds: 2));
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
easyLoading.dismissLoading();
|
easyLoading.dismissLoading();
|
||||||
easyLoading.backPressed = 1;
|
globalVar.backPressed = 'backNormal';
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await navigationService.navigateToLoginUserView();
|
await navigationService.navigateToLoginUserView();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class MasukanNoHpView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
body: WillPopScope(
|
body: WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
if (model.easyLoading.backPressed == 1) {
|
if (model.globalVar.backPressed == 'backNormal') {
|
||||||
model.navigationService.navigateToLoginUserView();
|
model.navigationService.navigateToLoginUserView();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -16,9 +16,9 @@ class MasukanNoHpViewModel extends CustomBaseViewModel {
|
|||||||
|
|
||||||
selanjutnya() async {
|
selanjutnya() async {
|
||||||
_easyloading.customLoading("Menghantar Kode OTP \nke WhatsApp Anda");
|
_easyloading.customLoading("Menghantar Kode OTP \nke WhatsApp Anda");
|
||||||
easyLoading.backPressed = 0;
|
globalVar.backPressed = 'cantBack';
|
||||||
await Future.delayed(const Duration(seconds: 3));
|
await Future.delayed(const Duration(seconds: 3));
|
||||||
easyLoading.backPressed = 1;
|
globalVar.backPressed = 'backNormal';
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
_easyloading.dismissLoading();
|
_easyloading.dismissLoading();
|
||||||
await navigationService.navigateToVerifikasiNoHpView();
|
await navigationService.navigateToVerifikasiNoHpView();
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class VerifikasiNoHpView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
body: WillPopScope(
|
body: WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
if (model.easyLoading.backPressed == 1) {
|
if (model.globalVar.backPressed == 'backNormal') {
|
||||||
model.back();
|
model.back();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -9,11 +9,11 @@ class VerifikasiNoHpViewModel extends CustomBaseViewModel {
|
|||||||
Future<void> init() async {}
|
Future<void> init() async {}
|
||||||
|
|
||||||
goToInputInformasiDiri() async {
|
goToInputInformasiDiri() async {
|
||||||
easyLoading.backPressed = 0;
|
globalVar.backPressed = 'cantBack';
|
||||||
easyLoading.customLoading("Ke Halaman Input Informasi Diri");
|
easyLoading.customLoading("Ke Halaman Input Informasi Diri");
|
||||||
await Future.delayed(const Duration(seconds: 3));
|
await Future.delayed(const Duration(seconds: 3));
|
||||||
easyLoading.dismissLoading();
|
easyLoading.dismissLoading();
|
||||||
easyLoading.backPressed = 1;
|
globalVar.backPressed = 'backNormal';
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await navigationService.navigateToInputInformasiDiriView(
|
await navigationService.navigateToInputInformasiDiriView(
|
||||||
noHp: "082293246583",
|
noHp: "082293246583",
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class LoginUserView extends StatelessWidget {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: WillPopScope(
|
body: WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
if (model.easyLoading.backPressed == 1) {
|
if (model.globalVar.backPressed == 'backNormal') {
|
||||||
// model.back();
|
// model.back();
|
||||||
model.quitApp(context);
|
model.quitApp(context);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,12 +17,12 @@ class LoginUserViewModel extends CustomBaseViewModel {
|
|||||||
|
|
||||||
login() async {
|
login() async {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
easyLoading.backPressed = 0;
|
globalVar.backPressed = 'cantBack';
|
||||||
easyLoading.showLoading();
|
easyLoading.showLoading();
|
||||||
await Future.delayed(const Duration(seconds: 5));
|
await Future.delayed(const Duration(seconds: 5));
|
||||||
easyLoading.dismissLoading();
|
easyLoading.dismissLoading();
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
easyLoading.backPressed = 1;
|
globalVar.backPressed = 'backNormal';
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await navigationService.navigateToUserIndexTrackingView();
|
await navigationService.navigateToUserIndexTrackingView();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:reza_app/app/app.router.dart';
|
|
||||||
import 'package:reza_app/app/themes/app_colors.dart';
|
import 'package:reza_app/app/themes/app_colors.dart';
|
||||||
import 'package:reza_app/app/themes/app_text.dart';
|
import 'package:reza_app/app/themes/app_text.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
@ -26,19 +25,35 @@ class MejaDetailView extends StatelessWidget {
|
|||||||
MejaDetailViewModel model,
|
MejaDetailViewModel model,
|
||||||
Widget? child,
|
Widget? child,
|
||||||
) {
|
) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
onWillPop: () async {
|
||||||
|
if (model.globalVar.backPressed == 'backNormal') {
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// model.quitApp(context);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('MejaDetailView',
|
title: const Text('MejaDetailView',
|
||||||
style: TextStyle(color: Colors.white)),
|
style: TextStyle(color: Colors.white)),
|
||||||
backgroundColor: mainColor,
|
backgroundColor: mainColor,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
onPressed: () => model.navigationService.popUntil((route) =>
|
onPressed: () {
|
||||||
route.settings.name == Routes.userIndexTrackingView),
|
if (model.globalVar.backPressed == 'backNormal') {
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
model.navigationService.back();
|
||||||
|
// return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -139,6 +154,7 @@ class MejaDetailView extends StatelessWidget {
|
|||||||
floatingActionButtonAnimator: FloatingActionButtonAnimator.scaling,
|
floatingActionButtonAnimator: FloatingActionButtonAnimator.scaling,
|
||||||
floatingActionButtonLocation:
|
floatingActionButtonLocation:
|
||||||
FloatingActionButtonLocation.centerFloat,
|
FloatingActionButtonLocation.centerFloat,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class MejaDetailViewModel extends CustomBaseViewModel {
|
|||||||
log.i('MejaDetailViewModel init');
|
log.i('MejaDetailViewModel init');
|
||||||
log.i('mejaId : $mejaId');
|
log.i('mejaId : $mejaId');
|
||||||
this.mejaId = mejaId;
|
this.mejaId = mejaId;
|
||||||
easyLoading.backPressed = 3;
|
globalVar.backPressed = 'backNormal';
|
||||||
// seperate the number from the string
|
// seperate the number from the string
|
||||||
var number = int.parse(mejaId.replaceAll(RegExp(r'[^0-9]'), ''));
|
var number = int.parse(mejaId.replaceAll(RegExp(r'[^0-9]'), ''));
|
||||||
// log.i('number : $number');
|
// log.i('number : $number');
|
||||||
|
|||||||
@ -20,7 +20,17 @@ class AkunUserView extends StatelessWidget {
|
|||||||
AkunUserViewModel model,
|
AkunUserViewModel model,
|
||||||
Widget? child,
|
Widget? child,
|
||||||
) {
|
) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
onWillPop: () async {
|
||||||
|
// model.log.i('onWillPop di akun_user_view.dart');
|
||||||
|
if (model.globalVar.backPressed == 'exitApp') {
|
||||||
|
model.quitApp(context);
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
'Akun Saya',
|
'Akun Saya',
|
||||||
@ -126,6 +136,7 @@ class AkunUserView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,6 +2,6 @@ import 'package:reza_app/app/core/custom_base_view_model.dart';
|
|||||||
|
|
||||||
class AkunUserViewModel extends CustomBaseViewModel {
|
class AkunUserViewModel extends CustomBaseViewModel {
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
easyLoading.backPressed = 2;
|
globalVar.backPressed = 'exitApp';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,17 @@ class DetailMakananView extends HookWidget {
|
|||||||
DetailMakananViewModel model,
|
DetailMakananViewModel model,
|
||||||
Widget? child,
|
Widget? child,
|
||||||
) {
|
) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
onWillPop: () async {
|
||||||
|
// model.log.i('onWillPop di reservasi_meja_view.dart');
|
||||||
|
// if (model.globalVar.backPressed == 'exitApp') {
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
model.back();
|
||||||
|
return false;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
body: SizedBox(
|
body: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
@ -203,7 +213,9 @@ class DetailMakananView extends HookWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -257,6 +269,7 @@ class TopBarWidget extends ViewModelWidget<DetailMakananViewModel> {
|
|||||||
),
|
),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
viewModel.globalVar.backPressed = 'exitApp';
|
||||||
viewModel.back();
|
viewModel.back();
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
|
|||||||
@ -5,6 +5,6 @@ class DetailMakananViewModel extends CustomBaseViewModel {
|
|||||||
final log = getLogger('DetailMakananViewModel');
|
final log = getLogger('DetailMakananViewModel');
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
easyLoading.backPressed = 3;
|
globalVar.backPressed = 'backNormal';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,17 @@ class MakananListView extends StatelessWidget {
|
|||||||
MakananListViewModel model,
|
MakananListViewModel model,
|
||||||
Widget? child,
|
Widget? child,
|
||||||
) {
|
) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
onWillPop: () async {
|
||||||
|
// model.log.i('onWillPop di reservasi_meja_view.dart');
|
||||||
|
if (model.globalVar.backPressed == 'exitApp') {
|
||||||
|
model.quitApp(context);
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
body: Column(
|
body: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@ -38,7 +48,14 @@ class MakananListView extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () => model.back(),
|
onPressed: () {
|
||||||
|
if (model.globalVar.backPressed == 'exitApp') {
|
||||||
|
model.quitApp(context);
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
} else {
|
||||||
|
model.navigationService.back();
|
||||||
|
}
|
||||||
|
},
|
||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -230,7 +247,9 @@ class MakananListView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import '../../../../app/core/custom_base_view_model.dart';
|
|||||||
class MakananListViewModel extends CustomBaseViewModel {
|
class MakananListViewModel extends CustomBaseViewModel {
|
||||||
final log = getLogger('MakananListViewModel');
|
final log = getLogger('MakananListViewModel');
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
easyLoading.backPressed = 2;
|
globalVar.backPressed = 'exitApp';
|
||||||
}
|
}
|
||||||
|
|
||||||
goToDetailMakanan() {
|
goToDetailMakanan() {
|
||||||
|
|||||||
@ -21,7 +21,17 @@ class KeranjangSayaView extends StatelessWidget {
|
|||||||
KeranjangSayaViewModel model,
|
KeranjangSayaViewModel model,
|
||||||
Widget? child,
|
Widget? child,
|
||||||
) {
|
) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
onWillPop: () async {
|
||||||
|
// model.log.i('onWillPop di reservasi_meja_view.dart');
|
||||||
|
if (model.globalVar.backPressed == 'backNormal') {
|
||||||
|
// model.quitApp(context);
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Keranjang Saya',
|
title: const Text('Keranjang Saya',
|
||||||
style: TextStyle(color: Colors.white)),
|
style: TextStyle(color: Colors.white)),
|
||||||
@ -67,7 +77,8 @@ class KeranjangSayaView extends StatelessWidget {
|
|||||||
height: 150,
|
height: 150,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
errorBuilder: (context, error, stackTrace) {
|
errorBuilder:
|
||||||
|
(context, error, stackTrace) {
|
||||||
return const Icon(Icons.error);
|
return const Icon(Icons.error);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -77,7 +88,8 @@ class KeranjangSayaView extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
@ -165,7 +177,8 @@ class KeranjangSayaView extends StatelessWidget {
|
|||||||
Icons.shopping_cart_outlined,
|
Icons.shopping_cart_outlined,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
));
|
)),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,6 @@ import '../../../../../app/app.logger.dart';
|
|||||||
class KeranjangSayaViewModel extends CustomBaseViewModel {
|
class KeranjangSayaViewModel extends CustomBaseViewModel {
|
||||||
final log = getLogger('KeranjangSayaViewModel');
|
final log = getLogger('KeranjangSayaViewModel');
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
easyLoading.backPressed = 3;
|
globalVar.backPressed = 'backNormal';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,17 @@ class PesananListView extends StatelessWidget {
|
|||||||
PesananListViewModel model,
|
PesananListViewModel model,
|
||||||
Widget? child,
|
Widget? child,
|
||||||
) {
|
) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
onWillPop: () async {
|
||||||
|
// model.log.i('onWillPop di reservasi_meja_view.dart');
|
||||||
|
if (model.globalVar.backPressed == 'exitApp') {
|
||||||
|
model.quitApp(context);
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
'List Pesanan',
|
'List Pesanan',
|
||||||
@ -173,7 +183,8 @@ class PesananListView extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Nama Makanan',
|
'Nama Makanan',
|
||||||
style: regularTextStyle.copyWith(
|
style:
|
||||||
|
regularTextStyle.copyWith(
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
),
|
),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
@ -186,7 +197,8 @@ class PesananListView extends StatelessWidget {
|
|||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Text(
|
child: Text(
|
||||||
'x 1',
|
'x 1',
|
||||||
style: regularTextStyle.copyWith(
|
style:
|
||||||
|
regularTextStyle.copyWith(
|
||||||
color: mainGrey,
|
color: mainGrey,
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
),
|
),
|
||||||
@ -199,7 +211,8 @@ class PesananListView extends StatelessWidget {
|
|||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Rp. 100.000',
|
'Rp. 100.000',
|
||||||
style: regularTextStyle.copyWith(
|
style:
|
||||||
|
regularTextStyle.copyWith(
|
||||||
color: redColor,
|
color: redColor,
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
),
|
),
|
||||||
@ -303,6 +316,7 @@ class PesananListView extends StatelessWidget {
|
|||||||
// ),
|
// ),
|
||||||
// backgroundColor: mainColor,
|
// backgroundColor: mainColor,
|
||||||
// ),
|
// ),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,6 +2,6 @@ import 'package:reza_app/app/core/custom_base_view_model.dart';
|
|||||||
|
|
||||||
class PesananListViewModel extends CustomBaseViewModel {
|
class PesananListViewModel extends CustomBaseViewModel {
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
easyLoading.backPressed = 2;
|
globalVar.backPressed = 'exitApp';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,17 @@ class ReservasiMejaView extends StatelessWidget {
|
|||||||
ReservasiMejaViewModel model,
|
ReservasiMejaViewModel model,
|
||||||
Widget? child,
|
Widget? child,
|
||||||
) {
|
) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
onWillPop: () async {
|
||||||
|
// model.log.i('onWillPop di reservasi_meja_view.dart');
|
||||||
|
if (model.globalVar.backPressed == 'exitApp') {
|
||||||
|
model.quitApp(context);
|
||||||
|
model.globalVar.backPressed = 'exitApp';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('RESERVASI MEJA',
|
title: const Text('RESERVASI MEJA',
|
||||||
style: TextStyle(color: Colors.white)),
|
style: TextStyle(color: Colors.white)),
|
||||||
@ -75,7 +85,8 @@ class ReservasiMejaView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
CarouselSlider.builder(
|
CarouselSlider.builder(
|
||||||
itemCount: model.imagePaths.length,
|
itemCount: model.imagePaths.length,
|
||||||
itemBuilder: (BuildContext context, int index, int realIndex) {
|
itemBuilder:
|
||||||
|
(BuildContext context, int index, int realIndex) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: MediaQuery.of(context)
|
width: MediaQuery.of(context)
|
||||||
.size
|
.size
|
||||||
@ -105,7 +116,9 @@ class ReservasiMejaView extends StatelessWidget {
|
|||||||
// model.controllerCompleter.complete(webViewController);
|
// model.controllerCompleter.complete(webViewController);
|
||||||
},
|
},
|
||||||
onProgress: (int progress) {
|
onProgress: (int progress) {
|
||||||
model.log.i('WebView is loading (progress : $progress%)');
|
// model.log.i('WebView is loading (progress : $progress%)');
|
||||||
|
// show a loading indicator when the WebView is loading using circular progress indicator
|
||||||
|
model.easyLoading.customLoading('Loading Data Meja');
|
||||||
},
|
},
|
||||||
// javascriptChannels: <JavascriptChannel>{
|
// javascriptChannels: <JavascriptChannel>{
|
||||||
// _toasterJavascriptChannel(context),
|
// _toasterJavascriptChannel(context),
|
||||||
@ -115,10 +128,10 @@ class ReservasiMejaView extends StatelessWidget {
|
|||||||
name: 'messageHandler',
|
name: 'messageHandler',
|
||||||
onMessageReceived: (JavascriptMessage message) async {
|
onMessageReceived: (JavascriptMessage message) async {
|
||||||
// model.log.i('messageHandler : ${message.message}');
|
// model.log.i('messageHandler : ${message.message}');
|
||||||
model.easyLoading.backPressed = 1;
|
// model.easyLoading.backPressed = 1;
|
||||||
model.notifyListeners();
|
model.notifyListeners();
|
||||||
model.log.i(
|
// model.log.i(
|
||||||
'backPressed : ${model.easyLoading.backPressed}');
|
// 'backPressed : ${model.easyLoading.backPressed}');
|
||||||
String mejaId = message.message;
|
String mejaId = message.message;
|
||||||
model.navigationService.navigateToView(
|
model.navigationService.navigateToView(
|
||||||
MejaDetailView(
|
MejaDetailView(
|
||||||
@ -150,6 +163,7 @@ class ReservasiMejaView extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
onPageFinished: (String url) {
|
onPageFinished: (String url) {
|
||||||
model.log.i('Page finished loading: $url');
|
model.log.i('Page finished loading: $url');
|
||||||
|
model.easyLoading.dismissLoading();
|
||||||
},
|
},
|
||||||
gestureNavigationEnabled: true,
|
gestureNavigationEnabled: true,
|
||||||
backgroundColor: const Color(0x00000000),
|
backgroundColor: const Color(0x00000000),
|
||||||
@ -201,6 +215,7 @@ class ReservasiMejaView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -13,6 +13,6 @@ class ReservasiMejaViewModel extends CustomBaseViewModel {
|
|||||||
];
|
];
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
easyLoading.backPressed = 2;
|
globalVar.backPressed = 'exitApp';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,52 +1,49 @@
|
|||||||
import 'package:back_button_interceptor/back_button_interceptor.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:reza_app/services/my_easyloading.dart';
|
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
import 'package:stacked_services/stacked_services.dart';
|
import 'package:stacked_services/stacked_services.dart';
|
||||||
|
|
||||||
import '../../../../app/app.locator.dart';
|
import '../../../../app/app.locator.dart';
|
||||||
import '../../../../app/app.logger.dart';
|
import '../../../../app/app.logger.dart';
|
||||||
import '../../../../app/app.router.dart';
|
import '../../../../app/app.router.dart';
|
||||||
import '../../../../app/themes/app_colors.dart';
|
import '../../../../services/global_var.dart';
|
||||||
|
|
||||||
class UserIndexTrackingViewModel extends IndexTrackingViewModel {
|
class UserIndexTrackingViewModel extends IndexTrackingViewModel {
|
||||||
final log = getLogger('UserIndexTrackingViewModel');
|
final log = getLogger('UserIndexTrackingViewModel');
|
||||||
final navigationService = locator<NavigationService>();
|
final navigationService = locator<NavigationService>();
|
||||||
final easyLoading = locator<MyEasyLoading>();
|
final globalVar = locator<GlobalVar>();
|
||||||
// late bool backPressed;
|
// late bool backPressed;
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
BackButtonInterceptor.add(myInterceptor);
|
// BackButtonInterceptor.add(myInterceptor);
|
||||||
// backPressed = easyLoading.backPressed;
|
// backPressed = easyLoading.backPressed;
|
||||||
easyLoading.backPressed = 2;
|
globalVar.backPressed = 'exitApp';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool myInterceptor(bool stopDefaultButtonEvent, RouteInfo info) {
|
// bool myInterceptor(bool stopDefaultButtonEvent, RouteInfo info) {
|
||||||
// print("BACK BUTTON!"); // Do some stuff.
|
// // print("BACK BUTTON!"); // Do some stuff.
|
||||||
|
|
||||||
log.i('myInterceptor : ${easyLoading.backPressed}');
|
// log.i('myInterceptor : ${easyLoading.backPressed}');
|
||||||
|
|
||||||
if (easyLoading.backPressed == 2) {
|
// if (easyLoading.backPressed == 2) {
|
||||||
quitApp(null);
|
// quitApp(null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (easyLoading.backPressed == 3) {
|
// if (easyLoading.backPressed == 3) {
|
||||||
|
// // easyLoading.backPressed = 2;
|
||||||
|
// // notifyListeners();
|
||||||
|
// // navigationService.back();
|
||||||
// easyLoading.backPressed = 2;
|
// easyLoading.backPressed = 2;
|
||||||
// notifyListeners();
|
// return false;
|
||||||
// navigationService.back();
|
// }
|
||||||
easyLoading.backPressed = 2;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (easyLoading.backPressed == 1) {
|
// if (easyLoading.backPressed == 1) {
|
||||||
// easyLoading.backPressed = 2;
|
// // easyLoading.backPressed = 2;
|
||||||
// notifyListeners();
|
// // notifyListeners();
|
||||||
// navigationService.back();
|
// // navigationService.back();
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
final _bottomNavBarList = [
|
final _bottomNavBarList = [
|
||||||
{
|
{
|
||||||
@ -95,37 +92,37 @@ class UserIndexTrackingViewModel extends IndexTrackingViewModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
quitApp(BuildContext? context) {
|
// quitApp(BuildContext? context) {
|
||||||
easyLoading.backPressed = 0;
|
// easyLoading.backPressed = 0;
|
||||||
showDialog(
|
// showDialog(
|
||||||
context: context ?? StackedService.navigatorKey!.currentContext!,
|
// context: context ?? StackedService.navigatorKey!.currentContext!,
|
||||||
builder: (BuildContext context) {
|
// builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
// return AlertDialog(
|
||||||
title: const Text('Keluar'),
|
// title: const Text('Keluar'),
|
||||||
content: const Text('Apakah Anda yakin ingin keluar?'),
|
// content: const Text('Apakah Anda yakin ingin keluar?'),
|
||||||
actions: [
|
// actions: [
|
||||||
TextButton(
|
// TextButton(
|
||||||
onPressed: () {
|
// onPressed: () {
|
||||||
easyLoading.backPressed = 2;
|
// easyLoading.backPressed = 2;
|
||||||
Navigator.of(context).pop(false);
|
// Navigator.of(context).pop(false);
|
||||||
},
|
// },
|
||||||
child: const Text('Batal'),
|
// child: const Text('Batal'),
|
||||||
),
|
// ),
|
||||||
TextButton(
|
// TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(true),
|
// onPressed: () => Navigator.of(context).pop(true),
|
||||||
child: const Text(
|
// child: const Text(
|
||||||
'Keluar',
|
// 'Keluar',
|
||||||
style: TextStyle(color: dangerColor),
|
// style: TextStyle(color: dangerColor),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
).then((value) {
|
// ).then((value) {
|
||||||
if (value == true) {
|
// if (value == true) {
|
||||||
SystemNavigator.pop();
|
// SystemNavigator.pop();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
notifyListeners();
|
// notifyListeners();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user