Commit 603e48d1 authored by Dio Maulana's avatar Dio Maulana

voucher payment fixed

parent 75fd958c
...@@ -1068,8 +1068,8 @@ class Api { ...@@ -1068,8 +1068,8 @@ class Api {
EasyLoading.showToast( EasyLoading.showToast(
'Pembayaran berhasil, anda akan di alihkan ke halaman bill'); 'Pembayaran berhasil, anda akan di alihkan ke halaman bill');
Future.delayed(const Duration(milliseconds: 1000), () async { Future.delayed(const Duration(milliseconds: 1000), () async {
Navigator.push( Navigator.push(context,
context, MaterialPageRoute(builder: (_) => ViewBill())); MaterialPageRoute(builder: (_) => const ViewBillNew()));
}); });
return 'OK'; return 'OK';
} }
...@@ -1078,8 +1078,8 @@ class Api { ...@@ -1078,8 +1078,8 @@ class Api {
EasyLoading.showToast( EasyLoading.showToast(
'Pembayaran berhasil, anda akan dialihkan ke halaman bill'); 'Pembayaran berhasil, anda akan dialihkan ke halaman bill');
Future.delayed(const Duration(milliseconds: 1000), () async { Future.delayed(const Duration(milliseconds: 1000), () async {
Navigator.push( Navigator.push(context,
context, MaterialPageRoute(builder: (_) => ViewBill())); MaterialPageRoute(builder: (_) => const ViewBillNew()));
}); });
return 'OK'; return 'OK';
} else { } else {
......
...@@ -266,12 +266,14 @@ const Color backgroundColor = Color(0xffF4F4F4); ...@@ -266,12 +266,14 @@ const Color backgroundColor = Color(0xffF4F4F4);
const Color backgroundColorViewBill = Color(0xffE5E5E5); const Color backgroundColorViewBill = Color(0xffE5E5E5);
const Color backgroundWhite = Color(0xffFFFFFF); const Color backgroundWhite = Color(0xffFFFFFF);
const Color dividerGrey = Color(0xff898A8D); const Color dividerGrey = Color(0xff898A8D);
const Color dividerGrey2 = Color(0xffF2F2F2);
const Color greyColor = Color(0xffD9D9D9); const Color greyColor = Color(0xffD9D9D9);
const textColorTabel = Color(0xff333333); const textColorTabel = Color(0xff333333);
const textColorBlack = Color(0xff000000); const textColorBlack = Color(0xff000000);
const textColorRed = Color(0xffE73636); const textColorRed = Color(0xffE73636);
const textColorPlaceHolder = Color(0xffA89C9C); const textColorPlaceHolder = Color(0xffA89C9C);
const textGrey = Color(0xffE0E0E0); const textGrey = Color(0xffE0E0E0);
const dashGrey = Color(0xffCCCCCC);
const textGreyBill = Color(0xff828282); const textGreyBill = Color(0xff828282);
const textGreyDeskripsi = Color(0xffBDBDBD); const textGreyDeskripsi = Color(0xffBDBDBD);
const backgroundColorBottomSheet = Color(0xffE5E5E5); const backgroundColorBottomSheet = Color(0xffE5E5E5);
...@@ -289,6 +291,7 @@ const Color pendingColor = Colors.amber; ...@@ -289,6 +291,7 @@ const Color pendingColor = Colors.amber;
const Color disabledColor = Colors.grey; const Color disabledColor = Colors.grey;
// const Color selectedColor = Color.fromARGB(255, 225, 250, 5); // const Color selectedColor = Color.fromARGB(255, 225, 250, 5);
Color selectedColor = (!isExcelso) ? Colors.green : const Color(0xff047383); Color selectedColor = (!isExcelso) ? Colors.green : const Color(0xff047383);
Color selectedColorVoucher = const Color(0xff48B8C8);
Color? backGroundPayment = Colors.grey[200] ?? Colors.grey; Color? backGroundPayment = Colors.grey[200] ?? Colors.grey;
Color responsiveLeftRigth = buttonColor; Color responsiveLeftRigth = buttonColor;
......
...@@ -4,6 +4,7 @@ import 'package:byod/helper/widget/style.dart'; ...@@ -4,6 +4,7 @@ import 'package:byod/helper/widget/style.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../helper.dart'; import '../helper.dart';
import 'button_modal.dart';
Future<dynamic> buttonDialogGlobal( Future<dynamic> buttonDialogGlobal(
BuildContext context, BuildContext context,
...@@ -44,22 +45,9 @@ Future<dynamic> buttonDialogGlobal( ...@@ -44,22 +45,9 @@ Future<dynamic> buttonDialogGlobal(
onTap: () { onTap: () {
ontapOk(); ontapOk();
}, },
child: Container( child: ButtonModal(
width: double.infinity, buttonColor: okButtonColor,
height: 40, teksButton: textOnOk,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(roundedButton),
color: okButtonColor),
child: Center(
child: defaultText(
context,
textOnOk,
style: textStyleNormalFont(
context,
color: textInButton,
),
),
),
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
...@@ -67,23 +55,10 @@ Future<dynamic> buttonDialogGlobal( ...@@ -67,23 +55,10 @@ Future<dynamic> buttonDialogGlobal(
onTap: () { onTap: () {
ontapCancel(); ontapCancel();
}, },
child: Container( child: ButtonModal(
width: double.infinity, buttonColor: Colors.transparent,
height: 40, teksButton: textOnCancel,
decoration: BoxDecoration( teksButtonColor: textColorBlack,
borderRadius: BorderRadius.circular(roundedButton),
color: Colors.transparent,
),
child: Center(
child: defaultText(
context,
textOnCancel,
style: textStyleNormalFont(
context,
color: textCancelColor,
),
),
),
), ),
) )
], ],
......
import 'package:byod/helper/helper.dart';
import 'package:flutter/material.dart';
import 'style.dart';
class ButtonModal extends StatelessWidget {
const ButtonModal({
Key? key,
required this.buttonColor,
required this.teksButton,
this.teksButtonColor = textInButton,
}) : super(key: key);
final Color buttonColor;
final String teksButton;
final Color teksButtonColor;
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 43,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: buttonColor,
),
child: Center(
child: defaultText(
context,
teksButton,
style: addButton(
font: 14,
color: teksButtonColor,
),
),
),
);
}
}
// ignore_for_file: sized_box_for_whitespace // ignore_for_file: sized_box_for_whitespace
import 'package:byod/helper/widget/style.dart'; import 'package:byod/helper/widget/style.dart';
import 'package:byod/main.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../helper.dart'; import '../helper.dart';
...@@ -61,6 +62,8 @@ class PlusMinusButton extends StatelessWidget { ...@@ -61,6 +62,8 @@ class PlusMinusButton extends StatelessWidget {
child: Image( child: Image(
image: AssetImage((initialValue < 2 && isFromVariant) image: AssetImage((initialValue < 2 && isFromVariant)
? 'assets/icons/minus.png' ? 'assets/icons/minus.png'
: (isExcelso)
? 'assets/icons/minus-gold.png'
: 'assets/icons/minus-blue.png'), : 'assets/icons/minus-blue.png'),
), ),
), ),
...@@ -80,8 +83,10 @@ class PlusMinusButton extends StatelessWidget { ...@@ -80,8 +83,10 @@ class PlusMinusButton extends StatelessWidget {
child: Container( child: Container(
width: 22, width: 22,
height: 22, height: 22,
child: const Image( child: Image(
image: AssetImage('assets/icons/plus.png'), image: AssetImage((isExcelso)
? 'assets/icons/plus-gold.png'
: 'assets/icons/plus.png'),
), ),
), ),
), ),
......
...@@ -387,6 +387,19 @@ TextStyle modalNamaHeader({ ...@@ -387,6 +387,19 @@ TextStyle modalNamaHeader({
); );
} }
TextStyle modalPaymentStyle({
font = 18,
Color color = textColorBlack,
FontWeight fontWeight = FontWeight.w600,
}) {
return TextStyle(
fontFamily: (fontFamily == '') ? null : fontFamily,
fontSize: font,
fontWeight: fontWeight,
color: color,
);
}
Text fontAwesome(BuildContext context, String unicode, double fontSize, Text fontAwesome(BuildContext context, String unicode, double fontSize,
{Color? color, isBold = true}) { {Color? color, isBold = true}) {
// double widthScreens = responsiveWidthScreen(context); // double widthScreens = responsiveWidthScreen(context);
......
...@@ -1071,10 +1071,13 @@ class _NewHome2State extends State<NewHome2> { ...@@ -1071,10 +1071,13 @@ class _NewHome2State extends State<NewHome2> {
const SizedBox( const SizedBox(
width: 7, width: 7,
), ),
const Image( Image(
width: 20, width: 20,
height: 20, height: 20,
image: AssetImage('assets/icons/cart.png')) image: AssetImage((isExcelso)
? 'assets/icons/cart-gold.png'
: 'assets/icons/cart.png'),
)
], ],
), ),
), ),
......
...@@ -118,7 +118,8 @@ class ListVoucher extends StatelessWidget { ...@@ -118,7 +118,8 @@ class ListVoucher extends StatelessWidget {
fit: BoxFit.fill, fit: BoxFit.fill,
image: NetworkImage( image: NetworkImage(
voucherListData[i].titleImageUrl, voucherListData[i].titleImageUrl,
)), ),
),
), ),
// child: ClipRRect( // child: ClipRRect(
// borderRadius: BorderRadius.only( // borderRadius: BorderRadius.only(
......
// ignore_for_file: sized_box_for_whitespace
import 'package:byod/bloc/check_voucher.dart';
import 'package:byod/bloc/voucher_list.dart';
import 'package:byod/helper/helper.dart';
import 'package:byod/helper/widget/button_modal.dart';
import 'package:byod/main.dart';
import 'package:byod/ui/screen_responsive.dart';
import 'package:byod/ui/viewbill/view_bill_new.dart';
import 'package:dotted_line/dotted_line.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../../helper/widget/style.dart';
import '../../models/bill.dart';
import '../../models/voucher_list.dart';
import 'function.dart';
class PaymentVoucher extends StatelessWidget {
const PaymentVoucher(
{super.key, required this.outstandingAll, required this.dataBill});
final int outstandingAll;
final List<Bill> dataBill;
@override
Widget build(BuildContext context) {
context.read<VoucherCheck>().changeVoucher();
double currentScreen = MediaQuery.of(context).size.width;
return SafeArea(
child: Scaffold(
backgroundColor: backgroundColor,
body: ScreenResponsive(
widget: CorePaymentVoucher(
outstandingAll: outstandingAll,
dataBill: dataBill,
),
isCoreLayout: true,
widthScreen: currentScreen,
),
));
}
}
class CorePaymentVoucher extends StatelessWidget {
CorePaymentVoucher(
{super.key, required this.outstandingAll, required this.dataBill});
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") ?? '';
@override
Widget build(BuildContext context) {
double widthScreen = responsiveWidthScreen(context);
String logoUrl = prefs.getString('logoUrl') ?? '';
return Container(
width: widthScreen,
child: BlocBuilder<VoucherCheck, List<dynamic>>(
builder: (ctxVocherCheck, listVoucher) {
return Stack(
children: [
Column(
children: [
CustomAppBarVoucher(
listVoucher: listVoucher,
),
const SizedBox(
height: 20,
),
RincianPembayaranVoucher(
listVoucher: listVoucher,
outstandingAll: outstandingAll,
),
const SizedBox(
height: 16,
),
BlocBuilder<VoucherListBloc, List<VoucherList>>(
builder: (contextVoucherListBloc, voucherListData) {
return Expanded(
child: ListView.builder(
itemCount: voucherListData.length,
itemBuilder: (ctxVoucherList, i) {
// String minTransaction;
int valueMinTransaction;
if (voucherListData[i].minTransaction >
voucherListData[i].value) {
valueMinTransaction =
voucherListData[i].minTransaction;
// minTransaction =
// "Min Transaksi ${formatNumber().format(valueMinTransaction)}";
// minTransaction =
// " ${formatNumber().format(valueMinTransaction)}";
} else {
valueMinTransaction = voucherListData[i].value;
// minTransaction =
// "Min Transaksi ${formatNumber().format(valueMinTransaction)}";
}
bool isCanSelect = true;
if (outstandingAll <
voucherListData[i].minTransaction ||
outstandingAll < voucherListData[i].value) {
isCanSelect = false;
}
return GestureDetector(
onTap: () {
if (isCanSelect) {
if (listVoucher.isNotEmpty &&
listVoucher[0] != '0' &&
listVoucher[2] ==
voucherListData[i]
.verificationNumber) {
context
.read<VoucherCheck>()
.changeVoucher();
} else {
context.read<VoucherCheck>().check(
voucherListData[i].verificationNumber);
}
} else {
EasyLoading.showToast(
"Tambah minimal ${formatNumber().format(valueMinTransaction - outstandingAll)} untuk menggunakan voucher");
}
},
child: ListVoucherView(
logoUrl: logoUrl,
valueMinTransaction: valueMinTransaction,
outstandingAll: outstandingAll,
isCanSelect: isCanSelect,
voucherListData: voucherListData,
index: i,
listVoucher: listVoucher,
),
);
},
),
);
},
)
],
),
Positioned(
bottom: 0,
child: GestureDetector(
onTap: () {
if (listVoucher.isNotEmpty && listVoucher[0] != '0') {
// if (voucherNominal > totalPembayaran) {
// EasyLoading.showInfo(
// 'Total Tagihan Lebih Kecil Daripada Nominal Voucher');
// } else {
addPayment(
context,
dataBill[0].id,
branchCode,
brandCode,
customerName,
payVoucher,
fullPayment,
listVoucher[2],
amountParseToInt(listVoucher[1]),
);
// }
}
},
child: Container(
width: widthScreen,
color: backgroundWhite,
padding: const EdgeInsets.symmetric(
horizontal: paddingLeftRight, vertical: 16),
child: ButtonModal(
buttonColor:
(listVoucher.isNotEmpty && listVoucher[0] != '0')
? buttonColor
: disabledColor,
teksButton: 'Gunakan Voucher',
),
),
),
)
],
);
},
),
);
}
}
class ListVoucherView extends StatelessWidget {
const ListVoucherView({
Key? key,
required this.logoUrl,
required this.valueMinTransaction,
required this.outstandingAll,
required this.isCanSelect,
required this.voucherListData,
required this.index,
required this.listVoucher,
}) : super(key: key);
final String logoUrl;
final int valueMinTransaction;
final int outstandingAll;
final bool isCanSelect;
final List<VoucherList> voucherListData;
final int index;
final List<dynamic> listVoucher;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: (listVoucher.isNotEmpty &&
listVoucher[0] != '0' &&
listVoucher[2] == voucherListData[index].verificationNumber)
? selectedColorVoucher
: backgroundWhite,
),
padding: const EdgeInsets.all(16),
margin: EdgeInsets.only(
left: paddingLeftRight,
right: paddingLeftRight,
bottom: (index + 1 == voucherListData.length) ? 80 : 12,
),
child: Column(
children: [
Container(
height: 72,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
image: DecorationImage(
colorFilter: (!isCanSelect)
? const ColorFilter.mode(
Colors.grey,
BlendMode.saturation,
)
: null,
fit: BoxFit.fill,
image: NetworkImage(
voucherListData[index].titleImageUrl,
),
),
),
// child: const ClipRRect(
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(8),
// topRight: Radius.circular(8),
// ),
// child: Image(
// fit: BoxFit.fill,
// image: NetworkImage(
// 'https://bandar-media.s3.amazonaws.com/member/7fc891b5-712c-4962-82e1-447261bc2601-title.jpg'),
// ),
// ),
),
const SizedBox(
height: 7,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: 111,
height: 42,
color: (listVoucher.isNotEmpty &&
listVoucher[0] != '0' &&
listVoucher[2] ==
voucherListData[index].verificationNumber)
? selectedColorVoucher
: backgroundWhite,
child: Image(
width: 111,
height: 42,
image: NetworkImage(logoUrl),
),
),
Container(
width: 108,
child: defaultText(
context,
voucherListData[index].rewardTitle,
textAlign: TextAlign.right,
style: rincianPembayaran(
font: 14,
),
),
)
],
),
const SizedBox(
height: 12,
),
const DottedLine(
dashColor: dashGrey,
dashLength: 12,
),
const SizedBox(
height: 12,
),
Row(
children: [
Image(
width: 20,
height: 20,
image: AssetImage((isExcelso)
? 'assets/icons/clock-gold.png'
: 'assets/icons/clock.png'),
),
const SizedBox(
width: 14,
),
defaultText(
context,
formatDate(
voucherListData[index].expired,
toLocal: true,
),
style: addButton(
font: 12,
color: textColorBlack,
),
),
const Spacer(),
Container(
height: 30,
width: 98,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(21),
color: (listVoucher.isNotEmpty &&
listVoucher[0] != '0' &&
listVoucher[2] ==
voucherListData[index].verificationNumber)
? disabledColor
: buttonColor,
),
child: Center(
child: defaultText(
context,
(listVoucher.isNotEmpty &&
listVoucher[0] != '0' &&
listVoucher[2] ==
voucherListData[index].verificationNumber)
? 'Batal'
: 'Pakai',
style: addButton(font: 8),
),
),
)
],
),
(!isCanSelect)
? Column(
children: [
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
fontAwesome(
context,
infoCircle,
infoCircleSize,
color: Colors.grey,
),
const SizedBox(
width: 10,
),
defaultText(
context,
'Tambah minimal ${formatNumber().format(valueMinTransaction - outstandingAll)} untuk menggunakan voucher',
style: textStyleVoucherListAddMore(context),
),
],
),
],
)
: const SizedBox(),
const SizedBox(
height: 20,
),
],
),
);
}
}
class RincianPembayaranVoucher extends StatelessWidget {
const RincianPembayaranVoucher({
Key? key,
required this.listVoucher,
required this.outstandingAll,
}) : super(key: key);
final List<dynamic> listVoucher;
final int outstandingAll;
@override
Widget build(BuildContext context) {
int voucherNominal = 0;
if (listVoucher.isNotEmpty && listVoucher[0] != '0') {
voucherNominal = amountParseToInt(listVoucher[1]);
}
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: backgroundWhite,
),
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
defaultText(
context,
'Rincian Pembayaran',
style: rincianPembayaran(
font: 14,
),
),
(listVoucher.isNotEmpty && listVoucher[0] != '0')
? Column(
children: [
const SizedBox(
height: 16,
),
const Divider(
thickness: 0.5,
color: dividerGrey2,
),
const SizedBox(
height: 12,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
defaultText(
context,
'Discount Potongan',
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
),
defaultText(
context,
"Rp ${formatNumber().format(voucherNominal)}",
style: rincianPembayaran(
font: 12,
color: textGreyBill,
),
)
],
),
],
)
: const SizedBox(),
const SizedBox(
height: 16,
),
const Divider(
thickness: 0.5,
color: dividerGrey2,
),
const SizedBox(
height: 12,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
defaultText(
context,
'Total Harga',
style: rincianPembayaran(
font: 14,
),
),
defaultText(
context,
"Rp ${formatNumber().format(outstandingAll)}",
style: rincianPembayaran(
font: 14,
),
)
],
)
],
),
);
}
}
class CustomAppBarVoucher extends StatelessWidget {
CustomAppBarVoucher({
Key? key,
required this.listVoucher,
}) : super(key: key);
final List<dynamic> listVoucher;
final TextEditingController voucherController = TextEditingController();
@override
Widget build(BuildContext context) {
bool enabledTextField = true;
if (listVoucher.isNotEmpty && listVoucher[0] != '0') {
enabledTextField = false;
}
return Container(
padding: const EdgeInsets.only(
top: 15,
bottom: 17,
left: paddingLeftRight,
right: paddingLeftRight,
),
// padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
color: backgroundWhite,
child: Column(
children: [
Row(
// mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const ViewBillNew()),
);
},
child: Container(
width: 24,
height: 24,
child: Center(
child: fontAwesomeNew(
arrowBack,
arrowBackSize,
),
),
),
),
const SizedBox(
width: 16,
),
Center(
child: defaultText(
context,
'Voucher',
maxLines: 1,
overFlow: TextOverflow.ellipsis,
style: appBarNameViewBill(),
),
),
],
),
const SizedBox(
height: 16,
),
Row(
children: [
Expanded(
child: Container(
width: 236,
height: 36,
child: TextField(
controller:
(listVoucher.isNotEmpty && listVoucher[0] != '0')
? TextEditingController(text: listVoucher[0])
: voucherController,
// autofocus: true,
enabled: enabledTextField,
style: TextStyle(
color: Colors.black,
fontFamily: fontFamily,
fontSize: 15,
),
textAlignVertical: TextAlignVertical.center,
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,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
),
contentPadding: const EdgeInsets.all(5),
),
),
),
),
const SizedBox(
width: 12,
),
GestureDetector(
onTap: () {
if (enabledTextField) {
if (voucherController.text.isEmpty) {
EasyLoading.showToast('Kode voucher harus diisi');
} else {
context
.read<VoucherCheck>()
.check(voucherController.text);
}
} else {
context.read<VoucherCheck>().changeVoucher();
}
},
child: Container(
height: 36,
width: 87,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: buttonColor,
),
child: Center(
child: defaultText(
context,
(enabledTextField) ? 'Redeem' : 'Ganti',
style: addButton(
font: 8,
),
),
),
),
),
],
),
],
),
);
}
}
...@@ -206,14 +206,17 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> { ...@@ -206,14 +206,17 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
], ],
), ),
), ),
Container( (!widget.isHistory && widget.tableStatus == tableStatusOpen)
? Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: paddingLeftRightBill, right: paddingLeftRightBill), left: paddingLeftRightBill,
right: paddingLeftRightBill),
child: const Divider( child: const Divider(
thickness: 1, thickness: 1,
color: backgroundColor, color: backgroundColor,
), ),
), )
: const SizedBox(),
(!widget.isHistory && widget.tableStatus == tableStatusOpen) (!widget.isHistory && widget.tableStatus == tableStatusOpen)
? const SizedBox( ? const SizedBox(
height: 11, height: 11,
......
// ignore_for_file: sized_box_for_whitespace // ignore_for_file: sized_box_for_whitespace
import 'dart:convert';
import 'dart:math'; import 'dart:math';
import 'package:byod/bloc/feedback_select.dart';
import 'package:byod/bloc/member_info.dart'; import 'package:byod/bloc/member_info.dart';
import 'package:byod/helper/helper.dart'; import 'package:byod/helper/helper.dart';
import 'package:byod/helper/widget/button_modal.dart';
import 'package:byod/helper/widget/style.dart'; 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/screen_responsive.dart'; import 'package:byod/ui/screen_responsive.dart';
...@@ -20,20 +18,17 @@ import '../../bloc/feedback_option.dart'; ...@@ -20,20 +18,17 @@ import '../../bloc/feedback_option.dart';
import '../../bloc/view_bill.dart'; import '../../bloc/view_bill.dart';
import '../../bloc/voucher_list.dart'; import '../../bloc/voucher_list.dart';
import '../../helper/widget/button_dialog.dart'; import '../../helper/widget/button_dialog.dart';
import '../../helper/widget/emoticon_rate.dart';
import '../../helper/widget/emoticon_rate_new.dart'; import '../../helper/widget/emoticon_rate_new.dart';
import '../../helper/widget/open_url.dart'; import '../../helper/widget/open_url.dart';
import '../../helper/widget/thousand_formatter.dart'; import '../../helper/widget/thousand_formatter.dart';
import '../../main.dart'; import '../../main.dart';
import '../../models/bill.dart'; import '../../models/bill.dart';
import '../../models/feedback_option.dart';
import '../../models/member_info.dart'; import '../../models/member_info.dart';
import '../../models/rate_value_selected.dart';
import '../build_version.dart'; import '../build_version.dart';
import '../history_order/history.dart';
import '../home/new_home2.dart'; import '../home/new_home2.dart';
import '../payment/function.dart'; import '../payment/function.dart';
import '../payment/payment.dart'; import '../payment/payment.dart';
import '../payment/payment_voucher.dart';
import 'app_bar.dart'; import 'app_bar.dart';
import 'list_order.dart'; import 'list_order.dart';
import 'rincian_pembayaran.dart'; import 'rincian_pembayaran.dart';
...@@ -368,6 +363,13 @@ class CoreBill extends StatelessWidget { ...@@ -368,6 +363,13 @@ class CoreBill extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<MemberInfoBloc, MemberInfo>( return BlocBuilder<MemberInfoBloc, MemberInfo>(
builder: (contextMember, memberinfo) { builder: (contextMember, memberinfo) {
int outStandingTopayMember = 0;
if (memberinfo.id != '') {
outStandingTopayMember =
min(outStandingAll, amountParseToIntCrm(memberinfo.balance));
}
int indexDataIndividu =
dataBill.indexWhere((data) => data.customerName == customerName);
return Container( return Container(
width: widthScreen, width: widthScreen,
// padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight), // padding: const EdgeInsets.symmetric(horizontal: paddingLeftRight),
...@@ -841,21 +843,220 @@ class CoreBill extends StatelessWidget { ...@@ -841,21 +843,220 @@ class CoreBill extends StatelessWidget {
'', '',
outStandingAll, outStandingAll,
); );
} else if (tableMode == singleTable &&
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 =
prefs.getString('userName') ??
'';
bool isIndividu;
if (tableMode == multiTable) {
isIndividu = true;
titlePayment = 'Semua Bill';
} else { } else {
buttonDialogAllPayment( isIndividu = false;
titlePayment = customerName;
}
if (outStandingAll > 0) {
if (tableMode == singleTable) {
addPayment(
context, context,
dataBill, dataBill[0].id,
customerName,
outStandingIndividu,
outStandingAll,
tableMode,
onTapCashier,
widthScreen,
memberinfo,
branchCode, branchCode,
brandCode, brandCode,
customerName,
payCard,
fullPayment,
'',
outStandingAll,
); );
} else {
Navigator.pop(context);
buttonDialog(
context,
dataBill,
outStandingAll,
widthScreen);
}
} else {
EasyLoading.showToast(
'Semua Tagihan Sudah Dibayar');
}
},
child: ButtonModal(
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,
),
),
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)));
} }
} else {
EasyLoading.showToast(
'Semua Tagihan Sudah Dibayar');
}
},
child: ButtonModal(
buttonColor: buttonColor,
teksButton:
'Excelso CRM Balance'),
),
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(
'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');
}
},
child: ButtonModal(
buttonColor: buttonColor,
teksButton:
'Excelso CRM Voucher'),
),
],
),
);
},
);
}
// else {
// buttonDialogAllPayment(
// context,
// dataBill,
// customerName,
// outStandingIndividu,
// outStandingAll,
// tableMode,
// onTapCashier,
// widthScreen,
// memberinfo,
// branchCode,
// brandCode,
// );
// }
} }
}, },
child: Container( child: Container(
...@@ -863,7 +1064,11 @@ class CoreBill extends StatelessWidget { ...@@ -863,7 +1064,11 @@ class CoreBill extends StatelessWidget {
height: 43, height: 43,
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(33), borderRadius: BorderRadius.circular(
(dataBill[0].tableStatus == tableStatusOpen)
? 8
: 33,
),
color: (dataBill[0].tableStatus == tableStatusOpen) color: (dataBill[0].tableStatus == tableStatusOpen)
? buttonColor ? buttonColor
: disabledColor, : disabledColor,
...@@ -881,7 +1086,12 @@ class CoreBill extends StatelessWidget { ...@@ -881,7 +1086,12 @@ class CoreBill extends StatelessWidget {
), ),
(dataBill[0].isFeedBack == false && (dataBill[0].isFeedBack == false &&
dataBill[0].tableStatus == tableStatusOpen) dataBill[0].tableStatus == tableStatusOpen)
? GestureDetector( ? Column(
children: [
const SizedBox(
height: 12,
),
GestureDetector(
onTap: () { onTap: () {
if (dataBill[0].tableStatus == if (dataBill[0].tableStatus ==
tableStatusOpen) { tableStatusOpen) {
...@@ -897,24 +1107,33 @@ class CoreBill extends StatelessWidget { ...@@ -897,24 +1107,33 @@ class CoreBill extends StatelessWidget {
} }
} }
}, },
child: Container( child: ButtonModal(
margin: const EdgeInsets.only(top: 12), buttonColor: successColor,
height: 43, teksButton: (dataBill[0].tableStatus ==
width: double.infinity, tableStatusOpen)
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(33),
color: successColor,
),
child: Center(
child: defaultText(
context,
(dataBill[0].tableStatus == tableStatusOpen)
? 'Tutup Pesanan & Minta Bill' ? 'Tutup Pesanan & Minta Bill'
: 'Beri Penilaian', : 'Beri Penilaian',
style: buttonBottomBill(), )
), // 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(),
// ),
// ),
// ),
), ),
],
) )
: const SizedBox(), : const SizedBox(),
const SizedBox( const SizedBox(
...@@ -991,8 +1210,11 @@ class EmptyBill extends StatelessWidget { ...@@ -991,8 +1210,11 @@ class EmptyBill extends StatelessWidget {
right: paddingLeftRight, right: paddingLeftRight,
bottom: 18, bottom: 18,
), ),
child: defaultText(context, customerName, child: defaultText(
style: customerNameViewbill()), context,
customerName,
style: customerNameViewbill(),
),
), ),
const SizedBox( const SizedBox(
height: 24, height: 24,
......
...@@ -7,7 +7,7 @@ packages: ...@@ -7,7 +7,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.8.2" version: "2.9.0"
bloc: bloc:
dependency: transitive dependency: transitive
description: description:
...@@ -28,7 +28,7 @@ packages: ...@@ -28,7 +28,7 @@ packages:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.1"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
...@@ -42,7 +42,7 @@ packages: ...@@ -42,7 +42,7 @@ packages:
name: clock name: clock
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
...@@ -64,13 +64,20 @@ packages: ...@@ -64,13 +64,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.17.2" version: "0.17.2"
dotted_line:
dependency: "direct main"
description:
name: dotted_line
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.1"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
...@@ -183,21 +190,21 @@ packages: ...@@ -183,21 +190,21 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11" version: "0.12.12"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.4" version: "0.1.5"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0"
nested: nested:
dependency: transitive dependency: transitive
description: description:
...@@ -211,7 +218,7 @@ packages: ...@@ -211,7 +218,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.2"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
...@@ -349,7 +356,7 @@ packages: ...@@ -349,7 +356,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.2" version: "1.9.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
...@@ -370,21 +377,21 @@ packages: ...@@ -370,21 +377,21 @@ packages:
name: string_scanner name: string_scanner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.1"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.9" version: "0.4.12"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
......
...@@ -27,6 +27,7 @@ environment: ...@@ -27,6 +27,7 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer # the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`. # versions available, run `flutter pub outdated`.
dependencies: dependencies:
dotted_line: ^3.1.0
flutter: flutter:
sdk: flutter sdk: flutter
flutter_bloc: ^8.0.1 flutter_bloc: ^8.0.1
......
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