diff --git a/lib/app/app.router.dart b/lib/app/app.router.dart index 4e8533b..1b9bc39 100644 --- a/lib/app/app.router.dart +++ b/lib/app/app.router.dart @@ -138,14 +138,18 @@ class StackedRouter extends _i1.RouterBase { ); }, _i8.MejaEditView: (data) { + final args = data.getArgs(nullOk: false); return _i10.MaterialPageRoute( - builder: (context) => const _i8.MejaEditView(), + builder: (context) => + _i8.MejaEditView(key: args.key, mejaId: args.mejaId), settings: data, ); }, _i9.MejaHistoryLogView: (data) { + final args = data.getArgs(nullOk: false); return _i10.MaterialPageRoute( - builder: (context) => const _i9.MejaHistoryLogView(), + builder: (context) => + _i9.MejaHistoryLogView(key: args.key, mejaId: args.mejaId), settings: data, ); }, @@ -184,6 +188,60 @@ class MejaDetailViewArguments { } } +class MejaEditViewArguments { + const MejaEditViewArguments({ + this.key, + required this.mejaId, + }); + + final _i10.Key? key; + + final String mejaId; + + @override + String toString() { + return '{"key": "$key", "mejaId": "$mejaId"}'; + } + + @override + bool operator ==(covariant MejaEditViewArguments other) { + if (identical(this, other)) return true; + return other.key == key && other.mejaId == mejaId; + } + + @override + int get hashCode { + return key.hashCode ^ mejaId.hashCode; + } +} + +class MejaHistoryLogViewArguments { + const MejaHistoryLogViewArguments({ + this.key, + required this.mejaId, + }); + + final _i10.Key? key; + + final String mejaId; + + @override + String toString() { + return '{"key": "$key", "mejaId": "$mejaId"}'; + } + + @override + bool operator ==(covariant MejaHistoryLogViewArguments other) { + if (identical(this, other)) return true; + return other.key == key && other.mejaId == mejaId; + } + + @override + int get hashCode { + return key.hashCode ^ mejaId.hashCode; + } +} + class AdminIndexTrackingViewRoutes { static const mejaListView = ''; @@ -342,28 +400,34 @@ extension NavigatorStateExtension on _i15.NavigationService { transition: transition); } - Future navigateToMejaEditView([ + Future navigateToMejaEditView({ + _i10.Key? key, + required String mejaId, int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, - ]) async { + }) async { return navigateTo(Routes.mejaEditView, + arguments: MejaEditViewArguments(key: key, mejaId: mejaId), id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, transition: transition); } - Future navigateToMejaHistoryLogView([ + Future navigateToMejaHistoryLogView({ + _i10.Key? key, + required String mejaId, int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, - ]) async { + }) async { return navigateTo(Routes.mejaHistoryLogView, + arguments: MejaHistoryLogViewArguments(key: key, mejaId: mejaId), id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, @@ -515,28 +579,34 @@ extension NavigatorStateExtension on _i15.NavigationService { transition: transition); } - Future replaceWithMejaEditView([ + Future replaceWithMejaEditView({ + _i10.Key? key, + required String mejaId, int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, - ]) async { + }) async { return replaceWith(Routes.mejaEditView, + arguments: MejaEditViewArguments(key: key, mejaId: mejaId), id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, transition: transition); } - Future replaceWithMejaHistoryLogView([ + Future replaceWithMejaHistoryLogView({ + _i10.Key? key, + required String mejaId, int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, - ]) async { + }) async { return replaceWith(Routes.mejaHistoryLogView, + arguments: MejaHistoryLogViewArguments(key: key, mejaId: mejaId), id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, diff --git a/lib/ui/views/admin_ui/meja_list/meja_detail/meja_detail_view.dart b/lib/ui/views/admin_ui/meja_list/meja_detail/meja_detail_view.dart index 06fcf16..ec583c4 100644 --- a/lib/ui/views/admin_ui/meja_list/meja_detail/meja_detail_view.dart +++ b/lib/ui/views/admin_ui/meja_list/meja_detail/meja_detail_view.dart @@ -3,6 +3,7 @@ import 'package:stacked/stacked.dart'; import '../../../../../app/themes/app_colors.dart'; import '../../../../../app/themes/app_text.dart'; +import '../../../../../app/app.router.dart'; import './meja_detail_view_model.dart'; class MejaDetailView extends StatelessWidget { @@ -27,6 +28,7 @@ class MejaDetailView extends StatelessWidget { ) { return WillPopScope( onWillPop: () async { + model.log.i('onWillPop ${model.globalVar.backPressed}'); if (model.globalVar.backPressed == 'backNormal') { model.globalVar.backPressed = 'exitApp'; return true; @@ -37,8 +39,8 @@ class MejaDetailView extends StatelessWidget { }, child: Scaffold( appBar: AppBar( - title: const Text('MejaDetailView', - style: TextStyle(color: Colors.white)), + title: Text('Detail ${model.namaMeja}', + style: const TextStyle(color: Colors.white)), backgroundColor: mainColor, leading: IconButton( onPressed: () { @@ -225,7 +227,9 @@ class MejaDetailView extends StatelessWidget { Expanded( child: GestureDetector( onTap: () { - model.log.i('Edit'); + // model.log.i('Edit'); + model.navigationService + .navigateToMejaEditView(mejaId: mejaId); }, child: const Column( mainAxisAlignment: MainAxisAlignment.center, @@ -258,6 +262,8 @@ class MejaDetailView extends StatelessWidget { onTap: () { model.log.i('List'); // model.navigationService.navigateToMakananListView(); + model.navigationService + .navigateToMejaHistoryLogView(mejaId: mejaId); }, child: const Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/ui/views/admin_ui/meja_list/meja_edit/meja_edit_view.dart b/lib/ui/views/admin_ui/meja_list/meja_edit/meja_edit_view.dart index 170de75..c28ef77 100644 --- a/lib/ui/views/admin_ui/meja_list/meja_edit/meja_edit_view.dart +++ b/lib/ui/views/admin_ui/meja_list/meja_edit/meja_edit_view.dart @@ -1,27 +1,208 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; +import '../../../../../app/themes/app_colors.dart'; +import '../../../../../app/themes/app_text.dart'; import './meja_edit_view_model.dart'; class MejaEditView extends StatelessWidget { - const MejaEditView({super.key}); + final String mejaId; + const MejaEditView({ + Key? key, + required this.mejaId, + }) : super(key: key); @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => MejaEditViewModel(), onViewModelReady: (MejaEditViewModel model) async { - await model.init(); + await model.init(mejaId); }, builder: ( BuildContext context, MejaEditViewModel model, Widget? child, ) { - return const Scaffold( - body: Center( - child: Text( - 'MejaEditView', + return WillPopScope( + onWillPop: () async { + model.log.i( + 'backPressed : ${model.globalVar.backPressed} in MejaEditView'); + if (model.globalVar.backPressed == 'backNormal') { + // model.globalVar.backPressed = 'exitApp'; + return true; + } + // model.quitApp(context); + + return false; + }, + child: Scaffold( + appBar: AppBar( + title: Text('Edit Detail ${model.namaMeja}', + style: const TextStyle(color: Colors.white)), + backgroundColor: mainColor, + leading: IconButton( + onPressed: () { + if (model.globalVar.backPressed == 'backNormal') { + model.globalVar.backPressed = 'exitApp'; + model.navigationService.back(); + // return true; + } + }, + icon: const Icon(Icons.arrow_back, color: Colors.white), + ), + ), + body: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 250, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: mainGrey, + ), + child: Stack( + children: [ + Center( + child: Text( + 'Insert Image', + style: regularTextStyle.copyWith( + fontSize: 20, + color: Colors.white, + ), + ), + ), + Positioned( + bottom: 10, + right: 10, + child: IconButton( + onPressed: () {}, + icon: const Icon( + Icons.camera_alt, + color: Colors.white, + ), + ), + ), + ], + ), + ), + const SizedBox(height: 5), + Text( + model.namaMeja, + style: const TextStyle( + fontSize: 20, + // fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 10), + RichText( + text: TextSpan( + text: 'Status : ', + style: regularTextStyle, + children: [ + TextSpan( + text: 'Tersedia', + style: regularTextStyle.copyWith( + color: Colors.green, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Expanded( + child: RichText( + text: TextSpan( + text: 'Kapasitas : ', + style: regularTextStyle, + children: [ + TextSpan( + text: 'Maksimal 8 Orang', + style: regularTextStyle.copyWith( + color: Colors.green, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic, + ), + ), + ], + ), + ), + ), + const SizedBox( + width: 10, + ), + IconButton( + onPressed: () {}, + icon: const Icon(Icons.edit), + ), + ], + ), + const SizedBox(height: 10), + RichText( + text: TextSpan( + text: 'Lokasi : ', + style: regularTextStyle, + children: [ + TextSpan( + text: 'Luar Ruangan', + style: regularTextStyle.copyWith( + color: Colors.green, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + const SizedBox(height: 10), + Row( + children: [ + Expanded( + child: RichText( + text: TextSpan( + text: 'Harga : ', + style: regularTextStyle, + children: [ + TextSpan( + text: 'Rp. 20.000', + style: regularTextStyle.copyWith( + color: Colors.orange, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic, + ), + ), + ], + ), + ), + ), + const SizedBox( + width: 10, + ), + IconButton( + onPressed: () {}, + icon: const Icon(Icons.edit), + ), + ], + ), + const Expanded(child: SizedBox(height: 10)), + SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton( + onPressed: () { + model.navigationService.back(); + }, + child: const Text('Simpan Perubahan'), + ), + ), + ], + ), ), ), ); diff --git a/lib/ui/views/admin_ui/meja_list/meja_edit/meja_edit_view_model.dart b/lib/ui/views/admin_ui/meja_list/meja_edit/meja_edit_view_model.dart index 770e9ac..9362d91 100644 --- a/lib/ui/views/admin_ui/meja_list/meja_edit/meja_edit_view_model.dart +++ b/lib/ui/views/admin_ui/meja_list/meja_edit/meja_edit_view_model.dart @@ -1,7 +1,28 @@ +import '../../../../../app/app.logger.dart'; import '../../../../../app/core/custom_base_view_model.dart'; class MejaEditViewModel extends CustomBaseViewModel { - Future init() async { + final log = getLogger('MejaEditViewModel'); + late String mejaId; + late String namaMeja; + Future init(String mejaId) async { globalVar.backPressed = 'backNormal'; + log.i('MejaEditViewModel init mejaId : $mejaId'); + + this.mejaId = mejaId; + + // seperate the number from the string + var number = int.parse(mejaId.replaceAll(RegExp(r'[^0-9]'), '')); + // log.i('number : $number'); + if (number <= 4) { + namaMeja = 'Gazebo'; + } else if (number >= 5 && number <= 12) { + namaMeja = 'Meja'; + } else if (number >= 13 && number <= 22) { + namaMeja = 'Meja'; + } + namaMeja = '$namaMeja $number'; + notifyListeners(); + log.i('backPressed : ${globalVar.backPressed}'); } } diff --git a/lib/ui/views/admin_ui/meja_list/meja_history_log/meja_history_log_view.dart b/lib/ui/views/admin_ui/meja_list/meja_history_log/meja_history_log_view.dart index 5d6d2e1..a76168c 100644 --- a/lib/ui/views/admin_ui/meja_list/meja_history_log/meja_history_log_view.dart +++ b/lib/ui/views/admin_ui/meja_list/meja_history_log/meja_history_log_view.dart @@ -1,27 +1,107 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; +import '../../../../../app/themes/app_colors.dart'; +import '../../../../../app/themes/app_text.dart'; import './meja_history_log_view_model.dart'; class MejaHistoryLogView extends StatelessWidget { - const MejaHistoryLogView({super.key}); + final String mejaId; + const MejaHistoryLogView({Key? key, required this.mejaId}) : super(key: key); @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( viewModelBuilder: () => MejaHistoryLogViewModel(), onViewModelReady: (MejaHistoryLogViewModel model) async { - await model.init(); + await model.init(mejaId); }, builder: ( BuildContext context, MejaHistoryLogViewModel model, Widget? child, ) { - return const Scaffold( - body: Center( - child: Text( - 'MejaHistoryLogView', + return WillPopScope( + onWillPop: () async { + model.log.i( + 'backPressed : ${model.globalVar.backPressed} in MejaHistoryLogView'); + if (model.globalVar.backPressed == 'backNormal') { + // model.globalVar.backPressed = 'exitApp'; + return true; + } + // model.quitApp(context); + + return false; + }, + child: Scaffold( + appBar: AppBar( + title: Text('History Log ${model.namaMeja}', + style: const TextStyle(color: Colors.white)), + backgroundColor: mainColor, + leading: IconButton( + onPressed: () { + if (model.globalVar.backPressed == 'backNormal') { + model.globalVar.backPressed = 'exitApp'; + model.navigationService.back(); + // return true; + } + }, + icon: const Icon(Icons.arrow_back, color: Colors.white), + ), + ), + body: Padding( + padding: const EdgeInsets.all(15), + child: ListView.builder( + itemCount: 2, + shrinkWrap: true, + itemBuilder: (context, index) { + // make the color random between red and blue + const color = Colors.blue; + String pesanStatus = 'Menunggu Pengesahan'; + return Card( + color: color, + child: ListTile( + // leading: CircleAvatar( + // backgroundColor: Colors.white, + // child: Text( + // index.toString(), + // style: regularTextStyle, + // ), + // ), + title: Text( + 'Nama Pemesan', + style: regularTextStyle.copyWith( + fontSize: 18, + color: Colors.white, + fontStyle: FontStyle.italic, + ), + ), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + '08:00.00 - 09:00.00', + style: TextStyle( + color: Colors.white, + ), + ), + Text( + pesanStatus, + style: const TextStyle( + color: Colors.white, + ), + ), + ], + ), + trailing: const Icon(Icons.arrow_forward_ios, + color: Colors.white), + onTap: () { + model.log.i('Meja 1'); + }, + ), + ); + }, + ), ), ), ); diff --git a/lib/ui/views/admin_ui/meja_list/meja_history_log/meja_history_log_view_model.dart b/lib/ui/views/admin_ui/meja_list/meja_history_log/meja_history_log_view_model.dart index 4e616ba..42b921a 100644 --- a/lib/ui/views/admin_ui/meja_list/meja_history_log/meja_history_log_view_model.dart +++ b/lib/ui/views/admin_ui/meja_list/meja_history_log/meja_history_log_view_model.dart @@ -1,7 +1,28 @@ +import '../../../../../app/app.logger.dart'; import '../../../../../app/core/custom_base_view_model.dart'; class MejaHistoryLogViewModel extends CustomBaseViewModel { - Future init() async { + final log = getLogger('MejaHistoryLogViewModel'); + late String mejaId; + late String namaMeja; + Future init(String mejaId) async { globalVar.backPressed = 'backNormal'; + log.i('MejaEditViewModel init mejaId : $mejaId'); + + this.mejaId = mejaId; + + // seperate the number from the string + var number = int.parse(mejaId.replaceAll(RegExp(r'[^0-9]'), '')); + // log.i('number : $number'); + if (number <= 4) { + namaMeja = 'Gazebo'; + } else if (number >= 5 && number <= 12) { + namaMeja = 'Meja'; + } else if (number >= 13 && number <= 22) { + namaMeja = 'Meja'; + } + namaMeja = '$namaMeja $number'; + notifyListeners(); + log.i('backPressed : ${globalVar.backPressed}'); } }