Commit f80b3813 authored by Dio Maulana's avatar Dio Maulana

edit api v2 dan prefs global

parent 1d42dd8f
This diff is collapsed.
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../api/api.dart';
import '../helper/helper.dart';
import 'filter_menu.dart';
class BranchExist extends Cubit<String> {
BranchExist() : super(responseApiWaiting);
Future<String> getBranch(String branchCode, String brandCode, String role,
String cashierName, String sessionId) async {
var apiGetBranch = await Api.getBranch(
branchCode, brandCode, role, cashierName, sessionId);
String cashierName, String orderId) async {
var apiGetBranch =
await Api.getBranch(branchCode, brandCode, role, cashierName, orderId);
return apiGetBranch;
}
void branchExist(String branchCode, String brandCode, String role,
String cashierName, String sessionId) {
getBranch(branchCode, brandCode, role, cashierName, sessionId)
.then((value) {
String cashierName, String orderId, BuildContext context,
{bool getMenu = false}) {
getBranch(branchCode, brandCode, role, cashierName, orderId).then((value) {
if (getMenu) {
context
.read<FilterMenuBloc>()
.catAndMenu(branchCode, brandCode, role, cashierName, orderId);
}
emit(value);
});
}
......
import 'package:byod/helper/prefs.dart';
import 'package:byod/models/bill.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../api/api.dart';
import '../helper/helper.dart';
import '../main.dart';
class ViewBillBloc extends Cubit<List<Bill>> {
ViewBillBloc()
......@@ -29,7 +29,7 @@ class ViewBillBloc extends Cubit<List<Bill>> {
)
]);
void getBill({
String sessionIdH = '',
String orderIdH = '',
String branchCodeH = '',
String brandCodeH = '',
String tableNumberH = '',
......@@ -40,20 +40,20 @@ class ViewBillBloc extends Cubit<List<Bill>> {
String brandCode;
String tableNumber;
String token;
if (sessionIdH != '') {
if (orderIdH != '') {
// for history view
branchCode = branchCodeH;
brandCode = brandCodeH;
tableNumber = tableNumberH;
token = tokenH;
} else {
branchCode = prefs.getString("outlet") ?? '';
brandCode = prefs.getString("brand") ?? '';
tableNumber = prefs.getString("table_number") ?? '';
token = prefs.getString("token") ?? '';
branchCode = getBranchPref();
brandCode = getBrand();
tableNumber = getTabelNumber();
token = getToken();
}
List<Bill> bill;
if (sessionIdH == '') {
if (orderIdH == '') {
bill = await Api.getBill(
branchCode,
brandCode,
......@@ -66,7 +66,7 @@ class ViewBillBloc extends Cubit<List<Bill>> {
brandCode,
tableNumber,
token,
sessionIdH: sessionIdH,
orderIdH: orderIdH,
userNameH: userNameH,
);
}
......
......@@ -2,6 +2,8 @@
import 'dart:convert';
import 'package:byod/helper/prefs.dart';
import 'package:crypto/crypto.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:http/http.dart' as http;
......@@ -244,6 +246,21 @@ String localDate(String date, {isHistory = false}) {
//** convert UTC to local */
//** Generate SIGN */
String signApi() {
String secretKey = getSecretKey();
int sessionCounter = getSessionCounter();
int sessionC = sessionCounter + 1;
List<int> bytes = utf8.encode("$secretKey$sessionC");
Digest digest = sha256.convert(bytes);
String signString = digest.toString();
setSessionCounterPlus(sessionCounter);
return signString;
}
//** Generate SIGN */
//** END FUNCTION */
//** START CONSTANT */
......
import 'package:byod/helper/helper.dart';
import '../main.dart';
const String _orderId = 'order_id';
const String _secretKey = 'secret_key';
const String _sessionCounter = 'session_counter';
const String _sessionId = 'session_id';
const String _baseUrl = 'baseUrl';
const String _tableNumber = 'table_number';
const String _tableMode = 'table_mode';
const String _customerName = 'userName';
const String _totalOrder = 'total_order';
const String _dateOrder = 'date_order';
const String _branch = 'outlet';
const String _brand = 'brand';
const String _token = 'token';
const String _listHistory = 'list_history';
const String _logo = 'logo';
const String _role = 'role';
const String _cashierName = 'cashier_name';
String getBaseUrl() {
return prefs.getString(_baseUrl) ?? '';
}
Future<void> setBaseUrl(String value) async {
prefs.setString(_baseUrl, value);
}
String getOrderId() {
return prefs.getString(_orderId) ?? '';
}
Future<void> setOrderId(String value) async {
prefs.setString(_orderId, value);
}
String getSecretKey() {
return prefs.getString(_secretKey) ?? '';
}
Future<void> setSecretKey(String value) async {
prefs.setString(_secretKey, value);
}
int getSessionCounter() {
return prefs.getInt(_sessionCounter) ?? 0;
}
Future<void> setSessionCounter(int value) async {
prefs.setInt(_sessionCounter, value);
}
Future<void> setSessionCounterPlus(int value) async {
prefs.setInt(_sessionCounter, value + 1);
}
String getSessionId() {
return prefs.getString(_sessionId) ?? '';
}
Future<void> setSesssionId(String value) async {
prefs.setString(_sessionId, value);
}
String getTabelNumber() {
return prefs.getString(_tableNumber) ?? '';
}
Future<void> setTableNumber(String value) async {
prefs.setString(_tableNumber, value);
}
String getCustomerName() {
return prefs.getString(_customerName) ?? '';
}
Future<void> setCustomerName(String value) async {
prefs.setString(_customerName, value);
}
String getTotalOrder() {
return prefs.getString(_totalOrder) ?? '';
}
Future<void> setTotalOrder(String value) async {
prefs.setString(_totalOrder, value);
}
String getOrderDate() {
return prefs.getString(_dateOrder) ?? '';
}
Future<void> setOrderDate(String value) async {
prefs.setString(_dateOrder, value);
}
String getBranchPref() {
return prefs.getString(_branch) ?? '';
}
Future<void> setBranch(String value) async {
prefs.setString(_branch, value);
}
String getBrand() {
return prefs.getString(_brand) ?? '';
}
Future<void> setBrand(String value) async {
prefs.setString(_brand, value);
}
String getToken() {
return prefs.getString(_token) ?? '';
}
Future<void> setToken(String value) async {
prefs.setString(_token, value);
}
List<String> getListHistory() {
return prefs.getStringList(_listHistory) ?? [];
}
Future<void> setListHistory(List<String> value) async {
prefs.setStringList(_listHistory, value);
}
int getTableMode() {
return prefs.getInt(_tableMode) ?? defaultTable;
}
Future<void> setTableMode(int value) async {
prefs.setInt(_tableMode, value);
}
String getLogoUrl() {
return prefs.getString(_logo) ?? '';
}
Future<void> setLogoUrl(String value) async {
prefs.setString(_logo, value);
}
String getRole() {
return prefs.getString(_role) ?? 'customer';
}
Future<void> setRole(String value) async {
prefs.setString(_role, value);
}
String getCashierName() {
return prefs.getString(_cashierName) ?? '';
}
Future<void> setCashierName(String value) async {
prefs.setString(_cashierName, value);
}
......@@ -3,6 +3,7 @@
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';
......@@ -298,19 +299,18 @@ class _EmoticonRateState extends State<EmoticonRate> {
if (!widget.isHistory) {
context.read<ViewBillBloc>().getBill();
} else {
List<String> listHistory =
prefs.getStringList('list_history') ?? [];
List<String> listHistory = getListHistory();
if (listHistory.isNotEmpty) {
int indexHistory = listHistory.indexWhere(
(listHistory) =>
jsonDecode(listHistory)['session'] ==
jsonDecode(listHistory)['order_id'] ==
widget.sessionId,
);
if (indexHistory != -1) {
dynamic jsonDecodeHistory =
jsonDecode(listHistory[indexHistory]);
context.read<ViewBillBloc>().getBill(
sessionIdH: jsonDecodeHistory['session'],
orderIdH: jsonDecodeHistory['order_id'],
branchCodeH:
jsonDecodeHistory['branch_code'],
brandCodeH: jsonDecodeHistory['brand'],
......
import 'dart:convert';
import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
......@@ -22,14 +23,14 @@ class EmoticonRateNew extends StatelessWidget {
required this.rateNote,
required this.isHistory,
required this.dataBill,
this.sessionID = '',
this.orderId = '',
}) : super(key: key);
final double sizeImage;
final TextEditingController rateNote;
final bool isHistory;
final List<Bill> dataBill;
final String sessionID;
final String orderId;
@override
Widget build(BuildContext context) {
......@@ -242,19 +243,18 @@ class EmoticonRateNew extends StatelessWidget {
if (!isHistory) {
context.read<ViewBillBloc>().getBill();
} else {
List<String> listHistory =
prefs.getStringList('list_history') ?? [];
List<String> listHistory = getListHistory();
if (listHistory.isNotEmpty) {
int indexHistory = listHistory.indexWhere(
(listHistory) =>
jsonDecode(listHistory)['session'] ==
sessionID,
jsonDecode(listHistory)['order_id'] ==
orderId,
);
if (indexHistory != -1) {
dynamic jsonDecodeHistory =
jsonDecode(listHistory[indexHistory]);
context.read<ViewBillBloc>().getBill(
sessionIdH: jsonDecodeHistory['session'],
orderIdH: jsonDecodeHistory['order_id'],
branchCodeH:
jsonDecodeHistory['branch_code'],
brandCodeH: jsonDecodeHistory['brand'],
......
......@@ -7,6 +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/prefs.dart';
import 'package:byod/ui/no_route.dart';
import 'package:byod/ui/splash.dart';
import 'package:flutter/material.dart';
......@@ -123,12 +124,12 @@ class MyApp extends StatelessWidget {
//** UUID */
//** Check Session ID */
String currentSessionId = prefs.getString('sessionId') ?? '';
String sessionId;
if (currentSessionId != '') {
sessionId = currentSessionId;
String currentOrderId = getOrderId();
String orderId;
if (currentOrderId != '') {
orderId = currentOrderId;
} else {
sessionId = uuid;
orderId = uuid;
}
//** Check Session ID */
......@@ -186,7 +187,7 @@ class MyApp extends StatelessWidget {
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
sessionId: sessionId,
orderId: orderId,
token: tokenUser));
} else if (uri.pathSegments.length == 4) {
brandStrg = uri.pathSegments.first;
......@@ -208,7 +209,7 @@ class MyApp extends StatelessWidget {
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
sessionId: sessionId,
orderId: orderId,
token: tokenUser));
} else if (uri.pathSegments.length == 5) {
brandStrg = uri.pathSegments.first;
......@@ -232,7 +233,7 @@ class MyApp extends StatelessWidget {
role: roleStrg,
cashierName: cashierNameStrg,
toBill: toBill,
sessionId: sessionId,
orderId: orderId,
token: tokenUser));
}
return null;
......
// ignore_for_file: unnecessary_brace_in_string_interps, sized_box_for_whitespace
import 'package:byod/bloc/order_bloc.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/ui/screen_responsive.dart';
import 'package:flutter/material.dart';
......@@ -80,7 +81,7 @@ class _CheckOutState extends State<CheckOut> {
double widthScreen = responsiveWidthScreen(context);
double currentScreen = MediaQuery.of(context).size.width;
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
int tableMode = prefs.getInt('table_mode') ?? defaultTable;
int tableMode = getTableMode();
return SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
......@@ -338,12 +339,12 @@ class _CheckOutState extends State<CheckOut> {
bottom: MediaQuery.of(context).size.height * positionedBottom,
child: GestureDetector(
onTap: () {
String namaPelanggan = prefs.getString("userName") ?? '';
String namaPelanggan = getCustomerName();
if (tableMode == singleTable && namaPelanggan != '') {
checkOut(context, listOrders, namaPelanggan);
} else {
String namaPelanggan = prefs.getString("userName") ?? '';
String namaPelanggan = getCustomerName();
buttonDialog(context, namaPelanggan, listOrders,
tableMode, widthScreen);
}
......
import 'package:byod/helper/prefs.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../../api/api.dart';
import '../../main.dart';
import '../../models/orders.dart';
checkOut(BuildContext context, List<Orders> listOrders, String name) async {
String namaPelanggan = prefs.getString("userName") ?? '';
String namaPelanggan = getCustomerName();
String namaPelangganFix = '';
if (namaPelanggan == '') {
await prefs.setString("userName", name);
setCustomerName(name);
namaPelangganFix = name;
} else {
namaPelangganFix = namaPelanggan;
......@@ -18,10 +18,10 @@ checkOut(BuildContext context, List<Orders> listOrders, String name) async {
status: 'Memproses pesanan...',
maskType: EasyLoadingMaskType.none,
);
String branchCode = prefs.getString('outlet') ?? '';
String brand = prefs.getString('brand') ?? '';
String branchCode = getBranchPref();
String brand = getBrand();
String tableNumber = prefs.getString('table_number') ?? '';
String tableNumber = getTabelNumber();
// String baseUrl = prefs.getString('baseUrl') ?? '';
// String urlCheckout = "${baseUrl}checkout";
......
......@@ -108,7 +108,7 @@ class HistoryOrder extends StatelessWidget {
MaterialPageRoute(
builder: (_) => ViewBillNew(
isHistory: true,
sessionId: jsonDecodeHistory['session'],
orderId: jsonDecodeHistory['order_id'],
branchCodeH: jsonDecodeHistory['branch_code'],
brandCodeH: jsonDecodeHistory['brand'],
token: jsonDecodeHistory['token'],
......
......@@ -62,7 +62,7 @@ class HistoryOrderNew extends StatelessWidget {
MaterialPageRoute(
builder: (_) => ViewBillNew(
isHistory: true,
sessionId: jsonDecodeHistory['session'],
orderId: jsonDecodeHistory['order_id'],
branchCodeH: jsonDecodeHistory['branch_code'],
brandCodeH: jsonDecodeHistory['brand'],
token: jsonDecodeHistory['token'],
......
......@@ -62,12 +62,20 @@ class ShowMenuBottomSheet extends StatelessWidget {
),
ClipRRect(
borderRadius: BorderRadius.circular(21),
child: Image(
child: (menuDetail[i].imageUrlMedium != '')
? Image(
width: widthImage,
height: widthImage,
image: NetworkImage(
menuDetail[i].imageUrlMedium,
),
)
: Image(
width: widthImage,
height: widthImage,
image: const AssetImage(
'assets/noimage.png',
),
),
),
const SizedBox(
......
......@@ -6,6 +6,7 @@ import 'package:byod/bloc/filter_menu.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/prefs.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/models/category_list.dart';
import 'package:byod/models/filter_menu.dart';
......@@ -32,8 +33,8 @@ class Home extends StatefulWidget {
}
class _HomeState extends State<Home> {
String tableNumber = prefs.getString("table_number") ?? "";
String userName = prefs.getString("userName") ?? "";
String tableNumber = getTabelNumber();
String userName = getCustomerName();
final searchController = TextEditingController();
final _scrollController = ScrollController();
bool isSearch = true;
......@@ -75,7 +76,7 @@ class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
int tableMode = prefs.getInt('table_mode') ?? defaultTable;
int tableMode = getTableMode();
// context.read<FeedBackOptionBloc>().getOptionFeedback();
double widthScreen = responsiveWidthScreen(context);
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
......@@ -485,12 +486,12 @@ class _HomeState extends State<Home> {
}
return GestureDetector(
onTap: () {
String namaPelanggan = prefs.getString("userName") ?? '';
String namaPelanggan = getCustomerName();
if (tableMode == singleTable) {
if (tableMode == singleTable && namaPelanggan != '') {
checkOut(context, listOrders, namaPelanggan);
} else {
String namaPelanggan = prefs.getString("userName") ?? '';
String namaPelanggan = getCustomerName();
buttonDialog(
context, namaPelanggan, listOrders, tableMode, widthScreen);
}
......
......@@ -7,6 +7,7 @@ import 'package:byod/bloc/order_bloc.dart';
import 'package:byod/bloc/search_active.dart';
import 'package:byod/bloc/search_menu.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/models/filter_menu.dart';
import 'package:byod/models/orders.dart';
......@@ -201,9 +202,9 @@ class _NewHome2State extends State<NewHome2> {
// categoryFont -
// spacerAboveCatList;
int tableMode = prefs.getInt('table_mode') ?? defaultTable;
String tableNumber = prefs.getString("table_number") ?? "";
String userName = prefs.getString("userName") ?? "";
int tableMode = getTableMode();
String tableNumber = getTabelNumber();
String userName = getCustomerName();
double widthScreen = responsiveWidthScreen(context);
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
return BlocBuilder<BranchExist, String>(
......@@ -582,7 +583,7 @@ class _NewHome2State extends State<NewHome2> {
int tableMode,
bool isSearchActive,
) {
String logoUrl = prefs.getString("logoUrl") ?? "";
String logoUrl = getLogoUrl();
return Stack(
children: [
Container(
......
......@@ -2,6 +2,7 @@
import 'package:byod/bloc/check_voucher.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/ui/screen_responsive.dart';
import 'package:byod/ui/viewbill/view_bill.dart';
......@@ -56,9 +57,9 @@ class _PaymentState extends State<Payment> {
double currentScreen = MediaQuery.of(context).size.width;
double maxWidthScreen = getMaxWidthScreen(context, useResponsive);
double paddingLeftRight = widthScreen * 0.05;
String branchCode = prefs.getString("outlet") ?? '';
String brandCode = prefs.getString("brand") ?? '';
String customerName = prefs.getString("userName") ?? '';
String branchCode = getBranchPref();
String brandCode = getBrand();
String customerName = getCustomerName();
context
.read<VoucherCheck>()
.changeVoucher(); // user dipaksa input ulang voucher
......
......@@ -2,13 +2,13 @@
import 'dart:math';
import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/button_modal.dart';
import 'package:byod/ui/payment/function.dart';
import 'package:flutter/material.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../main.dart';
import '../screen_responsive.dart';
import '../viewbill/view_bill_new.dart';
......@@ -58,9 +58,9 @@ class CorePaymentBalance extends StatelessWidget {
Widget build(BuildContext context) {
int outStandingTopayMember = min(outStanding, balanceMember);
double widthScreen = responsiveWidthScreen(context);
String branchCode = prefs.getString("outlet") ?? '';
String brandCode = prefs.getString("brand") ?? '';
String customerName = prefs.getString("userName") ?? '';
String branchCode = getBranchPref();
String brandCode = getBrand();
String customerName = getCustomerName();
return Container(
width: widthScreen,
child: Stack(
......
......@@ -3,6 +3,7 @@
import 'package:byod/bloc/check_voucher.dart';
import 'package:byod/bloc/voucher_list.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/button_modal.dart';
import 'package:byod/main.dart';
import 'package:byod/ui/screen_responsive.dart';
......@@ -51,13 +52,13 @@ class CorePaymentVoucher extends StatelessWidget {
final int outstandingAll;
final List<Bill> dataBill;
final String branchCode = prefs.getString("outlet") ?? '';
final String brandCode = prefs.getString("brand") ?? '';
final String customerName = prefs.getString("userName") ?? '';
final String branchCode = getBranchPref();
final String brandCode = getBrand();
final String customerName = getCustomerName();
@override
Widget build(BuildContext context) {
double widthScreen = responsiveWidthScreen(context);
String logoUrl = prefs.getString('logoUrl') ?? '';
String logoUrl = getLogoUrl();
return Container(
width: widthScreen,
child: BlocBuilder<VoucherCheck, List<dynamic>>(
......
......@@ -2,9 +2,9 @@
import 'dart:convert';
import 'package:byod/bloc/filter_menu.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/viewbill/view_bill_new.dart';
import 'package:flutter/material.dart';
......@@ -18,7 +18,7 @@ import 'home/shimmer_menu.dart';
import 'screen_responsive.dart';
class Splash extends StatefulWidget {
final String param, brand, tn, role, cashierName, toBill, sessionId, token;
final String param, brand, tn, role, cashierName, toBill, orderId, token;
const Splash(
{Key? key,
required this.param,
......@@ -27,7 +27,7 @@ class Splash extends StatefulWidget {
required this.role,
required this.cashierName,
required this.toBill,
required this.sessionId,
required this.orderId,
required this.token})
: super(key: key);
......@@ -54,30 +54,32 @@ class _SplashState extends State<Splash> {
@override
void initState() {
loadBaseUrl().then((baseUrl) {
prefs.setString('baseUrl', baseUrl);
setBaseUrl(baseUrl);
context.read<BranchExist>().branchExist(
widget.param,
widget.brand,
widget.role,
widget.cashierName,
widget.sessionId,
widget.orderId,
context,
getMenu: true,
);
// context.read<CategoryMenu>().catAndMenu(widget.param, widget.brand,
// widget.role, widget.cashierName, widget.token);
context.read<FilterMenuBloc>().catAndMenu(widget.param, widget.brand,
widget.role, widget.cashierName, widget.token);
// context.read<FilterMenuBloc>().catAndMenu(widget.param, widget.brand,
// widget.role, widget.cashierName, widget.token);
if (widget.token != '') {
context.read<MemberInfoBloc>().getMemberInfo(widget.token);
}
Future.delayed(const Duration(milliseconds: 1000), () async {
await prefs.setString('token', widget.token);
await prefs.setString('outlet', widget.param);
await prefs.setString('brand', widget.brand);
await prefs.setString('table_number', widget.tn);
await prefs.setString('role', widget.role);
await prefs.setString('cashier_name', widget.cashierName);
setToken(widget.token);
setBranch(widget.param);
setBrand(widget.brand);
setTableNumber(widget.tn);
setRole(widget.role);
setCashierName(widget.cashierName);
// ignore: use_build_context_synchronously
if (widget.toBill == 'go') {
......
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/helper/prefs.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/branch_exist.dart';
import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../main.dart';
import '../home/new_home2.dart';
class CustomAppBar extends StatelessWidget {
......@@ -19,11 +19,11 @@ class CustomAppBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
String branchCode = prefs.getString('outlet') ?? '';
String brandCode = prefs.getString('brand') ?? '';
String role = prefs.getString('role') ?? '';
String cashierName = prefs.getString('cashier_name') ?? '';
String sessionId = prefs.getString('sessionId') ?? '';
String branchCode = getBranchPref();
String brandCode = getBrand();
String role = getRole();
String cashierName = getCashierName();
String sessionId = getOrderId();
return Container(
padding: const EdgeInsets.only(
top: 15,
......@@ -42,7 +42,13 @@ class CustomAppBar extends StatelessWidget {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (_) => const NewHome2()));
context.read<BranchExist>().branchExist(
branchCode, brandCode, role, cashierName, sessionId);
branchCode,
brandCode,
role,
cashierName,
sessionId,
context,
);
} else {
Navigator.pop(context);
}
......
......@@ -149,13 +149,22 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
children: [
ClipRRect(
borderRadius: BorderRadius.circular(5),
child: Image(
child: (widget.billDetail.imageUrl != '')
? Image(
width: 80,
height: 80,
fit: BoxFit.fill,
image: NetworkImage(
widget.billDetail.imageUrl,
),
)
: const Image(
width: 80,
height: 80,
fit: BoxFit.fill,
image: AssetImage(
'assets/noimage.png',
),
),
),
const SizedBox(
......
......@@ -37,7 +37,7 @@ import 'order_view_bill.dart';
class ViewBill extends StatefulWidget {
// ini berlaku ketika lihat history
bool isHistory;
String sessionId;
String orderId;
String branchCode;
String brandCode;
String tableNumber;
......@@ -46,7 +46,7 @@ class ViewBill extends StatefulWidget {
ViewBill({
Key? key,
this.isHistory = false,
this.sessionId = '',
this.orderId = '',
this.branchCode = '',
this.brandCode = '',
this.tableNumber = '',
......@@ -81,7 +81,7 @@ class _ViewBillState extends State<ViewBill> {
context.read<ViewBillBloc>().getBill();
} else {
context.read<ViewBillBloc>().getBill(
sessionIdH: widget.sessionId,
orderIdH: widget.orderId,
branchCodeH: widget.branchCode,
brandCodeH: widget.brandCode,
tableNumberH: widget.tableNumber,
......@@ -227,7 +227,7 @@ class _ViewBillState extends State<ViewBill> {
context,
dataBill,
widget.isHistory,
sessionID: widget.sessionId,
sessionID: widget.orderId,
);
}
});
......@@ -415,6 +415,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
role,
cashierName,
sessionID,
context,
);
Navigator.push(
context,
......@@ -648,7 +649,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
context,
dataBill,
widget.isHistory,
sessionID: widget.sessionId,
sessionID: widget.orderId,
);
},
child: Container(
......@@ -750,6 +751,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
role,
cashierName,
sessionID,
context,
);
Navigator.push(
context,
......@@ -1250,7 +1252,13 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (_) => const NewHome2()));
context.read<BranchExist>().branchExist(
branchCode, brandCode, role, cashierName, sessionId);
branchCode,
brandCode,
role,
cashierName,
sessionId,
context,
);
} else {
Navigator.pop(context);
}
......
......@@ -3,6 +3,7 @@
import 'dart:math';
import 'package:byod/bloc/member_info.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/prefs.dart';
import 'package:byod/helper/widget/button_modal.dart';
import 'package:byod/helper/widget/style.dart';
import 'package:byod/ui/history_order/history_new.dart';
......@@ -22,7 +23,6 @@ import '../../helper/widget/button_dialog.dart';
import '../../helper/widget/emoticon_rate_new.dart';
import '../../helper/widget/open_url.dart';
import '../../helper/widget/thousand_formatter.dart';
import '../../main.dart';
import '../../models/bill.dart';
import '../../models/member_info.dart';
import '../build_version.dart';
......@@ -39,7 +39,7 @@ class ViewBillNew extends StatelessWidget {
// const ViewBillNew({Key? key}) : super(key: key);
final bool isHistory;
final String sessionId;
final String orderId;
final String branchCodeH;
final String brandCodeH;
final String tableNumberH;
......@@ -48,7 +48,7 @@ class ViewBillNew extends StatelessWidget {
const ViewBillNew({
Key? key,
this.isHistory = false,
this.sessionId = '',
this.orderId = '',
this.branchCodeH = '',
this.brandCodeH = '',
this.tableNumberH = '',
......@@ -60,8 +60,8 @@ class ViewBillNew extends StatelessWidget {
// RefreshController(initialRefresh: false);
void saveBillDetail(List<Bill> dataBill) async {
await prefs.setString('total_order', dataBill[0].totalSeluruhOrderan);
await prefs.setString('date_order', dataBill[0].dateOrder);
setTotalOrder(dataBill[0].totalSeluruhOrderan);
setOrderDate(dataBill[0].dateOrder);
}
void getBillFunc(BuildContext context) {
......@@ -69,7 +69,7 @@ class ViewBillNew extends StatelessWidget {
context.read<ViewBillBloc>().getBill();
} else {
context.read<ViewBillBloc>().getBill(
sessionIdH: sessionId,
orderIdH: orderId,
branchCodeH: branchCodeH,
brandCodeH: brandCodeH,
tableNumberH: tableNumberH,
......@@ -92,16 +92,16 @@ class ViewBillNew extends StatelessWidget {
const uuidInit = Uuid();
var uuid = uuidInit.v4();
//** UUID */
String branchCode = prefs.getString("outlet") ?? '';
String brandCode = prefs.getString("brand") ?? '';
String tableNumber = prefs.getString("table_number") ?? '';
String role = prefs.getString("role") ?? '';
String customerName = prefs.getString("userName") ?? '';
String cashierName = prefs.getString("cashier_name") ?? '';
String branchCode = getBranchPref();
String brandCode = getBrand();
String tableNumber = getTabelNumber();
String role = getRole();
String customerName = getCustomerName();
String cashierName = getCashierName();
// String token = prefs.getString("token") ?? '';
String sessionID = prefs.getString("sessionId") ?? uuid;
int tableMode = prefs.getInt('table_mode') ?? defaultTable;
List<String> historyOrder = prefs.getStringList('list_history') ?? [];
String orderId = getOrderId();
int tableMode = getTableMode();
List<String> historyOrder = getListHistory();
return SafeArea(
child: Scaffold(
......@@ -222,7 +222,7 @@ class ViewBillNew extends StatelessWidget {
context,
dataBill,
isHistory,
sessionID: sessionId,
orderId: orderId,
);
}
});
......@@ -281,7 +281,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
onTapCashier: onTapCashier,
branchCode: branchCode,
brandCode: brandCode,
sessionId: sessionId,
orderId: orderId,
),
widthScreen: MediaQuery.of(context).size.width,
isCoreLayout: true,
......@@ -295,7 +295,6 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
brandCode: brandCode,
customerName: customerName,
isHistory: isHistory,
sessionId: sessionID,
historyOrder: historyOrder,
),
widthScreen: currentScreen,
......@@ -344,7 +343,7 @@ class CoreBill extends StatelessWidget {
required this.onTapCashier,
required this.branchCode,
required this.brandCode,
required this.sessionId,
required this.orderId,
}) : super(key: key);
final double widthScreen;
......@@ -358,7 +357,7 @@ class CoreBill extends StatelessWidget {
final void Function() onTapCashier;
final String branchCode;
final String brandCode;
final String sessionId;
final String orderId;
@override
Widget build(BuildContext context) {
......@@ -879,8 +878,7 @@ class CoreBill extends StatelessWidget {
onTap: () {
String titlePayment;
String customerName =
prefs.getString('userName') ??
'';
getCustomerName();
bool isIndividu;
if (tableMode == multiTable) {
isIndividu = true;
......@@ -1117,7 +1115,7 @@ class CoreBill extends StatelessWidget {
context,
dataBill,
isHistory,
sessionID: sessionId,
orderId: orderId,
);
}
}
......@@ -1175,7 +1173,6 @@ class EmptyBill extends StatelessWidget {
required this.customerName,
required this.branchCode,
required this.brandCode,
required this.sessionId,
required this.historyOrder,
}) : super(key: key);
......@@ -1184,13 +1181,12 @@ class EmptyBill extends StatelessWidget {
final String customerName;
final String branchCode;
final String brandCode;
final String sessionId;
final String tableNumber = prefs.getString("table_number") ?? '';
final String tableNumber = getTabelNumber();
final List<String> historyOrder;
final String role = prefs.getString('role') ?? '';
final String cashierName = prefs.getString('cashier_name') ?? '';
final String sessionID = prefs.getString('sessionId') ?? '';
final String role = getRole();
final String cashierName = getCashierName();
final String orderId = getOrderId();
@override
Widget build(BuildContext context) {
return BlocBuilder<MemberInfoBloc, MemberInfo>(
......@@ -1308,7 +1304,8 @@ class EmptyBill extends StatelessWidget {
brandCode,
role,
cashierName,
sessionID,
orderId,
context,
);
Navigator.push(
context,
......@@ -1357,7 +1354,7 @@ class EmptyBill extends StatelessWidget {
Future<dynamic> ratingModal(
BuildContext context, List<Bill> dataBill, bool isHistory,
{String sessionID = ''}) {
{String orderId = ''}) {
double sizeImage = 76;
final rateNote = TextEditingController();
return showDialog(
......@@ -1368,7 +1365,7 @@ Future<dynamic> ratingModal(
rateNote: rateNote,
isHistory: isHistory,
dataBill: dataBill,
sessionID: sessionID,
orderId: orderId,
),
),
);
......@@ -1550,7 +1547,7 @@ Future<dynamic> buttonDialogAllPayment(
GestureDetector(
onTap: () {
String titlePayment;
String customerName = prefs.getString('userName') ?? '';
String customerName = getCustomerName();
bool isIndividu;
if (tableMode == multiTable) {
isIndividu = true;
......
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