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);
}
...@@ -7,15 +7,17 @@ import '../helper.dart'; ...@@ -7,15 +7,17 @@ import '../helper.dart';
import 'button_modal.dart'; import 'button_modal.dart';
Future<dynamic> buttonDialogGlobal( Future<dynamic> buttonDialogGlobal(
BuildContext context, BuildContext context,
String title, String title,
String description, String description,
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,23 +61,25 @@ void main() async { ...@@ -61,23 +61,25 @@ 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) {
configLoading(); prefs = value;
for (int d = 0; d < Uri.base.pathSegments.length; d++) { configLoading();
stringPath.add(Uri.base.pathSegments[d]); for (int d = 0; d < Uri.base.pathSegments.length; d++) {
if (d == Uri.base.pathSegments.length - 1) { stringPath.add(Uri.base.pathSegments[d]);
routesToAccess += Uri.base.pathSegments[d]; if (d == Uri.base.pathSegments.length - 1) {
} else { routesToAccess += Uri.base.pathSegments[d];
routesToAccess += '${Uri.base.pathSegments[d]}/'; } else {
routesToAccess += '${Uri.base.pathSegments[d]}/';
}
} }
} loadAssetConfig().then((title) {
loadAssetConfig().then((title) { setTitleWeb(title);
setTitleWeb(title); runApp(
runApp( MyApp(
MyApp( title: title,
title: title, ),
), );
); });
}); });
} }
...@@ -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,31 +23,35 @@ class Bill { ...@@ -23,31 +23,35 @@ 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,
required this.customerName, required this.customerName,
required this.tableStatus, required this.tableStatus,
required this.orderStatus, required this.orderStatus,
required this.state, required this.state,
required this.outStandingPay, required this.outStandingPay,
required this.outStandingIndividu, required this.outStandingIndividu,
required this.dateOrder, required this.dateOrder,
this.billDetail = const [], this.billDetail = const [],
this.paymentList = const [], this.paymentList = const [],
required this.invoice, required this.invoice,
required this.totalService, required this.totalService,
required this.totalServiceTax, required this.totalServiceTax,
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.memberInfo = const [] this.packagingFee = "0.00",
}); this.platformFee = "0.00",
// this.memberInfo = const []
});
factory Bill.createBill(Map<String, dynamic> json) { factory Bill.createBill(Map<String, dynamic> json) {
return Bill( return Bill(
...@@ -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(),
),
),
],
),
);
}
}
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/ui/screen_responsive.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/order_bloc.dart';
import '../../helper/prefs.dart';
import '../../helper/widget/button_modal.dart';
import '../../helper/widget/modal_input_name.dart';
import '../../models/orders.dart';
import '../checkout/fuction.dart';
import 'app_bar_confirm.dart';
class ConfirmOrder extends StatelessWidget {
const ConfirmOrder({super.key});
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
body: ScreenResponsive(
widget: CoreConfirm(),
widthScreen: MediaQuery.of(context).size.width,
isCoreLayout: true,
),
));
}
}
class CoreConfirm extends StatelessWidget {
CoreConfirm({super.key});
final nameController = TextEditingController();
@override
Widget build(BuildContext context) {
double widthScreen = responsiveWidthScreen(context);
return BlocBuilder<OrdersBloc, List<Orders>>(
builder: (context, listOrders) {
int totalHarga = 0;
// List indexTidakAdaVariant = [];
// List<String> indexAdaVariant = [];
if (listOrders.isNotEmpty) {
int fixTotalHarga = 0;
int totalHargaOrderDetail = 0;
int totalHargaBukanOrderDetail = 0;
for (var i = 0; i < listOrders.length; i++) {
if (listOrders[i].orderDetail.isEmpty) {
// indexTidakAdaVariant.add(i);
totalHargaBukanOrderDetail +=
(listOrders[i].totalItem * listOrders[i].totalHarga);
} else {
// for (int kk = 0; kk < listOrders[i].orderDetail.length; kk++) {
// String indexWithVariant = '$i|$kk';
// indexAdaVariant.add(indexWithVariant);
// totalHargaOrderDetail +=
// listOrders[i].orderDetail[kk].totalHarga;
// }
fixTotalHarga = totalHargaOrderDetail;
}
}
totalHarga = fixTotalHarga + totalHargaBukanOrderDetail;
}
return Container(
width: widthScreen,
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const CustomAppBarConfirm(),
Expanded(
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: [
const SizedBox(
height: 24,
),
ListView.builder(
physics:
const NeverScrollableScrollPhysics(), // to disable scrolling
shrinkWrap: true,
itemCount: listOrders.length,
itemBuilder: (context, i) {
return Column(
children: [
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
horizontal: paddingLeftRight,
vertical: 16,
),
color: backgroundWhite,
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.start,
children: [
(listOrders[i].imageUrl != '')
? Image(
width: 80,
height: 80,
fit: BoxFit.fill,
image: NetworkImage(
listOrders[i].imageUrl),
)
: const Image(
width: 80,
height: 80,
fit: BoxFit.fill,
image: AssetImage(
'assets/noimage.png'),
),
const SizedBox(
width: 12,
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
defaultText(
context,
listOrders[i].namaMenu,
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: menuNameListViewBill(),
),
const SizedBox(
height: 6,
),
defaultText(
context,
'${listOrders[i].totalItem} X Rp ${formatNumber().format(listOrders[i].satuanHarga)}',
style: viewbillStyle(
font: 12,
fontWeight: FontWeight.w300,
),
),
const SizedBox(
height: 6,
),
(listOrders[i].note != '')
? defaultText(
context,
"Catatan: ${listOrders[i].note}",
maxLines: 2,
overFlow:
TextOverflow.ellipsis,
style: viewbillStyle(
font: 12,
fontWeight:
FontWeight.w300,
),
)
: const SizedBox(),
(listOrders[i]
.orderDetail
.isNotEmpty)
? defaultText(
context,
'Variant : ',
maxLines: 2,
overFlow:
TextOverflow.ellipsis,
style: viewbillStyle(
font: 12,
fontWeight:
FontWeight.w300,
),
)
: const SizedBox(),
if (listOrders[i]
.orderDetail
.isNotEmpty)
for (int a = 0;
a <
listOrders[i]
.orderDetail[0]
.orderVariant
.length;
a++)
defaultText(
context,
listOrders[i]
.orderDetail[0]
.orderVariant[a]
.name,
maxLines: 2,
overFlow:
TextOverflow.ellipsis,
style: viewbillStyle(
font: 12,
fontWeight: FontWeight.w300,
),
),
],
)
],
),
),
const SizedBox(
height: 24,
)
],
);
},
),
const AddMoreOrder()
],
),
),
)
],
),
Positioned(
bottom: 0,
child: Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
color: backgroundWhite,
boxShadow: [
BoxShadow(
color: Colors.grey,
blurRadius: 10.0,
)
],
),
padding: const EdgeInsets.all(paddingLeftRight),
width: widthScreen,
child: GestureDetector(
onTap: () {
String username = getCustomerName();
if (username != '') {
checkOut(context, listOrders, username);
} else {
modalInputName(context, nameController, listOrders);
}
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton:
'Pesan - Rp ${formatNumber().format(totalHarga)}'),
),
),
)
],
),
);
},
);
}
}
Future<dynamic> modalInputName(BuildContext context,
TextEditingController nameController, List<Orders> listOrders) {
return showDialog(
context: context,
builder: (BuildContext context) {
return CoreModalInputName(context, nameController, listOrders);
},
);
}
class AddMoreOrder extends StatelessWidget {
const AddMoreOrder({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
height: 80,
width: double.infinity,
color: backgroundWhite,
padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
// color: Colors.red,
child: Row(
children: [
Expanded(
child: Container(
child: defaultText(
context,
'Tambahkan menu lainnya?',
maxLines: 2,
overFlow: TextOverflow.ellipsis,
style: viewbillStyle(
font: 16,
fontWeight: FontWeight.w400,
),
),
),
),
const SizedBox(
width: 19,
),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: 98,
height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(21),
color: buttonColor,
),
child: Center(
child: defaultText(
context,
'Tambah',
style: addButton(
font: 8,
),
),
),
),
)
],
),
);
}
}
...@@ -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,21 +80,64 @@ class CoreBranch extends StatelessWidget { ...@@ -69,21 +80,64 @@ class CoreBranch extends StatelessWidget {
itemBuilder: (context, i) { itemBuilder: (context, i) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
context.read<FilterMenuBloc>().catAndMenu( if (listBranch[i].isDelivery == false &&
listBranch[i].branchCode, listBranch[i].isPickup == false) {
getBrand(), EasyLoading.showToast(
getRole(), 'Outlet tidak menerima delivery dan pickup');
getCashierName(), } else {
getOrderId(), if (isFormBill) {
changeBranch(listBranch[i].branchCode)
.then((value) {
if (value) {
context.read<FilterMenuBloc>().catAndMenu(
listBranch[i].branchCode,
getBrand(),
getRole(),
getCashierName(),
getOrderId(),
);
setIsDelivery(listBranch[i].isDelivery);
setIsPickup(listBranch[i].isPickup);
setBranch(listBranch[i].branchCode);
if (listBranch[i].isDelivery) {
setIsCustomerDelivery(true);
} else {
setIsCustomerDelivery(false);
}
Navigator.pushReplacement(
context,
MaterialPageRoute(
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()),
); );
setIsDelivery(listBranch[i].isDelivery); }
setIsPickup(listBranch[i].isPickup); }
setBranch(listBranch[i].branchCode);
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 {
Navigator.pushReplacement( if (getStatusOrderCreated()) {
widget.context, context.read<FilterMenuBloc>().catAndMenu(
MaterialPageRoute( getBranchPref(),
builder: (_) => const SelectBranch(), getBrand(),
), getRole(),
); getCashierName(),
getOrderId(),
);
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
builder: (_) => const NewHome2(),
),
);
} else {
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
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 OrderViewBillNew( return ListView.builder(
billDetail: billDetail[i], physics:
lastItem: (i + 1 == itemCounts) ? true : false, const NeverScrollableScrollPhysics(), // to disable scrolling
isHistory: isHistory, shrinkWrap: true,
tableStatus: tableStatus, itemCount: bill[i].billDetail.length,
); itemBuilder: (ctx, d) {
}, return OrderViewBillNew(
); billDetail: bill[i].billDetail[d],
lastItem: (i + 1 == bill[i].billDetail.length) ? true : false,
isHistory: isHistory,
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,
), ),
......
...@@ -9,6 +9,7 @@ import 'package:byod/helper/widget/style.dart'; ...@@ -9,6 +9,7 @@ import 'package:byod/helper/widget/style.dart';
import 'package:byod/ui/history_order/history_new.dart'; import 'package:byod/ui/history_order/history_new.dart';
import 'package:byod/ui/payment/payment_balance.dart'; import 'package:byod/ui/payment/payment_balance.dart';
import 'package:byod/ui/screen_responsive.dart'; import 'package:byod/ui/screen_responsive.dart';
import 'package:byod/ui/select_branch.dart';
import 'package:dotted_line/dotted_line.dart'; import 'package:dotted_line/dotted_line.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';
...@@ -411,7 +412,9 @@ class CoreBill extends StatelessWidget { ...@@ -411,7 +412,9 @@ class CoreBill extends StatelessWidget {
child: defaultText( child: defaultText(
context, context,
(isDeliveryPickuup) (isDeliveryPickuup)
? 'Delivery' ? (getIsCustomerDelivery())
? 'Delivery'
: 'Pickup'
: 'Meja ${dataBill[0].tableName}', : 'Meja ${dataBill[0].tableName}',
style: viewbillStyle()), style: viewbillStyle()),
), ),
...@@ -430,112 +433,7 @@ class CoreBill extends StatelessWidget { ...@@ -430,112 +433,7 @@ class CoreBill extends StatelessWidget {
(isDeliveryPickuup) (isDeliveryPickuup)
? GestureDetector( ? GestureDetector(
onTap: () { onTap: () {
showModalBottomSheet( modalBottomSelectOption(context);
backgroundColor: backgroundWhite,
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(19),
topRight: Radius.circular(19),
),
),
barrierColor:
Colors.grey.withOpacity(0.9),
builder: (contextModal) {
return Container(
padding:
const EdgeInsets.symmetric(
horizontal: paddingLeftRight,
),
child: Column(
mainAxisSize:
MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Center(
child: Container(
margin: const EdgeInsets
.only(
top: 8,
bottom: 28,
),
width: 50,
height: 3,
color: disabledColor,
),
),
defaultText(
context,
'Pilih Tipe Order',
style:
pickUpdeliveryStyleFont(),
),
Container(
padding:
const EdgeInsets.only(
top: 19,
bottom: 25,
left: 10),
child: Row(
children: [
const Image(
image: AssetImage(
'assets/icons/pickup-icon.png'),
),
const SizedBox(
width: 12,
),
defaultText(
context,
'Pick Up',
style:
pickUpdeliveryStyleFont(),
)
],
),
),
Container(
padding:
const EdgeInsets.only(
left: 10,
bottom: 24),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Row(
children: [
const Image(
image: AssetImage(
'assets/icons/delivery-icon.png'),
),
const SizedBox(
width: 12,
),
defaultText(
context,
'Delivery',
style:
pickUpdeliveryStyleFont(),
)
],
),
defaultText(
context,
'23 Menit',
style:
pickUpdeliveryStyleFont(),
)
],
),
)
],
),
);
},
);
}, },
child: Container( child: Container(
height: 30, height: 30,
...@@ -573,7 +471,7 @@ class CoreBill extends StatelessWidget { ...@@ -573,7 +471,7 @@ class CoreBill extends StatelessWidget {
) )
: const SizedBox(), : const SizedBox(),
(isDeliveryPickuup) (isDeliveryPickuup)
? const DeliveryPickupDetail() ? DeliveryPickupDetail()
: const SizedBox(), : const SizedBox(),
const SizedBox( const SizedBox(
height: 24, height: 24,
...@@ -671,7 +569,7 @@ class CoreBill extends StatelessWidget { ...@@ -671,7 +569,7 @@ class CoreBill extends StatelessWidget {
), ),
), ),
ListOrder( ListOrder(
billDetail: dataBill[0].billDetail, bill: dataBill,
isHistory: isHistory, isHistory: isHistory,
tableStatus: dataBill[0].tableStatus, tableStatus: dataBill[0].tableStatus,
), ),
...@@ -1350,124 +1248,100 @@ class CoreBill extends StatelessWidget { ...@@ -1350,124 +1248,100 @@ class CoreBill extends StatelessWidget {
}, },
); );
} }
}
class DeliveryPickupDetail extends StatelessWidget { Future<dynamic> modalBottomSelectOption(BuildContext context) {
const DeliveryPickupDetail({ return showModalBottomSheet(
Key? key, backgroundColor: backgroundWhite,
}) : super(key: key); context: context,
shape: const RoundedRectangleBorder(
@override borderRadius: BorderRadius.only(
Widget build(BuildContext context) { topLeft: Radius.circular(19),
return Container( topRight: Radius.circular(19),
padding: const EdgeInsets.symmetric( ),
horizontal: paddingLeftRight,
vertical: 12,
), ),
color: backgroundWhite.withOpacity(0.9), barrierColor: Colors.grey.withOpacity(0.9),
child: Column( builder: (contextModal) {
crossAxisAlignment: CrossAxisAlignment.start, return Container(
children: [ padding: const EdgeInsets.symmetric(
Row( horizontal: paddingLeftRight,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded( Center(
child: Column( child: Container(
crossAxisAlignment: CrossAxisAlignment.start, margin: const EdgeInsets.only(
children: [ top: 8,
defaultText(context, 'Alamat Pengantaran'), bottom: 28,
const SizedBox( ),
height: 6, width: 50,
), height: 3,
defaultText(context, 'Blok M Barat'), color: disabledColor,
],
), ),
), ),
const SizedBox( defaultText(
width: 5, context,
'Pilih Tipe Order',
style: pickUpdeliveryStyleFont(),
), ),
Container( GestureDetector(
width: 98, onTap: () {
height: 30, setIsCustomerDelivery(false);
decoration: BoxDecoration( getBillFunc(context);
borderRadius: BorderRadius.circular(40), Navigator.pop(context);
},
child: Container(
padding: const EdgeInsets.only(top: 19, bottom: 25, left: 10),
color: backgroundWhite, color: backgroundWhite,
border: Border.all(
color: buttonColor,
),
),
child: Center(
child: defaultText(
context,
'Ganti Alamat',
style: addButton(
font: 8,
color: buttonColor,
),
),
),
)
],
),
const SizedBox(
height: 21,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
width: 100,
height: 23,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: buttonColor,
),
child: Center(
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const Image( const Image(
image: AssetImage('assets/icons/pin-address.png'), image: AssetImage('assets/icons/pickup-icon.png'),
), ),
const SizedBox( const SizedBox(
width: 12.6, width: 12,
), ),
defaultText( defaultText(
context, context,
'Detail Alamat', 'Pick Up',
style: addButton( style: pickUpdeliveryStyleFont(),
font: 8,
),
) )
], ],
), ),
), ),
), ),
const SizedBox( GestureDetector(
width: 16, onTap: () {
), setIsCustomerDelivery(true);
Container( getBillFunc(context);
width: 84, Navigator.pop(context);
height: 23, },
decoration: BoxDecoration( child: Container(
borderRadius: BorderRadius.circular(40), padding: const EdgeInsets.only(left: 10, bottom: 24),
color: buttonColor, color: backgroundWhite,
),
child: Center(
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const Image( Row(
image: AssetImage('assets/icons/note.png'), children: [
), const Image(
const SizedBox( image: AssetImage('assets/icons/delivery-icon.png'),
width: 10, ),
const SizedBox(
width: 12,
),
defaultText(
context,
'Delivery',
style: pickUpdeliveryStyleFont(),
)
],
), ),
defaultText( defaultText(
context, context,
'Catatan', '23 Menit',
style: addButton(font: 8), style: pickUpdeliveryStyleFont(),
) )
], ],
), ),
...@@ -1475,8 +1349,228 @@ class DeliveryPickupDetail extends StatelessWidget { ...@@ -1475,8 +1349,228 @@ class DeliveryPickupDetail extends StatelessWidget {
) )
], ],
), ),
], );
},
);
}
}
class DeliveryPickupDetail extends StatelessWidget {
DeliveryPickupDetail({
Key? key,
}) : super(key: key);
final bool isDelivery = getIsCustomerDelivery();
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(
horizontal: paddingLeftRight,
vertical: 12,
), ),
color: backgroundWhite.withOpacity(0.9),
child: (isDelivery) ? deliveryOption(context) : pickupOption(context),
);
}
Row pickupOption(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Image(
fit: BoxFit.fill,
width: 40,
height: 40,
image: AssetImage('assets/icons/outlet.png'),
),
const SizedBox(
width: 12,
),
defaultText(
context,
getBranchName(),
maxLines: 2,
overFlow: TextOverflow.ellipsis,
),
const SizedBox(
width: 12,
),
const Spacer(),
GestureDetector(
onTap: () {
void ontapOkeChange() {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const SelectBranch(
isFormBill: true,
),
),
);
}
void onTapCancelChange() {
Navigator.pop(context);
}
String textOnOk = 'OK';
String textOnCancel = 'Batal';
String title = 'Ganti Outlet';
String description = '''
Ganti outlet akan menyebabkan orderan anda saat ini hilang.
Apakah ingin melanjutkan ?''';
buttonDialogGlobal(
context,
title,
description,
textOnOk,
textOnCancel,
ontapOkeChange,
onTapCancelChange,
okButtonColor: buttonColor,
);
},
child: Container(
width: 98,
height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: backgroundWhite,
border: Border.all(
color: buttonColor,
),
),
child: Center(
child: defaultText(
context,
'Ganti Outlet',
style: addButton(
font: 8,
color: buttonColor,
),
),
),
),
)
],
);
}
Column deliveryOption(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
defaultText(context, 'Alamat Pengantaran'),
const SizedBox(
height: 6,
),
defaultText(context, 'Blok M Barat'),
],
),
),
const SizedBox(
width: 5,
),
Container(
width: 98,
height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: backgroundWhite,
border: Border.all(
color: buttonColor,
),
),
child: Center(
child: defaultText(
context,
'Ganti Alamat',
style: addButton(
font: 8,
color: buttonColor,
),
),
),
)
],
),
const SizedBox(
height: 21,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
width: 100,
height: 23,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: buttonColor,
),
child: Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Image(
image: AssetImage('assets/icons/pin-address.png'),
),
const SizedBox(
width: 12.6,
),
defaultText(
context,
'Detail Alamat',
style: addButton(
font: 8,
),
)
],
),
),
),
const SizedBox(
width: 16,
),
Container(
width: 84,
height: 23,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(40),
color: buttonColor,
),
child: Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Image(
image: AssetImage('assets/icons/note.png'),
),
const SizedBox(
width: 10,
),
defaultText(
context,
'Catatan',
style: addButton(font: 8),
)
],
),
),
)
],
),
],
); );
} }
} }
......
...@@ -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