Commit 208bf8af authored by Dio Maulana's avatar Dio Maulana

06/10

parent bfc893f0
{ {
"base_url": "https://58a4-125-165-98-228.ap.ngrok.io/", "base_url": "https://7f25-125-165-111-49.ap.ngrok.io/",
"title": "Ravintola Dev BYOD", "title": "Ravintola Dev BYOD",
"isResponsive": true, "isResponsive": true,
"debug": true "debug": true
......
...@@ -142,6 +142,7 @@ class Api { ...@@ -142,6 +142,7 @@ class Api {
); );
setListTypeUrl(listTypeUrl); setListTypeUrl(listTypeUrl);
setMqMessage('update-${jsonObject['data']['order_id']}');
setOrderId(jsonObject['data']['order_id']); setOrderId(jsonObject['data']['order_id']);
setTypeOrder(jsonObject['data']['type_order']); setTypeOrder(jsonObject['data']['type_order']);
setLogoUrl(jsonObject['data']['logo']); setLogoUrl(jsonObject['data']['logo']);
...@@ -150,6 +151,13 @@ class Api { ...@@ -150,6 +151,13 @@ class Api {
setSessionCounter(jsonObject['data']['session_counter']); setSessionCounter(jsonObject['data']['session_counter']);
setBranch(jsonObject['data']['code']); setBranch(jsonObject['data']['code']);
setBrand(jsonObject['data']['brand_code']); setBrand(jsonObject['data']['brand_code']);
setBranchName(jsonObject['data']['name']);
if (jsonObject['data']['payment_mode'] != null) {
setPaymentMode(jsonObject['data']['payment_mode']);
}
if (jsonObject['data']['table_mode'] != null) {
setTableMode(jsonObject['data']['table_mode']);
}
return responseByodBranchExist; return responseByodBranchExist;
} else if (jsonObject['status'] == 'error' && } else if (jsonObject['status'] == 'error' &&
(jsonObject['code'] == 'BYOD_ALWAYS_OFF' || (jsonObject['code'] == 'BYOD_ALWAYS_OFF' ||
...@@ -817,7 +825,6 @@ class Api { ...@@ -817,7 +825,6 @@ class Api {
// memberInfo.add(MemberInfo.getInfo( // memberInfo.add(MemberInfo.getInfo(
// (jsonObject as Map<dynamic, dynamic>)['data']['member_info'])); // (jsonObject as Map<dynamic, dynamic>)['data']['member_info']));
// } // }
for (int d = 0; d < orderDetail.length; d++) { for (int d = 0; d < orderDetail.length; d++) {
if (orderDetail[d]['parent_id'] == '') { if (orderDetail[d]['parent_id'] == '') {
// yang variant gak dimasukin dulu // yang variant gak dimasukin dulu
...@@ -890,14 +897,17 @@ class Api { ...@@ -890,14 +897,17 @@ class Api {
"invoice": jsonObject['data']['code'], "invoice": jsonObject['data']['code'],
"total_service": jsonObject['data']['service'], "total_service": jsonObject['data']['service'],
"total_service_tax": jsonObject['data']['service_tax'], "total_service_tax": jsonObject['data']['service_tax'],
"my_self_outstanding": jsonObject['data'] "my_self_outstanding":
['my_self_outstanding'], jsonObject['data']['my_self_outstanding'] ?? "0.00",
"discount_total": jsonObject['data']['discount'], "discount_total": jsonObject['data']['discount'],
"table_number": jsonObject['data']['table_number'] ?? '', "table_number": jsonObject['data']['table_number'] ?? '',
"is_feedback": jsonObject['data']['is_feedback'], "is_feedback": jsonObject['data']['is_feedback'],
"doku_minimum_payment": jsonObject['data'] "doku_minimum_payment": jsonObject['data']
['doku_minimum_payment'], ['doku_minimum_payment'],
"order_date": jsonObject['data']['order_date'], "order_date": jsonObject['data']['order_date'],
"packaging_fee":
jsonObject['data']['packaging_fee'] ?? "0.00",
"platform_fee": jsonObject['data']['platform_fee'] ?? "0.00",
}; };
bill.add(Bill.createBill(i)); bill.add(Bill.createBill(i));
// billDetail.add(BillDetail.createBillDetail(orderDetail[d])); // billDetail.add(BillDetail.createBillDetail(orderDetail[d]));
...@@ -1311,6 +1321,7 @@ class Api { ...@@ -1311,6 +1321,7 @@ class Api {
var jsonObject = await httpPost(apiUrl, bodies, 'checkOut'); var jsonObject = await httpPost(apiUrl, bodies, 'checkOut');
if (jsonObject != false) { if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') { if (jsonObject['status'].toString().toLowerCase() == 'ok') {
setStatusOrderCreated(true);
await EasyLoading.dismiss(); await EasyLoading.dismiss();
// Navigator.pushAndRemoveUntil( // Navigator.pushAndRemoveUntil(
// context, // context,
...@@ -1955,4 +1966,47 @@ class Api { ...@@ -1955,4 +1966,47 @@ class Api {
return branchList; return branchList;
} }
} }
static Future<bool> changeBranch(String newBranch) async {
String baseUrl = getBaseUrl();
String apiUrl = "$baseUrl${endPoint}change_branch";
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
try {
Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"brand_code": getBrand(),
"order_id": getOrderId(),
"role": getRole(),
"old_branch_code": getBranchPref(),
"new_branch_code": newBranch,
"type_order": getTypeOrder(),
"cashier_name": getCashierName(),
"from": fromByod,
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'changeBranch');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
setBranch(newBranch);
setBranchName(jsonObject['data']['branch_name']);
return true;
}
return false;
} else {
return false;
}
} catch (e) {
if (debug) {
logd('API CLASS ON API.DART, FUNGSI: changeBranch, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
return false;
}
}
} }
...@@ -7,6 +7,7 @@ import 'package:crypto/crypto.dart'; ...@@ -7,6 +7,7 @@ import 'package:crypto/crypto.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import '../api/api.dart';
import '../main.dart'; import '../main.dart';
import 'logger.dart'; import 'logger.dart';
...@@ -366,6 +367,11 @@ bool isCanButtonCheckoutToTap(int orderState) { ...@@ -366,6 +367,11 @@ bool isCanButtonCheckoutToTap(int orderState) {
} }
} }
Future<bool> changeBranch(String newBranch) async {
bool result = await Api.changeBranch(newBranch);
return result;
}
//** END FUNCTION */ //** END FUNCTION */
//** START CONSTANT */ //** START CONSTANT */
...@@ -507,11 +513,16 @@ const String responseByodBranchExist = 'branchExist'; ...@@ -507,11 +513,16 @@ const String responseByodBranchExist = 'branchExist';
//** untuk response API getbranch */ //** untuk response API getbranch */
//** TABLE BILL MODE */ //** TABLE BILL MODE */
const int closebill = 1; const int closebill = 0;
const int openBill = 2; const int openBill = 1;
const int defaultBillTable = 2; // default table di open aja const int defaultBillTable = 1; // default table di open aja
//** TABLE BILL MODE */ //** TABLE BILL MODE */
//** TABLE TABLE MODE */
const int tableIndividu = 1;
const int tableGroup = 2;
//** TABLE TABLE MODE */
//** DURATION ANIMATED SWITECHER in ms */ //** DURATION ANIMATED SWITECHER in ms */
int animatedTime = 200; int animatedTime = 200;
//** DURATION ANIMATED SWITECHER */ //** DURATION ANIMATED SWITECHER */
......
// ignore_for_file: unused_catch_clause
import 'dart:io';
import 'package:byod/helper/logger.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:mqtt_client/mqtt_browser_client.dart';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:uuid/uuid.dart';
String mqttUrl = 'wss://mq.jasadigital.co.id';
final mqClient = MqttBrowserClient(mqttUrl, '');
const int mqttPort = 8083;
const String queueTopic = 'byod/bill/update';
String queueMessage = getMqMessage();
const String usernameMq = 'jasadigital';
const String passwordMq = 'jasadigital';
const uuidInit = Uuid();
var uuid = uuidInit.v4();
Future<int> runMqTT(BuildContext context) async {
mqClient.logging(on: false);
mqClient.setProtocolV311();
mqClient.keepAlivePeriod = 86400;
mqClient.port = mqttPort;
mqClient.onDisconnected;
mqClient.onConnected;
mqClient.onSubscribed;
// mqClient.pongCallback = pong;
final connMess = MqttConnectMessage()
.withClientIdentifier(uuid)
.withWillTopic('willtopic') // If you set this you must set a will message
.withWillMessage('My Will message')
.startClean() // Non persistent session for testing
.withWillQos(MqttQos.atLeastOnce);
// print('EXAMPLE::Mosquitto client connecting....');
mqClient.connectionMessage = connMess;
try {
await mqClient.connect(usernameMq, passwordMq);
} on NoConnectionException catch (e) {
if (debug) {
logd('MQ CONFIG::client exception', '$e');
}
mqClient.disconnect();
} on SocketException catch (e) {
if (debug) {
logd('MQ CONFIG::socket exception', '$e');
}
mqClient.disconnect();
}
if (mqClient.connectionStatus!.state == MqttConnectionState.connected) {
if (debug) {
logd('CHECK CONNECTION', 'CONNECTED');
}
} else {
/// Use status here rather than state if you also want the broker return code.
// print(
// 'EXAMPLE::ERROR Mosquitto client connection failed - disconnecting, status is ${mqClient.connectionStatus}');
mqClient.disconnect();
exit(-1);
}
/// Ok, lets try a subscription
// print('EXAMPLE::Subscribing to the queuetest/1 topic');
var topic = queueTopic; // Not a wildcard topic
mqClient.subscribe(topic, MqttQos.atMostOnce);
/// The client has a change notifier object(see the Observable class) which we then listen to to get
/// notifications of published updates to each subscribed topic.
mqClient.updates!.listen((List<MqttReceivedMessage<MqttMessage?>>? c) {
final recMess = c![0].payload as MqttPublishMessage;
final pt =
MqttPublishPayload.bytesToStringAsString(recMess.payload.message);
// print('Notifikasi masuk dari topic <${c[0].topic}>, isinya adalah: $pt ');
// print('');
if (c[0].topic == topic && pt == queueMessage) {
// update bill disini
if (debug) {
logd('CHECK TOPIC', 'TOPIC MASUK::$topic , MESSAGE::$queueMessage');
}
}
if (debug) {
logd('CHECK TOPIC',
'TOPIC TIDAK SAMA YANG -> MASUK::$topic , MESSAGE::$pt');
}
});
return 0;
}
...@@ -8,7 +8,7 @@ const String _sessionCounter = 'session_counter'; ...@@ -8,7 +8,7 @@ const String _sessionCounter = 'session_counter';
const String _sessionId = 'session_id'; const String _sessionId = 'session_id';
const String _baseUrl = 'baseUrl'; const String _baseUrl = 'baseUrl';
const String _tableNumber = 'table_number'; const String _tableNumber = 'table_number';
const String _tableMode = 'table_mode'; const String _paymentMethod = 'pM';
const String _customerName = 'userName'; const String _customerName = 'userName';
const String _totalOrder = 'total_order'; const String _totalOrder = 'total_order';
const String _dateOrder = 'date_order'; const String _dateOrder = 'date_order';
...@@ -29,6 +29,11 @@ const String _listTypeUrl = 'urlTypeList'; ...@@ -29,6 +29,11 @@ const String _listTypeUrl = 'urlTypeList';
const String _orderType = 'orderType'; const String _orderType = 'orderType';
const String _isDelivery = 'isDelivery'; const String _isDelivery = 'isDelivery';
const String _isPickup = 'isPickup'; const String _isPickup = 'isPickup';
const String _isCustomerDelivery = 'isCustomerDelivery';
const String _mqMessage = 'mqmsg';
const String _tableMode = 'tbm';
const String _branchName = 'bN';
const String _orderCreated = 'oC';
String getBaseUrl() { String getBaseUrl() {
return prefs.getString(_baseUrl) ?? ''; return prefs.getString(_baseUrl) ?? '';
...@@ -139,11 +144,11 @@ Future<void> setListHistory(List<String> value) async { ...@@ -139,11 +144,11 @@ Future<void> setListHistory(List<String> value) async {
} }
int getPaymentMode() { int getPaymentMode() {
return prefs.getInt(_tableMode) ?? defaultBillTable; return prefs.getInt(_paymentMethod) ?? defaultBillTable;
} }
Future<void> setPaymentMode(int value) async { Future<void> setPaymentMode(int value) async {
prefs.setInt(_tableMode, value); prefs.setInt(_paymentMethod, value);
} }
String getLogoUrl() { String getLogoUrl() {
...@@ -249,3 +254,44 @@ bool getIsDelivery() { ...@@ -249,3 +254,44 @@ bool getIsDelivery() {
Future<void> setIsDelivery(bool value) async { Future<void> setIsDelivery(bool value) async {
prefs.setBool(_isDelivery, value); prefs.setBool(_isDelivery, value);
} }
bool getIsCustomerDelivery() {
return prefs.getBool(_isCustomerDelivery) ?? false;
}
Future<void> setIsCustomerDelivery(bool value) async {
prefs.setBool(_isCustomerDelivery, value);
}
String getMqMessage() {
return prefs.getString(_mqMessage) ?? 'default';
}
Future<void> setMqMessage(String value) async {
prefs.setString(_mqMessage, value);
}
int getTableMode() {
return prefs.getInt(_tableMode) ?? 0;
}
Future<void> setTableMode(int value) async {
prefs.setInt(_tableMode, value);
}
String getBranchName() {
return prefs.getString(_branchName) ?? '';
}
Future<void> setBranchName(String value) async {
prefs.setString(_branchName, value);
}
bool getStatusOrderCreated() {
return prefs.getBool(_orderCreated) ?? false;
}
Future<void> setStatusOrderCreated(bool value) async {
prefs.setBool(_orderCreated, value);
}
...@@ -13,9 +13,11 @@ Future<dynamic> buttonDialogGlobal( ...@@ -13,9 +13,11 @@ Future<dynamic> buttonDialogGlobal(
String textOnOk, String textOnOk,
String textOnCancel, String textOnCancel,
void Function() ontapOk, void Function() ontapOk,
void Function() ontapCancel, void Function() ontapCancel, {
{Color okButtonColor = Colors.indigo, Color okButtonColor = Colors.indigo,
Color cancelButtonColor = Colors.red}) { Color cancelButtonColor = Colors.transparent,
Color textCancelColor = textColorBlack,
}) {
return showDialog( return showDialog(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
......
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../../models/orders.dart';
import '../../ui/checkout/fuction.dart';
import '../helper.dart';
import 'style.dart';
// ignore: non_constant_identifier_names
AnimatedContainer CoreModalInputName(BuildContext context,
TextEditingController nameController, List<Orders> listOrders) {
return AnimatedContainer(
duration: const Duration(milliseconds: 300),
child: AlertDialog(
scrollable: true,
title: defaultText(
context,
"Masukkan Nama",
style: modalNamaHeader(),
),
content: SizedBox(
height: 216,
width: 303,
child: Column(
children: [
TextField(
keyboardType: TextInputType.text,
controller: nameController,
style: const TextStyle(
fontFamily: 'OpenSans',
fontSize: 14,
color: textColorModalHeaderNama,
),
decoration: const InputDecoration(
labelText: 'Nama panggilan',
labelStyle: TextStyle(
fontFamily: 'OpenSans',
fontSize: 14,
color: textColorModalHeaderNama,
),
),
),
const SizedBox(
height: 47,
),
GestureDetector(
onTap: () {
if (nameController.text != '') {
checkOut(context, listOrders, nameController.text);
} else {
EasyLoading.showToast("Nama wajib diisi");
}
},
child: Container(
height: 43,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(31),
color: buttonColor),
child: Center(
child: defaultText(
context,
"Simpan",
style: simpanButtonNote(
font: 14,
fontWeight: FontWeight.w600,
),
),
),
),
),
const SizedBox(
height: 20,
),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
height: 43,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(31),
color: Colors.transparent,
),
child: Center(
child: defaultText(
context,
"Batal",
style: simpanButtonNote(
font: 14,
fontWeight: FontWeight.w600,
color: textColorRed,
),
),
),
),
),
],
),
),
),
);
}
...@@ -34,7 +34,7 @@ import 'bloc/view_bill.dart'; ...@@ -34,7 +34,7 @@ import 'bloc/view_bill.dart';
import 'package:flutter/services.dart' as bundle_root; import 'package:flutter/services.dart' as bundle_root;
import 'bloc/voucher_list.dart'; import 'bloc/voucher_list.dart';
import 'ui/select_branch.dart'; import 'ui/confirm_order/confirm_order.dart';
late SharedPreferences prefs; late SharedPreferences prefs;
bool isExcelso = false; bool isExcelso = false;
...@@ -61,7 +61,8 @@ void main() async { ...@@ -61,7 +61,8 @@ void main() async {
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
setPathUrlStrategy(); setPathUrlStrategy();
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
prefs = await SharedPreferences.getInstance(); SharedPreferences.getInstance().then((value) {
prefs = value;
configLoading(); configLoading();
for (int d = 0; d < Uri.base.pathSegments.length; d++) { for (int d = 0; d < Uri.base.pathSegments.length; d++) {
stringPath.add(Uri.base.pathSegments[d]); stringPath.add(Uri.base.pathSegments[d]);
...@@ -79,6 +80,7 @@ void main() async { ...@@ -79,6 +80,7 @@ void main() async {
), ),
); );
}); });
});
} }
//easy loading //easy loading
...@@ -206,7 +208,7 @@ class _MyAppState extends State<MyApp> { ...@@ -206,7 +208,7 @@ class _MyAppState extends State<MyApp> {
// initialRoute: '/', // initialRoute: '/',
// routes: { // routes: {
// '/': (context) => const SelectBranch(), // '/': (context) => const ConfirmOrder(),
// }, // },
// onGenerateRoute: (routes) { // onGenerateRoute: (routes) {
// return MaterialPageRoute( // return MaterialPageRoute(
......
...@@ -23,10 +23,12 @@ class Bill { ...@@ -23,10 +23,12 @@ class Bill {
String tableName; String tableName;
bool isFeedBack; bool isFeedBack;
String dokuMinPay; String dokuMinPay;
String packagingFee;
String platformFee;
// List<MemberInfo> memberInfo; // List<MemberInfo> memberInfo;
Bill( Bill({
{required this.id, required this.id,
required this.totalSeluruhOrderan, required this.totalSeluruhOrderan,
required this.subTotalSeluruhOrderan, required this.subTotalSeluruhOrderan,
required this.totalPerCustomer, required this.totalPerCustomer,
...@@ -45,7 +47,9 @@ class Bill { ...@@ -45,7 +47,9 @@ class Bill {
required this.discountTotal, required this.discountTotal,
required this.tableName, required this.tableName,
required this.isFeedBack, required this.isFeedBack,
required this.dokuMinPay required this.dokuMinPay,
this.packagingFee = "0.00",
this.platformFee = "0.00",
// this.memberInfo = const [] // this.memberInfo = const []
}); });
...@@ -71,6 +75,8 @@ class Bill { ...@@ -71,6 +75,8 @@ class Bill {
isFeedBack: json['is_feedback'], isFeedBack: json['is_feedback'],
dokuMinPay: json['doku_minimum_payment'], dokuMinPay: json['doku_minimum_payment'],
dateOrder: json['order_date'], dateOrder: json['order_date'],
packagingFee: json['packaging_fee'],
platformFee: json['platform_fee'],
// memberInfo: json['member_info'] // memberInfo: json['member_info']
); );
} }
......
// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
class CustomAppBarConfirm extends StatelessWidget {
const CustomAppBarConfirm({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.only(
top: 15,
bottom: 19,
left: paddingLeftRight,
right: paddingLeftRight,
),
// padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
color: backgroundWhite,
child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: 24,
height: 24,
child: Center(
child: fontAwesomeNew(
arrowBack,
arrowBackSize,
),
),
),
),
const SizedBox(
width: 16,
),
Center(
child: defaultText(
context,
'Konfirmasi Orderan',
maxLines: 1,
overFlow: TextOverflow.ellipsis,
style: appBarNameViewBill(),
),
),
],
),
);
}
}
This diff is collapsed.
...@@ -14,16 +14,16 @@ import 'package:byod/models/orders.dart'; ...@@ -14,16 +14,16 @@ import 'package:byod/models/orders.dart';
import 'package:byod/ui/home/menu_list_utama.dart'; import 'package:byod/ui/home/menu_list_utama.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import 'package:sliver_tools/sliver_tools.dart'; import 'package:sliver_tools/sliver_tools.dart';
import '../../bloc/filter_menu.dart'; import '../../bloc/filter_menu.dart';
import '../../helper/widget/button_dialog.dart'; import '../../helper/widget/button_dialog.dart';
import '../../helper/widget/modal_input_name.dart';
import '../../main.dart'; import '../../main.dart';
import '../../models/fav_group.dart'; import '../../models/fav_group.dart';
import '../checkout/checkout.dart';
import '../checkout/fuction.dart'; import '../checkout/fuction.dart';
import '../confirm_order/confirm_order.dart';
import '../screen_responsive.dart'; import '../screen_responsive.dart';
import '../viewbill/view_bill_new.dart'; import '../viewbill/view_bill_new.dart';
import 'cat_list.dart'; import 'cat_list.dart';
...@@ -924,102 +924,11 @@ class _NewHome2State extends State<NewHome2> { ...@@ -924,102 +924,11 @@ class _NewHome2State extends State<NewHome2> {
if (namaPelanggan != '') { if (namaPelanggan != '') {
checkOut(context, listOrders, namaPelanggan); checkOut(context, listOrders, namaPelanggan);
} else { } else {
showDialog( modalInputName(context, nameController, listOrders);
context: context,
builder: (BuildContext context) {
return AnimatedContainer(
duration: const Duration(milliseconds: 300),
child: AlertDialog(
scrollable: true,
title: defaultText(
context,
"Masukkan Nama",
style: modalNamaHeader(),
),
content: SizedBox(
height: 216,
width: 303,
child: Column(
children: [
TextField(
keyboardType: TextInputType.text,
controller: nameController,
style: textStyleNormalFont(context),
decoration: const InputDecoration(
labelText: 'Nama panggilan',
labelStyle: TextStyle(
fontFamily: 'OpenSans',
fontSize: 14,
color: textColorModalHeaderNama,
),
),
),
const SizedBox(
height: 47,
),
GestureDetector(
onTap: () {
if (nameController.text != '' ||
namaPelanggan != '') {
checkOut(
context, listOrders, nameController.text);
} else {
EasyLoading.showToast("Nama wajib diisi");
}
},
child: Container(
height: 43,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(31),
color: buttonColor),
child: Center(
child: defaultText(
context,
"Simpan",
style: simpanButtonNote(
font: 14,
fontWeight: FontWeight.w600,
),
),
),
),
),
const SizedBox(
height: 20,
),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
height: 43,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(31),
color: Colors.transparent,
),
child: Center(
child: defaultText(
context,
"Batal",
style: simpanButtonNote(
font: 14,
fontWeight: FontWeight.w600,
color: textColorRed,
),
),
),
),
),
],
),
),
),
);
});
} }
} else { } else {
Navigator.push(context, Navigator.push(context,
MaterialPageRoute(builder: (context) => const CheckOut())); MaterialPageRoute(builder: (context) => const ConfirmOrder()));
} }
}, },
child: Stack( child: Stack(
...@@ -1127,6 +1036,16 @@ class _NewHome2State extends State<NewHome2> { ...@@ -1127,6 +1036,16 @@ class _NewHome2State extends State<NewHome2> {
); );
} }
Future<dynamic> modalInputName(BuildContext context,
TextEditingController nameController, List<Orders> listOrders) {
return showDialog(
context: context,
builder: (BuildContext context) {
return CoreModalInputName(context, nameController, listOrders);
},
);
}
Container customAppBar( Container customAppBar(
BuildContext context, BuildContext context,
double paddingLeftRight, double paddingLeftRight,
......
...@@ -9,21 +9,28 @@ import 'package:byod/ui/home/new_home2.dart'; ...@@ -9,21 +9,28 @@ import 'package:byod/ui/home/new_home2.dart';
import 'package:byod/ui/screen_responsive.dart'; import 'package:byod/ui/screen_responsive.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../bloc/search_branch.dart'; import '../bloc/search_branch.dart';
import '../helper/widget/style.dart'; import '../helper/widget/style.dart';
import 'app_bar_select_branch.dart'; import 'app_bar_select_branch.dart';
class SelectBranch extends StatelessWidget { class SelectBranch extends StatelessWidget {
const SelectBranch({super.key}); const SelectBranch({
super.key,
this.isFormBill = false,
});
final bool isFormBill;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
body: ScreenResponsive( body: ScreenResponsive(
widget: const CoreBranch(), widget: CoreBranch(
isFormBill: isFormBill,
),
widthScreen: MediaQuery.of(context).size.width, widthScreen: MediaQuery.of(context).size.width,
isCoreLayout: true, isCoreLayout: true,
), ),
...@@ -33,8 +40,12 @@ class SelectBranch extends StatelessWidget { ...@@ -33,8 +40,12 @@ class SelectBranch extends StatelessWidget {
} }
class CoreBranch extends StatelessWidget { class CoreBranch extends StatelessWidget {
const CoreBranch({super.key}); const CoreBranch({
super.key,
required this.isFormBill,
});
final bool isFormBill;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double widthScreen = responsiveWidthScreen(context); double widthScreen = responsiveWidthScreen(context);
...@@ -69,6 +80,15 @@ class CoreBranch extends StatelessWidget { ...@@ -69,6 +80,15 @@ class CoreBranch extends StatelessWidget {
itemBuilder: (context, i) { itemBuilder: (context, i) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
if (listBranch[i].isDelivery == false &&
listBranch[i].isPickup == false) {
EasyLoading.showToast(
'Outlet tidak menerima delivery dan pickup');
} else {
if (isFormBill) {
changeBranch(listBranch[i].branchCode)
.then((value) {
if (value) {
context.read<FilterMenuBloc>().catAndMenu( context.read<FilterMenuBloc>().catAndMenu(
listBranch[i].branchCode, listBranch[i].branchCode,
getBrand(), getBrand(),
...@@ -79,11 +99,45 @@ class CoreBranch extends StatelessWidget { ...@@ -79,11 +99,45 @@ class CoreBranch extends StatelessWidget {
setIsDelivery(listBranch[i].isDelivery); setIsDelivery(listBranch[i].isDelivery);
setIsPickup(listBranch[i].isPickup); setIsPickup(listBranch[i].isPickup);
setBranch(listBranch[i].branchCode); setBranch(listBranch[i].branchCode);
if (listBranch[i].isDelivery) {
setIsCustomerDelivery(true);
} else {
setIsCustomerDelivery(false);
}
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => const NewHome2()), builder: (_) => const NewHome2()),
); );
} else {
EasyLoading.showToast(
'Outlet tidak dapat dipilih');
}
});
} else {
setIsDelivery(listBranch[i].isDelivery);
setIsPickup(listBranch[i].isPickup);
setBranch(listBranch[i].branchCode);
context.read<FilterMenuBloc>().catAndMenu(
listBranch[i].branchCode,
getBrand(),
getRole(),
getCashierName(),
getOrderId(),
);
if (listBranch[i].isDelivery) {
setIsCustomerDelivery(true);
} else {
setIsCustomerDelivery(false);
}
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const NewHome2()),
);
}
}
}, },
child: Container( child: Container(
margin: const EdgeInsets.only( margin: const EdgeInsets.only(
......
...@@ -12,6 +12,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; ...@@ -12,6 +12,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import '../bloc/branch_exist.dart'; import '../bloc/branch_exist.dart';
import '../bloc/filter_menu.dart';
import '../helper/mq.dart';
import '../main.dart'; import '../main.dart';
import 'package:flutter/services.dart' as bundle_root; import 'package:flutter/services.dart' as bundle_root;
import 'home/new_home2.dart'; import 'home/new_home2.dart';
...@@ -50,6 +52,7 @@ class _SplashState extends State<Splash> { ...@@ -50,6 +52,7 @@ class _SplashState extends State<Splash> {
@override @override
void initState() { void initState() {
loadBaseUrl().then((baseUrl) { loadBaseUrl().then((baseUrl) {
runMqTT(context);
setBaseUrl(baseUrl); setBaseUrl(baseUrl);
if (widget.pathSegmentString.isEmpty) { if (widget.pathSegmentString.isEmpty) {
Geolocator.requestPermission().then((permission) { Geolocator.requestPermission().then((permission) {
...@@ -87,12 +90,28 @@ class _SplashState extends State<Splash> { ...@@ -87,12 +90,28 @@ class _SplashState extends State<Splash> {
getBrancList: true, getBrancList: true,
); );
Future.delayed(const Duration(milliseconds: 2000), () async { Future.delayed(const Duration(milliseconds: 2000), () async {
if (getStatusOrderCreated()) {
context.read<FilterMenuBloc>().catAndMenu(
getBranchPref(),
getBrand(),
getRole(),
getCashierName(),
getOrderId(),
);
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
builder: (_) => const NewHome2(),
),
);
} else {
Navigator.pushReplacement( Navigator.pushReplacement(
widget.context, widget.context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => const SelectBranch(), builder: (_) => const SelectBranch(),
), ),
); );
}
}); });
}); });
} else { } else {
......
// ignore_for_file: sized_box_for_whitespace // ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../models/bill.dart';
import '../../models/bill_detail.dart'; import '../../models/bill_detail.dart';
import 'order_view_bill_new.dart'; import 'order_view_bill_new.dart';
class ListOrder extends StatelessWidget { class ListOrder extends StatelessWidget {
const ListOrder({ const ListOrder({
Key? key, Key? key,
required this.billDetail, required this.bill,
required this.isHistory, required this.isHistory,
required this.tableStatus, required this.tableStatus,
}) : super(key: key); }) : super(key: key);
final List<BillDetail> billDetail; final List<Bill> bill;
final bool isHistory; final bool isHistory;
final int tableStatus; final int tableStatus;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
int itemCounts = billDetail.length;
return ListView.builder( return ListView.builder(
physics: const NeverScrollableScrollPhysics(), // to disable scrolling physics: const NeverScrollableScrollPhysics(), // to disable scrolling
shrinkWrap: true, shrinkWrap: true,
itemCount: itemCounts, itemCount: bill.length,
itemBuilder: (ctx, i) { itemBuilder: (context, i) {
return ListView.builder(
physics:
const NeverScrollableScrollPhysics(), // to disable scrolling
shrinkWrap: true,
itemCount: bill[i].billDetail.length,
itemBuilder: (ctx, d) {
return OrderViewBillNew( return OrderViewBillNew(
billDetail: billDetail[i], billDetail: bill[i].billDetail[d],
lastItem: (i + 1 == itemCounts) ? true : false, lastItem: (i + 1 == bill[i].billDetail.length) ? true : false,
isHistory: isHistory, isHistory: isHistory,
tableStatus: tableStatus, tableStatus: tableStatus,
); );
}, },
); );
});
} }
} }
...@@ -125,6 +125,13 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> { ...@@ -125,6 +125,13 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
@override @override
Widget build(BuildContext contextOrderViewBill) { Widget build(BuildContext contextOrderViewBill) {
double paddingLeftRightBill = 32; double paddingLeftRightBill = 32;
int paymentMode = getPaymentMode();
String itemQuantityString;
if (widget.billDetail.quantity > 1) {
itemQuantityString = '${widget.billDetail.quantity} items';
} else {
itemQuantityString = '${widget.billDetail.quantity} item';
}
return Container( return Container(
// padding: const EdgeInsets.symmetric(horizontal: 32), // padding: const EdgeInsets.symmetric(horizontal: 32),
padding: EdgeInsets.only( padding: EdgeInsets.only(
...@@ -197,7 +204,9 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> { ...@@ -197,7 +204,9 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
), ),
defaultText( defaultText(
context, context,
'Rp ${formatNumber().format(amountParseToInt(widget.billDetail.total))}', (paymentMode == openBill)
? 'Rp ${formatNumber().format(amountParseToInt(widget.billDetail.total))} | $itemQuantityString '
: 'Rp ${formatNumber().format(amountParseToInt(widget.billDetail.total))}',
style: viewbillStyle( style: viewbillStyle(
font: 12, font: 12,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
...@@ -226,8 +235,8 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> { ...@@ -226,8 +235,8 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
], ],
), ),
), ),
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory, isVisibleAddRemoveQuantityButtonCheckout(
widget.billDetail.orderStatus) widget.isHistory, widget.billDetail.orderStatus)
? Container( ? Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: paddingLeftRightBill, left: paddingLeftRightBill,
...@@ -238,14 +247,14 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> { ...@@ -238,14 +247,14 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
), ),
) )
: const SizedBox(), : const SizedBox(),
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory, isVisibleAddRemoveQuantityButtonCheckout(
widget.billDetail.orderStatus) widget.isHistory, widget.billDetail.orderStatus)
? const SizedBox( ? const SizedBox(
height: 11, height: 11,
) )
: const SizedBox(), : const SizedBox(),
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory, isVisibleAddRemoveQuantityButtonCheckout(
widget.billDetail.orderStatus) widget.isHistory, widget.billDetail.orderStatus)
? Container( ? Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: paddingLeftRightBill, left: paddingLeftRightBill,
......
import 'package:byod/helper/prefs.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../helper/helper.dart'; import '../../helper/helper.dart';
...@@ -23,10 +24,11 @@ class RincianPembayaran extends StatelessWidget { ...@@ -23,10 +24,11 @@ class RincianPembayaran extends StatelessWidget {
horizontal: paddingLeftRight, horizontal: paddingLeftRight,
vertical: 16, vertical: 16,
), ),
height: 209, // height: 209,
color: backgroundWhite, color: backgroundWhite,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [ children: [
defaultText( defaultText(
context, context,
...@@ -87,6 +89,66 @@ class RincianPembayaran extends StatelessWidget { ...@@ -87,6 +89,66 @@ class RincianPembayaran extends StatelessWidget {
), ),
], ],
), ),
(getIsDeliveryPickup())
? const SizedBox(
height: 8,
)
: const SizedBox(),
(getIsDeliveryPickup())
? Row(
children: [
defaultText(
context,
'Packaging Fee',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
const Spacer(),
defaultText(
context,
(amountParseToInt(dataBill[0].packagingFee) == 0)
? '-'
: 'Rp ${formatNumber().format(amountParseToInt(dataBill[0].packagingFee))}',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
],
)
: const SizedBox(),
(getIsDeliveryPickup())
? const SizedBox(
height: 8,
)
: const SizedBox(),
(getIsDeliveryPickup())
? Row(
children: [
defaultText(
context,
'Platform Fee',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
const Spacer(),
defaultText(
context,
(amountParseToInt(dataBill[0].platformFee) == 0)
? '-'
: 'Rp ${formatNumber().format(amountParseToInt(dataBill[0].platformFee))}',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
],
)
: const SizedBox(),
const SizedBox( const SizedBox(
height: 8, height: 8,
), ),
......
This diff is collapsed.
...@@ -71,6 +71,13 @@ packages: ...@@ -71,6 +71,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.1.0" version: "3.1.0"
event_bus:
dependency: transitive
description:
name: event_bus
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
...@@ -268,6 +275,13 @@ packages: ...@@ -268,6 +275,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
mqtt_client:
dependency: "direct main"
description:
name: mqtt_client
url: "https://pub.dartlang.org"
source: hosted
version: "9.7.2"
nested: nested:
dependency: transitive dependency: transitive
description: description:
......
...@@ -39,6 +39,7 @@ dependencies: ...@@ -39,6 +39,7 @@ dependencies:
http: ^0.13.4 http: ^0.13.4
intl: ^0.17.0 intl: ^0.17.0
loading_animations: ^2.2.0 loading_animations: ^2.2.0
mqtt_client: ^9.7.2
scrollable_positioned_list: ^0.3.4 scrollable_positioned_list: ^0.3.4
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
shimmer: ^2.0.0 shimmer: ^2.0.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment