Commit 23a8182d authored by Dio Maulana's avatar Dio Maulana

pull to refresh viewbill

parent 427674c0
...@@ -245,6 +245,7 @@ double heightTombol = 0.06; // untuk dikalikan di height media query ...@@ -245,6 +245,7 @@ double heightTombol = 0.06; // untuk dikalikan di height media query
//** core warna */ //** core warna */
// const Color backgroundColor = Colors.white; // const Color backgroundColor = Colors.white;
const Color backgroundColor = Color(0xffF4F4F4); const Color backgroundColor = Color(0xffF4F4F4);
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 textColorTabel = Color(0xff333333); const textColorTabel = Color(0xff333333);
......
...@@ -337,10 +337,10 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> { ...@@ -337,10 +337,10 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
height: 11, height: 11,
) )
: const SizedBox(), : const SizedBox(),
(widget.lastItem) (!widget.lastItem)
? const Divider( ? const Divider(
thickness: 1, thickness: 2,
color: dividerGrey, color: backgroundColorViewBill,
) )
: const SizedBox() : const SizedBox()
], ],
......
...@@ -5,7 +5,6 @@ import 'package:byod/helper/widget/style.dart'; ...@@ -5,7 +5,6 @@ import 'package:byod/helper/widget/style.dart';
import 'package:byod/ui/screen_responsive.dart'; import 'package:byod/ui/screen_responsive.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import '../../api/api.dart'; import '../../api/api.dart';
...@@ -93,181 +92,194 @@ class ViewBillNew extends StatelessWidget { ...@@ -93,181 +92,194 @@ class ViewBillNew extends StatelessWidget {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
backgroundColor: backgroundWhite, backgroundColor: backgroundWhite,
body: BlocBuilder<ViewBillBloc, List<Bill>>( body: RefreshIndicator(
builder: (ctxViewBill, dataBill) { color: buttonColor,
if (dataBill.isNotEmpty) { backgroundColor: backgroundColor,
if (dataBill[0].id == defaultViewBill) { onRefresh: () {
return ScreenResponsive( return Future.delayed(
// widget: waitingBill( const Duration(milliseconds: 1500),
// context, () {
// widthScreen, context.read<ViewBillBloc>().getBill();
// maxWidthScreen, },
// ), );
widget: ShimmerBill( },
widthScreen: widthScreen, child: BlocBuilder<ViewBillBloc, List<Bill>>(
maxWidthScreen: maxWidthScreen, builder: (ctxViewBill, dataBill) {
context: context, if (dataBill.isNotEmpty) {
), if (dataBill[0].id == defaultViewBill) {
widthScreen: currentScreen, return ScreenResponsive(
isCoreLayout: true, // widget: waitingBill(
); // context,
} else { // widthScreen,
saveBillDetail(dataBill); // maxWidthScreen,
// ),
int totalService = 0; widget: ShimmerBill(
int totalServiceTax = 0; widthScreen: widthScreen,
maxWidthScreen: maxWidthScreen,
int individuTotalPayment = 0; context: context,
int individuPaymentPaid = 0; ),
int outStandingIndividu = 0; widthScreen: currentScreen,
isCoreLayout: true,
);
} else {
saveBillDetail(dataBill);
int allPaymentPaid = 0; // int totalService = 0;
int outStandingAll = 0; // int totalServiceTax = 0;
int totalDiscount = 0;
bool isIndividuHaveWaitingPayment = false; // int individuTotalPayment = 0;
String paymentToRedirect = ''; // int individuPaymentPaid = 0;
String paymentId = ''; // int outStandingIndividu = 0;
// check payment pending ketika table di lock backend // int allPaymentPaid = 0;
bool isStillHavePaymentPending = false; int outStandingAll = 0;
int totalDiscount = 0;
if (dataBill.isNotEmpty) { // bool isIndividuHaveWaitingPayment = false;
int indexWherePendingPayment = dataBill[0] // String paymentToRedirect = '';
.paymentList // String paymentId = '';
.indexWhere((element) => element.isApproved == false);
if (indexWherePendingPayment != -1) {
isStillHavePaymentPending = true;
}
//service and servicetax // check payment pending ketika table di lock backend
totalService = amountParseToInt(dataBill[0].totalService); // bool isStillHavePaymentPending = false;
totalServiceTax =
amountParseToInt(dataBill[0].totalServiceTax);
for (var x in dataBill) { if (dataBill.isNotEmpty) {
if (x.customerName == customerName) { // int indexWherePendingPayment = dataBill[0]
individuTotalPayment = x.totalPerCustomer; // .paymentList
} // .indexWhere((element) => element.isApproved == false);
// if (indexWherePendingPayment != -1) {
// isStillHavePaymentPending = true;
// }
//service and tax //service and servicetax
// for (var bd in x.billDetail) { // totalService = amountParseToInt(dataBill[0].totalService);
// totalService += amountParseToInt(bd.service); // totalServiceTax =
// totalServiceTax += amountParseToInt(bd.serviceTax); // amountParseToInt(dataBill[0].totalServiceTax);
// for (var x in dataBill) {
// if (x.customerName == customerName) {
// // individuTotalPayment = x.totalPerCustomer;
// }
// //service and tax
// // for (var bd in x.billDetail) {
// // totalService += amountParseToInt(bd.service);
// // totalServiceTax += amountParseToInt(bd.serviceTax);
// // }
// } // }
// if (dataBill[0].paymentList.isNotEmpty) {
// for (var p in dataBill[0].paymentList) {
// // if (p.isApproved && p.customerNamePay == customerName) {
// // individuPaymentPaid += amountParseToInt(p.amount);
// // }
// if (p.isApproved) {
// allPaymentPaid += amountParseToInt(p.amount);
// }
// if (!p.isApproved) {
// if (p.paymentUrl != '' &&
// p.customerNamePay == customerName) {
// isIndividuHaveWaitingPayment = true;
// paymentToRedirect = p.paymentUrl;
// paymentId = p.id;
// }
// }
// }
// }
outStandingAll =
amountParseToInt(dataBill[0].outStandingPay);
totalDiscount = amountParseToInt(dataBill[0].discountTotal);
// outStandingIndividu =
// amountParseToInt(dataBill[0].outStandingIndividu);
} }
if (dataBill[0].paymentList.isNotEmpty) {
for (var p in dataBill[0].paymentList) { void ontapOkAfterCashier() async {
// if (p.isApproved && p.customerNamePay == customerName) { Api.addPayment(
// individuPaymentPaid += amountParseToInt(p.amount); context,
// } dataBill[0].id,
if (p.isApproved) { branchCode,
allPaymentPaid += amountParseToInt(p.amount); brandCode,
} customerName,
if (!p.isApproved) { payCash,
if (p.paymentUrl != '' && fullPayment,
p.customerNamePay == customerName) { '',
isIndividuHaveWaitingPayment = true; outStandingAll,
paymentToRedirect = p.paymentUrl; ).then((value) {
paymentId = p.id; if (value == 'OK') {
} ratingModal(
context,
dataBill,
isHistory,
sessionID: sessionId,
);
} }
} });
Navigator.pop(context);
// Navigator.push(context,
// MaterialPageRoute(builder: (_) => FinishOrder()));
} }
outStandingAll = amountParseToInt(dataBill[0].outStandingPay);
totalDiscount = amountParseToInt(dataBill[0].discountTotal);
outStandingIndividu =
amountParseToInt(dataBill[0].outStandingIndividu);
}
void ontapOkAfterCashier() async { void ontapCancelAfterCashier() {
Api.addPayment( Navigator.pop(context);
context, }
dataBill[0].id,
branchCode,
brandCode,
customerName,
payCash,
fullPayment,
'',
outStandingAll,
).then((value) {
if (value == 'OK') {
ratingModal(
context,
dataBill,
isHistory,
sessionID: sessionId,
);
}
});
Navigator.pop(context);
// Navigator.push(context,
// MaterialPageRoute(builder: (_) => FinishOrder()));
}
void ontapCancelAfterCashier() {
Navigator.pop(context);
}
void onTapCashier() { void onTapCashier() {
String title; String title;
String description; String description;
String textOnOk = 'OK'; String textOnOk = 'OK';
String textOnCancel = 'Batal'; String textOnCancel = 'Batal';
// if (outStandingAll > 0) { // if (outStandingAll > 0) {
// Navigator.pop(context); // Navigator.pop(context);
title = 'Tutup Pesanan'; title = 'Tutup Pesanan';
description = ''' description = '''
Selesaikan transaksi dan tutup pesanan ? Selesaikan transaksi dan tutup pesanan ?
Mohon menuju kasir untuk meminta bukti pembayaran''';
// } else {
// // // Navigator.pop(context);
// // EasyLoading.showInfo('Tidak ada tagihan yang perlu dibayar');
// title = 'Tutup Pesanan & Minta Bill';
// description =
// 'Transaksi akan ditutup dan silakan meminta bill di kasir';
// }
Mohon menuju kasir untuk meminta bukti pembayaran'''; buttonDialogGlobal(
// } else { context,
// // // Navigator.pop(context); title,
// // EasyLoading.showInfo('Tidak ada tagihan yang perlu dibayar'); description,
// title = 'Tutup Pesanan & Minta Bill'; textOnOk,
// description = textOnCancel,
// 'Transaksi akan ditutup dan silakan meminta bill di kasir'; ontapOkAfterCashier,
// } ontapCancelAfterCashier,
okButtonColor: buttonColor,
cancelButtonColor: cancelColorButton,
);
}
buttonDialogGlobal( return ScreenResponsive(
context, widget: CoreBill(
title, widthScreen: widthScreen,
description, dataBill: dataBill,
textOnOk, outStandingAll: outStandingAll,
textOnCancel, totalDiscount: totalDiscount,
ontapOkAfterCashier, isHistory: isHistory,
ontapCancelAfterCashier, ),
okButtonColor: buttonColor, widthScreen: MediaQuery.of(context).size.width,
cancelButtonColor: cancelColorButton, isCoreLayout: true,
); );
} }
} else {
return ScreenResponsive( return ScreenResponsive(
widget: CoreBill( widget: emptyBill(
widthScreen: widthScreen, widthScreen,
dataBill: dataBill, maxWidthScreen,
outStandingAll: outStandingAll, historyOrder,
totalDiscount: totalDiscount, context,
isHistory: isHistory,
), ),
widthScreen: MediaQuery.of(context).size.width, widthScreen: currentScreen,
isCoreLayout: true, isCoreLayout: true,
); );
} }
} else { },
return ScreenResponsive( ),
widget: emptyBill(
widthScreen,
maxWidthScreen,
historyOrder,
context,
),
widthScreen: currentScreen,
isCoreLayout: true,
);
}
},
), ),
), ),
); );
...@@ -494,7 +506,7 @@ class CoreBill extends StatelessWidget { ...@@ -494,7 +506,7 @@ class CoreBill extends StatelessWidget {
height: 18, height: 18,
), ),
const Divider( const Divider(
color: backgroundColor, color: backgroundColorViewBill,
thickness: 24, thickness: 24,
), ),
const SizedBox( const SizedBox(
...@@ -519,12 +531,12 @@ class CoreBill extends StatelessWidget { ...@@ -519,12 +531,12 @@ class CoreBill extends StatelessWidget {
height: 11, height: 11,
), ),
const Divider( const Divider(
color: backgroundColor, color: backgroundColorViewBill,
thickness: 24, thickness: 24,
), ),
const AddMoreOrder(), const AddMoreOrder(),
const Divider( const Divider(
color: backgroundColor, color: backgroundColorViewBill,
thickness: 24, thickness: 24,
), ),
RincianPembayaran( RincianPembayaran(
...@@ -533,7 +545,7 @@ class CoreBill extends StatelessWidget { ...@@ -533,7 +545,7 @@ class CoreBill extends StatelessWidget {
outStandingAll: outStandingAll, outStandingAll: outStandingAll,
), ),
const Divider( const Divider(
color: backgroundColor, color: backgroundColorViewBill,
thickness: 24, thickness: 24,
), ),
], ],
......
...@@ -261,13 +261,6 @@ packages: ...@@ -261,13 +261,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.3" version: "6.0.3"
pull_to_refresh:
dependency: "direct main"
description:
name: pull_to_refresh
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
scrollable_positioned_list: scrollable_positioned_list:
dependency: "direct main" dependency: "direct main"
description: description:
......
...@@ -34,7 +34,6 @@ dependencies: ...@@ -34,7 +34,6 @@ dependencies:
http: ^0.13.4 http: ^0.13.4
intl: ^0.17.0 intl: ^0.17.0
loading_animations: ^2.2.0 loading_animations: ^2.2.0
pull_to_refresh: ^2.0.0
scrollable_positioned_list: ^0.3.4 scrollable_positioned_list: ^0.3.4
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
shimmer: ^2.0.0 shimmer: ^2.0.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment