Compare commits
18
Commits
5b980d237f
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
457ed38827 | ||
|
|
d34487d883 | ||
|
|
f4cdfcb96f | ||
|
|
0bccec8a1e | ||
|
|
86d2196a04 | ||
|
|
aa25de8da7 | ||
|
|
96387c08f4 | ||
|
|
e585cf4292 | ||
|
|
290360674f | ||
|
|
1fbacae1f4 | ||
|
|
613b216c04 | ||
|
|
455a6afd70 | ||
|
|
2813011fac | ||
|
|
83af323a2f | ||
|
|
cef1f79032 | ||
|
|
59a8d7f661 | ||
|
|
a58d1040af | ||
|
|
72a464b4c0 |
@@ -47,7 +47,7 @@ android {
|
||||
applicationId "com.appscale.pos"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdkVersion 23
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
targetSdkVersion 35
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||
import 'package:enaklo_pos/core/utils/printer_service.dart';
|
||||
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/printer/printer_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/settings_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
@@ -31,10 +31,10 @@ Future<void> onPrint(
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('checker');
|
||||
final kitchenPrinter =
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('kitchen');
|
||||
final barPrinter =
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('bar');
|
||||
final receiptPrinter =
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
final barPrinter =
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('bar');
|
||||
|
||||
if (receiptPrinter != null) {
|
||||
try {
|
||||
@@ -135,7 +135,8 @@ Future<void> onPrint(
|
||||
final productByPrinter = productQuantity
|
||||
.where((item) => item.product.printerType == 'kitchen')
|
||||
.toList();
|
||||
final printValue = await PrintDataoutputs.instance.printKitchen(
|
||||
final printValue =
|
||||
await PrintDataoutputs.instance.printKitchenPerProduct(
|
||||
productByPrinter,
|
||||
order.tableNumber ?? "",
|
||||
order.orderNumber ?? "",
|
||||
@@ -279,6 +280,114 @@ Future<void> onPrint(
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onPrintBill(
|
||||
BuildContext context, {
|
||||
required List<ProductQuantity> productQuantity,
|
||||
required Order order,
|
||||
}) async {
|
||||
final outlet = await OutletLocalDatasource().get();
|
||||
final settings = await SettingsLocalDatasource().getTax();
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
|
||||
if (outlet.businessType == BusinessType.restaurant) {
|
||||
final receiptPrinter =
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
|
||||
if (receiptPrinter != null) {
|
||||
try {
|
||||
final printValue = await PrintDataoutputs.instance.printOrderV4(
|
||||
order,
|
||||
authData.user?.name ?? "",
|
||||
'',
|
||||
0,
|
||||
0,
|
||||
settings.value,
|
||||
receiptPrinter.paper.toIntegerFromText,
|
||||
order.orderType ?? "",
|
||||
outlet,
|
||||
productQuantity);
|
||||
await PrinterService()
|
||||
.printWithPrinter(receiptPrinter, printValue, context);
|
||||
} catch (e, stackTrace) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
e,
|
||||
stackTrace,
|
||||
reason: 'Print receipt failed',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
'Printer: ${receiptPrinter.name}',
|
||||
],
|
||||
);
|
||||
log("Error printing receipt order: $e");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error printing receipt order: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Receipt printer not found',
|
||||
null,
|
||||
reason:
|
||||
'Receipt printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer receipt')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (outlet.businessType == BusinessType.ticketing) {
|
||||
final ticketPrinter =
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('ticket');
|
||||
|
||||
final barcode = await generateBarcodeAsUint8List(order.orderNumber ?? "");
|
||||
|
||||
if (ticketPrinter != null) {
|
||||
try {
|
||||
final printValue = await PrintDataoutputs.instance.printTicket(
|
||||
order.totalAmount ?? 0,
|
||||
barcode,
|
||||
ticketPrinter.paper.toIntegerFromText,
|
||||
);
|
||||
|
||||
await PrinterService()
|
||||
// ignore: use_build_context_synchronously
|
||||
.printWithPrinter(ticketPrinter, printValue, context);
|
||||
} catch (e, stackTrace) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
e,
|
||||
stackTrace,
|
||||
reason: 'Error printing ticket ${ticketPrinter.name}',
|
||||
information: [
|
||||
'Printer: ticket',
|
||||
'data: ${ticketPrinter.toMap()}',
|
||||
],
|
||||
);
|
||||
log("Error printing ticket: $e");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error printing ticket: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Ticket printer not found',
|
||||
null,
|
||||
reason:
|
||||
'Ticket printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer ticket')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onPrintRecipt(
|
||||
context, {
|
||||
required Order order,
|
||||
@@ -372,6 +481,56 @@ Future<void> onPrinVoidRecipt(
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onPrintSplit(
|
||||
context, {
|
||||
required Order order,
|
||||
}) async {
|
||||
final receiptPrinter =
|
||||
await PrinterLocalDatasource.instance.getPrinterByCode('receipt');
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final settings = await SettingsLocalDatasource().getTax();
|
||||
final outlet = await OutletLocalDatasource().get();
|
||||
|
||||
if (receiptPrinter != null) {
|
||||
try {
|
||||
final printValue = await PrintDataoutputs.instance.printSplitBill(
|
||||
order,
|
||||
authData.user?.name ?? "",
|
||||
receiptPrinter.paper.toIntegerFromText,
|
||||
outlet,
|
||||
);
|
||||
await PrinterService()
|
||||
.printWithPrinter(receiptPrinter, printValue, context);
|
||||
} catch (e, stackTrace) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
e,
|
||||
stackTrace,
|
||||
reason: 'Print receipt failed',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
'Printer: ${receiptPrinter.name}',
|
||||
],
|
||||
);
|
||||
log("Error printing receipt order: $e");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error printing receipt order: $e')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Kitchen printer not found',
|
||||
null,
|
||||
reason: 'Kitchen printer not found / Printer not setting in printer page',
|
||||
information: [
|
||||
'Order ID: ${order.id}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Anda belum menghubungkan printer kitchen')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Uint8List> generateBarcodeAsUint8List(String data) async {
|
||||
// 1. Buat barcode instance (code128, qrCode, dll)
|
||||
final barcode = Barcode.code128();
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'package:awesome_dio_interceptor/awesome_dio_interceptor.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:enaklo_pos/core/constants/variables.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/auth_response_model.dart';
|
||||
import 'package:enaklo_pos/presentation/auth/login_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -124,13 +127,17 @@ class AuthInterceptorWithRefresh extends Interceptor {
|
||||
Future<bool> _tryRefreshToken() async {
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final refreshToken = prefs.getString('refresh_token');
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
|
||||
if (refreshToken == null) return false;
|
||||
final url = '${Variables.baseUrl}/api/v1/auth/refresh';
|
||||
|
||||
final response = await Dio().post(
|
||||
'YOUR_REFRESH_TOKEN_ENDPOINT',
|
||||
data: {'refresh_token': refreshToken},
|
||||
url,
|
||||
options: Options(
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${authData.refreshToken}',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -140,6 +147,11 @@ class AuthInterceptorWithRefresh extends Interceptor {
|
||||
await prefs.setString('auth_token', newToken);
|
||||
await prefs.setString('refresh_token', newRefreshToken);
|
||||
|
||||
AuthResponseModel authResponseModel =
|
||||
AuthResponseModel.fromMap(response.data['data']);
|
||||
|
||||
AuthLocalDataSource().saveAuthData(authResponseModel);
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:enaklo_pos/core/utils/helper_pdf_service.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/inventory_analytic_response_model.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
|
||||
@@ -4,12 +4,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_esc_pos_network/flutter_esc_pos_network.dart';
|
||||
import 'package:print_bluetooth_thermal/print_bluetooth_thermal.dart';
|
||||
import 'package:enaklo_pos/data/models/response/print_model.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
|
||||
class PrinterService {
|
||||
static final PrinterService _instance = PrinterService._internal();
|
||||
factory PrinterService() => _instance;
|
||||
PrinterService._internal();
|
||||
|
||||
final Map<String, Lock> _locks = {};
|
||||
String? _connectedMac;
|
||||
|
||||
/// Connect to Bluetooth printer
|
||||
Future<bool> connectBluetoothPrinter(String macAddress) async {
|
||||
try {
|
||||
@@ -56,6 +60,71 @@ class PrinterService {
|
||||
}
|
||||
}
|
||||
|
||||
Lock _getLock(String address) {
|
||||
return _locks.putIfAbsent(address, () => Lock());
|
||||
}
|
||||
|
||||
Future<bool> printWithPrinter(
|
||||
PrintModel printer, List<int> printData, BuildContext context) async {
|
||||
if (printer.type == 'Bluetooth') {
|
||||
return await _getLock(printer.address).synchronized(() async {
|
||||
try {
|
||||
bool isConnected = await PrintBluetoothThermal.connectionStatus;
|
||||
if (!isConnected || _connectedMac != printer.address) {
|
||||
if (isConnected) {
|
||||
await PrintBluetoothThermal.disconnect;
|
||||
await Future.delayed(const Duration(milliseconds: 1500));
|
||||
}
|
||||
bool connected = await PrintBluetoothThermal.connect(
|
||||
macPrinterAddress: printer.address);
|
||||
if (!connected) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Gagal connect ke ${printer.name}')),
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_connectedMac = printer.address;
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 1000)); // naikkan dari 500ms
|
||||
}
|
||||
|
||||
bool result = await _writeBytesChunked(printData);
|
||||
|
||||
// Beri waktu printer flush sebelum job berikutnya
|
||||
await Future.delayed(const Duration(milliseconds: 1000));
|
||||
|
||||
log("Print result ${printer.name}: $result");
|
||||
return result;
|
||||
} catch (e, stackTrace) {
|
||||
_connectedMac = null;
|
||||
FirebaseCrashlytics.instance.recordError(e, stackTrace,
|
||||
reason: 'Error printing ${printer.name}',
|
||||
information: [
|
||||
'Printer: ${printer.name}',
|
||||
'MAC: ${printer.address}'
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return await printNetwork(printer, printData, context);
|
||||
}
|
||||
}
|
||||
|
||||
// Kirim data per chunk untuk hindari buffer overflow Bluetooth
|
||||
Future<bool> _writeBytesChunked(List<int> data, {int chunkSize = 512}) async {
|
||||
for (int i = 0; i < data.length; i += chunkSize) {
|
||||
final end = (i + chunkSize > data.length) ? data.length : i + chunkSize;
|
||||
final chunk = data.sublist(i, end);
|
||||
bool result = await PrintBluetoothThermal.writeBytes(chunk);
|
||||
if (!result) return false;
|
||||
await Future.delayed(const Duration(milliseconds: 30));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Print using Bluetooth printer
|
||||
Future<bool> printBluetooth(List<int> printData) async {
|
||||
try {
|
||||
@@ -99,17 +168,18 @@ class PrinterService {
|
||||
}
|
||||
|
||||
/// Print using Network printer
|
||||
Future<bool> printNetwork(String ipAddress, List<int> printData) async {
|
||||
Future<bool> printNetwork(
|
||||
PrintModel printer, List<int> printData, BuildContext context) async {
|
||||
try {
|
||||
final printer = PrinterNetworkManager(ipAddress);
|
||||
PosPrintResult connect = await printer.connect();
|
||||
final networkPrinter = PrinterNetworkManager(printer.address);
|
||||
PosPrintResult connect = await networkPrinter.connect();
|
||||
|
||||
if (connect == PosPrintResult.success) {
|
||||
PosPrintResult printing = await printer.printTicket(printData);
|
||||
printer.disconnect();
|
||||
PosPrintResult printing = await networkPrinter.printTicket(printData);
|
||||
networkPrinter.disconnect();
|
||||
|
||||
if (printing == PosPrintResult.success) {
|
||||
log("Successfully printed via Network printer: $ipAddress");
|
||||
log("Successfully printed via Network printer: ${printer.address}");
|
||||
return true;
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
@@ -117,28 +187,34 @@ class PrinterService {
|
||||
null,
|
||||
reason: 'Failed to print via Network printer',
|
||||
information: [
|
||||
'function: printNetwork(String ipAddress, List<int> printData)',
|
||||
'Printer: Network printer',
|
||||
'ipAddress: $ipAddress',
|
||||
'printData: $printData',
|
||||
'Printer: ${printer.name}',
|
||||
'ipAddress: ${printer.address}',
|
||||
],
|
||||
);
|
||||
log("Failed to print via Network printer: ${printing.msg}");
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Gagal print ke ${printer.name}')),
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Failed to connect to Network printer: ${connect.msg}',
|
||||
null,
|
||||
reason: 'Failed to connectNetwork printer',
|
||||
reason: 'Failed to connect Network printer',
|
||||
information: [
|
||||
'function: printNetwork(String ipAddress, List<int> printData)',
|
||||
'Printer: Network printer',
|
||||
'ipAddress: $ipAddress',
|
||||
'printData: $printData',
|
||||
'Printer: ${printer.name}',
|
||||
'ipAddress: ${printer.address}',
|
||||
],
|
||||
);
|
||||
log("Failed to connect to Network printer: ${connect.msg}");
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Gagal connect ke ${printer.name}')),
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
@@ -147,10 +223,8 @@ class PrinterService {
|
||||
stackTrace,
|
||||
reason: 'Error printing via Network',
|
||||
information: [
|
||||
'function: printNetwork(String ipAddress, List<int> printData)',
|
||||
'Printer: Network printer',
|
||||
'ipAddress: $ipAddress',
|
||||
'printData: $printData',
|
||||
'Printer: ${printer.name}',
|
||||
'ipAddress: ${printer.address}',
|
||||
],
|
||||
);
|
||||
log("Error printing via Network: $e");
|
||||
@@ -158,81 +232,6 @@ class PrinterService {
|
||||
}
|
||||
}
|
||||
|
||||
/// Print with automatic printer type detection
|
||||
Future<bool> printWithPrinter(
|
||||
PrintModel printer, List<int> printData, BuildContext context) async {
|
||||
try {
|
||||
if (printer.type == 'Bluetooth') {
|
||||
bool connected = await connectBluetoothPrinter(printer.address);
|
||||
if (!connected) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Failed to connect to Bluetooth printer',
|
||||
null,
|
||||
reason: 'Failed to connect to Bluetooth printe',
|
||||
information: [
|
||||
'function: connectBluetoothPrinter(String macAddress)',
|
||||
'Printer: ${printer.name}',
|
||||
'macAddress: ${printer.address}',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to connect to ${printer.name}')),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool printResult = await printBluetooth(printData);
|
||||
if (!printResult) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Failed to print to ${printer.name}',
|
||||
null,
|
||||
information: [
|
||||
'function: await printBluetooth(printData);',
|
||||
'print: $printData',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to print to ${printer.name}')),
|
||||
);
|
||||
}
|
||||
return printResult;
|
||||
} else {
|
||||
bool printResult = await printNetwork(printer.address, printData);
|
||||
if (!printResult) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
'Failed to connect to Network Printer',
|
||||
null,
|
||||
reason: 'Failed to connect to Network Printer',
|
||||
information: [
|
||||
'function: await printNetwork(printer.address, printData);',
|
||||
'Printer: ${printer.name}',
|
||||
'ipAddress: ${printer.address}',
|
||||
'print: $printData',
|
||||
],
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to print to ${printer.name}')),
|
||||
);
|
||||
}
|
||||
return printResult;
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
e,
|
||||
stackTrace,
|
||||
reason: 'Error printing with printer ${printer.name}',
|
||||
information: [
|
||||
'Printer: ${printer.name}',
|
||||
],
|
||||
);
|
||||
log("Error printing with printer ${printer.name}: $e");
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error printing to ${printer.name}: $e')),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Disconnect from Bluetooth printer
|
||||
Future<bool> disconnectBluetooth() async {
|
||||
try {
|
||||
|
||||
@@ -882,6 +882,20 @@ class PrintDataoutputs {
|
||||
styles: const PosStyles(bold: true, align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
if (product.notes != '') {
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Note',
|
||||
width: 4,
|
||||
styles: const PosStyles(bold: false, align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: product.notes,
|
||||
width: 8,
|
||||
styles: const PosStyles(bold: false, align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
@@ -1398,141 +1412,7 @@ class PrintDataoutputs {
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
paper == 80 ? bytes += generator.feed(3) : bytes += generator.feed(1);
|
||||
//cut
|
||||
if (paper == 80) {
|
||||
bytes += generator.cut();
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Future<List<int>> printKitchen(
|
||||
List<ProductQuantity> products,
|
||||
String tableNumber,
|
||||
String draftName,
|
||||
String cashierName,
|
||||
String customerName,
|
||||
int paper,
|
||||
String orderType) async {
|
||||
List<int> bytes = [];
|
||||
|
||||
final profile = await CapabilityProfile.load();
|
||||
final generator =
|
||||
Generator(paper == 58 ? PaperSize.mm58 : PaperSize.mm80, profile);
|
||||
|
||||
bytes += generator.reset();
|
||||
|
||||
bytes += generator.text('Table Kitchen',
|
||||
styles: const PosStyles(
|
||||
bold: true,
|
||||
align: PosAlign.center,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size2,
|
||||
));
|
||||
bytes += generator.feed(1);
|
||||
if (tableNumber.isNotEmpty) {
|
||||
bytes += generator.text(tableNumber,
|
||||
styles: const PosStyles(
|
||||
bold: true,
|
||||
align: PosAlign.center,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size2,
|
||||
));
|
||||
bytes += generator.feed(1);
|
||||
}
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Date',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
// bytes += generator.text(
|
||||
// 'Date: ${DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now())}',
|
||||
// styles: const PosStyles(bold: false, align: PosAlign.left));
|
||||
//reciept number
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Receipt',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: DateFormat('yyyyMMddhhmm').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Cashier',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: cashierName,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: '$customerName - $draftName',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: orderType,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right, bold: true),
|
||||
),
|
||||
]);
|
||||
|
||||
//----
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
bytes += generator.feed(1);
|
||||
final kitchenProducts =
|
||||
products.where((p) => p.product.printerType == 'kitchen');
|
||||
for (final product in kitchenProducts) {
|
||||
bytes += generator.text('${product.quantity} x ${product.product.name}',
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.left,
|
||||
bold: false,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size1,
|
||||
));
|
||||
if (product.notes.isNotEmpty) {
|
||||
bytes += generator.text(' Notes: ${product.notes}',
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.left,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1,
|
||||
fontType: PosFontType.fontA,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
bytes += generator.feed(1);
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
paper == 80 ? bytes += generator.feed(3) : bytes += generator.feed(1);
|
||||
//cut
|
||||
if (paper == 80) {
|
||||
bytes += generator.cut();
|
||||
}
|
||||
bytes += generator.cut();
|
||||
|
||||
return bytes;
|
||||
}
|
||||
@@ -1662,9 +1542,7 @@ class PrintDataoutputs {
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
paper == 80 ? bytes += generator.feed(3) : bytes += generator.feed(1);
|
||||
//cut
|
||||
if (paper == 80) {
|
||||
bytes += generator.cut();
|
||||
}
|
||||
bytes += generator.cut();
|
||||
|
||||
return bytes;
|
||||
}
|
||||
@@ -1703,4 +1581,520 @@ class PrintDataoutputs {
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Future<List<int>> printKitchenAllItem(
|
||||
List<ProductQuantity> products,
|
||||
String tableNumber,
|
||||
String draftName,
|
||||
String cashierName,
|
||||
String customerName,
|
||||
int paper,
|
||||
String orderType) async {
|
||||
List<int> bytes = [];
|
||||
|
||||
final profile = await CapabilityProfile.load();
|
||||
final generator =
|
||||
Generator(paper == 58 ? PaperSize.mm58 : PaperSize.mm80, profile);
|
||||
|
||||
bytes += generator.reset();
|
||||
|
||||
bytes += generator.text('Table Kitchen',
|
||||
styles: const PosStyles(
|
||||
bold: true,
|
||||
align: PosAlign.center,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size2,
|
||||
));
|
||||
bytes += generator.feed(1);
|
||||
if (tableNumber.isNotEmpty) {
|
||||
bytes += generator.text(tableNumber,
|
||||
styles: const PosStyles(
|
||||
bold: true,
|
||||
align: PosAlign.center,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size2,
|
||||
));
|
||||
bytes += generator.feed(1);
|
||||
}
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Date',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
// bytes += generator.text(
|
||||
// 'Date: ${DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now())}',
|
||||
// styles: const PosStyles(bold: false, align: PosAlign.left));
|
||||
//reciept number
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Receipt',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: DateFormat('yyyyMMddhhmm').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Cashier',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: cashierName,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: '$customerName - $draftName',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: orderType,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right, bold: true),
|
||||
),
|
||||
]);
|
||||
|
||||
//----
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
bytes += generator.feed(1);
|
||||
final kitchenProducts =
|
||||
products.where((p) => p.product.printerType == 'kitchen');
|
||||
for (final product in kitchenProducts) {
|
||||
bytes += generator.text('${product.quantity} x ${product.product.name}',
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.left,
|
||||
bold: false,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size1,
|
||||
));
|
||||
if (product.notes.isNotEmpty) {
|
||||
bytes += generator.text(' Notes: ${product.notes}',
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.left,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1,
|
||||
fontType: PosFontType.fontA,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
bytes += generator.feed(1);
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
paper == 80 ? bytes += generator.feed(3) : bytes += generator.feed(1);
|
||||
bytes += generator.cut();
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Future<List<int>> printKitchenPerProduct(
|
||||
List<ProductQuantity> products,
|
||||
String tableNumber,
|
||||
String draftName,
|
||||
String cashierName,
|
||||
String customerName,
|
||||
int paper,
|
||||
String orderType) async {
|
||||
List<int> allBytes = [];
|
||||
|
||||
final profile = await CapabilityProfile.load();
|
||||
final generator =
|
||||
Generator(paper == 58 ? PaperSize.mm58 : PaperSize.mm80, profile);
|
||||
|
||||
// Loop untuk setiap produk - print terpisah
|
||||
for (final product in products) {
|
||||
List<int> bytes = [];
|
||||
|
||||
bytes += generator.reset();
|
||||
|
||||
bytes += generator.text('Table Kitchen',
|
||||
styles: const PosStyles(
|
||||
bold: true,
|
||||
align: PosAlign.center,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size2,
|
||||
));
|
||||
bytes += generator.feed(1);
|
||||
|
||||
if (tableNumber.isNotEmpty) {
|
||||
bytes += generator.text(tableNumber,
|
||||
styles: const PosStyles(
|
||||
bold: true,
|
||||
align: PosAlign.center,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size2,
|
||||
));
|
||||
bytes += generator.feed(1);
|
||||
}
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: DateFormat('dd MMM yyyy').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: DateFormat('HH:mm').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: draftName,
|
||||
width: 8,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: '',
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: customerName,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: orderType,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right, bold: true),
|
||||
),
|
||||
]);
|
||||
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
bytes += generator.feed(1);
|
||||
|
||||
// Print hanya 1 produk per struk
|
||||
bytes += generator.text('${product.quantity} x ${product.product.name}',
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.left,
|
||||
bold: false,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size1,
|
||||
));
|
||||
|
||||
if (product.notes.isNotEmpty) {
|
||||
bytes += generator.text(' Notes: ${product.notes}',
|
||||
styles: const PosStyles(
|
||||
align: PosAlign.left,
|
||||
bold: false,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1,
|
||||
fontType: PosFontType.fontA,
|
||||
));
|
||||
}
|
||||
|
||||
bytes += generator.feed(1);
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
|
||||
paper == 80 ? bytes += generator.feed(3) : bytes += generator.feed(2);
|
||||
|
||||
bytes += generator.cut();
|
||||
|
||||
// Tambahkan ke allBytes
|
||||
allBytes += bytes;
|
||||
}
|
||||
|
||||
return allBytes;
|
||||
}
|
||||
|
||||
Future<List<int>> printSplitBill(
|
||||
Order order,
|
||||
String chashierName,
|
||||
int paper,
|
||||
Outlet outlet,
|
||||
) async {
|
||||
List<int> bytes = [];
|
||||
|
||||
final profile = await CapabilityProfile.load();
|
||||
final generator =
|
||||
Generator(paper == 58 ? PaperSize.mm58 : PaperSize.mm80, profile);
|
||||
|
||||
bytes += generator.reset();
|
||||
|
||||
bytes += generator.text(outlet.name ?? "",
|
||||
styles: const PosStyles(
|
||||
bold: true,
|
||||
align: PosAlign.center,
|
||||
height: PosTextSize.size1,
|
||||
width: PosTextSize.size1,
|
||||
));
|
||||
|
||||
bytes += generator.text(outlet.address ?? "",
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
bytes += generator.text(outlet.phoneNumber ?? "",
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: DateFormat('dd MMM yyyy').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: DateFormat('HH:mm').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Receipt Number',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: DateFormat('yyyyMMddhhmm').format(DateTime.now()),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Order ID',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: Random().nextInt(100000).toString(),
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Bill Name',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: order.metadata?['customer_name'] ?? '',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Collected By',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: chashierName,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
if (order.payments != null) {
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Payment',
|
||||
width: 8,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: order.payments?.last.paymentMethodName ?? '-',
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
bytes += generator.text(order.orderType ?? '-',
|
||||
styles: const PosStyles(bold: true, align: PosAlign.center));
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
bytes += generator.text("SPLIT",
|
||||
styles: const PosStyles(bold: true, align: PosAlign.center));
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
|
||||
for (final item in (order.orderItems ?? <OrderItem>[])) {
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: '${item.quantity} x ${item.productName}',
|
||||
width: 8,
|
||||
styles: const PosStyles(bold: true, align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: (((item.unitPrice ?? 0) * (item.quantity ?? 0)))
|
||||
.currencyFormatRpV2,
|
||||
width: 4,
|
||||
styles: const PosStyles(bold: true, align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
if (item.notes != '') {
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Note',
|
||||
width: 4,
|
||||
styles: const PosStyles(bold: false, align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: item.notes ?? "-",
|
||||
width: 8,
|
||||
styles: const PosStyles(bold: false, align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (order.orderItems?.isNotEmpty ?? false) {
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
}
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Subtotal',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: order.payments?.last.amount?.currencyFormatRpV2 ?? '-',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Discount',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: (order.discountAmount ?? 0).currencyFormatRpV2,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
|
||||
// Only show tax if it's greater than 0
|
||||
if ((order.taxAmount ?? 0) > 0) {
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Tax PB1 (${order.taxAmount}%)',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: (order.taxAmount ?? 0).currencyFormatRpV2,
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
// Only show service charge if it's greater than 0
|
||||
// if (serviceCharge > 0) {
|
||||
// bytes += generator.row([
|
||||
// PosColumn(
|
||||
// text: 'Service Charge($serviceChargePercentage%)',
|
||||
// width: 6,
|
||||
// styles: const PosStyles(align: PosAlign.left),
|
||||
// ),
|
||||
// PosColumn(
|
||||
// text: serviceCharge.currencyFormatRpV2,
|
||||
// width: 6,
|
||||
// styles: const PosStyles(align: PosAlign.right),
|
||||
// ),
|
||||
// ]);
|
||||
// }
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Total',
|
||||
width: 6,
|
||||
styles: const PosStyles(bold: true, align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: order.payments?.last.amount?.currencyFormatRpV2 ?? '-',
|
||||
width: 6,
|
||||
styles: const PosStyles(bold: true, align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.row([
|
||||
PosColumn(
|
||||
text: 'Dibayar',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.left),
|
||||
),
|
||||
PosColumn(
|
||||
text: order.payments?.last.amount?.currencyFormatRpV2 ?? '-',
|
||||
width: 6,
|
||||
styles: const PosStyles(align: PosAlign.right),
|
||||
),
|
||||
]);
|
||||
bytes += generator.text(
|
||||
paper == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
paper == 80 ? bytes += generator.feed(3) : bytes += generator.feed(1);
|
||||
bytes += generator.cut();
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class CategoryLocalDatasource {
|
||||
whereArgs.add('%$search%');
|
||||
}
|
||||
|
||||
query += ' ORDER BY name ASC';
|
||||
// query += ' ORDER BY name ASC';
|
||||
|
||||
if (limit > 0) {
|
||||
query += ' LIMIT ?';
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ import 'dart:developer';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:enaklo_pos/core/network/dio_client.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/settings_local_datasource.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||
import 'package:enaklo_pos/presentation/setting/models/tax_model.dart';
|
||||
import '../../core/constants/variables.dart';
|
||||
import 'auth_local_datasource.dart';
|
||||
import '../../../core/constants/variables.dart';
|
||||
import '../auth_local_datasource.dart';
|
||||
|
||||
class OutletRemoteDataSource {
|
||||
final Dio dio = DioClient.instance;
|
||||
@@ -2,9 +2,11 @@ import 'dart:convert';
|
||||
|
||||
class AuthResponseModel {
|
||||
final String? token;
|
||||
final String? refreshToken;
|
||||
final User? user;
|
||||
|
||||
AuthResponseModel({
|
||||
this.refreshToken,
|
||||
this.token,
|
||||
this.user,
|
||||
});
|
||||
@@ -17,11 +19,13 @@ class AuthResponseModel {
|
||||
factory AuthResponseModel.fromMap(Map<String, dynamic> json) =>
|
||||
AuthResponseModel(
|
||||
token: json["token"],
|
||||
refreshToken: json["refresh_token"],
|
||||
user: json["user"] == null ? null : User.fromMap(json["user"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"token": token,
|
||||
"refresh_token": refreshToken,
|
||||
"user": user?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -117,4 +117,14 @@ class CategoryModel {
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
factory CategoryModel.all() => CategoryModel(
|
||||
id: 'all',
|
||||
organizationId: '',
|
||||
name: 'Semua',
|
||||
businessType: 'restaurant',
|
||||
metadata: {},
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -401,3 +401,103 @@ extension OrderItemListExtension on List<OrderItem> {
|
||||
quantity: e.quantity ?? 0,
|
||||
)).toList();
|
||||
}
|
||||
|
||||
extension OrderCopyWith on Order {
|
||||
Order copyWith({
|
||||
String? id,
|
||||
String? orderNumber,
|
||||
String? outletId,
|
||||
String? userId,
|
||||
String? tableNumber,
|
||||
String? orderType,
|
||||
String? status,
|
||||
int? subtotal,
|
||||
int? taxAmount,
|
||||
int? discountAmount,
|
||||
int? totalAmount,
|
||||
num? totalCost,
|
||||
int? remainingAmount,
|
||||
String? paymentStatus,
|
||||
int? refundAmount,
|
||||
bool? isVoid,
|
||||
bool? isRefund,
|
||||
String? notes,
|
||||
Map<String, dynamic>? metadata,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
List<OrderItem>? orderItems,
|
||||
List<Payment>? payments,
|
||||
int? totalPaid,
|
||||
int? paymentCount,
|
||||
String? splitType,
|
||||
}) {
|
||||
return Order(
|
||||
id: id ?? this.id,
|
||||
orderNumber: orderNumber ?? this.orderNumber,
|
||||
outletId: outletId ?? this.outletId,
|
||||
userId: userId ?? this.userId,
|
||||
tableNumber: tableNumber ?? this.tableNumber,
|
||||
orderType: orderType ?? this.orderType,
|
||||
status: status ?? this.status,
|
||||
subtotal: subtotal ?? this.subtotal,
|
||||
taxAmount: taxAmount ?? this.taxAmount,
|
||||
discountAmount: discountAmount ?? this.discountAmount,
|
||||
totalAmount: totalAmount ?? this.totalAmount,
|
||||
totalCost: totalCost ?? this.totalCost,
|
||||
remainingAmount: remainingAmount ?? this.remainingAmount,
|
||||
paymentStatus: paymentStatus ?? this.paymentStatus,
|
||||
refundAmount: refundAmount ?? this.refundAmount,
|
||||
isVoid: isVoid ?? this.isVoid,
|
||||
isRefund: isRefund ?? this.isRefund,
|
||||
notes: notes ?? this.notes,
|
||||
metadata: metadata ?? this.metadata,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
orderItems: orderItems ?? this.orderItems,
|
||||
payments: payments ?? this.payments,
|
||||
totalPaid: totalPaid ?? this.totalPaid,
|
||||
paymentCount: paymentCount ?? this.paymentCount,
|
||||
splitType: splitType ?? this.splitType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension OrderItemCopyWith on OrderItem {
|
||||
OrderItem copyWith({
|
||||
String? id,
|
||||
String? orderId,
|
||||
String? productId,
|
||||
String? productName,
|
||||
String? productVariantId,
|
||||
String? productVariantName,
|
||||
int? quantity,
|
||||
int? unitPrice,
|
||||
int? totalPrice,
|
||||
List<dynamic>? modifiers,
|
||||
String? notes,
|
||||
String? status,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
String? printerType,
|
||||
int? paidQuantity,
|
||||
}) {
|
||||
return OrderItem(
|
||||
id: id ?? this.id,
|
||||
orderId: orderId ?? this.orderId,
|
||||
productId: productId ?? this.productId,
|
||||
productName: productName ?? this.productName,
|
||||
productVariantId: productVariantId ?? this.productVariantId,
|
||||
productVariantName: productVariantName ?? this.productVariantName,
|
||||
quantity: quantity ?? this.quantity,
|
||||
unitPrice: unitPrice ?? this.unitPrice,
|
||||
totalPrice: totalPrice ?? this.totalPrice,
|
||||
modifiers: modifiers ?? this.modifiers,
|
||||
notes: notes ?? this.notes,
|
||||
status: status ?? this.status,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
printerType: printerType ?? this.printerType,
|
||||
paidQuantity: paidQuantity ?? this.paidQuantity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,4 +282,16 @@ class CategoryRepository {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> clearAllCategories() async {
|
||||
try {
|
||||
log('🗑️ Clearing all categories from repository...');
|
||||
await _localDatasource.clearAllCategories();
|
||||
clearCache();
|
||||
log('✅ All categories cleared successfully');
|
||||
} catch (e) {
|
||||
log('❌ Error clearing all categories: $e');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import 'dart:developer';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:enaklo_pos/data/datasources/product/product_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/product_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/product_response_model.dart';
|
||||
|
||||
class ProductRepository {
|
||||
static ProductRepository? _instance;
|
||||
|
||||
final ProductLocalDatasource _localDatasource;
|
||||
final ProductRemoteDatasource _remoteDatasource;
|
||||
|
||||
ProductRepository._internal()
|
||||
: _localDatasource = ProductLocalDatasource.instance;
|
||||
: _localDatasource = ProductLocalDatasource.instance,
|
||||
_remoteDatasource = ProductRemoteDatasource();
|
||||
|
||||
static ProductRepository get instance {
|
||||
_instance ??= ProductRepository._internal();
|
||||
@@ -85,6 +88,66 @@ class ProductRepository {
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// PRODUCT SYNC OPERATIONS
|
||||
// ========================================
|
||||
Future<Either<String, String>> syncAllProducts() async {
|
||||
try {
|
||||
log('🔄 Starting manual sync of all products...');
|
||||
|
||||
int page = 1;
|
||||
const limit = 50; // Higher limit for bulk sync
|
||||
bool hasMore = true;
|
||||
int totalSynced = 0;
|
||||
|
||||
// Clear local data first for fresh sync
|
||||
await _localDatasource.clearAllProducts();
|
||||
|
||||
while (hasMore) {
|
||||
log('📄 Syncing page $page...');
|
||||
|
||||
final result = await _remoteDatasource.getProducts(
|
||||
page: page,
|
||||
limit: limit,
|
||||
);
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
log('❌ Sync failed at page $page: $failure');
|
||||
throw Exception(failure);
|
||||
},
|
||||
(response) async {
|
||||
final products = response.data?.products ?? [];
|
||||
|
||||
if (products.isNotEmpty) {
|
||||
await _localDatasource.saveProductsBatch(
|
||||
products,
|
||||
clearFirst: false, // Don't clear on subsequent pages
|
||||
);
|
||||
totalSynced += products.length;
|
||||
|
||||
// Check if we have more pages
|
||||
hasMore = page < (response.data?.totalPages ?? 0);
|
||||
page++;
|
||||
|
||||
log('📦 Page $page synced: ${products.length} products');
|
||||
} else {
|
||||
hasMore = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
final message = 'Berhasil sinkronisasi $totalSynced produk';
|
||||
log('✅ $message');
|
||||
return Right(message);
|
||||
} catch (e) {
|
||||
final error = 'Gagal sinkronisasi produk: $e';
|
||||
log('❌ $error');
|
||||
return Left(error);
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// LOCAL DATABASE OPERATIONS
|
||||
// ========================================
|
||||
@@ -142,4 +205,16 @@ class ProductRepository {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> clearAllProducts() async {
|
||||
try {
|
||||
log('🗑️ Clearing all products from repository...');
|
||||
await _localDatasource.clearAllProducts();
|
||||
clearCache();
|
||||
log('✅ All products cleared successfully');
|
||||
} catch (e) {
|
||||
log('❌ Error clearing all products: $e');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import 'package:enaklo_pos/core/network/dio_client.dart';
|
||||
import 'package:enaklo_pos/data/datasources/analytic_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/customer_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/file_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/data/datasources/table_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/user_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/presentation/customer/bloc/customer_form/customer_form_bloc.dart';
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'dart:async';
|
||||
import 'dart:developer';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/product/product_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/category/category_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/repositories/category/category_repository.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import '../../../data/datasources/product_remote_datasource.dart';
|
||||
|
||||
@@ -9,7 +11,7 @@ part 'data_sync_event.dart';
|
||||
part 'data_sync_state.dart';
|
||||
part 'data_sync_bloc.freezed.dart';
|
||||
|
||||
enum SyncStep { products, categories, variants, completed }
|
||||
enum SyncStep { categories, products, variants, completed }
|
||||
|
||||
class SyncStats {
|
||||
final int totalProducts;
|
||||
@@ -26,9 +28,13 @@ class SyncStats {
|
||||
}
|
||||
|
||||
class DataSyncBloc extends Bloc<DataSyncEvent, DataSyncState> {
|
||||
final ProductRemoteDatasource _remoteDatasource = ProductRemoteDatasource();
|
||||
final ProductLocalDatasource _localDatasource =
|
||||
final ProductRemoteDatasource _productRemoteDatasource =
|
||||
ProductRemoteDatasource();
|
||||
final ProductLocalDatasource _productLocalDatasource =
|
||||
ProductLocalDatasource.instance;
|
||||
final CategoryLocalDatasource _categoryLocalDatasource =
|
||||
CategoryLocalDatasource.instance;
|
||||
final CategoryRepository _categoryRepository = CategoryRepository.instance;
|
||||
|
||||
Timer? _progressTimer;
|
||||
bool _isCancelled = false;
|
||||
@@ -48,36 +54,75 @@ class DataSyncBloc extends Bloc<DataSyncEvent, DataSyncState> {
|
||||
_StartSync event,
|
||||
Emitter<DataSyncState> emit,
|
||||
) async {
|
||||
log('🔄 Starting data sync...');
|
||||
log('🔄 Starting full data sync (categories + products)...');
|
||||
_isCancelled = false;
|
||||
|
||||
try {
|
||||
// Step 1: Clear existing local data
|
||||
emit(const DataSyncState.syncing(
|
||||
SyncStep.products, 0.1, 'Membersihkan data lama...'));
|
||||
await _localDatasource.clearAllProducts();
|
||||
SyncStep.categories, 0.05, 'Membersihkan data lama...'));
|
||||
|
||||
await _productLocalDatasource.clearAllProducts();
|
||||
await _categoryLocalDatasource.clearAllCategories();
|
||||
|
||||
if (_isCancelled) return;
|
||||
|
||||
// Step 2: Sync products
|
||||
// Step 2: Sync categories first (products depend on categories)
|
||||
await _syncCategories(emit);
|
||||
|
||||
if (_isCancelled) return;
|
||||
|
||||
// Step 3: Sync products
|
||||
await _syncProducts(emit);
|
||||
|
||||
if (_isCancelled) return;
|
||||
|
||||
// Step 3: Generate final stats
|
||||
// Step 4: Generate final stats
|
||||
emit(const DataSyncState.syncing(
|
||||
SyncStep.completed, 0.9, 'Menyelesaikan sinkronisasi...'));
|
||||
SyncStep.completed, 0.95, 'Menyelesaikan sinkronisasi...'));
|
||||
|
||||
final stats = await _generateSyncStats();
|
||||
|
||||
emit(DataSyncState.completed(stats));
|
||||
log('✅ Sync completed successfully');
|
||||
log('✅ Full sync completed successfully');
|
||||
} catch (e) {
|
||||
log('❌ Sync failed: $e');
|
||||
emit(DataSyncState.error('Gagal sinkronisasi: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _syncCategories(Emitter<DataSyncState> emit) async {
|
||||
log('📁 Syncing categories...');
|
||||
|
||||
emit(const DataSyncState.syncing(
|
||||
SyncStep.categories,
|
||||
0.1,
|
||||
'Mengunduh kategori...',
|
||||
));
|
||||
|
||||
try {
|
||||
// Use CategoryRepository sync method
|
||||
final result = await _categoryRepository.syncAllCategories();
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
throw Exception('Gagal sync kategori: $failure');
|
||||
},
|
||||
(successMessage) async {
|
||||
log('✅ Categories sync completed: $successMessage');
|
||||
emit(const DataSyncState.syncing(
|
||||
SyncStep.categories,
|
||||
0.2,
|
||||
'Kategori berhasil diunduh',
|
||||
));
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
log('❌ Category sync failed: $e');
|
||||
throw Exception('Gagal sync kategori: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _syncProducts(Emitter<DataSyncState> emit) async {
|
||||
log('📦 Syncing products...');
|
||||
|
||||
@@ -88,10 +133,10 @@ class DataSyncBloc extends Bloc<DataSyncEvent, DataSyncState> {
|
||||
bool shouldContinue = true;
|
||||
|
||||
while (!_isCancelled && shouldContinue) {
|
||||
// Calculate accurate progress based on total count
|
||||
// Calculate accurate progress (categories = 0.2, products = 0.2-0.9)
|
||||
double progress = 0.2;
|
||||
if (totalCount != null && (totalCount ?? 0) > 0) {
|
||||
progress = 0.2 + (totalSynced / (totalCount ?? 0)) * 0.6;
|
||||
progress = 0.2 + (totalSynced / (totalCount ?? 0)) * 0.7;
|
||||
}
|
||||
|
||||
emit(DataSyncState.syncing(
|
||||
@@ -102,7 +147,7 @@ class DataSyncBloc extends Bloc<DataSyncEvent, DataSyncState> {
|
||||
: 'Mengunduh produk... ($totalSynced produk)',
|
||||
));
|
||||
|
||||
final result = await _remoteDatasource.getProducts(
|
||||
final result = await _productRemoteDatasource.getProducts(
|
||||
page: page,
|
||||
limit: 50, // Bigger batch for sync
|
||||
);
|
||||
@@ -128,7 +173,7 @@ class DataSyncBloc extends Bloc<DataSyncEvent, DataSyncState> {
|
||||
}
|
||||
|
||||
// Save to local database in batches
|
||||
await _localDatasource.saveProductsBatch(products);
|
||||
await _productLocalDatasource.saveProductsBatch(products);
|
||||
|
||||
totalSynced += products.length;
|
||||
page++;
|
||||
@@ -154,8 +199,8 @@ class DataSyncBloc extends Bloc<DataSyncEvent, DataSyncState> {
|
||||
}
|
||||
|
||||
emit(DataSyncState.syncing(
|
||||
SyncStep.completed,
|
||||
0.8,
|
||||
SyncStep.products,
|
||||
0.9,
|
||||
'Produk berhasil diunduh ($totalSynced dari ${totalCount ?? totalSynced})',
|
||||
));
|
||||
|
||||
@@ -163,13 +208,15 @@ class DataSyncBloc extends Bloc<DataSyncEvent, DataSyncState> {
|
||||
}
|
||||
|
||||
Future<SyncStats> _generateSyncStats() async {
|
||||
final dbStats = await _localDatasource.getDatabaseStats();
|
||||
final productStats = await _productLocalDatasource.getDatabaseStats();
|
||||
final categoryStats = await _categoryLocalDatasource.getDatabaseStats();
|
||||
|
||||
return SyncStats(
|
||||
totalProducts: dbStats['total_products'] ?? 0,
|
||||
totalCategories: dbStats['total_categories'] ?? 0,
|
||||
totalVariants: dbStats['total_variants'] ?? 0,
|
||||
databaseSizeMB: dbStats['database_size_mb'] ?? 0.0,
|
||||
totalProducts: productStats['total_products'] ?? 0,
|
||||
totalCategories: categoryStats['total_categories'] ?? 0,
|
||||
totalVariants: productStats['total_variants'] ?? 0,
|
||||
databaseSizeMB: (productStats['database_size_mb'] ?? 0.0) +
|
||||
(categoryStats['database_size_mb'] ?? 0.0),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,20 +87,15 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
);
|
||||
}
|
||||
|
||||
// Portrait layout (original)
|
||||
// Portrait layout
|
||||
Widget _buildPortraitLayout(DataSyncState state, double screenHeight) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(24),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: screenHeight * 0.08), // Responsive spacing
|
||||
|
||||
// Header
|
||||
_buildHeader(false),
|
||||
|
||||
SizedBox(height: screenHeight * 0.08),
|
||||
|
||||
// Sync progress
|
||||
_buildHeader(false),
|
||||
SizedBox(height: screenHeight * 0.08),
|
||||
Expanded(
|
||||
child: state.when(
|
||||
initial: () => _buildInitialState(false),
|
||||
@@ -110,24 +105,20 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
error: (message) => _buildErrorState(message, false),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 20),
|
||||
|
||||
// Actions
|
||||
_buildActions(state),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Landscape layout (side by side)
|
||||
// Landscape layout
|
||||
Widget _buildLandscapeLayout(
|
||||
DataSyncState state, double screenWidth, double screenHeight) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 32, vertical: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
// Left side - Header and info
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
@@ -139,10 +130,7 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(width: 40),
|
||||
|
||||
// Right side - Sync progress
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
@@ -188,7 +176,7 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
),
|
||||
SizedBox(height: isLandscape ? 4 : 8),
|
||||
Text(
|
||||
'Mengunduh data terbaru ke perangkat',
|
||||
'Mengunduh kategori dan produk terbaru',
|
||||
style: TextStyle(
|
||||
fontSize: isLandscape ? 14 : 16,
|
||||
color: Colors.grey.shade600,
|
||||
@@ -319,8 +307,8 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
|
||||
Widget _buildStepIndicator(SyncStep currentStep, bool isLandscape) {
|
||||
final steps = [
|
||||
('Produk', SyncStep.products, Icons.inventory_2),
|
||||
('Kategori', SyncStep.categories, Icons.category),
|
||||
('Produk', SyncStep.products, Icons.inventory_2),
|
||||
('Variant', SyncStep.variants, Icons.tune),
|
||||
('Selesai', SyncStep.completed, Icons.check_circle),
|
||||
];
|
||||
@@ -551,11 +539,11 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
// Vertical layout for landscape
|
||||
Column(
|
||||
children: [
|
||||
_buildStatItem('Produk', '${stats.totalProducts}',
|
||||
Icons.inventory_2, Colors.blue, isLandscape),
|
||||
SizedBox(height: 8),
|
||||
_buildStatItem('Kategori', '${stats.totalCategories}',
|
||||
Icons.category, Colors.green, isLandscape),
|
||||
Icons.category, Colors.blue, isLandscape),
|
||||
SizedBox(height: 8),
|
||||
_buildStatItem('Produk', '${stats.totalProducts}',
|
||||
Icons.inventory_2, Colors.green, isLandscape),
|
||||
SizedBox(height: 8),
|
||||
_buildStatItem('Variant', '${stats.totalVariants}',
|
||||
Icons.tune, Colors.orange, isLandscape),
|
||||
@@ -566,10 +554,10 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildStatItem('Produk', '${stats.totalProducts}',
|
||||
Icons.inventory_2, Colors.blue, isLandscape),
|
||||
_buildStatItem('Kategori', '${stats.totalCategories}',
|
||||
Icons.category, Colors.green, isLandscape),
|
||||
Icons.category, Colors.blue, isLandscape),
|
||||
_buildStatItem('Produk', '${stats.totalProducts}',
|
||||
Icons.inventory_2, Colors.green, isLandscape),
|
||||
_buildStatItem('Variant', '${stats.totalVariants}',
|
||||
Icons.tune, Colors.orange, isLandscape),
|
||||
],
|
||||
@@ -765,10 +753,10 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
|
||||
IconData _getSyncIcon(SyncStep step) {
|
||||
switch (step) {
|
||||
case SyncStep.products:
|
||||
return Icons.inventory_2;
|
||||
case SyncStep.categories:
|
||||
return Icons.category;
|
||||
case SyncStep.products:
|
||||
return Icons.inventory_2;
|
||||
case SyncStep.variants:
|
||||
return Icons.tune;
|
||||
case SyncStep.completed:
|
||||
@@ -778,10 +766,10 @@ class _DataSyncPageState extends State<DataSyncPage>
|
||||
|
||||
String _getStepLabel(SyncStep step) {
|
||||
switch (step) {
|
||||
case SyncStep.products:
|
||||
return 'Mengunduh Produk';
|
||||
case SyncStep.categories:
|
||||
return 'Mengunduh Kategori';
|
||||
case SyncStep.products:
|
||||
return 'Mengunduh Produk';
|
||||
case SyncStep.variants:
|
||||
return 'Mengunduh Variant';
|
||||
case SyncStep.completed:
|
||||
|
||||
@@ -47,7 +47,7 @@ class CategoryLoaderBloc
|
||||
|
||||
final result = await _categoryRepository.getCategories(
|
||||
page: 1,
|
||||
limit: 10,
|
||||
limit: 50,
|
||||
isActive: event.isActive,
|
||||
search: event.search,
|
||||
forceRemote: event.forceRemote,
|
||||
@@ -59,9 +59,13 @@ class CategoryLoaderBloc
|
||||
emit(CategoryLoaderState.error(failure));
|
||||
},
|
||||
(response) async {
|
||||
final categories = response.data.categories;
|
||||
final categories = [
|
||||
CategoryModel.all(),
|
||||
...response.data.categories,
|
||||
];
|
||||
|
||||
final totalPages = response.data.totalPages;
|
||||
final hasReachedMax = categories.length < 10 || 1 >= totalPages;
|
||||
final hasReachedMax = categories.length < 50 || 1 >= totalPages;
|
||||
|
||||
log('✅ Categories loaded: ${categories.length}, hasReachedMax: $hasReachedMax');
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
|
||||
@@ -81,11 +81,11 @@ class _HomePageState extends State<HomePage> {
|
||||
context.read<CurrentOutletBloc>().add(CurrentOutletEvent.currentOutlet());
|
||||
}
|
||||
|
||||
void _refreshData() {
|
||||
log('🔄 Refreshing local data...');
|
||||
context.read<ProductLoaderBloc>().add(const ProductLoaderEvent.refresh());
|
||||
context.read<CategoryLoaderBloc>().add(const CategoryLoaderEvent.refresh());
|
||||
}
|
||||
// void _refreshData() {
|
||||
// log('🔄 Refreshing l ocal data...');
|
||||
// context.read<ProductLoaderBloc>().add(const ProductLoaderEvent.refresh());
|
||||
// context.read<CategoryLoaderBloc>().add(const CategoryLoaderEvent.refresh());
|
||||
// }
|
||||
|
||||
void onCategoryTap(int index) {
|
||||
searchController.clear();
|
||||
@@ -130,9 +130,6 @@ class _HomePageState extends State<HomePage> {
|
||||
backgroundColor: AppColors.white,
|
||||
body: Column(
|
||||
children: [
|
||||
// Simple local mode indicator
|
||||
_buildLocalIndicator(),
|
||||
|
||||
// Main content
|
||||
Expanded(
|
||||
child: Row(
|
||||
@@ -171,44 +168,6 @@ class _HomePageState extends State<HomePage> {
|
||||
);
|
||||
}
|
||||
|
||||
// Simple local mode indicator without sync
|
||||
Widget _buildLocalIndicator() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
color: Colors.blue.shade600,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.storage, color: Colors.white, size: 16),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Mode Lokal - Data tersimpan di perangkat',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Only refresh button
|
||||
InkWell(
|
||||
onTap: _refreshData,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Icon(Icons.refresh, color: Colors.white, size: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategoryLoadingState() {
|
||||
return Center(
|
||||
child: Column(
|
||||
@@ -269,6 +228,7 @@ class _HomePageState extends State<HomePage> {
|
||||
child: BlocBuilder<ProductLoaderBloc, ProductLoaderState>(
|
||||
builder: (context, productState) {
|
||||
return CategoryTabBar(
|
||||
key: ValueKey(categories.length),
|
||||
categories: categories,
|
||||
tabViews: categories.map((category) {
|
||||
return SizedBox(
|
||||
@@ -303,32 +263,25 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
// Simple home title
|
||||
Widget _buildSimpleHomeTitle() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(bottom: BorderSide(color: Colors.grey.shade200)),
|
||||
),
|
||||
child: HomeTitle(
|
||||
controller: searchController,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
searchQuery = value;
|
||||
});
|
||||
return HomeTitle(
|
||||
controller: searchController,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
searchQuery = value;
|
||||
});
|
||||
|
||||
// Fast local search
|
||||
Future.delayed(Duration(milliseconds: 200), () {
|
||||
if (value == searchController.text) {
|
||||
log('🔍 Local search: "$value"');
|
||||
context.read<ProductLoaderBloc>().add(
|
||||
ProductLoaderEvent.searchProduct(
|
||||
query: value,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
// Fast local search
|
||||
Future.delayed(Duration(milliseconds: 200), () {
|
||||
if (value == searchController.text) {
|
||||
log('🔍 Local search: "$value"');
|
||||
context.read<ProductLoaderBloc>().add(
|
||||
ProductLoaderEvent.searchProduct(
|
||||
query: value,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,36 @@ class _CategoryTabBarState extends State<CategoryTabBar>
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(CategoryTabBar oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
|
||||
// ✅ Update TabController when categories length changes
|
||||
if (oldWidget.categories.length != widget.categories.length) {
|
||||
_tabController.dispose();
|
||||
_tabController = TabController(
|
||||
length: widget.categories.length,
|
||||
vsync: this,
|
||||
initialIndex: 0, // Reset to first tab
|
||||
);
|
||||
|
||||
_tabController.addListener(() {
|
||||
if (_tabController.indexIsChanging) {
|
||||
if (_tabController.index == 0) {
|
||||
context.read<ProductLoaderBloc>().add(
|
||||
ProductLoaderEvent.getProduct(),
|
||||
);
|
||||
} else {
|
||||
selectedCategoryId = widget.categories[_tabController.index].id;
|
||||
context.read<ProductLoaderBloc>().add(
|
||||
ProductLoaderEvent.getProduct(categoryId: selectedCategoryId),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
@@ -49,48 +79,45 @@ class _CategoryTabBarState extends State<CategoryTabBar>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultTabController(
|
||||
length: widget.categories.length,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Material(
|
||||
elevation: 0,
|
||||
color: Colors.white,
|
||||
borderOnForeground: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
labelColor: AppColors.primary,
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
dividerColor: AppColors.primary,
|
||||
unselectedLabelColor: AppColors.primary,
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
indicatorWeight: 4,
|
||||
indicatorColor: AppColors.primary,
|
||||
tabs: widget.categories
|
||||
.map((category) => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Tab(text: category.name),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
// ✅ ini bagian penting
|
||||
child: TabBarView(
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Material(
|
||||
elevation: 0,
|
||||
color: Colors.white,
|
||||
borderOnForeground: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
children: widget.tabViews,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
labelColor: AppColors.primary,
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
dividerColor: AppColors.primary,
|
||||
unselectedLabelColor: AppColors.primary,
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
indicatorWeight: 4,
|
||||
indicatorColor: AppColors.primary,
|
||||
tabs: widget.categories
|
||||
.map((category) => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Tab(text: category.name),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
// ✅ ini bagian penting
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: widget.tabViews,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class ConfirmPaymentTitle extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: context.deviceHeight * 0.1,
|
||||
height: context.deviceHeight * 0.123,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/home/dialog/variant_dialog.dart';
|
||||
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:enaklo_pos/core/constants/variables.dart';
|
||||
@@ -53,27 +54,47 @@ class ProductCard extends StatelessWidget {
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: (data.imageUrl ?? "").contains('http')
|
||||
? data.imageUrl!
|
||||
: '${Variables.baseUrl}/${data.imageUrl}',
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: 120,
|
||||
memCacheHeight: 120,
|
||||
memCacheWidth: 120,
|
||||
errorWidget: (context, url, error) => Container(
|
||||
width: double.infinity,
|
||||
height: 120,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.disabled.withOpacity(0.4),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.image,
|
||||
color: AppColors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: data.imageUrl == ""
|
||||
? Container(
|
||||
width: double.infinity,
|
||||
height: 120,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.disabled.withOpacity(0.4),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.image,
|
||||
color: AppColors.grey,
|
||||
),
|
||||
)
|
||||
: CachedNetworkImage(
|
||||
imageUrl: (data.imageUrl ?? "").contains('http')
|
||||
? data.imageUrl!
|
||||
: '${Variables.baseUrl}/${data.imageUrl}',
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: 120,
|
||||
memCacheHeight: 120,
|
||||
memCacheWidth: 120,
|
||||
errorWidget: (context, url, error) {
|
||||
FirebaseCrashlytics.instance.recordError(
|
||||
error,
|
||||
StackTrace.current,
|
||||
reason:
|
||||
'Failed to load image from: $url, productId: ${data.id}, productName: ${data.name}, dataUrl: ${data.imageUrl}',
|
||||
fatal: false,
|
||||
);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 120,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.disabled.withOpacity(0.4),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.image,
|
||||
color: AppColors.grey,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:enaklo_pos/presentation/home/bloc/payment_methods/payment_method
|
||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/blocs/payment_form/payment_form_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/success/pages/success_payment_page.dart';
|
||||
import 'package:enaklo_pos/presentation/success/pages/success_split_bill_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
@@ -370,23 +371,43 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
state.maybeWhen(
|
||||
orElse: () {},
|
||||
success: (data) {
|
||||
context.pushReplacement(SuccessPaymentPage(
|
||||
productQuantity: widget.order.orderItems
|
||||
?.map(
|
||||
(item) => ProductQuantity(
|
||||
product: Product(
|
||||
name: item.productName,
|
||||
price: item.unitPrice,
|
||||
),
|
||||
quantity: item.quantity ?? 0,
|
||||
if (widget.isSplit) {
|
||||
context.pushReplacement(SuccessSplitBillPage(
|
||||
productQuantity: getOrderItemPending()
|
||||
.map(
|
||||
(item) => ProductQuantity(
|
||||
product: Product(
|
||||
name: item.productName,
|
||||
price: item.unitPrice,
|
||||
),
|
||||
)
|
||||
.toList() ??
|
||||
[],
|
||||
payment: data,
|
||||
paymentMethod: selectedPaymentMethod?.name ?? '',
|
||||
nominalBayar: totalPriceController.text.toIntegerFromText,
|
||||
));
|
||||
quantity: item.quantity ?? 0,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
payment: data,
|
||||
paymentMethod: selectedPaymentMethod?.name ?? '',
|
||||
nominalBayar:
|
||||
totalPriceController.text.toIntegerFromText,
|
||||
));
|
||||
} else {
|
||||
context.pushReplacement(SuccessPaymentPage(
|
||||
productQuantity: getOrderItemPending()
|
||||
.map(
|
||||
(item) => ProductQuantity(
|
||||
product: Product(
|
||||
name: item.productName,
|
||||
price: item.unitPrice,
|
||||
),
|
||||
quantity: item.quantity ?? 0,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
payment: data,
|
||||
paymentMethod: selectedPaymentMethod?.name ?? '',
|
||||
nominalBayar:
|
||||
totalPriceController.text.toIntegerFromText,
|
||||
));
|
||||
}
|
||||
},
|
||||
error: (message) {
|
||||
AppFlushbar.showError(context, message);
|
||||
@@ -443,6 +464,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
final itemPending = widget.order.orderItems
|
||||
?.where((item) => item.status == "pending")
|
||||
.toList();
|
||||
|
||||
if (widget.isSplit == false) {
|
||||
final request = PaymentRequestModel(
|
||||
amount: widget.order.totalAmount ?? 0,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/analytic_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/outlet/outlet_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/category_analytic_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/payment_method_analytic_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/product_analytic_response_model.dart';
|
||||
|
||||
@@ -271,18 +271,24 @@ class _SalesPageState extends State<SalesPage> {
|
||||
nominalBayar: orderDetail?.totalPaid ?? 0,
|
||||
kembalian: 0,
|
||||
productQuantity: orderDetail!.orderItems!
|
||||
.where((item) =>
|
||||
item.status != 'cancelled')
|
||||
.toList()
|
||||
.toProductQuantities(),
|
||||
);
|
||||
} else {
|
||||
onPrint(
|
||||
onPrintBill(
|
||||
context,
|
||||
productQuantity: orderDetail!.orderItems!
|
||||
.where((item) =>
|
||||
item.status != 'cancelled')
|
||||
.toList()
|
||||
.toProductQuantities(),
|
||||
order: orderDetail!,
|
||||
);
|
||||
}
|
||||
},
|
||||
label: 'Print',
|
||||
label: 'Print Bill',
|
||||
icon: Icon(
|
||||
Icons.print,
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/setting/pages/printer_page.dart';
|
||||
import 'package:enaklo_pos/presentation/setting/pages/setting_tile.dart';
|
||||
import 'package:enaklo_pos/presentation/setting/pages/sync_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SettingPage extends StatefulWidget {
|
||||
@@ -84,6 +85,14 @@ class _SettingPageState extends State<SettingPage> {
|
||||
icon: Icons.print_outlined,
|
||||
onTap: () => indexValue(0),
|
||||
),
|
||||
SettingTile(
|
||||
index: 1,
|
||||
currentIndex: currentIndex,
|
||||
title: 'Sinkronisasi',
|
||||
subtitle: 'Sinkronisasi data',
|
||||
icon: Icons.sync_outlined,
|
||||
onTap: () => indexValue(1),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -101,6 +110,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
index: currentIndex,
|
||||
children: [
|
||||
SettingPrinterPage(),
|
||||
SettingSyncPage(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,580 @@
|
||||
import 'dart:developer';
|
||||
import 'package:enaklo_pos/core/components/flushbar.dart';
|
||||
import 'package:enaklo_pos/core/components/buttons.dart';
|
||||
import 'package:enaklo_pos/data/repositories/product/product_repository.dart';
|
||||
import 'package:enaklo_pos/data/repositories/category/category_repository.dart';
|
||||
import 'package:enaklo_pos/data/datasources/product/product_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/category/category_local_datasource.dart';
|
||||
import 'package:enaklo_pos/presentation/setting/widgets/settings_title.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SettingSyncPage extends StatefulWidget {
|
||||
const SettingSyncPage({super.key});
|
||||
|
||||
@override
|
||||
State<SettingSyncPage> createState() => _SettingSyncPageState();
|
||||
}
|
||||
|
||||
class _SettingSyncPageState extends State<SettingSyncPage> {
|
||||
final ProductRepository _productRepository = ProductRepository.instance;
|
||||
final CategoryRepository _categoryRepository = CategoryRepository.instance;
|
||||
final ProductLocalDatasource _productLocalDatasource =
|
||||
ProductLocalDatasource.instance;
|
||||
final CategoryLocalDatasource _categoryLocalDatasource =
|
||||
CategoryLocalDatasource.instance;
|
||||
|
||||
bool _isLoading = false;
|
||||
bool _isSyncing = false;
|
||||
Map<String, dynamic> _productStats = {};
|
||||
Map<String, dynamic> _categoryStats = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadStats();
|
||||
}
|
||||
|
||||
Future<void> _loadStats() async {
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
final productStats = await _productRepository.getDatabaseStats();
|
||||
final categoryStats = await _categoryRepository.getDatabaseStats();
|
||||
|
||||
setState(() {
|
||||
_productStats = productStats;
|
||||
_categoryStats = categoryStats;
|
||||
_isLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
log('Error loading stats: $e');
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _syncAllData() async {
|
||||
setState(() => _isSyncing = true);
|
||||
|
||||
try {
|
||||
// Show loading dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text('Sinkronisasi semua data...'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Sync categories first
|
||||
final categoryResult = await _categoryRepository.syncAllCategories();
|
||||
|
||||
await categoryResult.fold(
|
||||
(error) async {
|
||||
Navigator.of(context).pop();
|
||||
AppFlushbar.showError(context, 'Gagal sync kategori: $error');
|
||||
return;
|
||||
},
|
||||
(success) async {
|
||||
log('Categories synced successfully');
|
||||
},
|
||||
);
|
||||
|
||||
// Sync products after categories
|
||||
final productResult = await _productRepository.syncAllProducts();
|
||||
|
||||
await productResult.fold(
|
||||
(error) async {
|
||||
Navigator.of(context).pop();
|
||||
AppFlushbar.showError(context, 'Gagal sync produk: $error');
|
||||
return;
|
||||
},
|
||||
(success) async {
|
||||
log('Products synced successfully');
|
||||
},
|
||||
);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
AppFlushbar.showSuccess(context, 'Sinkronisasi berhasil');
|
||||
_loadStats(); // Refresh stats
|
||||
} catch (e) {
|
||||
Navigator.of(context).pop();
|
||||
AppFlushbar.showError(context, 'Gagal sinkronisasi: $e');
|
||||
} finally {
|
||||
setState(() => _isSyncing = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _clearAllData() async {
|
||||
// Show confirmation dialog
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Hapus Semua Data'),
|
||||
content: Text(
|
||||
'Apakah Anda yakin ingin menghapus semua data lokal? Tindakan ini tidak dapat dibatalkan.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text('Batal'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text('Hapus', style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirmed != true) return;
|
||||
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
try {
|
||||
// Clear products and categories using datasource
|
||||
await _productLocalDatasource.clearAllProducts();
|
||||
await _categoryLocalDatasource.clearAllCategories();
|
||||
|
||||
// Clear caches
|
||||
_productRepository.clearCache();
|
||||
_categoryRepository.clearCache();
|
||||
|
||||
AppFlushbar.showSuccess(context, 'Semua data berhasil dihapus');
|
||||
_loadStats(); // Refresh stats
|
||||
} catch (e) {
|
||||
AppFlushbar.showError(context, 'Gagal menghapus data: $e');
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _syncProducts() async {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
try {
|
||||
final result = await _productRepository.syncAllProducts();
|
||||
|
||||
await result.fold(
|
||||
(error) async {
|
||||
AppFlushbar.showError(context, 'Gagal sync produk: $error');
|
||||
},
|
||||
(success) async {
|
||||
AppFlushbar.showSuccess(context, success);
|
||||
_loadStats(); // Refresh stats
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
AppFlushbar.showError(context, 'Gagal sync produk: $e');
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _syncCategories() async {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
try {
|
||||
final result = await _categoryRepository.syncAllCategories();
|
||||
|
||||
await result.fold(
|
||||
(error) async {
|
||||
AppFlushbar.showError(context, 'Gagal sync kategori: $error');
|
||||
},
|
||||
(success) async {
|
||||
AppFlushbar.showSuccess(context, success);
|
||||
_loadStats(); // Refresh stats
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
AppFlushbar.showError(context, 'Gagal sync kategori: $e');
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
SettingsTitle(
|
||||
'Sinkronisasi',
|
||||
subtitle: 'Sinkronisasi data dengan server',
|
||||
),
|
||||
|
||||
SizedBox(height: 24),
|
||||
|
||||
// Quick Actions
|
||||
_buildQuickActions(),
|
||||
|
||||
SizedBox(height: 24),
|
||||
|
||||
// Sync Tables
|
||||
_buildSyncTables(),
|
||||
|
||||
SizedBox(height: 24),
|
||||
|
||||
// Database Stats
|
||||
_buildDatabaseStats(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildQuickActions() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.grey.shade200),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Aksi Cepat',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey.shade800,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Button.filled(
|
||||
onPressed: _isSyncing || _isLoading ? null : _syncAllData,
|
||||
label: _isSyncing ? 'Menyinkronkan...' : 'Sync Semua Data',
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Button.outlined(
|
||||
onPressed: _isLoading || _isSyncing ? null : _clearAllData,
|
||||
label: 'Hapus Semua Data',
|
||||
textColor: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSyncTables() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.grey.shade200),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Sinkronisasi per Tabel',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey.shade800,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
// Categories Sync
|
||||
_buildSyncTableItem(
|
||||
title: 'Kategori',
|
||||
subtitle: 'Sinkronkan data kategori produk',
|
||||
icon: Icons.category,
|
||||
color: Colors.blue,
|
||||
count: _categoryStats['total_categories'] ?? 0,
|
||||
onSync: _syncCategories,
|
||||
onClear: () async {
|
||||
final confirmed = await _showClearConfirmation('kategori');
|
||||
if (confirmed) {
|
||||
await _categoryLocalDatasource.clearAllCategories();
|
||||
_categoryRepository.clearCache();
|
||||
AppFlushbar.showSuccess(
|
||||
context, 'Data kategori berhasil dihapus');
|
||||
_loadStats();
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
SizedBox(height: 12),
|
||||
Divider(),
|
||||
SizedBox(height: 12),
|
||||
|
||||
// Products Sync
|
||||
_buildSyncTableItem(
|
||||
title: 'Produk',
|
||||
subtitle: 'Sinkronkan data produk dan variant',
|
||||
icon: Icons.inventory_2,
|
||||
color: Colors.green,
|
||||
count: _productStats['total_products'] ?? 0,
|
||||
onSync: _syncProducts,
|
||||
onClear: () async {
|
||||
final confirmed = await _showClearConfirmation('produk');
|
||||
if (confirmed) {
|
||||
await _productLocalDatasource.clearAllProducts();
|
||||
_productRepository.clearCache();
|
||||
AppFlushbar.showSuccess(
|
||||
context, 'Data produk berhasil dihapus');
|
||||
_loadStats();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSyncTableItem({
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required IconData icon,
|
||||
required Color color,
|
||||
required int count,
|
||||
required VoidCallback onSync,
|
||||
required VoidCallback onClear,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
// Icon and info
|
||||
Container(
|
||||
padding: EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icon, color: color, size: 24),
|
||||
),
|
||||
|
||||
SizedBox(width: 12),
|
||||
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'$count',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Actions
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: _isLoading || _isSyncing ? null : onSync,
|
||||
icon: Icon(Icons.sync, size: 20),
|
||||
tooltip: 'Sync $title',
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: color.withOpacity(0.1),
|
||||
foregroundColor: color,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
IconButton(
|
||||
onPressed: _isLoading || _isSyncing ? null : onClear,
|
||||
icon: Icon(Icons.delete_outline, size: 20),
|
||||
tooltip: 'Hapus $title',
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: Colors.red.withOpacity(0.1),
|
||||
foregroundColor: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDatabaseStats() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.grey.shade200),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'Statistik Database',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey.shade800,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
if (_isLoading)
|
||||
SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
else
|
||||
IconButton(
|
||||
onPressed: _loadStats,
|
||||
icon: Icon(Icons.refresh, size: 20),
|
||||
tooltip: 'Refresh Stats',
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
if (_isLoading)
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 20),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
else
|
||||
Column(
|
||||
children: [
|
||||
// Category stats
|
||||
_buildStatRow(
|
||||
'Kategori',
|
||||
_categoryStats['total_categories']?.toString() ?? '0',
|
||||
Icons.category,
|
||||
Colors.blue,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
|
||||
// Product stats
|
||||
_buildStatRow(
|
||||
'Produk',
|
||||
_productStats['total_products']?.toString() ?? '0',
|
||||
Icons.inventory_2,
|
||||
Colors.green,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
|
||||
// Variant stats
|
||||
_buildStatRow(
|
||||
'Variant',
|
||||
_productStats['total_variants']?.toString() ?? '0',
|
||||
Icons.tune,
|
||||
Colors.orange,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
|
||||
// Cache stats
|
||||
_buildStatRow(
|
||||
'Cache Entries',
|
||||
'${(_productStats['cache_entries'] ?? 0) + (_categoryStats['cache_entries'] ?? 0)}',
|
||||
Icons.memory,
|
||||
Colors.purple,
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
|
||||
// Database size
|
||||
_buildStatRow(
|
||||
'Ukuran Database',
|
||||
'${((_productStats['database_size_mb'] ?? 0.0) + (_categoryStats['database_size_mb'] ?? 0.0)).toStringAsFixed(2)} MB',
|
||||
Icons.storage,
|
||||
Colors.grey.shade600,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatRow(String label, String value, IconData icon, Color color) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, size: 16, color: color),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade700,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> _showClearConfirmation(String dataType) async {
|
||||
return await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Hapus Data $dataType'),
|
||||
content:
|
||||
Text('Apakah Anda yakin ingin menghapus semua data $dataType?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text('Batal'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text('Hapus', style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
),
|
||||
) ??
|
||||
false;
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ class _KitchenPrinterPageState extends State<KitchenPrinterPage> {
|
||||
// Generate test print data
|
||||
final testPrintData = await PrintDataoutputs
|
||||
.instance
|
||||
.printKitchen(
|
||||
.printKitchenAllItem(
|
||||
[], // Empty product list for test
|
||||
'Test Table',
|
||||
'Test Order',
|
||||
|
||||
@@ -0,0 +1,993 @@
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||
import 'package:enaklo_pos/core/function/app_function.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/payment_response_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class SuccessSplitBillPage extends StatefulWidget {
|
||||
final List<ProductQuantity> productQuantity;
|
||||
final PaymentData payment;
|
||||
final String paymentMethod;
|
||||
final int nominalBayar;
|
||||
const SuccessSplitBillPage({
|
||||
super.key,
|
||||
required this.payment,
|
||||
required this.productQuantity,
|
||||
required this.paymentMethod,
|
||||
required this.nominalBayar,
|
||||
});
|
||||
|
||||
@override
|
||||
State<SuccessSplitBillPage> createState() => _SuccessSplitBillPageState();
|
||||
}
|
||||
|
||||
class _SuccessSplitBillPageState extends State<SuccessSplitBillPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
context
|
||||
.read<OrderLoaderBloc>()
|
||||
.add(OrderLoaderEvent.getById(widget.payment.orderId ?? ""));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.background,
|
||||
body: SafeArea(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
AppColors.primary.withOpacity(0.05),
|
||||
AppColors.background,
|
||||
AppColors.background,
|
||||
],
|
||||
),
|
||||
),
|
||||
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => SizedBox.shrink(),
|
||||
loading: () => Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
loadedDetail: (order) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Row(
|
||||
children: [
|
||||
// Left Panel - Success Message & Order Info
|
||||
Expanded(
|
||||
flex: 35,
|
||||
child: _buildLeftPanel(order),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Right Panel - Order Details
|
||||
Expanded(
|
||||
flex: 65,
|
||||
child: _buildRightPanel(order),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLeftPanel(Order order) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.1),
|
||||
blurRadius: 30,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Success Header
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColors.primary.withOpacity(0.1),
|
||||
AppColors.primary.withOpacity(0.05),
|
||||
],
|
||||
),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(24),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Success Icon
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColors.primary,
|
||||
AppColors.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.3),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.check_rounded,
|
||||
size: 48,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Success Title
|
||||
const Text(
|
||||
'Split Bill Berhasil!',
|
||||
style: TextStyle(
|
||||
fontSize: 26,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: const Text(
|
||||
'Pesanan telah diterima dan sedang diproses',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Order Information Section
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildSectionTitle('Informasi Pesanan'),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Customer Card
|
||||
_buildInfoCard(
|
||||
icon: Icons.person_outline_rounded,
|
||||
title: 'Nama Pelanggan',
|
||||
value: order.metadata?['customer_name'] ?? "-",
|
||||
gradient: [
|
||||
Colors.blue.withOpacity(0.1),
|
||||
Colors.purple.withOpacity(0.1),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Order Details
|
||||
Column(
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
icon: Icons.receipt_long_outlined,
|
||||
label: 'No. Pesanan',
|
||||
value: order.orderNumber ?? "-",
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.receipt_long_outlined,
|
||||
label: 'Metode Pembayaran',
|
||||
value: widget.paymentMethod,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.access_time_rounded,
|
||||
label: 'Waktu',
|
||||
value: (order.createdAt ?? DateTime.now())
|
||||
.toFormattedDate3(),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.check_circle_outline,
|
||||
label: 'Status Pembayaran',
|
||||
value: 'Lunas',
|
||||
valueColor: Colors.green,
|
||||
showBadge: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Total and Action Buttons
|
||||
_buildBottomSection(order),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRightPanel(Order order) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.08),
|
||||
blurRadius: 30,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Header
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColors.background,
|
||||
Colors.grey.shade50,
|
||||
],
|
||||
),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(24),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.primary.withOpacity(0.2),
|
||||
AppColors.primary.withOpacity(0.1),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.receipt_long_rounded,
|
||||
color: AppColors.primary,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Detail Pesanan',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Ringkasan item yang dipesan',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.primary,
|
||||
AppColors.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.3),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
'${widget.productQuantity.length} Items',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Product List
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
itemCount: widget.productQuantity.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildProductCard(index);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// Summary Footer
|
||||
_buildSummaryFooter(order),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProductCard(int index) {
|
||||
final item = widget.productQuantity[index];
|
||||
final totalPrice = (item.product.price ?? 0) * item.quantity;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Colors.grey.shade50,
|
||||
Colors.white,
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
border: Border.all(
|
||||
color: Colors.grey.withOpacity(0.1),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Product Image
|
||||
Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColors.primary.withOpacity(0.2),
|
||||
AppColors.primary.withOpacity(0.1),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.2),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
Icons.restaurant_rounded,
|
||||
color: AppColors.primary,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Product Details
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.product.name ?? "-",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
(item.product.price ?? 0).toString().currencyFormatRpV2,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade700,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Quantity and Total
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.primary,
|
||||
AppColors.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.3),
|
||||
blurRadius: 6,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
'${item.quantity}x',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
totalPrice.toString().currencyFormatRpV2,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoCard({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required String value,
|
||||
required List<Color> gradient,
|
||||
}) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: gradient,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade600,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required String value,
|
||||
Color? valueColor,
|
||||
bool showBadge = false,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 18,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (showBadge && valueColor != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: valueColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.check_circle,
|
||||
size: 14,
|
||||
color: valueColor,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor ?? Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottomSection(Order order) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.grey.shade50,
|
||||
Colors.white,
|
||||
],
|
||||
),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
bottom: Radius.circular(24),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Total Amount
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColors.primary.withOpacity(0.1),
|
||||
AppColors.primary.withOpacity(0.05),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: AppColors.primary.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'Total Pembayaran',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.nominalBayar.currencyFormatRpV2,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Action Buttons
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: AppColors.primary.withOpacity(0.3),
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
onTap: () {
|
||||
context.push(DashboardPage());
|
||||
},
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Kembali ke Beranda',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
AppColors.primary,
|
||||
AppColors.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.3),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () async {
|
||||
final updatedOrderItems =
|
||||
widget.productQuantity.map((pq) {
|
||||
return OrderItem(
|
||||
productName: pq.product.name,
|
||||
printerType: pq.product.printerType,
|
||||
productVariantName: pq.variant?.name,
|
||||
quantity: pq.quantity,
|
||||
unitPrice: pq.product.price,
|
||||
totalPrice: (pq.product.price ?? 0) * (pq.quantity),
|
||||
);
|
||||
}).toList();
|
||||
onPrintSplit(
|
||||
context,
|
||||
order: order.copyWith(
|
||||
orderItems: updatedOrderItems,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.print_rounded,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'Cetak Struk',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSummaryFooter(Order order) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.grey.shade50,
|
||||
Colors.white,
|
||||
],
|
||||
),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
bottom: Radius.circular(24),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Decorative Divider
|
||||
Container(
|
||||
height: 1,
|
||||
margin: const EdgeInsets.only(bottom: 20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
AppColors.primary.withOpacity(0.3),
|
||||
Colors.transparent,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Subtotal Row
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.shopping_cart_outlined,
|
||||
size: 16,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Subtotal (${widget.productQuantity.length} items)',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey.shade600,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
widget.nominalBayar.currencyFormatRpV2,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Total Payment Row
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColors.primary.withOpacity(0.1),
|
||||
AppColors.primary.withOpacity(0.05),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppColors.primary.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.payments_rounded,
|
||||
size: 16,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Text(
|
||||
'Total Pembayaran',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.primary,
|
||||
AppColors.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.3),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
widget.nominalBayar.currencyFormatRpV2,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+32
-45
@@ -5,10 +5,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab"
|
||||
sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "76.0.0"
|
||||
version: "67.0.0"
|
||||
_flutterfire_internals:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -17,19 +17,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.61"
|
||||
_macros:
|
||||
dependency: transitive
|
||||
description: dart
|
||||
source: sdk
|
||||
version: "0.3.3"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e"
|
||||
sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.11.0"
|
||||
version: "6.4.1"
|
||||
another_flushbar:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -114,10 +109,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build
|
||||
sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0
|
||||
sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.2"
|
||||
version: "2.4.1"
|
||||
build_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -138,26 +133,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_resolvers
|
||||
sha256: "99d3980049739a985cf9b21f30881f46db3ebc62c5b8d5e60e27440876b1ba1e"
|
||||
sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.3"
|
||||
version: "2.4.2"
|
||||
build_runner:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: build_runner
|
||||
sha256: "74691599a5bc750dc96a6b4bfd48f7d9d66453eab04c7f4063134800d6a5c573"
|
||||
sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.14"
|
||||
version: "2.4.13"
|
||||
build_runner_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_runner_core
|
||||
sha256: "22e3aa1c80e0ada3722fe5b63fd43d9c8990759d0a2cf489c8c5d7b2bdebc021"
|
||||
sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.0.0"
|
||||
version: "7.3.2"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -322,10 +317,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab"
|
||||
sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.7"
|
||||
version: "2.3.6"
|
||||
dartx:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -633,10 +628,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: freezed
|
||||
sha256: "44c19278dd9d89292cf46e97dc0c1e52ce03275f40a97c5a348e802a924bf40e"
|
||||
sha256: a434911f643466d78462625df76fd9eb13e57348ff43fe1f77bbe909522c67a1
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.7"
|
||||
version: "2.5.2"
|
||||
freezed_annotation:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -857,26 +852,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker
|
||||
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
|
||||
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.9"
|
||||
version: "11.0.2"
|
||||
leak_tracker_flutter_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_flutter_testing
|
||||
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
|
||||
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.9"
|
||||
version: "3.0.10"
|
||||
leak_tracker_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_testing
|
||||
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
||||
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
version: "3.0.2"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -893,14 +888,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
macros:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: macros
|
||||
sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.3-main.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -921,10 +908,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
version: "1.17.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1451,13 +1438,13 @@ packages:
|
||||
source: hosted
|
||||
version: "30.2.5"
|
||||
synchronized:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: synchronized
|
||||
sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225"
|
||||
sha256: c254ade258ec8282947a0acbbc90b9575b4f19673533ee46f2f6e9b3aeefd7c0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.3.0+3"
|
||||
version: "3.4.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1470,10 +1457,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
|
||||
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.4"
|
||||
version: "0.7.7"
|
||||
time:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1534,10 +1521,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
version: "2.2.0"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1635,5 +1622,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.7.0 <4.0.0"
|
||||
dart: ">=3.8.0 <4.0.0"
|
||||
flutter: ">=3.29.0"
|
||||
|
||||
+2
-1
@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.0+1
|
||||
version: 1.0.5+16
|
||||
|
||||
environment:
|
||||
sdk: ">=3.2.4 <4.0.0"
|
||||
@@ -70,6 +70,7 @@ dependencies:
|
||||
firebase_core: ^4.1.0
|
||||
firebase_crashlytics: ^5.0.1
|
||||
path: ^1.9.1
|
||||
synchronized: ^3.4.0
|
||||
# imin_printer: ^0.6.10
|
||||
|
||||
dev_dependencies:
|
||||
|
||||
Reference in New Issue
Block a user