Commit 3e82ff72 authored by Dio Maulana's avatar Dio Maulana

04/10/22

parent 1296ca98
......@@ -21,6 +21,7 @@ import 'package:uuid/uuid.dart';
import '../bloc/order_bloc.dart';
import '../helper/widget/open_url.dart';
import '../main.dart';
import '../models/branchs.dart';
import '../models/variant_categories.dart';
import '../models/variants.dart';
// ignore: avoid_web_libraries_in_flutter
......@@ -50,6 +51,8 @@ class Api {
String latitude = getLatitude();
String longitude = getLongitude();
String currentSessionId = getSessionId();
int urlType = getUrlType();
String currentOrderId;
const uuidInit = Uuid();
var uuid = uuidInit.v4();
String sessionId;
......@@ -58,18 +61,38 @@ class Api {
} else {
sessionId = uuid;
}
List<String> listTypeUrl = getListTypeUrl();
int indexTypeUrl = listTypeUrl.indexWhere(
(element) => jsonDecode(element)['url_type'] == urlType,
);
if (indexTypeUrl != -1) {
currentOrderId = jsonDecode(listTypeUrl[indexTypeUrl])['order_id'];
} else {
currentOrderId = getOrderId();
}
var uuidOrderId = uuidInit.v4();
String orderID;
if (currentOrderId != '') {
orderID = currentOrderId;
} else {
orderID = uuidOrderId;
}
try {
Map data = {
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"order_id": orderId,
"order_id": orderID,
"session_id": sessionId,
"from": fromByod,
"url_lookup": 'https://dimas.com',
"url_lookup": (urlType == typeUrlTiga) ? 'https://dimas.com' : '',
"customer_lat": latitude,
"customer_long": longitude,
"type_url": urlType,
};
var bodies = json.encode(data);
// var apiResult = await http.post(Uri.parse(apiUrl), body: bodies);
......@@ -87,7 +110,7 @@ class Api {
String branchCode = getBranchPref();
String brandCode = getBrand();
String token = getToken();
if (orderId != jsonObject['data']['order_id']) {
if (orderID != jsonObject['data']['order_id']) {
Map historyOrder = {
"order_id": orderId,
"table": tableNumber,
......@@ -105,7 +128,22 @@ class Api {
listHistory.add(historySave);
setListHistory(listHistory);
}
if (indexTypeUrl != -1) {
listTypeUrl.removeWhere(
(element) => jsonDecode(element)['url_type'] == urlType);
}
Map saveTypeUrlAndOrderId = {
"url_type": urlType,
"order_id": jsonObject['data']['order_id'],
};
listTypeUrl.add(
jsonEncode(saveTypeUrlAndOrderId),
);
setListTypeUrl(listTypeUrl);
setOrderId(jsonObject['data']['order_id']);
setTypeOrder(jsonObject['data']['type_order']);
setLogoUrl(jsonObject['data']['logo']);
setSesssionId(jsonObject['data']['session_id']);
setSecretKey(jsonObject['data']['secret_key']);
......@@ -1247,6 +1285,7 @@ class Api {
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
int typeOrder = getTypeOrder();
try {
Map data = {
......@@ -1262,7 +1301,8 @@ class Api {
"order_id": orderId,
"menu": variantData,
'secure_token': secureToken,
"from": fromByod
"from": fromByod,
"type_order": typeOrder
};
var bodies = jsonEncode(data);
// var apiResult = await http.post(Uri.parse(urlCheckout), body: bodies);
......@@ -1809,4 +1849,110 @@ class Api {
return feedBack;
}
}
static Future<bool> setToPendingOrder() async {
String baseUrl = getBaseUrl();
String apiUrl = "$baseUrl${endPoint}order";
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
String branchCode = getBranchPref();
String brandCode = getBrand();
String role = getRole();
String cashierName = getCashierName();
String userName = getCustomerName();
String orderID = getOrderId();
try {
Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"customer_name": userName,
"from": fromByod,
"order_id": orderID
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'setToPendingOrder');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
EasyLoading.showToast(
'Orderan telah dikrim, menunggu untuk di setujui');
return true;
}
EasyLoading.showToast(jsonObject['msg']);
return false;
} else {
EasyLoading.showToast('Something went wrong with our server');
return false;
}
} catch (e) {
if (debug) {
logd('API CLASS ON API.DART, FUNGSI: setToPendingOrder, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
EasyLoading.showToast('Something went wrong with our server');
return false;
}
}
static Future<List<Branch>> getBranchList() async {
String baseUrl = getBaseUrl();
String apiUrl = "$baseUrl${endPoint}get_branch_list";
String sessionId = getSessionId();
String signString = signApi();
int sessionC = getSessionCounter();
String brandCode = getBrand();
String role = getRole();
String cashierName = getCashierName();
String userName = getCustomerName();
List<Branch> branchList = [];
try {
Map data = {
"session_id": sessionId,
"count": sessionC,
"sign": signString,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"customer_name": userName,
"from": fromByod,
"is_pickup": false,
"is_delivery": false,
"customer_lat": getLatitude(),
"customer_long": getLongitude(),
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'getBranchList');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
List<dynamic> data = (jsonObject as Map<dynamic, dynamic>)['data'];
for (int d = 0; d < data.length; d++) {
branchList.add(
Branch.json(data[d]),
);
}
return branchList;
}
return branchList;
} else {
return branchList;
}
} catch (e) {
if (debug) {
logd('API CLASS ON API.DART, FUNGSI: getBranchList, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
return branchList;
}
}
}
import 'package:byod/bloc/branch_list.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
......@@ -15,15 +16,25 @@ class BranchExist extends Cubit<String> {
return apiGetBranch;
}
void branchExist(String branchCode, String brandCode, String role,
String cashierName, String orderId, BuildContext context,
{bool getMenu = false}) {
void branchExist(
String branchCode,
String brandCode,
String role,
String cashierName,
String orderId,
BuildContext context, {
bool getMenu = false,
bool getBrancList = false,
}) {
getBranch(branchCode, brandCode, role, cashierName, orderId).then((value) {
if (getMenu) {
context
.read<FilterMenuBloc>()
.catAndMenu(branchCode, brandCode, role, cashierName, orderId);
}
if (getBrancList) {
context.read<BranchList>().getBranchList();
}
emit(value);
});
......
import 'package:byod/models/branchs.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../api/api.dart';
class BranchList extends Cubit<List<Branch>> {
BranchList() : super([]);
void getBranchList() async {
List<Branch> result = await Api.getBranchList();
emit(result);
}
}
import 'package:byod/models/branchs.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class SearchBranch extends Cubit<List<Branch>> {
SearchBranch()
: super([
Branch(
id: '0',
branchCode: '',
name: '',
image: '',
logo: '',
isDineIn: false,
isDelivery: false,
isPickup: false,
distance: 0,
)
]);
void search(String keyword, List<Branch> allBranch) {
List<Branch> result = [];
if (keyword.isNotEmpty) {
for (var x in allBranch) {
if (x.name.toLowerCase().contains(keyword.toLowerCase())) {
result.add(x);
}
}
emit(result);
} else {
emit(allBranch);
}
}
}
......@@ -273,6 +273,99 @@ String signApi() {
//** Generate SIGN */
//** untuk mengembalikan warna pada tombol tambah di checkout */
Color getAddMoreColorButton(int orderState) {
if (orderState == orderStateCreated || orderState == orderStateApproved) {
return buttonColor;
} else {
return disabledColor;
}
}
//** untuk mengembalikan warna pada tombol tambah di checkout */
bool isCanTapAddMoreButton(int orderState) {
int paymentMethod = getPaymentMode();
if (paymentMethod == closebill) {
if (orderState == orderStatePending) {
return false;
}
}
return true;
}
bool isVisibleAddMoreButton(int tableStatus, int orderState) {
int paymentMethod = getPaymentMode();
if (tableStatus == tableStatusOpen) {
if (paymentMethod == closebill) {
if (orderState == orderStatePending ||
orderState == orderStateCreated ||
orderState == orderStateApproved) {
return true;
}
} else {
if (orderState == orderStatePending ||
orderState == orderStateCreated ||
orderState == orderStateReady) {
return true;
}
}
}
return false;
}
bool isVisibleAddRemoveQuantityButtonCheckout(bool isHistory, int orderStatus) {
int paymentMethod = getPaymentMode();
if (!isHistory && paymentMethod == closebill && orderStatus == pendingOrder) {
return true;
}
return false;
}
String textButtonCheckout(int orderState) {
int paymentMethod = getPaymentMode();
if (paymentMethod == closebill && orderState == orderStateCreated) {
return 'Pesan';
} else if (paymentMethod == closebill &&
(orderState == orderStatePending ||
orderState == orderStateApproved) ||
paymentMethod == openBill &&
(orderState == orderStateCreated ||
orderState == orderStatePending)) {
return 'Bayar';
} else if (paymentMethod == closebill &&
(orderState == orderStatePaid ||
orderState == orderStateInproses ||
orderState == orderStateReady)) {
return 'Pesanan Diproses';
} else if (orderState == orderStateDone) {
return 'Buat Pesanan Baru';
} else if (orderState == orderStateCanceled) {
return 'Transaksi Dibatalkan';
} else {
return '';
}
}
bool isCanButtonCheckoutToTap(int orderState) {
int paymentMethod = getPaymentMode();
if (paymentMethod == closebill) {
if (orderState == orderStateCreated ||
orderState == orderStateApproved ||
orderState == orderStateDone) {
return true;
} else {
return false;
}
} else {
if (orderState == orderStateCanceled) {
return false;
} else {
return true;
}
}
}
//** END FUNCTION */
//** START CONSTANT */
......@@ -382,6 +475,8 @@ const int orderStateCreated = 0;
const int orderStatePending = 1;
const int orderStateApproved = 2;
const int orderStatePaid = 3;
const int orderStateInproses = 4;
const int orderStateReady = 5;
const int orderStateDone = 99;
//** constanta order status bill */
......@@ -589,4 +684,17 @@ String locationPermissinDenied = 'locationdisabled';
String configError = 'configError';
String titleError = 'titleError';
//** No Route Identification */
//** Type Url */
const int typeUrlSatu = 1;
const int typeUrlDua = 2;
const int typeUrlTiga = 3;
//** Type Url */
//** Type ORder */
const int typeOrderDelivery = 0;
const int typeOrderDineIn = 1;
const int typeOrderPickup = 1;
//** Type ORder */
//** END CONSTANT */
......@@ -24,6 +24,11 @@ const String _latitude = 'lat';
const String _longitude = 'long';
const String _titleWeb = 'title';
const String _isDeliveryPickup = 'is_delivery_pickup';
const String _typeUrl = 'urlType';
const String _listTypeUrl = 'urlTypeList';
const String _orderType = 'orderType';
const String _isDelivery = 'isDelivery';
const String _isPickup = 'isPickup';
String getBaseUrl() {
return prefs.getString(_baseUrl) ?? '';
......@@ -133,11 +138,11 @@ Future<void> setListHistory(List<String> value) async {
prefs.setStringList(_listHistory, value);
}
int getTableMode() {
int getPaymentMode() {
return prefs.getInt(_tableMode) ?? defaultBillTable;
}
Future<void> setTableMode(int value) async {
Future<void> setPaymentMode(int value) async {
prefs.setInt(_tableMode, value);
}
......@@ -204,3 +209,43 @@ bool getIsDeliveryPickup() {
Future<void> setIsDeliveryPickup(bool value) async {
prefs.setBool(_isDeliveryPickup, value);
}
int getUrlType() {
return prefs.getInt(_typeUrl) ?? 0; // 0 biar error kalau belum di set
}
Future<void> setUrlType(int value) async {
prefs.setInt(_typeUrl, value);
}
List<String> getListTypeUrl() {
return prefs.getStringList(_listTypeUrl) ?? [];
}
Future<void> setListTypeUrl(List<String> value) async {
prefs.setStringList(_listTypeUrl, value);
}
int getTypeOrder() {
return prefs.getInt(_orderType) ?? -1; // -1 biar ketahuan kalau ada error
}
Future<void> setTypeOrder(int value) async {
prefs.setInt(_orderType, value);
}
bool getIsPickup() {
return prefs.getBool(_isPickup) ?? false;
}
Future<void> setIsPickup(bool value) async {
prefs.setBool(_isPickup, value);
}
bool getIsDelivery() {
return prefs.getBool(_isDelivery) ?? false;
}
Future<void> setIsDelivery(bool value) async {
prefs.setBool(_isDelivery, value);
}
......@@ -4,7 +4,6 @@ import 'dart:convert';
import 'package:byod/bloc/feedback_option.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/main.dart';
import 'package:byod/models/bill.dart';
import 'package:byod/models/feedback_option.dart';
import 'package:byod/models/rate_value_selected.dart';
......
......@@ -10,7 +10,6 @@ import '../../api/api.dart';
import '../../bloc/feedback_option.dart';
import '../../bloc/feedback_select.dart';
import '../../bloc/view_bill.dart';
import '../../main.dart';
import '../../models/bill.dart';
import '../../models/feedback_option.dart';
import '../../models/rate_value_selected.dart';
......
......@@ -7,11 +7,7 @@ import 'package:byod/bloc/check_voucher.dart';
import 'package:byod/bloc/member_info.dart';
import 'package:byod/bloc/order_bloc.dart';
import 'package:byod/bloc/search_menu.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/logger.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/ui/home/shimmer_menu_new.dart';
import 'package:byod/ui/no_route.dart';
import 'package:byod/ui/splash.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
......@@ -19,10 +15,10 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_strategy/url_strategy.dart';
import 'package:uuid/uuid.dart';
import 'package:web_browser_detect/web_browser_detect.dart';
import 'bloc/branch_exist.dart';
import 'bloc/branch_list.dart';
import 'bloc/fav_selected_bar.dart';
import 'bloc/feedback_option.dart';
import 'bloc/feedback_select.dart';
......@@ -32,12 +28,13 @@ import 'bloc/order_detail_variant.dart';
import 'bloc/order_variant_temporary.dart';
import 'bloc/order_variant_value.dart';
import 'bloc/search_active.dart';
import 'bloc/search_branch.dart';
import 'bloc/search_history.dart';
import 'bloc/view_bill.dart';
import 'package:flutter/services.dart' as bundle_root;
import 'package:geolocator/geolocator.dart';
import 'bloc/voucher_list.dart';
import 'ui/select_branch.dart';
late SharedPreferences prefs;
bool isExcelso = false;
......@@ -51,6 +48,8 @@ String browserVersion = '';
//** Version Build Number */
const int majorVersion = 1;
const int minorVersion = 2;
List<String> stringPath = [];
String routesToAccess = '/';
//** Version Build Number */
void main() async {
......@@ -64,7 +63,14 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
prefs = await SharedPreferences.getInstance();
configLoading();
for (int d = 0; d < Uri.base.pathSegments.length; d++) {
stringPath.add(Uri.base.pathSegments[d]);
if (d == Uri.base.pathSegments.length - 1) {
routesToAccess += Uri.base.pathSegments[d];
} else {
routesToAccess += '${Uri.base.pathSegments[d]}/';
}
}
loadAssetConfig().then((title) {
setTitleWeb(title);
runApp(
......@@ -125,58 +131,31 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State<MyApp> {
Position? _currentPosition;
bool? permissionLocation;
_getCurrentLocation() {
Geolocator.checkPermission().then((value) {
if (value != LocationPermission.denied) {
permissionLocation = true;
Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.best,
forceAndroidLocationManager: true)
.then((Position position) {
setLatitude(position.latitude.toString());
setLongitude(position.longitude.toString());
setState(() {
_currentPosition = position;
});
}).catchError((e) {
if (debug) {
logd('GET CURRENTLOCATION, MAIN.DART', 'ERROR: $e');
}
});
} else {
permissionLocation = false;
}
});
}
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
//** UUID */
const uuidInit = Uuid();
var uuid = uuidInit.v4();
// const uuidInit = Uuid();
// var uuid = uuidInit.v4();
//** UUID */
//** Check Session ID */
String currentOrderId = getOrderId();
String orderId;
if (currentOrderId != '') {
orderId = currentOrderId;
} else {
orderId = uuid;
}
// String currentOrderId = getOrderId();
// String orderId;
// if (currentOrderId != '') {
// orderId = currentOrderId;
// } else {
// orderId = uuid;
// }
//** Check Session ID */
String branchStrg = '';
String brandStrg = '';
String tnStrg = '';
String roleStrg = 'customer';
String toBill = '';
String cashierNameStrg = '';
String tokenUser = '';
// String branchStrg = '';
// String brandStrg = '';
// String tnStrg = '';
// String roleStrg = 'customer';
// String toBill = '';
// String cashierNameStrg = '';
// String tokenUser = '';
// Future<bool> getLocationStatus() async {
// LocationPermission? permission;
......@@ -209,123 +188,149 @@ class _MyAppState extends State<MyApp> {
BlocProvider(create: (_) => MenuSelectedBar()),
BlocProvider(create: (_) => SearchActive()),
BlocProvider(create: (_) => SearchHistory()),
BlocProvider(create: (_) => BranchList()),
BlocProvider(create: (_) => SearchBranch()),
],
child: MaterialApp(
title: (widget.title == null) ? defaultTitle : widget.title,
builder: EasyLoading.init(),
debugShowCheckedModeBanner: false,
onGenerateRoute: (routes) {
var uri = Uri.parse(routes.name!);
if (uri.pathSegments.isEmpty) {
setTableMode(closebill);
setUrlLookUp(Uri.base.toString());
setIsDeliveryPickup(true);
return MaterialPageRoute(
builder: (_) => Splash(
branch: branchStrg,
brand: brandStrg,
tn: tnStrg,
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
orderId: orderId,
token: tokenUser,
),
);
} else if (uri.pathSegments.length == 2) {
setIsDeliveryPickup(false);
String firstPath = uri.pathSegments.first;
if (firstPath == 'o') {
setTableMode(openBill);
// String orderId = uri.pathSegments[1];
// do some api request for orderId
}
title: (widget.title == null) ? defaultTitle : widget.title,
builder: EasyLoading.init(),
debugShowCheckedModeBanner: false,
return MaterialPageRoute(
builder: (_) => Splash(
branch: branchStrg,
brand: brandStrg,
tn: tnStrg,
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
orderId: orderId,
token: tokenUser,
),
);
} else if (uri.pathSegments.length == 3) {
setIsDeliveryPickup(false);
brandStrg = uri.pathSegments.first;
branchStrg = uri.pathSegments[1];
tnStrg = uri.pathSegments[2];
initialRoute: routesToAccess,
routes: {
routesToAccess: (context) => Splash(
pathSegmentString: stringPath,
context: context,
),
},
return MaterialPageRoute(
builder: (_) => Splash(
branch: branchStrg,
brand: brandStrg,
tn: tnStrg,
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
orderId: orderId,
token: tokenUser,
),
);
} else if (uri.pathSegments.length == 4) {
setIsDeliveryPickup(false);
brandStrg = uri.pathSegments.first;
branchStrg = uri.pathSegments[1];
tnStrg = uri.pathSegments[2];
if (uri.pathSegments[3] == goBill) {
toBill = goBill;
} else if (uri.pathSegments[3].length == 32) {
// its uuid or not
// initialRoute: '/',
// routes: {
// '/': (context) => const SelectBranch(),
// },
// onGenerateRoute: (routes) {
// return MaterialPageRoute(
// builder: (context) => Splash(
// pathSegmentString: stringPath,
// context: context,
// ),
// );
// },
// onGenerateRoute: (routes) {
// var uri = Uri.parse(routes.name!);
// if (uri.pathSegments.isEmpty) {
// return MaterialPageRoute(
// builder: (context) => NoRoute(
// identification: 'emptyUri',
// ),
// );
// } else if (uri.pathSegments.length == 2) {
// setIsDeliveryPickup(false);
// String firstPath = uri.pathSegments.first;
// if (firstPath == 'o') {
// setTableMode(openBill);
// String orderIdPath = uri.pathSegments[1];
// return MaterialPageRoute(
// builder: (_) => Splash(
// branch: branchStrg,
// brand: brandStrg,
// tn: tnStrg,
// role: roleStrg,
// cashierName: cashierNameStrg,
// toBill: toBill,
// orderId: orderIdPath,
// token: tokenUser,
// ),
// );
// // do some api request for orderId
// }
tokenUser = uri.pathSegments[3];
isExcelso = true;
}
return MaterialPageRoute(
builder: (_) => Splash(
branch: branchStrg,
brand: brandStrg,
tn: tnStrg,
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
orderId: orderId,
token: tokenUser,
),
);
} else if (uri.pathSegments.length == 5) {
setIsDeliveryPickup(false);
brandStrg = uri.pathSegments.first;
branchStrg = uri.pathSegments[1];
tnStrg = uri.pathSegments[2];
if (uri.pathSegments[3] == 'cashier') {
// roleStrg = 'cashier';
roleStrg = 'customer';
cashierNameStrg = uri.pathSegments[4];
} else if (uri.pathSegments[3].length == 32 &&
uri.pathSegments[4] == goBill) {
tokenUser = uri.pathSegments[3];
isExcelso = true;
toBill = goBill;
}
return MaterialPageRoute(
builder: (_) => Splash(
branch: branchStrg,
brand: brandStrg,
tn: tnStrg,
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
orderId: orderId,
token: tokenUser,
),
);
}
return null;
}),
// return MaterialPageRoute(
// builder: (_) => Splash(
// branch: branchStrg,
// brand: brandStrg,
// tn: tnStrg,
// role: roleStrg,
// cashierName: cashierNameStrg,
// toBill: toBill,
// orderId: orderId,
// token: tokenUser,
// ),
// );
// } else if (uri.pathSegments.length == 3) {
// setIsDeliveryPickup(false);
// brandStrg = uri.pathSegments.first;
// branchStrg = uri.pathSegments[1];
// tnStrg = uri.pathSegments[2];
// return MaterialPageRoute(
// builder: (_) => Splash(
// branch: branchStrg,
// brand: brandStrg,
// tn: tnStrg,
// role: roleStrg,
// cashierName: cashierNameStrg,
// toBill: toBill,
// orderId: orderId,
// token: tokenUser,
// ),
// );
// } else if (uri.pathSegments.length == 4) {
// setIsDeliveryPickup(false);
// brandStrg = uri.pathSegments.first;
// branchStrg = uri.pathSegments[1];
// tnStrg = uri.pathSegments[2];
// if (uri.pathSegments[3] == goBill) {
// toBill = goBill;
// } else if (uri.pathSegments[3].length == 32) {
// // its uuid or not
// tokenUser = uri.pathSegments[3];
// isExcelso = true;
// }
// return MaterialPageRoute(
// builder: (_) => Splash(
// branch: branchStrg,
// brand: brandStrg,
// tn: tnStrg,
// role: roleStrg,
// cashierName: cashierNameStrg,
// toBill: toBill,
// orderId: orderId,
// token: tokenUser,
// ),
// );
// } else if (uri.pathSegments.length == 5) {
// setIsDeliveryPickup(false);
// brandStrg = uri.pathSegments.first;
// branchStrg = uri.pathSegments[1];
// tnStrg = uri.pathSegments[2];
// if (uri.pathSegments[3] == 'cashier') {
// // roleStrg = 'cashier';
// roleStrg = 'customer';
// cashierNameStrg = uri.pathSegments[4];
// } else if (uri.pathSegments[3].length == 32 &&
// uri.pathSegments[4] == goBill) {
// tokenUser = uri.pathSegments[3];
// isExcelso = true;
// toBill = goBill;
// }
// return MaterialPageRoute(
// builder: (_) => Splash(
// branch: branchStrg,
// brand: brandStrg,
// tn: tnStrg,
// role: roleStrg,
// cashierName: cashierNameStrg,
// toBill: toBill,
// orderId: orderId,
// token: tokenUser,
// ),
// );
// }
// return null;
// },
),
);
}
}
class Branch {
final String id;
final String branchCode;
final String name;
final String image;
final String logo;
final bool isDineIn;
final bool isDelivery;
final bool isPickup;
final double distance;
Branch({
required this.id,
required this.branchCode,
required this.name,
required this.image,
required this.logo,
required this.isDineIn,
required this.isDelivery,
required this.isPickup,
required this.distance,
});
factory Branch.json(Map<String, dynamic> json) {
return Branch(
id: json['id'],
branchCode: json['code'],
name: json['name'],
image: json['image'],
logo: json['logo'],
isDineIn: json['is_dinein'],
isDelivery: json['is_delivery'],
isPickup: json['is_pickup'],
distance: json['distance'],
);
}
}
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/bloc/search_branch.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../bloc/branch_list.dart';
import '../models/branchs.dart';
class CustomAppBar extends StatelessWidget {
CustomAppBar({
Key? key,
// required this.allBranch,
}) : super(key: key);
// final List<Branch> allBranch;
final _searchController = TextEditingController();
@override
Widget build(BuildContext context) {
return BlocBuilder<BranchList, List<Branch>>(
builder: (context, allBranch) {
return Container(
color: backgroundWhite,
padding: const EdgeInsets.symmetric(
horizontal: paddingLeftRight, vertical: 15),
child: Column(
children: [
Center(
child: defaultText(
context,
'Silahkan Pilih Outlet',
maxLines: 1,
overFlow: TextOverflow.ellipsis,
style: appBarNameViewBill(),
),
),
const SizedBox(
height: 16,
),
Container(
height: 36,
child: TextField(
controller: _searchController,
// autofocus: true,
onChanged: (sarchValue) {
context.read<SearchBranch>().search(sarchValue, allBranch);
},
key: const Key('SearchField'),
style: TextStyle(
color: Colors.black,
fontFamily: fontFamily,
fontSize: 15,
),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: Colors.grey.withOpacity(0.8),
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: buttonColor,
),
),
prefixIcon: Image(
image: const AssetImage('assets/icons/search.png'),
color: Colors.grey.withOpacity(0.8),
height: 20,
width: 20,
),
hintText: 'Excelso Puri Indah Mall',
hintStyle: TextStyle(
color: Colors.grey.withOpacity(0.8),
fontFamily: fontFamily,
fontSize: 10,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
),
),
),
),
],
),
);
},
);
}
}
......@@ -8,7 +8,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../../helper/helper.dart';
import '../../main.dart';
import '../../models/order_variants.dart';
import '../../models/orders.dart';
import 'fuction.dart';
......@@ -81,7 +80,7 @@ class _CheckOutState extends State<CheckOut> {
double widthScreen = responsiveWidthScreen(context);
double currentScreen = MediaQuery.of(context).size.width;
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
int tableMode = getTableMode();
int paymentMode = getPaymentMode();
return SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
......@@ -142,7 +141,7 @@ class _CheckOutState extends State<CheckOut> {
indexTidakAdaVariant,
listOrders,
indexAdaVariant,
tableMode,
paymentMode,
totalHarga,
widthScreen,
maxWidthScreen),
......
......@@ -20,7 +20,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../../bloc/branch_exist.dart';
import '../../helper/widget/button_dialog.dart';
import '../../main.dart';
import '../../models/fav_group.dart';
import '../checkout/fuction.dart';
import 'shimmer_menu.dart';
......@@ -76,7 +75,7 @@ class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
int tableMode = getTableMode();
int paymentMode = getPaymentMode();
// context.read<FeedBackOptionBloc>().getOptionFeedback();
double widthScreen = responsiveWidthScreen(context);
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
......@@ -169,7 +168,7 @@ class _HomeState extends State<Home> {
widthScreen,
maxWidthScreen,
context,
tableMode,
paymentMode,
favList,
),
widthScreen: MediaQuery.of(context).size.width,
......
......@@ -30,7 +30,6 @@ import 'cat_list.dart';
import 'fav_grid_menu.dart';
import 'fav_list.dart';
import 'package:byod/models/category_list.dart';
import 'shimmer_menu.dart';
import 'shimmer_menu_new.dart';
class NewHome2 extends StatefulWidget {
......@@ -203,7 +202,7 @@ class _NewHome2State extends State<NewHome2> {
// categoryFont -
// spacerAboveCatList;
int tableMode = getTableMode();
int paymentMode = getPaymentMode();
String tableNumber = getTabelNumber();
String userName = getCustomerName();
double widthScreen = responsiveWidthScreen(context);
......@@ -521,7 +520,7 @@ class _NewHome2State extends State<NewHome2> {
totalItem,
listOrders,
totalHarga,
tableMode,
paymentMode,
isSearchActive,
),
widthScreen:
......@@ -584,7 +583,7 @@ class _NewHome2State extends State<NewHome2> {
int totalItem,
List<Orders> listOrders,
int totalHarga,
int tableMode,
int paymentMode,
bool isSearchActive,
) {
String logoUrl = getLogoUrl();
......@@ -832,7 +831,7 @@ class _NewHome2State extends State<NewHome2> {
paddingLeftRight,
totalItem,
totalHarga,
tableMode,
paymentMode,
userName,
widthScreen,
)
......@@ -909,7 +908,7 @@ class _NewHome2State extends State<NewHome2> {
double paddingLeftRight,
int totalItem,
int totalHarga,
int tableMode,
int paymentMode,
String namaPelanggan,
double widthScreen) {
String itemString;
......@@ -921,7 +920,7 @@ class _NewHome2State extends State<NewHome2> {
final nameController = TextEditingController();
return GestureDetector(
onTap: () {
if (tableMode == closebill) {
if (paymentMode == closebill) {
if (namaPelanggan != '') {
checkOut(context, listOrders, namaPelanggan);
} else {
......
......@@ -5,6 +5,7 @@ import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:geolocator/geolocator.dart';
import '../helper/widget/button_modal.dart';
......@@ -75,7 +76,8 @@ class NoRoute extends StatelessWidget {
? GestureDetector(
onTap: () {
Geolocator.requestPermission().then((value) {
if (value != LocationPermission.denied) {
if (value != LocationPermission.denied &&
value != LocationPermission.deniedForever) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
......@@ -84,6 +86,9 @@ class NoRoute extends StatelessWidget {
),
),
);
} else {
EasyLoading.showToast(
'Silahkan aktifkan lokasi browser anda');
}
});
},
......
......@@ -10,7 +10,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../../api/api.dart';
import '../../main.dart';
import '../../models/bill.dart';
import 'function.dart';
import 'list_voucher.dart';
......
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/bloc/branch_list.dart';
import 'package:byod/bloc/filter_menu.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/models/branchs.dart';
import 'package:byod/ui/home/new_home2.dart';
import 'package:byod/ui/screen_responsive.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../bloc/search_branch.dart';
import '../helper/widget/style.dart';
import 'app_bar_select_branch.dart';
class SelectBranch extends StatelessWidget {
const SelectBranch({super.key});
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
body: ScreenResponsive(
widget: const CoreBranch(),
widthScreen: MediaQuery.of(context).size.width,
isCoreLayout: true,
),
),
);
}
}
class CoreBranch extends StatelessWidget {
const CoreBranch({super.key});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
child: BlocBuilder<BranchList, List<Branch>>(
builder: (context, listB) {
return BlocBuilder<SearchBranch, List<Branch>>(
builder: (contextSearch, listSearch) {
List<Branch> listBranch;
if (listSearch.isNotEmpty) {
if (listSearch[0].id == '0') {
listBranch = listB;
} else {
listBranch = listSearch;
}
} else {
listBranch = listSearch;
}
return Column(
children: [
CustomAppBar(
// allBranch: listB,
),
const SizedBox(
height: 16,
),
Expanded(
child: ListView.builder(
itemCount: listBranch.length,
itemBuilder: (context, i) {
return GestureDetector(
onTap: () {
context.read<FilterMenuBloc>().catAndMenu(
listBranch[i].branchCode,
getBrand(),
getRole(),
getCashierName(),
getOrderId(),
);
setIsDelivery(listBranch[i].isDelivery);
setIsPickup(listBranch[i].isPickup);
setBranch(listBranch[i].branchCode);
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const NewHome2()),
);
},
child: Container(
margin: const EdgeInsets.only(
bottom: 8,
left: paddingLeftRight,
right: paddingLeftRight,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: backgroundWhite,
),
height: 72,
child: Container(
padding: const EdgeInsets.only(
left: 16,
right: 12,
bottom: 16,
top: 5,
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
defaultText(
context,
listBranch[i].name,
style: historyOrderStyle(),
),
const SizedBox(
height: 4,
),
defaultText(
context,
"${listBranch[i].distance} KM",
style: historyOrderStyle(),
)
],
),
),
Container(
width: 145,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.end,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
defaultText(
context,
(listBranch[i].isDelivery)
? 'Delivery Tersedia'
: 'Delivery Tidak Tersedia',
style: historyOrderStyle(
color: textGreyDeskripsi,
),
),
const SizedBox(
height: 15,
),
defaultText(
context,
(listBranch[i].isPickup)
? 'Pickup Tersedia'
: 'Pickup Tidak Tersedia',
style: historyOrderStyle(
color: textGreyDeskripsi,
),
),
],
),
)
],
),
),
),
);
}),
),
],
);
},
);
},
),
);
}
}
......@@ -2,10 +2,12 @@
import 'dart:convert';
import 'package:byod/bloc/branch_list.dart';
import 'package:byod/bloc/member_info.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/ui/no_route.dart';
import 'package:byod/ui/select_branch.dart';
import 'package:byod/ui/viewbill/view_bill_new.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
......@@ -19,30 +21,12 @@ import 'home/shimmer_menu_new.dart';
import 'screen_responsive.dart';
class Splash extends StatefulWidget {
final String branch,
brand,
tn,
role,
cashierName,
toBill,
orderId,
token,
url,
lat,
long;
final List<String> pathSegmentString;
final BuildContext context;
const Splash({
Key? key,
required this.branch,
required this.brand,
required this.tn,
required this.role,
required this.cashierName,
required this.toBill,
required this.orderId,
required this.token,
this.url = '',
this.lat = '',
this.long = '',
required this.pathSegmentString,
required this.context,
}) : super(key: key);
@override
......@@ -68,33 +52,197 @@ class _SplashState extends State<Splash> {
@override
void initState() {
loadBaseUrl().then((baseUrl) {
Geolocator.checkPermission().then((permission) {
if (permission != LocationPermission.denied) {
Geolocator.getCurrentPosition().then((position) {
setLatitude(position.latitude.toString());
setLongitude(position.longitude.toString());
setBaseUrl(baseUrl);
context.read<BranchExist>().branchExist(
widget.branch,
widget.brand,
widget.role,
widget.cashierName,
widget.orderId,
context,
setBaseUrl(baseUrl);
if (widget.pathSegmentString.isEmpty) {
Geolocator.requestPermission().then((permission) {
if (permission != LocationPermission.denied &&
permission != LocationPermission.deniedForever) {
setPaymentMode(closebill);
setIsDeliveryPickup(true);
setUrlLookUp(Uri.base.toString());
Geolocator.getCurrentPosition().then((position) {
setLatitude(position.latitude.toString());
setLongitude(position.longitude.toString());
setUrlType(typeUrlTiga);
List<String> listTypeUrl = getListTypeUrl();
int indexTypeUrlTiga = listTypeUrl.indexWhere(
(list) => jsonDecode(list)['url_type'] == typeUrlTiga);
if (indexTypeUrlTiga == -1) {
Map saveTypeUrlAndOrderId = {
"url_type": typeUrlTiga,
"order_id": '',
};
listTypeUrl.add(
jsonEncode(saveTypeUrlAndOrderId),
);
setListTypeUrl(listTypeUrl);
}
widget.context.read<BranchExist>().branchExist(
getBranchPref(),
getBrand(),
getRole(),
getCashierName(),
'',
widget.context,
getBrancList: true,
);
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
builder: (_) => const SelectBranch(),
),
);
});
} else {
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
builder: (_) => NoRoute(
identification: locationPermissinDenied,
),
),
);
}
});
} else if (widget.pathSegmentString.length == 1) {
setPaymentMode(closebill);
setIsDeliveryPickup(false);
setUrlLookUp('');
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
builder: (_) => NoRoute(
identification: emptyUri,
),
),
);
} else if (widget.pathSegmentString.length == 2) {
setPaymentMode(openBill);
setIsDeliveryPickup(false);
setUrlLookUp('');
if (widget.pathSegmentString[0] == 'o') {
if (widget.pathSegmentString[1] != '') {
setOrderId(widget.pathSegmentString[1]);
setUrlType(typeUrlSatu);
List<String> listTypeUrl = getListTypeUrl();
int indexTypeUrlSatu = listTypeUrl.indexWhere(
(list) => jsonDecode(list)['url_type'] == typeUrlSatu);
if (indexTypeUrlSatu == 1) {
listTypeUrl.removeWhere(
(element) => jsonDecode(element)['url_type'] == typeUrlSatu);
}
Map saveTypeUrlAndOrderId = {
"url_type": typeUrlSatu,
"order_id": widget.pathSegmentString[1],
};
listTypeUrl.add(
jsonEncode(saveTypeUrlAndOrderId),
);
setListTypeUrl(listTypeUrl);
widget.context.read<BranchExist>().branchExist(
getBranchPref(),
getBrand(),
getRole(),
getCashierName(),
getOrderId(), // ini orderId dari path URL
widget.context,
getMenu: true,
);
});
goToMenu(widget.context);
} else {
Navigator.pushReplacement(
widget.context,
MaterialPageRoute(
builder: (_) => NoRoute(
identification: emptyUri,
),
),
);
}
} else {
Navigator.pushReplacement(
context,
widget.context,
MaterialPageRoute(
builder: (_) => NoRoute(
identification: locationPermissinDenied,
identification: emptyUri,
),
),
);
}
});
} else if (widget.pathSegmentString.length == 3) {
setPaymentMode(closebill);
setIsDeliveryPickup(false);
setUrlLookUp('');
setBranch(widget.pathSegmentString[1]);
setBrand(widget.pathSegmentString[0]);
setTableNumber(widget.pathSegmentString[2]);
setUrlType(typeUrlDua);
List<String> listTypeUrl = getListTypeUrl();
int indextypeUrlDua = listTypeUrl
.indexWhere((list) => jsonDecode(list)['url_type'] == typeUrlDua);
if (indextypeUrlDua == -1) {
Map saveTypeUrlAndOrderId = {
"url_type": typeUrlDua,
"order_id": '',
};
listTypeUrl.add(
jsonEncode(saveTypeUrlAndOrderId),
);
setListTypeUrl(listTypeUrl);
}
goToMenu(widget.context);
widget.context.read<BranchExist>().branchExist(
getBranchPref(),
getBrand(),
getRole(),
getCashierName(),
getOrderId(), // ini orderId dari path URL
widget.context,
getMenu: true,
);
goToMenu(widget.context);
} else if (widget.pathSegmentString.length == 4) {
setPaymentMode(closebill);
setIsDeliveryPickup(false);
setUrlLookUp('');
setBranch(widget.pathSegmentString[1]);
setBrand(widget.pathSegmentString[0]);
setTableNumber(widget.pathSegmentString[2]);
setToken(widget.pathSegmentString[3]);
context.read<MemberInfoBloc>().getMemberInfo(getToken());
setUrlType(typeUrlDua);
List<String> listTypeUrl = getListTypeUrl();
int indextypeUrlDua = listTypeUrl
.indexWhere((list) => jsonDecode(list)['url_type'] == typeUrlDua);
if (indextypeUrlDua == -1) {
Map saveTypeUrlAndOrderId = {
"url_type": typeUrlDua,
"order_id": '',
};
listTypeUrl.add(
jsonEncode(saveTypeUrlAndOrderId),
);
setListTypeUrl(listTypeUrl);
}
widget.context.read<BranchExist>().branchExist(
getBranchPref(),
getBrand(),
getRole(),
getCashierName(),
getOrderId(), // ini orderId dari path URL
widget.context,
getMenu: true,
);
goToMenu(widget.context);
}
// context.read<CategoryMenu>().catAndMenu(widget.branch, widget.brand,
// widget.role, widget.cashierName, widget.token);
......@@ -102,40 +250,53 @@ class _SplashState extends State<Splash> {
// context.read<FilterMenuBloc>().catAndMenu(widget.branch, widget.brand,
// widget.role, widget.cashierName, widget.token);
if (widget.token != '') {
context.read<MemberInfoBloc>().getMemberInfo(widget.token);
}
Future.delayed(const Duration(milliseconds: 1000), () async {
setToken(widget.token);
// setBranch(widget.branch);
// setBrand(widget.brand);
setTableNumber(widget.tn);
setRole(widget.role);
setCashierName(widget.cashierName);
// ignore: use_build_context_synchronously
// if (widget.token != '') {
// context.read<MemberInfoBloc>().getMemberInfo(widget.token);
// }
// Future.delayed(const Duration(milliseconds: 1000), () async {
// // setToken(widget.token);
// // setBranch(widget.branch);
// // setBrand(widget.brand);
// // setTableNumber(widget.tn);
// // setRole(widget.role);
// // setCashierName(widget.cashierName);
// // ignore: use_build_context_synchronously
if (widget.toBill == goBill) {
// ignore: use_build_context_synchronously
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (_) => const ViewBillNew()));
} else {
// ignore: use_build_context_synchronously
// Navigator.pushReplacement(
// context, MaterialPageRoute(builder: (_) => const Home()));
// ignore: use_build_context_synchronously
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (_) => const NewHome2()));
}
});
// // if (widget.toBill == goBill) {
// // // ignore: use_build_context_synchronously
// // Navigator.pushReplacement(
// // context, MaterialPageRoute(builder: (_) => const ViewBillNew()));
// // } else {
// // ignore: use_build_context_synchronously
// // Navigator.pushReplacement(
// // context, MaterialPageRoute(builder: (_) => const Home()));
// // ignore: use_build_context_synchronously
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (_) => const NewHome2(),
// ),
// );
// // }
// });
});
super.initState();
}
void goToMenu(contexts) {
Navigator.pushReplacement(
contexts,
MaterialPageRoute(
builder: (_) => const NewHome2(),
),
);
}
@override
Widget build(BuildContext context) {
double widthScreen = responsiveWidthScreen(context);
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
// double widthScreen = responsiveWidthScreen(context);
// double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
return SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
......
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/helper/prefs.dart';
import 'package:byod/models/filter_menu.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
......@@ -225,7 +226,8 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
],
),
),
(!widget.isHistory && widget.billDetail.orderStatus == pendingOrder)
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory,
widget.billDetail.orderStatus)
? Container(
padding: EdgeInsets.only(
left: paddingLeftRightBill,
......@@ -236,12 +238,14 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
),
)
: const SizedBox(),
(!widget.isHistory && widget.billDetail.orderStatus == pendingOrder)
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory,
widget.billDetail.orderStatus)
? const SizedBox(
height: 11,
)
: const SizedBox(),
(!widget.isHistory && widget.billDetail.orderStatus == pendingOrder)
isVisibleAddRemoveQuantityButtonCheckout(widget.isHistory,
widget.billDetail.orderStatus)
? Container(
padding: EdgeInsets.only(
left: paddingLeftRightBill,
......@@ -331,87 +335,6 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
plus: plus,
minus: minus,
),
// Stack(
// children: [
// Container(
// width: 94,
// height: 22,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(30),
// color: backgroundColor,
// ),
// child: Center(
// child: defaultText(
// context,
// widget.billDetail.quantity.toString(),
// style: amountViewBillButton(),
// ),
// ),
// ),
// Positioned(
// left: 0,
// child: GestureDetector(
// onTap: () {
// if (initialValue > 1) {
// setState(() {
// initialValue -= 1;
// amount = initialValue * amountPeritem;
// });
// changeOrderDetail(
// context,
// widget.billDetail.id,
// initialValue,
// widget.billDetail.notes);
// } else {
// deleteOrder(
// context,
// widget.billDetail.menuName,
// ontapOkDelete,
// ontapCancelDelete);
// }
// },
// child: Container(
// width: 22,
// height: 22,
// child: Image(
// color: buttonColor,
// image: const AssetImage(
// 'assets/icons/minus-blue.png'),
// ),
// ),
// ),
// ),
// Positioned(
// right: 0,
// child: GestureDetector(
// onTap: () {
// setState(() {
// initialValue += 1;
// amount = initialValue * amountPeritem;
// });
// // await Api.changeOrderDetail(
// // context,
// // widget.billDetail.id,
// // initialValue,
// // widget.billDetail.notes,
// // );
// changeOrderDetail(
// context,
// widget.billDetail.id,
// initialValue,
// widget.billDetail.notes);
// },
// child: Container(
// width: 22,
// height: 22,
// child: const Image(
// image: AssetImage('assets/icons/plus.png'),
// ),
// ),
// ),
// )
// ],
// ),
const SizedBox(
width: 12,
)
......
......@@ -100,7 +100,7 @@ class ViewBillNew extends StatelessWidget {
String cashierName = getCashierName();
// String token = prefs.getString("token") ?? '';
String orderId = getOrderId();
int tableMode = getTableMode();
int paymentMode = getPaymentMode();
List<String> historyOrder = getListHistory();
return SafeArea(
......@@ -277,7 +277,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
isHistory: isHistory,
customerName: customerName,
outStandingIndividu: outStandingIndividu,
tableMode: tableMode,
paymentMode: paymentMode,
onTapCashier: onTapCashier,
branchCode: branchCode,
brandCode: brandCode,
......@@ -339,7 +339,7 @@ class CoreBill extends StatelessWidget {
required this.isHistory,
required this.customerName,
required this.outStandingIndividu,
required this.tableMode,
required this.paymentMode,
required this.onTapCashier,
required this.branchCode,
required this.brandCode,
......@@ -353,12 +353,16 @@ class CoreBill extends StatelessWidget {
final bool isHistory;
final String customerName;
final int outStandingIndividu;
final int tableMode;
final int paymentMode;
final void Function() onTapCashier;
final String branchCode;
final String brandCode;
final String orderId;
void getBillFunc(BuildContext context) {
context.read<ViewBillBloc>().getBill();
}
@override
Widget build(BuildContext context) {
return BlocBuilder<MemberInfoBloc, MemberInfo>(
......@@ -511,13 +515,15 @@ class CoreBill extends StatelessWidget {
isHistory: isHistory,
tableStatus: dataBill[0].tableStatus,
),
(dataBill[0].tableStatus == tableStatusOpen)
isVisibleAddMoreButton(
dataBill[0].tableStatus, dataBill[0].state)
? const SizedBox(
height: 24,
)
: const SizedBox(),
(dataBill[0].tableStatus == tableStatusOpen)
? const AddMoreOrder()
isVisibleAddMoreButton(
dataBill[0].tableStatus, dataBill[0].state)
? AddMoreOrder(bill: dataBill[0])
: const SizedBox(),
const SizedBox(
height: 24,
......@@ -833,248 +839,258 @@ class CoreBill extends StatelessWidget {
GestureDetector(
onTap: () {
if (dataBill[0].tableStatus == tableStatusOpen) {
if (dataBill[0].state == orderStateCreated) {
} else {
if (tableMode == closebill &&
memberinfo.id == '') {
addPayment(
context,
dataBill[0].id,
branchCode,
brandCode,
customerName,
payCard,
fullPayment,
'',
outStandingAll,
);
} else if (tableMode == closebill &&
memberinfo.id != '') {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: defaultText(
context,
"Pilih cara pembayaran",
style: modalPaymentStyle(),
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
defaultText(
context,
'Pembayaran online menggunakan saldo eWallet atau Virtual Account',
textAlign: TextAlign.left,
style: modalPaymentStyle(
font: 12,
fontWeight: FontWeight.w400,
if (isCanButtonCheckoutToTap(dataBill[0].state)) {
if (dataBill[0].state == orderStateCreated) {
Api.setToPendingOrder();
getBillFunc(context);
} else if (dataBill[0].state ==
orderStatePending) {
EasyLoading.showToast(
'Status orderan anda menunggu untuk disetujui');
} else {
if (paymentMode == closebill &&
memberinfo.id == '') {
addPayment(
context,
dataBill[0].id,
branchCode,
brandCode,
customerName,
payCard,
fullPayment,
'',
outStandingAll,
);
} else if (paymentMode == closebill &&
memberinfo.id != '') {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: defaultText(
context,
"Pilih cara pembayaran",
style: modalPaymentStyle(),
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
defaultText(
context,
'Pembayaran online menggunakan saldo eWallet atau Virtual Account',
textAlign: TextAlign.left,
style: modalPaymentStyle(
font: 12,
fontWeight: FontWeight.w400,
),
),
),
const SizedBox(
height: 8,
),
GestureDetector(
onTap: () {
String titlePayment;
String customerName =
getCustomerName();
bool isIndividu;
if (tableMode == openBill) {
isIndividu = true;
titlePayment = 'Semua Bill';
} else {
isIndividu = false;
titlePayment = customerName;
}
if (outStandingAll > 0) {
if (tableMode == closebill) {
addPayment(
context,
dataBill[0].id,
branchCode,
brandCode,
customerName,
payCard,
fullPayment,
'',
outStandingAll,
);
const SizedBox(
height: 8,
),
GestureDetector(
onTap: () {
String titlePayment;
String customerName =
getCustomerName();
bool isIndividu;
if (paymentMode == openBill) {
isIndividu = true;
titlePayment = 'Semua Bill';
} else {
Navigator.pop(context);
buttonDialog(
isIndividu = false;
titlePayment = customerName;
}
if (outStandingAll > 0) {
if (paymentMode ==
closebill) {
addPayment(
context,
dataBill,
dataBill[0].id,
branchCode,
brandCode,
customerName,
payCard,
fullPayment,
'',
outStandingAll,
widthScreen);
);
} else {
Navigator.pop(context);
buttonDialog(
context,
dataBill,
outStandingAll,
widthScreen);
}
} else {
EasyLoading.showToast(
'Semua Tagihan Sudah Dibayar');
}
} else {
EasyLoading.showToast(
'Semua Tagihan Sudah Dibayar');
}
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton:
'Online - Rp ${formatNumber().format(outStandingAll)}'),
),
const SizedBox(
height: 16,
),
defaultText(
context,
'Pembayaran dengan saldo member excelso CRM',
textAlign: TextAlign.left,
style: modalPaymentStyle(
font: 12,
fontWeight: FontWeight.w400,
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton:
'Online - Rp ${formatNumber().format(outStandingAll)}'),
),
),
const SizedBox(
height: 8,
),
GestureDetector(
onTap: () {
if (outStandingAll > 0) {
if (outStandingTopayMember <=
0) {
EasyLoading.showToast(
'Tidak ada tagihan / Tidak ada balance');
} else {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) => Payment(
// dataBill: dataBill,
// isIndividu: true,
// outstandingIndividu:
// outStandingTopayMember, // karena hanya excelso untuk saat ini jadi overide outstandingindividu dulu
// outstandingAll:
// outStandingAll,
// title:
// 'Dengan Balance',
// isUsingBalance:
// true)));
Navigator.push(
context,
MaterialPageRoute(
builder: (_) =>
PaymentBalance(
outStanding:
outStandingAll,
balanceMember:
amountParseToIntCrm(
memberinfo
.balance),
orderId: dataBill[0].id,
const SizedBox(
height: 16,
),
defaultText(
context,
'Pembayaran dengan saldo member excelso CRM',
textAlign: TextAlign.left,
style: modalPaymentStyle(
font: 12,
fontWeight: FontWeight.w400,
),
),
const SizedBox(
height: 8,
),
GestureDetector(
onTap: () {
if (outStandingAll > 0) {
if (outStandingTopayMember <=
0) {
EasyLoading.showToast(
'Tidak ada tagihan / Tidak ada balance');
} else {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) => Payment(
// dataBill: dataBill,
// isIndividu: true,
// outstandingIndividu:
// outStandingTopayMember, // karena hanya excelso untuk saat ini jadi overide outstandingindividu dulu
// outstandingAll:
// outStandingAll,
// title:
// 'Dengan Balance',
// isUsingBalance:
// true)));
Navigator.push(
context,
MaterialPageRoute(
builder: (_) =>
PaymentBalance(
outStanding:
outStandingAll,
balanceMember:
amountParseToIntCrm(
memberinfo
.balance),
orderId:
dataBill[0].id,
),
),
),
);
);
}
} else {
EasyLoading.showToast(
'Semua Tagihan Sudah Dibayar');
}
} else {
EasyLoading.showToast(
'Semua Tagihan Sudah Dibayar');
}
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton:
'Excelso CRM Balance - Rp ${formatNumber().format(outStandingTopayMember)}'),
),
const SizedBox(
height: 16,
),
defaultText(
context,
'Pembayaran dengan e-Voucher excelso CRM',
textAlign: TextAlign.left,
style: modalPaymentStyle(
font: 12,
fontWeight: FontWeight.w400,
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton:
'Excelso CRM Balance - Rp ${formatNumber().format(outStandingTopayMember)}'),
),
),
const SizedBox(
height: 8,
),
GestureDetector(
onTap: () {
int indexVoucher = dataBill[0]
.paymentList
.indexWhere((element) =>
element.method ==
payVoucher);
if (indexVoucher != -1) {
// check apakah sudah pernah melakukan pembayran voucher
EasyLoading.showToast(
'Voucher telah digunakan pada orderan ini');
} else if (outStandingAll > 0) {
if (indexDataIndividu == -1) {
const SizedBox(
height: 16,
),
defaultText(
context,
'Pembayaran dengan e-Voucher excelso CRM',
textAlign: TextAlign.left,
style: modalPaymentStyle(
font: 12,
fontWeight: FontWeight.w400,
),
),
const SizedBox(
height: 8,
),
GestureDetector(
onTap: () {
int indexVoucher = dataBill[0]
.paymentList
.indexWhere((element) =>
element.method ==
payVoucher);
if (indexVoucher != -1) {
// check apakah sudah pernah melakukan pembayran voucher
EasyLoading.showToast(
'Kamu Belum Memiliki Orderan');
} else {
context
.read<VoucherListBloc>()
.getVoucherList();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) => Payment(
// dataBill: dataBill,
// isIndividu: false,
// indexIndividu:
// indexDataIndividu,
// isVoucher: true,
// outstandingIndividu:
// outStandingIndividu,
// outstandingAll:
// outStandingAll,
// title: 'Voucher',
// ),
// ),
// );
Navigator.push(
context,
MaterialPageRoute(
builder: (_) =>
PaymentVoucher(
outstandingAll:
outStandingAll,
dataBill: dataBill,
'Voucher telah digunakan pada orderan ini');
} else if (outStandingAll > 0) {
if (indexDataIndividu == -1) {
EasyLoading.showToast(
'Kamu Belum Memiliki Orderan');
} else {
context
.read<VoucherListBloc>()
.getVoucherList();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) => Payment(
// dataBill: dataBill,
// isIndividu: false,
// indexIndividu:
// indexDataIndividu,
// isVoucher: true,
// outstandingIndividu:
// outStandingIndividu,
// outstandingAll:
// outStandingAll,
// title: 'Voucher',
// ),
// ),
// );
Navigator.push(
context,
MaterialPageRoute(
builder: (_) =>
PaymentVoucher(
outstandingAll:
outStandingAll,
dataBill: dataBill,
),
),
),
);
);
}
} else {
EasyLoading.showToast(
'Tidak ada tagihan');
}
} else {
EasyLoading.showToast(
'Tidak ada tagihan');
}
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton:
'Excelso CRM Voucher'),
),
],
),
);
},
);
} else {
buttonDialogAllPayment(
context,
dataBill,
customerName,
outStandingIndividu,
outStandingAll,
tableMode,
onTapCashier,
widthScreen,
memberinfo,
branchCode,
brandCode,
);
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton:
'Excelso CRM Voucher'),
),
],
),
);
},
);
} else {
buttonDialogAllPayment(
context,
dataBill,
customerName,
outStandingIndividu,
outStandingAll,
paymentMode,
onTapCashier,
widthScreen,
memberinfo,
branchCode,
brandCode,
);
}
}
}
}
......@@ -1086,78 +1102,79 @@ class CoreBill extends StatelessWidget {
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(roundedButtonComponent),
color: (dataBill[0].tableStatus == tableStatusOpen)
color: (isCanButtonCheckoutToTap(dataBill[0].state))
? buttonColor
: disabledColor,
),
child: Center(
child: defaultText(
context,
(dataBill[0].tableStatus == tableStatusOpen &&
dataBill[0].state == orderStateCreated)
? 'Pesan'
: (dataBill[0].tableStatus ==
tableStatusOpen &&
dataBill[0].state ==
orderStatePending)
? 'Pembayaran Online'
: 'Transaksi Selesai',
textButtonCheckout(dataBill[0].state),
style: buttonBottomBill(),
),
),
),
),
(dataBill[0].isFeedBack == false &&
dataBill[0].tableStatus == tableStatusOpen)
? Column(
children: [
const SizedBox(
height: 12,
),
GestureDetector(
onTap: () {
if (dataBill[0].tableStatus ==
tableStatusOpen) {
onTapCashier();
} else {
if (dataBill[0].isFeedBack == false) {
ratingModal(
context,
dataBill,
isHistory,
orderId: orderId,
);
(!getIsDeliveryPickup())
? (dataBill[0].tableStatus == tableStatusOpen)
? Column(
children: [
const SizedBox(
height: 12,
),
GestureDetector(
onTap: () {
if (dataBill[0].tableStatus ==
tableStatusOpen) {
onTapCashier();
}
}
},
child: ButtonComponent(
buttonColor: successColor,
teksButton: (dataBill[0].tableStatus ==
tableStatusOpen)
? 'Tutup Pesanan & Minta Bill'
: 'Beri Penilaian',
)
// child: Container(
// margin: const EdgeInsets.only(top: 12),
// height: 43,
// width: double.infinity,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(8),
// color: successColor,
// ),
// child: Center(
// child: defaultText(
// context,
// (dataBill[0].tableStatus == tableStatusOpen)
// ? 'Tutup Pesanan & Minta Bill'
// : 'Beri Penilaian',
// style: buttonBottomBill(),
// ),
// ),
// ),
},
child: const ButtonComponent(
buttonColor: successColor,
teksButton:
'Tutup Pesanan & Minta Bill',
),
),
],
)
],
)
: (dataBill[0].tableStatus != tableStatusOpen)
? GestureDetector(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => const NewHome2()),
);
context.read<BranchExist>().branchExist(
getBranchPref(),
getBrand(),
getRole(),
getCashierName(),
getOrderId(),
context,
);
},
child: Column(
children: [
const SizedBox(
height: 12,
),
GestureDetector(
onTap: () {
// if (dataBill[0].tableStatus ==
// tableStatusOpen) {
// onTapCashier();
// }
},
child: const ButtonComponent(
buttonColor: successColor,
teksButton: 'Buat Pesanan Baru',
),
),
],
),
)
: const SizedBox()
: const SizedBox(),
const SizedBox(
height: 5,
......@@ -1838,8 +1855,11 @@ Future<dynamic> buttonDialogAllPayment(
class AddMoreOrder extends StatelessWidget {
const AddMoreOrder({
Key? key,
required this.bill,
}) : super(key: key);
final Bill bill;
@override
Widget build(BuildContext context) {
return Container(
......@@ -1870,19 +1890,21 @@ class AddMoreOrder extends StatelessWidget {
),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const NewHome2(),
),
);
if (isCanTapAddMoreButton(bill.state)) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const NewHome2(),
),
);
}
},
child: Container(
width: 98,
height: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(21),
color: buttonColor,
color: getAddMoreColorButton(bill.state),
),
child: Center(
child: defaultText(
......
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