added meja edit and meja history log page

This commit is contained in:
kicap
2023-08-10 02:16:16 +08:00
parent 696d48e3c3
commit 24cc3d3bd7
6 changed files with 406 additions and 27 deletions

View File

@ -138,14 +138,18 @@ class StackedRouter extends _i1.RouterBase {
);
},
_i8.MejaEditView: (data) {
final args = data.getArgs<MejaEditViewArguments>(nullOk: false);
return _i10.MaterialPageRoute<dynamic>(
builder: (context) => const _i8.MejaEditView(),
builder: (context) =>
_i8.MejaEditView(key: args.key, mejaId: args.mejaId),
settings: data,
);
},
_i9.MejaHistoryLogView: (data) {
final args = data.getArgs<MejaHistoryLogViewArguments>(nullOk: false);
return _i10.MaterialPageRoute<dynamic>(
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<dynamic> navigateToMejaEditView([
Future<dynamic> navigateToMejaEditView({
_i10.Key? key,
required String mejaId,
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
]) async {
}) async {
return navigateTo<dynamic>(Routes.mejaEditView,
arguments: MejaEditViewArguments(key: key, mejaId: mejaId),
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition);
}
Future<dynamic> navigateToMejaHistoryLogView([
Future<dynamic> navigateToMejaHistoryLogView({
_i10.Key? key,
required String mejaId,
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
]) async {
}) async {
return navigateTo<dynamic>(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<dynamic> replaceWithMejaEditView([
Future<dynamic> replaceWithMejaEditView({
_i10.Key? key,
required String mejaId,
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
]) async {
}) async {
return replaceWith<dynamic>(Routes.mejaEditView,
arguments: MejaEditViewArguments(key: key, mejaId: mejaId),
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition);
}
Future<dynamic> replaceWithMejaHistoryLogView([
Future<dynamic> replaceWithMejaHistoryLogView({
_i10.Key? key,
required String mejaId,
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
]) async {
}) async {
return replaceWith<dynamic>(Routes.mejaHistoryLogView,
arguments: MejaHistoryLogViewArguments(key: key, mejaId: mejaId),
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,

View File

@ -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,

View File

@ -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<MejaEditViewModel>.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(
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(
'MejaEditView',
'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'),
),
),
],
),
),
),
);

View File

@ -1,7 +1,28 @@
import '../../../../../app/app.logger.dart';
import '../../../../../app/core/custom_base_view_model.dart';
class MejaEditViewModel extends CustomBaseViewModel {
Future<void> init() async {
final log = getLogger('MejaEditViewModel');
late String mejaId;
late String namaMeja;
Future<void> 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}');
}
}

View File

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

View File

@ -1,7 +1,28 @@
import '../../../../../app/app.logger.dart';
import '../../../../../app/core/custom_base_view_model.dart';
class MejaHistoryLogViewModel extends CustomBaseViewModel {
Future<void> init() async {
final log = getLogger('MejaHistoryLogViewModel');
late String mejaId;
late String namaMeja;
Future<void> 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}');
}
}