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
//** core warna */
// const Color backgroundColor = Colors.white;
const Color backgroundColor = Color(0xffF4F4F4);
const Color backgroundColorViewBill = Color(0xffE5E5E5);
const Color backgroundWhite = Color(0xffFFFFFF);
const Color dividerGrey = Color(0xff898A8D);
const textColorTabel = Color(0xff333333);
......
......@@ -337,10 +337,10 @@ class _OrderViewBillNewState extends State<OrderViewBillNew> {
height: 11,
)
: const SizedBox(),
(widget.lastItem)
(!widget.lastItem)
? const Divider(
thickness: 1,
color: dividerGrey,
thickness: 2,
color: backgroundColorViewBill,
)
: const SizedBox()
],
......
......@@ -5,7 +5,6 @@ import 'package:byod/helper/widget/style.dart';
import 'package:byod/ui/screen_responsive.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:uuid/uuid.dart';
import '../../api/api.dart';
......@@ -93,181 +92,194 @@ class ViewBillNew extends StatelessWidget {
return SafeArea(
child: Scaffold(
backgroundColor: backgroundWhite,
body: BlocBuilder<ViewBillBloc, List<Bill>>(
builder: (ctxViewBill, dataBill) {
if (dataBill.isNotEmpty) {
if (dataBill[0].id == defaultViewBill) {
return ScreenResponsive(
// widget: waitingBill(
// context,
// widthScreen,
// maxWidthScreen,
// ),
widget: ShimmerBill(
widthScreen: widthScreen,
maxWidthScreen: maxWidthScreen,
context: context,
),
widthScreen: currentScreen,
isCoreLayout: true,
);
} else {
saveBillDetail(dataBill);
int totalService = 0;
int totalServiceTax = 0;
int individuTotalPayment = 0;
int individuPaymentPaid = 0;
int outStandingIndividu = 0;
body: RefreshIndicator(
color: buttonColor,
backgroundColor: backgroundColor,
onRefresh: () {
return Future.delayed(
const Duration(milliseconds: 1500),
() {
context.read<ViewBillBloc>().getBill();
},
);
},
child: BlocBuilder<ViewBillBloc, List<Bill>>(
builder: (ctxViewBill, dataBill) {
if (dataBill.isNotEmpty) {
if (dataBill[0].id == defaultViewBill) {
return ScreenResponsive(
// widget: waitingBill(
// context,
// widthScreen,
// maxWidthScreen,
// ),
widget: ShimmerBill(
widthScreen: widthScreen,
maxWidthScreen: maxWidthScreen,
context: context,
),
widthScreen: currentScreen,
isCoreLayout: true,
);
} else {
saveBillDetail(dataBill);
int allPaymentPaid = 0;
int outStandingAll = 0;
int totalDiscount = 0;
// int totalService = 0;
// int totalServiceTax = 0;
bool isIndividuHaveWaitingPayment = false;
String paymentToRedirect = '';
String paymentId = '';
// int individuTotalPayment = 0;
// int individuPaymentPaid = 0;
// int outStandingIndividu = 0;
// check payment pending ketika table di lock backend
bool isStillHavePaymentPending = false;
// int allPaymentPaid = 0;
int outStandingAll = 0;
int totalDiscount = 0;
if (dataBill.isNotEmpty) {
int indexWherePendingPayment = dataBill[0]
.paymentList
.indexWhere((element) => element.isApproved == false);
if (indexWherePendingPayment != -1) {
isStillHavePaymentPending = true;
}
// bool isIndividuHaveWaitingPayment = false;
// String paymentToRedirect = '';
// String paymentId = '';
//service and servicetax
totalService = amountParseToInt(dataBill[0].totalService);
totalServiceTax =
amountParseToInt(dataBill[0].totalServiceTax);
// check payment pending ketika table di lock backend
// bool isStillHavePaymentPending = false;
for (var x in dataBill) {
if (x.customerName == customerName) {
individuTotalPayment = x.totalPerCustomer;
}
if (dataBill.isNotEmpty) {
// int indexWherePendingPayment = dataBill[0]
// .paymentList
// .indexWhere((element) => element.isApproved == false);
// if (indexWherePendingPayment != -1) {
// isStillHavePaymentPending = true;
// }
//service and tax
// for (var bd in x.billDetail) {
// totalService += amountParseToInt(bd.service);
// totalServiceTax += amountParseToInt(bd.serviceTax);
//service and servicetax
// totalService = amountParseToInt(dataBill[0].totalService);
// totalServiceTax =
// 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) {
// 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;
}
void ontapOkAfterCashier() async {
Api.addPayment(
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()));
}
outStandingAll = amountParseToInt(dataBill[0].outStandingPay);
totalDiscount = amountParseToInt(dataBill[0].discountTotal);
outStandingIndividu =
amountParseToInt(dataBill[0].outStandingIndividu);
}
void ontapOkAfterCashier() async {
Api.addPayment(
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 ontapCancelAfterCashier() {
Navigator.pop(context);
}
void onTapCashier() {
String title;
String description;
String textOnOk = 'OK';
String textOnCancel = 'Batal';
// if (outStandingAll > 0) {
// Navigator.pop(context);
title = 'Tutup Pesanan';
description = '''
Selesaikan transaksi dan tutup pesanan ?
void onTapCashier() {
String title;
String description;
String textOnOk = 'OK';
String textOnCancel = 'Batal';
// if (outStandingAll > 0) {
// Navigator.pop(context);
title = 'Tutup Pesanan';
description = '''
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''';
// } 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';
// }
buttonDialogGlobal(
context,
title,
description,
textOnOk,
textOnCancel,
ontapOkAfterCashier,
ontapCancelAfterCashier,
okButtonColor: buttonColor,
cancelButtonColor: cancelColorButton,
);
}
buttonDialogGlobal(
context,
title,
description,
textOnOk,
textOnCancel,
ontapOkAfterCashier,
ontapCancelAfterCashier,
okButtonColor: buttonColor,
cancelButtonColor: cancelColorButton,
return ScreenResponsive(
widget: CoreBill(
widthScreen: widthScreen,
dataBill: dataBill,
outStandingAll: outStandingAll,
totalDiscount: totalDiscount,
isHistory: isHistory,
),
widthScreen: MediaQuery.of(context).size.width,
isCoreLayout: true,
);
}
} else {
return ScreenResponsive(
widget: CoreBill(
widthScreen: widthScreen,
dataBill: dataBill,
outStandingAll: outStandingAll,
totalDiscount: totalDiscount,
isHistory: isHistory,
widget: emptyBill(
widthScreen,
maxWidthScreen,
historyOrder,
context,
),
widthScreen: MediaQuery.of(context).size.width,
widthScreen: currentScreen,
isCoreLayout: true,
);
}
} else {
return ScreenResponsive(
widget: emptyBill(
widthScreen,
maxWidthScreen,
historyOrder,
context,
),
widthScreen: currentScreen,
isCoreLayout: true,
);
}
},
},
),
),
),
);
......@@ -494,7 +506,7 @@ class CoreBill extends StatelessWidget {
height: 18,
),
const Divider(
color: backgroundColor,
color: backgroundColorViewBill,
thickness: 24,
),
const SizedBox(
......@@ -519,12 +531,12 @@ class CoreBill extends StatelessWidget {
height: 11,
),
const Divider(
color: backgroundColor,
color: backgroundColorViewBill,
thickness: 24,
),
const AddMoreOrder(),
const Divider(
color: backgroundColor,
color: backgroundColorViewBill,
thickness: 24,
),
RincianPembayaran(
......@@ -533,7 +545,7 @@ class CoreBill extends StatelessWidget {
outStandingAll: outStandingAll,
),
const Divider(
color: backgroundColor,
color: backgroundColorViewBill,
thickness: 24,
),
],
......
......@@ -261,13 +261,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: "direct main"
description:
......
......@@ -34,7 +34,6 @@ dependencies:
http: ^0.13.4
intl: ^0.17.0
loading_animations: ^2.2.0
pull_to_refresh: ^2.0.0
scrollable_positioned_list: ^0.3.4
shared_preferences: ^2.0.15
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