first commit

This commit is contained in:
kicap
2023-08-10 01:23:34 +08:00
commit 696d48e3c3
175 changed files with 9675 additions and 0 deletions

View File

@ -0,0 +1,302 @@
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
import '../../../../../app/themes/app_colors.dart';
import '../../../../../app/themes/app_text.dart';
import './meja_detail_view_model.dart';
class MejaDetailView extends StatelessWidget {
final String mejaId;
const MejaDetailView({
Key? key,
required this.mejaId,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ViewModelBuilder<MejaDetailViewModel>.reactive(
viewModelBuilder: () => MejaDetailViewModel(),
onViewModelReady: (MejaDetailViewModel model) async {
await model.init(mejaId);
},
builder: (
BuildContext context,
MejaDetailViewModel model,
Widget? child,
) {
return WillPopScope(
onWillPop: () async {
if (model.globalVar.backPressed == 'backNormal') {
model.globalVar.backPressed = 'exitApp';
return true;
}
// model.quitApp(context);
return false;
},
child: Scaffold(
appBar: AppBar(
title: const Text('MejaDetailView',
style: 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),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: model.imgAsset == null
? const Center(child: CircularProgressIndicator())
: Image.asset(model.imgAsset!, fit: BoxFit.cover),
),
),
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),
RichText(
text: TextSpan(
text: 'Kapasitas : ',
style: regularTextStyle,
children: [
TextSpan(
text: 'Maksimal 8 Orang',
style: regularTextStyle.copyWith(
color: Colors.green,
fontWeight: FontWeight.bold,
),
),
],
),
),
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),
RichText(
text: TextSpan(
text: 'Harga : ',
style: regularTextStyle,
children: [
TextSpan(
text: 'Rp. 20.000',
style: regularTextStyle.copyWith(
color: Colors.orange,
fontWeight: FontWeight.bold,
),
),
],
),
),
const SizedBox(height: 10),
Expanded(
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');
},
),
);
},
),
),
],
),
),
bottomNavigationBar: Container(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
width: MediaQuery.of(context).size.width,
height: 70,
decoration: BoxDecoration(
color: mainColor,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 5,
spreadRadius: 5,
),
],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
child: Row(
children: [
Expanded(
child: GestureDetector(
onTap: () {
model.log.i('Edit');
},
child: const Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.edit,
color: Colors.white,
),
SizedBox(
height: 5,
),
Text(
'Edit',
style: TextStyle(
color: Colors.white,
),
),
],
),
),
),
// divider
Container(
width: 1,
height: 30,
color: Colors.white,
),
Expanded(
child: GestureDetector(
onTap: () {
model.log.i('List');
// model.navigationService.navigateToMakananListView();
},
child: const Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.list,
color: Colors.white,
),
SizedBox(
height: 5,
),
Text(
'History Booking',
style: TextStyle(
color: Colors.white,
),
),
],
),
),
),
],
),
),
floatingActionButton: FloatingActionButton(
backgroundColor: orangeColor,
onPressed: () {
// model.navigationService.navigateToAddEditMakananView();
},
// create a add product button
child: const Icon(
Icons.edit_calendar_outlined,
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.miniEndTop,
),
);
},
);
}
}

View File

@ -0,0 +1,35 @@
import '../../../../../app/app.logger.dart';
import '../../../../../app/core/custom_base_view_model.dart';
class MejaDetailViewModel extends CustomBaseViewModel {
final log = getLogger('MejaDetailViewModel');
late String mejaId;
late String namaMeja;
String? imgAsset;
Future<void> init(String mejaId) async {
log.i('MejaDetailViewModel init');
log.i('mejaId : $mejaId');
this.mejaId = mejaId;
globalVar.backPressed = 'backNormal';
// 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';
imgAsset = 'assets/reza_gazebo.jpeg';
} else if (number >= 5 && number <= 12) {
namaMeja = 'Meja';
imgAsset = 'assets/reza_meja_1.jpeg';
} else if (number >= 13 && number <= 22) {
namaMeja = 'Meja';
imgAsset = 'assets/reza_meja_2.jpeg';
}
namaMeja = '$namaMeja $number';
log.i('imgAsset : $imgAsset');
}
}

View File

@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
import './meja_edit_view_model.dart';
class MejaEditView extends StatelessWidget {
const MejaEditView({super.key});
@override
Widget build(BuildContext context) {
return ViewModelBuilder<MejaEditViewModel>.reactive(
viewModelBuilder: () => MejaEditViewModel(),
onViewModelReady: (MejaEditViewModel model) async {
await model.init();
},
builder: (
BuildContext context,
MejaEditViewModel model,
Widget? child,
) {
return const Scaffold(
body: Center(
child: Text(
'MejaEditView',
),
),
);
},
);
}
}

View File

@ -0,0 +1,7 @@
import '../../../../../app/core/custom_base_view_model.dart';
class MejaEditViewModel extends CustomBaseViewModel {
Future<void> init() async {
globalVar.backPressed = 'backNormal';
}
}

View File

@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
import './meja_history_log_view_model.dart';
class MejaHistoryLogView extends StatelessWidget {
const MejaHistoryLogView({super.key});
@override
Widget build(BuildContext context) {
return ViewModelBuilder<MejaHistoryLogViewModel>.reactive(
viewModelBuilder: () => MejaHistoryLogViewModel(),
onViewModelReady: (MejaHistoryLogViewModel model) async {
await model.init();
},
builder: (
BuildContext context,
MejaHistoryLogViewModel model,
Widget? child,
) {
return const Scaffold(
body: Center(
child: Text(
'MejaHistoryLogView',
),
),
);
},
);
}
}

View File

@ -0,0 +1,7 @@
import '../../../../../app/core/custom_base_view_model.dart';
class MejaHistoryLogViewModel extends CustomBaseViewModel {
Future<void> init() async {
globalVar.backPressed = 'backNormal';
}
}

View File

@ -0,0 +1,235 @@
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:reza_admin/app/app.router.dart';
import 'package:reza_admin/app/themes/app_colors.dart';
import 'package:reza_admin/app/themes/app_text.dart';
import 'package:stacked/stacked.dart';
import 'package:webview_flutter/webview_flutter.dart';
import './meja_list_view_model.dart';
class MejaListView extends StatelessWidget {
const MejaListView({super.key});
@override
Widget build(BuildContext context) {
return ViewModelBuilder<MejaListViewModel>.reactive(
viewModelBuilder: () => MejaListViewModel(),
onViewModelReady: (MejaListViewModel model) async {
await model.init();
},
builder: (
BuildContext context,
MejaListViewModel model,
Widget? child,
) {
return WillPopScope(
onWillPop: () async {
model.log.d('onWillPop ini meja');
if (model.globalVar.backPressed == 'exitApp') {
model.quitApp(context);
model.globalVar.backPressed = 'exitApp';
return false;
}
return false;
},
child: Scaffold(
appBar: AppBar(
title: const Text('Reservasi Meja',
style: TextStyle(
color: Colors.white,
)),
backgroundColor: mainColor,
automaticallyImplyLeading: false,
),
body: Column(
children: [
const SizedBox(
height: 20,
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.35,
child: WebView(
initialUrl: dotenv.env['table_url'],
// initialUrl: 'http://172.29.85.181/parkir/user',
// initialUrl: 'https://rekam-medis.airlangga-it.com/',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
// _controller.complete(webViewController);
// model.controllerCompleter.future
// .then((value) => model.webViewController = value);
// model.controllerCompleter.complete(webViewController);
},
onProgress: (int 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>{
// _toasterJavascriptChannel(context),
// },
javascriptChannels: <JavascriptChannel>{
JavascriptChannel(
name: 'messageHandler',
onMessageReceived: (JavascriptMessage message) async {
model.log.i('messageHandler : ${message.message}');
model.navigationService.navigateToMejaDetailView(
mejaId: message.message,
);
},
),
JavascriptChannel(
name: 'messageHandler1',
onMessageReceived: (JavascriptMessage message) async {
// String no_telpon = message.message;
// dev.i('no_telpon : $no_telpon');
// await launchUrl(Uri.parse('tel:$no_telpon'));
},
),
},
navigationDelegate: (NavigationRequest request) async {
// if (request.url.startsWith('https://www.youtube.com/')) {
// dev.log('blocking navigation to $request}');
// return NavigationDecision.prevent;
// }
// check if request.url has 'nrm'
return NavigationDecision.navigate;
},
onPageStarted: (String url) {
model.log.i('Page started loading: $url');
},
onPageFinished: (String url) {
model.log.i('Page finished loading: $url');
model.easyLoading.dismissLoading();
},
gestureNavigationEnabled: true,
backgroundColor: const Color(0x00000000),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
// create 3 circle color
Container(
width: 20,
height: 20,
decoration: const BoxDecoration(
color: Color.fromRGBO(223, 216, 214, 1),
shape: BoxShape.circle,
),
),
const SizedBox(width: 5),
const Text('Tersedia'),
const SizedBox(width: 10),
Container(
width: 20,
height: 20,
decoration: const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
const SizedBox(width: 5),
const Text('Dibooking'),
const SizedBox(width: 10),
Container(
width: 20,
height: 20,
decoration: const BoxDecoration(
color: Colors.blue,
shape: BoxShape.circle,
),
),
const SizedBox(width: 5),
const Text('Menunggu'),
const SizedBox(width: 10),
Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: Colors.grey[600],
shape: BoxShape.circle,
),
),
const SizedBox(width: 5),
const Text('Tidak Tersedia'),
const SizedBox(width: 10),
],
),
),
),
const SizedBox(
height: 15,
),
Expanded(
child: ListView.builder(
itemCount: 15,
shrinkWrap: true,
itemBuilder: (context, index) {
// make the color random between red and blue
final color = index % 2 == 0 ? Colors.red : Colors.blue;
String pesanStatus =
index % 2 == 0 ? 'Dibooking' : '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');
},
),
);
},
),
),
const SizedBox(
height: 15,
),
],
),
),
);
},
);
}
}

View File

@ -0,0 +1,10 @@
import 'package:reza_admin/app/app.logger.dart';
import '../../../../app/core/custom_base_view_model.dart';
class MejaListViewModel extends CustomBaseViewModel {
final log = getLogger('MejaListViewModel');
Future<void> init() async {
globalVar.backPressed = 'exitApp';
}
}