Compare commits
3 Commits
ea29c62af1
...
9a5f0c7415
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a5f0c7415 | ||
|
|
d345294a2f | ||
|
|
beb86f6259 |
@ -149,6 +149,26 @@ class Order with _$Order {
|
||||
categoryId: 'CAT-002',
|
||||
categoryName: 'Makanan',
|
||||
),
|
||||
OrderItem(
|
||||
id: 'ITEM-003',
|
||||
orderId: 'ORD-001',
|
||||
productId: 'PROD-003',
|
||||
productName: 'Pasta',
|
||||
productVariantId: 'VAR-002',
|
||||
productVariantName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 50000,
|
||||
totalPrice: 50000,
|
||||
modifiers: [],
|
||||
notes: '',
|
||||
status: 'Served',
|
||||
createdAt: DateTime.now().subtract(const Duration(hours: 1)),
|
||||
updatedAt: DateTime.now(),
|
||||
printerType: 'Kitchen',
|
||||
paidQuantity: 1,
|
||||
categoryId: 'CAT-002',
|
||||
categoryName: 'Makanan',
|
||||
),
|
||||
],
|
||||
payments: [
|
||||
Payment(
|
||||
|
||||
@ -30,6 +30,9 @@ class PrintUi {
|
||||
outletName: outlet.name,
|
||||
address: outlet.address,
|
||||
phoneNumber: outlet.phoneNumber,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.orderInfo(
|
||||
@ -38,9 +41,14 @@ class PrintUi {
|
||||
cashierName: cashierName,
|
||||
paymentMethod: order.payments.last.paymentMethodName,
|
||||
tableNumber: order.tableNumber,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.orderType(order.orderType);
|
||||
bytes += builder.orderType(order.orderType, fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,);
|
||||
|
||||
bytes += builder.emptyLines(1);
|
||||
|
||||
@ -52,6 +60,9 @@ class PrintUi {
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
notes: item.notes,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
}
|
||||
|
||||
@ -61,6 +72,9 @@ class PrintUi {
|
||||
discount: order.discountAmount.currencyFormatRpV2,
|
||||
total: order.totalAmount.currencyFormatRpV2,
|
||||
paid: order.totalPaid.currencyFormatRpV2,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.footer();
|
||||
@ -90,18 +104,14 @@ class PrintUi {
|
||||
|
||||
// Header
|
||||
bytes += builder.textCenter('Table Checker', bold: true);
|
||||
bytes += builder.separator();
|
||||
bytes += builder.textCenter(
|
||||
'Table : ${order.tableNumber.isNotEmpty ? order.tableNumber : '-'}',
|
||||
bold: true,
|
||||
);
|
||||
bytes += builder.separator();
|
||||
bytes += builder.tableName(order.tableNumber.isNotEmpty ? order.tableNumber : '-', height: PosTextSize.size3, width: PosTextSize.size3);
|
||||
|
||||
// Order info — label : value, left aligned
|
||||
bytes += builder.orderInfoSimple(
|
||||
orderNumber: order.orderNumber,
|
||||
orderType: order.orderType,
|
||||
cashierName: cashierName,
|
||||
customerName: order.metadata['customer_name'] ?? '-',
|
||||
);
|
||||
|
||||
bytes += builder.separator();
|
||||
@ -146,7 +156,7 @@ class PrintUi {
|
||||
bytes += generator.reset();
|
||||
|
||||
// Header
|
||||
bytes += builder.row2Columns('Kitchen', order.orderType, bold: true);
|
||||
bytes += builder.row2Columns('Kitchen', order.orderType.toUpperCase(), bold: true);
|
||||
bytes += builder.separator();
|
||||
bytes += builder.textCenter(
|
||||
'Table : ${order.tableNumber.isNotEmpty ? order.tableNumber : '-'}',
|
||||
@ -158,6 +168,7 @@ class PrintUi {
|
||||
bytes += builder.orderInfoSimple(
|
||||
orderNumber: order.orderNumber,
|
||||
cashierName: cashierName,
|
||||
customerName: order.metadata['customer_name'] ?? '-',
|
||||
);
|
||||
|
||||
bytes += builder.separator();
|
||||
@ -201,7 +212,7 @@ class PrintUi {
|
||||
bytes += generator.reset();
|
||||
|
||||
// Header
|
||||
bytes += builder.textCenter('Bar', bold: true);
|
||||
bytes += builder.row2Columns('Bar', order.orderType.toUpperCase(), bold: true);
|
||||
bytes += builder.separator();
|
||||
bytes += builder.textCenter(
|
||||
'Table : ${order.tableNumber.isNotEmpty ? order.tableNumber : '-'}',
|
||||
@ -212,7 +223,7 @@ class PrintUi {
|
||||
// Order info
|
||||
bytes += builder.orderInfoSimple(
|
||||
orderNumber: order.orderNumber,
|
||||
orderType: order.orderType,
|
||||
customerName: order.metadata['customer_name'] ?? '-',
|
||||
cashierName: cashierName,
|
||||
);
|
||||
|
||||
@ -299,6 +310,9 @@ class PrintUi {
|
||||
outletName: outlet.name,
|
||||
address: outlet.address,
|
||||
phoneNumber: outlet.phoneNumber,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.orderInfo(
|
||||
@ -309,9 +323,14 @@ class PrintUi {
|
||||
? null
|
||||
: order.payments.last.paymentMethodName,
|
||||
tableNumber: order.tableNumber,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.orderType(order.orderType);
|
||||
bytes += builder.orderType(order.orderType, fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,);
|
||||
|
||||
bytes += builder.emptyLines(1);
|
||||
|
||||
@ -323,6 +342,9 @@ class PrintUi {
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
notes: item.notes,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
}
|
||||
|
||||
@ -332,6 +354,9 @@ class PrintUi {
|
||||
discount: order.discountAmount.currencyFormatRpV2,
|
||||
total: order.totalAmount.currencyFormatRpV2,
|
||||
paid: order.totalPaid.currencyFormatRpV2,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.footer(message: 'Kasir');
|
||||
@ -363,6 +388,9 @@ class PrintUi {
|
||||
outletName: outlet.name,
|
||||
address: outlet.address,
|
||||
phoneNumber: outlet.phoneNumber,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.dateTime(DateTime.now());
|
||||
@ -375,9 +403,14 @@ class PrintUi {
|
||||
? null
|
||||
: order.payments.last.paymentMethodName,
|
||||
tableNumber: order.tableNumber,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.orderType('Void');
|
||||
bytes += builder.orderType('Void', fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,);
|
||||
|
||||
bytes += builder.emptyLines(1);
|
||||
|
||||
@ -389,6 +422,9 @@ class PrintUi {
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
notes: item.notes,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
}
|
||||
bytes += builder.summary(
|
||||
@ -397,6 +433,9 @@ class PrintUi {
|
||||
discount: order.discountAmount.currencyFormatRpV2,
|
||||
total: order.totalAmount.currencyFormatRpV2,
|
||||
paid: order.totalPaid.currencyFormatRpV2,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.footer(message: 'Kasir');
|
||||
@ -428,9 +467,14 @@ class PrintUi {
|
||||
outletName: outlet.name,
|
||||
address: outlet.address,
|
||||
phoneNumber: outlet.phoneNumber,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.dateTime(DateTime.now());
|
||||
bytes += builder.dateTime(DateTime.now(), fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,);
|
||||
|
||||
bytes += builder.orderInfo(
|
||||
orderNumber: order.orderNumber,
|
||||
@ -440,13 +484,21 @@ class PrintUi {
|
||||
? null
|
||||
: order.payments.last.paymentMethodName,
|
||||
tableNumber: order.tableNumber,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.orderType('Split');
|
||||
bytes += builder.orderType('Split', fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,);
|
||||
|
||||
bytes += builder.row2Columns(
|
||||
'Split',
|
||||
'${order.payments.last.splitNumber} / ${order.payments.last.splitTotal}',
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.separator();
|
||||
@ -461,6 +513,9 @@ class PrintUi {
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
notes: item.notes,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
}
|
||||
|
||||
@ -472,6 +527,9 @@ class PrintUi {
|
||||
discount: 0.currencyFormatRpV2,
|
||||
total: order.payments.last.amount.currencyFormatRpV2,
|
||||
paid: order.payments.last.amount.currencyFormatRpV2,
|
||||
fontType: PosFontType.fontA,
|
||||
width: PosTextSize.size1,
|
||||
height: PosTextSize.size1,
|
||||
);
|
||||
|
||||
bytes += builder.footer(message: 'Terima Kasih');
|
||||
|
||||
@ -9,26 +9,26 @@ class ReceiptComponentBuilder {
|
||||
|
||||
ReceiptComponentBuilder({required this.generator, this.paperSize = 58});
|
||||
|
||||
/// Helper: returns size2 for 80mm paper, size1 for 58mm
|
||||
PosTextSize get _titleSize =>
|
||||
paperSize == 80 ? PosTextSize.size3 : PosTextSize.size1;
|
||||
|
||||
/// Font type per paper size — easy to change here
|
||||
/// 58mm → fontA, 80mm → fontA
|
||||
PosFontType get _font =>
|
||||
paperSize == 80 ? PosFontType.fontA : PosFontType.fontA;
|
||||
paperSize == 80 ? PosFontType.fontB : PosFontType.fontA;
|
||||
|
||||
/// Text size for body — height size2 for 80mm to appear taller, size1 for 58mm
|
||||
PosTextSize get _bodySize =>
|
||||
PosTextSize get _bodyHeight =>
|
||||
paperSize == 80 ? PosTextSize.size2 : PosTextSize.size1;
|
||||
|
||||
/// Body width stays size1 always to prevent overflow
|
||||
PosTextSize get _bodyWidth => PosTextSize.size1;
|
||||
PosTextSize get _bodyWidth => paperSize == 80 ? PosTextSize.size2 : PosTextSize.size1;
|
||||
|
||||
/// Characters per line based on paper size (always size1 font)
|
||||
String get _separatorLine => paperSize == 80
|
||||
? '------------------------------------------------'
|
||||
: '--------------------------------';
|
||||
/// Characters per line based on paper size and font
|
||||
String get _separatorLine {
|
||||
if (paperSize == 80) {
|
||||
return _font == PosFontType.fontB
|
||||
? '----------------------------------------------------------------'
|
||||
: '------------------------------------------------';
|
||||
} else {
|
||||
return _font == PosFontType.fontB
|
||||
? '------------------------------------------'
|
||||
: '--------------------------------';
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Basic text
|
||||
@ -37,43 +37,48 @@ class ReceiptComponentBuilder {
|
||||
List<int> textCenter(
|
||||
String text, {
|
||||
bool bold = false,
|
||||
PosTextSize height = PosTextSize.size1,
|
||||
PosTextSize width = PosTextSize.size1,
|
||||
PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
return generator.text(
|
||||
text,
|
||||
styles: PosStyles(
|
||||
bold: bold,
|
||||
align: PosAlign.center,
|
||||
height: height,
|
||||
width: width,
|
||||
fontType: _font,
|
||||
height: height ?? _bodyHeight,
|
||||
width: width ?? _bodyWidth,
|
||||
fontType: fontType ?? _font,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<int> textLeft(String text, {bool bold = false}) {
|
||||
List<int> textLeft(String text, {bool bold = false, PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,}) {
|
||||
return generator.text(
|
||||
text,
|
||||
styles: PosStyles(
|
||||
bold: bold,
|
||||
align: PosAlign.left,
|
||||
fontType: _font,
|
||||
height: _bodySize,
|
||||
width: _bodyWidth,
|
||||
height: height ?? _bodyHeight,
|
||||
width: width ?? _bodyWidth,
|
||||
fontType: fontType ?? _font,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<int> textRight(String text, {bool bold = false}) {
|
||||
List<int> textRight(String text, {bool bold = false, PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,}) {
|
||||
return generator.text(
|
||||
text,
|
||||
styles: PosStyles(
|
||||
bold: bold,
|
||||
align: PosAlign.right,
|
||||
fontType: _font,
|
||||
height: _bodySize,
|
||||
width: _bodyWidth,
|
||||
height: height ?? _bodyHeight,
|
||||
width: width ?? _bodyWidth,
|
||||
fontType: fontType ?? _font,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -101,6 +106,9 @@ class ReceiptComponentBuilder {
|
||||
bool bold = false,
|
||||
int leftWidth = 6,
|
||||
int rightWidth = 6,
|
||||
PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
return generator.row([
|
||||
PosColumn(
|
||||
@ -109,9 +117,9 @@ class ReceiptComponentBuilder {
|
||||
styles: PosStyles(
|
||||
align: PosAlign.left,
|
||||
bold: bold,
|
||||
fontType: _font,
|
||||
height: _bodySize,
|
||||
width: _bodyWidth,
|
||||
height: height ?? _bodyHeight,
|
||||
width: width ?? _bodyWidth,
|
||||
fontType: fontType ?? _font,
|
||||
),
|
||||
),
|
||||
PosColumn(
|
||||
@ -120,9 +128,9 @@ class ReceiptComponentBuilder {
|
||||
styles: PosStyles(
|
||||
align: PosAlign.right,
|
||||
bold: bold,
|
||||
fontType: _font,
|
||||
height: _bodySize,
|
||||
width: _bodyWidth,
|
||||
height: height ?? _bodyHeight,
|
||||
width: width ?? _bodyWidth,
|
||||
fontType: fontType ?? _font,
|
||||
),
|
||||
),
|
||||
]);
|
||||
@ -163,8 +171,8 @@ class ReceiptComponentBuilder {
|
||||
bold: bold,
|
||||
align: PosAlign.left,
|
||||
fontType: _font,
|
||||
height: PosTextSize.size2,
|
||||
width: PosTextSize.size2,
|
||||
height: _bodyHeight,
|
||||
width: _bodyWidth,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -182,25 +190,34 @@ class ReceiptComponentBuilder {
|
||||
required String outletName,
|
||||
required String address,
|
||||
required String phoneNumber,
|
||||
PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
List<int> bytes = [];
|
||||
bytes += textCenter(outletName, bold: true, height: _titleSize, width: _titleSize);
|
||||
bytes += textCenter(address);
|
||||
bytes += textCenter(phoneNumber);
|
||||
bytes += textCenter(outletName, height: PosTextSize.size2, width: PosTextSize.size2, fontType: fontType, bold: true);
|
||||
bytes += textCenter(address, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
bytes += textCenter(phoneNumber, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
bytes += separator();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// Centered printer type label (e.g. KITCHEN, BAR)
|
||||
List<int> printerType({required String printerType}) {
|
||||
return textCenter(printerType, bold: true, height: _titleSize, width: _titleSize);
|
||||
return textCenter(printerType, bold: true);
|
||||
}
|
||||
|
||||
/// Date + time row (receipt style)
|
||||
List<int> dateTime(DateTime dateTime) {
|
||||
List<int> dateTime(DateTime dateTime, { PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
return row2Columns(
|
||||
DateFormat('dd MMM yyyy').format(dateTime),
|
||||
DateFormat('HH:mm').format(dateTime),
|
||||
height: height ?? _bodyHeight,
|
||||
width: width ?? _bodyWidth,
|
||||
fontType: fontType ?? _font,
|
||||
);
|
||||
}
|
||||
|
||||
@ -209,15 +226,21 @@ class ReceiptComponentBuilder {
|
||||
required String orderNumber,
|
||||
String? orderType,
|
||||
required String cashierName,
|
||||
String? customerName,
|
||||
}) {
|
||||
List<int> bytes = [];
|
||||
final dateStr = DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now());
|
||||
bytes += textLeft('Order : $orderNumber');
|
||||
bytes += textLeft('Date : $dateStr');
|
||||
if(orderType != null) {
|
||||
bytes += textLeft('Purpose : $orderType');
|
||||
bytes += textLeft('Order : $orderNumber');
|
||||
bytes += textLeft('Date : $dateStr');
|
||||
|
||||
|
||||
if(customerName != null) {
|
||||
bytes += textLeft('Customer : $customerName');
|
||||
}
|
||||
bytes += textLeft('Waiter : $cashierName');
|
||||
if(orderType != null) {
|
||||
bytes += textLeft('Purpose : ${orderType.toUpperCase()}');
|
||||
}
|
||||
bytes += textLeft('Waiter : $cashierName');
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -228,29 +251,48 @@ class ReceiptComponentBuilder {
|
||||
required String cashierName,
|
||||
String? paymentMethod,
|
||||
String? tableNumber,
|
||||
PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
List<int> bytes = [];
|
||||
final dateStr = DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now());
|
||||
bytes += textLeft('Order : $orderNumber');
|
||||
bytes += textLeft('Date : $dateStr');
|
||||
bytes += textLeft('Order : $orderNumber', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
bytes += textLeft('Date : $dateStr', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
if (tableNumber != null && tableNumber.isNotEmpty) {
|
||||
bytes += textLeft('Table : $tableNumber');
|
||||
bytes += textLeft('Table : $tableNumber', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
}
|
||||
bytes += textLeft('Waiter : $cashierName');
|
||||
bytes += textLeft('Customer : $customerName');
|
||||
bytes += textLeft('Waiter : $cashierName', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
bytes += textLeft('Customer : $customerName', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
|
||||
if (paymentMethod != null) {
|
||||
bytes += textLeft('Payment : $paymentMethod');
|
||||
bytes += textLeft('Payment : $paymentMethod', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// Order type banner (separator + type + separator)
|
||||
List<int> orderType(String type) {
|
||||
List<int> orderType(String type, {
|
||||
PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
List<int> bytes = [];
|
||||
bytes += separator();
|
||||
bytes += textCenter(type, bold: true, height: _titleSize, width: _titleSize);
|
||||
bytes += textCenter(type.toUpperCase(), fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth, bold: true);
|
||||
bytes += separator();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
List<int> tableName(String table, {
|
||||
PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
List<int> bytes = [];
|
||||
bytes += separator();
|
||||
bytes += textCenter( 'Table : ${table.isNotEmpty ? table : '-'}', fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth, bold: true);
|
||||
bytes += separator();
|
||||
return bytes;
|
||||
}
|
||||
@ -263,15 +305,18 @@ class ReceiptComponentBuilder {
|
||||
required String totalPrice,
|
||||
String? variantName,
|
||||
String? notes,
|
||||
PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
List<int> bytes = [];
|
||||
final displayName = (variantName != null && variantName.isNotEmpty)
|
||||
? '$productName ($variantName)'
|
||||
: productName;
|
||||
bytes += textLeft(displayName, bold: paperSize == 80);
|
||||
bytes += row2Columns('$quantity x $unitPrice', totalPrice, leftWidth: 8, rightWidth: 4);
|
||||
bytes += textLeft(displayName, bold: true, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
bytes += row2Columns('${quantity}x $unitPrice', totalPrice, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
||||
if (notes != null && notes.isNotEmpty) {
|
||||
bytes += row2Columns('Note', notes, leftWidth: 4, rightWidth: 8);
|
||||
bytes += row2Columns('Note', notes, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth, leftWidth: 4, rightWidth: 8);
|
||||
}
|
||||
bytes += emptyLines(1);
|
||||
return bytes;
|
||||
@ -284,17 +329,20 @@ class ReceiptComponentBuilder {
|
||||
required String discount,
|
||||
required String total,
|
||||
required String paid,
|
||||
PosTextSize? height,
|
||||
PosTextSize? width,
|
||||
PosFontType? fontType,
|
||||
}) {
|
||||
List<int> bytes = [];
|
||||
bytes += separator();
|
||||
if (totalItems > 0) {
|
||||
bytes += row2Columns('Total Item', totalItems.toString());
|
||||
bytes += row2Columns('Total Item', totalItems.toString(), fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
||||
}
|
||||
bytes += row2Columns('Subtotal', subtotal);
|
||||
bytes += row2Columns('Diskon', discount);
|
||||
bytes += row2Columns('Subtotal', subtotal, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
||||
bytes += row2Columns('Diskon', discount, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
||||
bytes += separator();
|
||||
bytes += row2Columns('Total', total, bold: true);
|
||||
bytes += row2Columns('Bayar', paid);
|
||||
bytes += row2Columns('Total', total, bold: true, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
||||
bytes += row2Columns('Bayar', paid, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
||||
bytes += separator();
|
||||
return bytes;
|
||||
}
|
||||
@ -303,7 +351,7 @@ class ReceiptComponentBuilder {
|
||||
List<int> footer({String message = 'Terima kasih'}) {
|
||||
List<int> bytes = [];
|
||||
bytes += emptyLines(2);
|
||||
bytes += textCenter(message, bold: true, height: _titleSize, width: _titleSize);
|
||||
bytes += textCenter(message, bold: true);
|
||||
if (kDebugMode) {
|
||||
bytes += textCenter('$paperSize MM');
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@ class SettingPrinterForm extends StatefulWidget {
|
||||
|
||||
class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
||||
final TextEditingController _nameController = TextEditingController();
|
||||
final TextEditingController _networkController = TextEditingController();
|
||||
|
||||
void setup() {
|
||||
if (widget.printer != null) {
|
||||
context.read<PrinterFormBloc>().add(
|
||||
@ -50,6 +52,7 @@ class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
||||
PrinterFormEvent.paperChanged(widget.printer!.paper),
|
||||
);
|
||||
_nameController.text = widget.printer!.name;
|
||||
_networkController.text = widget.printer!.address;
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,6 +166,7 @@ class _SettingPrinterFormState extends State<SettingPrinterForm> {
|
||||
)
|
||||
: AppTextFormField(
|
||||
label: 'Network',
|
||||
controller: _networkController,
|
||||
onChanged: (value) {
|
||||
context.read<PrinterFormBloc>().add(
|
||||
PrinterFormEvent.addressChanged(value),
|
||||
|
||||
42
pubspec.lock
42
pubspec.lock
@ -189,10 +189,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
|
||||
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
version: "1.4.1"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -493,10 +493,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fl_chart
|
||||
sha256: d3f82f4a38e33ba23d05a08ff304d7d8b22d2a59a5503f20bd802966e915db89
|
||||
sha256: b938f77d042cbcd822936a7a359a7235bad8bd72070de1f827efc2cc297ac888
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -796,26 +796,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:
|
||||
@ -836,26 +836,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
|
||||
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.17"
|
||||
version: "0.12.19"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
|
||||
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.11.1"
|
||||
version: "0.13.0"
|
||||
meta:
|
||||
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:
|
||||
@ -1337,10 +1337,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
|
||||
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.4"
|
||||
version: "0.7.10"
|
||||
time:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1409,10 +1409,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:
|
||||
@ -1502,5 +1502,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.8.1 <4.0.0"
|
||||
dart: ">=3.9.0-0 <4.0.0"
|
||||
flutter: ">=3.29.0"
|
||||
|
||||
@ -41,7 +41,7 @@ dependencies:
|
||||
cached_network_image: ^3.4.1
|
||||
shimmer: ^3.0.0
|
||||
dropdown_search: ^5.0.6
|
||||
fl_chart: ^1.1.0
|
||||
fl_chart: ^1.1.1
|
||||
permission_handler: ^12.0.1
|
||||
print_bluetooth_thermal: ^1.1.7
|
||||
flutter_esc_pos_network: ^1.0.3
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user