From d8a28c084dc6af49760142a3975bcf1fc4e33003 Mon Sep 17 00:00:00 2001 From: efrilm Date: Thu, 13 Nov 2025 13:04:32 +0700 Subject: [PATCH] update printer bar --- .../components/print/print_ui.dart | 47 ++--- lib/presentation/pages/main/main_page.dart | 194 ++++++++++-------- 2 files changed, 128 insertions(+), 113 deletions(-) diff --git a/lib/presentation/components/print/print_ui.dart b/lib/presentation/components/print/print_ui.dart index 004c040..b2d42f0 100644 --- a/lib/presentation/components/print/print_ui.dart +++ b/lib/presentation/components/print/print_ui.dart @@ -201,32 +201,23 @@ class PrintUi { paperSize: 58, ); - bytes += generator.reset(); - - bytes += builder.header( - outletName: outlet.name, - address: outlet.address, - phoneNumber: outlet.phoneNumber, - ); - - bytes += builder.printerType(printerType: 'BAR'); - - bytes += builder.separator(); - - bytes += builder.dateTime(DateTime.now()); - bytes += builder.orderInfo( - orderNumber: order.orderNumber, - customerName: order.metadata['customer_name'] ?? 'John Doe', - cashierName: cashierName, - paymentMethod: order.payments.last.paymentMethodName, - tableNumber: order.tableNumber, - ); - - bytes += builder.orderType(order.orderType); - - bytes += builder.emptyLines(1); - for (final item in order.orderItems) { + bytes += generator.reset(); + + bytes += builder.separator(); + bytes += builder.printerType(printerType: 'BAR'); + bytes += builder.separator(); + bytes += builder.dateTime(DateTime.now()); + bytes += builder.orderInfo( + orderNumber: order.orderNumber, + customerName: order.metadata['customer_name'] ?? 'John Doe', + cashierName: cashierName, + tableNumber: order.tableNumber, + ); + + bytes += builder.separator(); + bytes += builder.emptyLines(1); + bytes += builder.orderItem( productName: item.productName, quantity: item.quantity, @@ -235,10 +226,10 @@ class PrintUi { variantName: item.productVariantName, notes: item.notes, ); - } - bytes += builder.separator(); - bytes += builder.footer(); + bytes += builder.separator(); + bytes += builder.footer(); + } return bytes; } diff --git a/lib/presentation/pages/main/main_page.dart b/lib/presentation/pages/main/main_page.dart index 2bcdade..5f031ba 100644 --- a/lib/presentation/pages/main/main_page.dart +++ b/lib/presentation/pages/main/main_page.dart @@ -62,96 +62,120 @@ class _MainPageState extends State { return Scaffold( body: Row( children: [ - NavigationRail( - selectedIndex: tabsRouter.activeIndex, - onDestinationSelected: tabsRouter.setActiveIndex, - labelType: NavigationRailLabelType.none, - backgroundColor: AppColor.primary, - selectedIconTheme: const IconThemeData(color: Colors.white), - indicatorColor: AppColor.disabled.withOpacity(0.25), - indicatorShape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), - ), - minExtendedWidth: 56, - leading: Padding( - padding: EdgeInsets.all(8.0), - child: Assets.images.logoWhite.image( - width: 40, - height: 40, - fit: BoxFit.contain, + // Bungkus NavigationRail dengan SingleChildScrollView + SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: MediaQuery.of(context).size.height, ), - ), - trailing: Expanded( - child: Align( - alignment: Alignment.bottomCenter, - child: Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: IconButton( - icon: const Icon( - Icons.logout, - color: AppColor.disabled, - ), - onPressed: () { - showDialog( - context: context, - builder: (context) => LogoutModalDialog(), - ); - }, - tooltip: 'Logout', + child: IntrinsicHeight( + child: NavigationRail( + selectedIndex: tabsRouter.activeIndex, + onDestinationSelected: tabsRouter.setActiveIndex, + labelType: NavigationRailLabelType.none, + backgroundColor: AppColor.primary, + selectedIconTheme: const IconThemeData( + color: Colors.white, ), + indicatorColor: AppColor.disabled.withOpacity(0.25), + indicatorShape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.0), + ), + minExtendedWidth: 56, + leading: Padding( + padding: EdgeInsets.all(8.0), + child: Assets.images.logoWhite.image( + width: 40, + height: 40, + fit: BoxFit.contain, + ), + ), + trailing: Expanded( + child: Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: IconButton( + icon: const Icon( + Icons.logout, + color: AppColor.disabled, + ), + onPressed: () { + showDialog( + context: context, + builder: (context) => LogoutModalDialog(), + ); + }, + tooltip: 'Logout', + ), + ), + ), + ), + destinations: const [ + NavigationRailDestination( + icon: Icon( + Icons.home_outlined, + color: AppColor.disabled, + ), + selectedIcon: Icon( + Icons.home, + color: AppColor.white, + ), + label: Text('POS'), + padding: EdgeInsets.symmetric(vertical: 8), + ), + NavigationRailDestination( + icon: Icon( + Icons.table_bar_outlined, + color: AppColor.disabled, + ), + selectedIcon: Icon( + Icons.table_bar, + color: AppColor.white, + ), + label: Text('Meja'), + padding: EdgeInsets.symmetric(vertical: 8), + ), + NavigationRailDestination( + icon: Icon( + Icons.pie_chart_outline_outlined, + color: AppColor.disabled, + ), + selectedIcon: Icon( + Icons.pie_chart, + color: AppColor.white, + ), + label: Text('Laporan'), + padding: EdgeInsets.symmetric(vertical: 8), + ), + NavigationRailDestination( + icon: Icon( + Icons.person_2_outlined, + color: AppColor.disabled, + ), + selectedIcon: Icon( + Icons.person_2, + color: AppColor.white, + ), + label: Text('Pelanggan'), + padding: EdgeInsets.symmetric(vertical: 8), + ), + NavigationRailDestination( + icon: Icon( + Icons.settings_outlined, + color: AppColor.disabled, + ), + selectedIcon: Icon( + Icons.settings, + color: AppColor.white, + ), + label: Text('Pengaturan'), + padding: EdgeInsets.symmetric(vertical: 8), + ), + ], ), ), ), - destinations: const [ - NavigationRailDestination( - icon: Icon(Icons.home_outlined, color: AppColor.disabled), - selectedIcon: Icon(Icons.home, color: AppColor.white), - label: Text('POS'), - padding: EdgeInsets.symmetric(vertical: 8), - ), - NavigationRailDestination( - icon: Icon( - Icons.table_bar_outlined, - color: AppColor.disabled, - ), - selectedIcon: Icon( - Icons.table_bar, - color: AppColor.white, - ), - label: Text('Meja'), - padding: EdgeInsets.symmetric(vertical: 8), - ), - NavigationRailDestination( - icon: Icon( - Icons.pie_chart_outline_outlined, - color: AppColor.disabled, - ), - selectedIcon: Icon( - Icons.pie_chart, - color: AppColor.white, - ), - label: Text('Laporan'), - padding: EdgeInsets.symmetric(vertical: 8), - ), - NavigationRailDestination( - icon: Icon( - Icons.person_2_outlined, - color: AppColor.disabled, - ), - selectedIcon: Icon(Icons.person_2, color: AppColor.white), - label: Text('Pelanggan'), - padding: EdgeInsets.symmetric(vertical: 8), - ), - NavigationRailDestination( - icon: Icon( - Icons.settings_outlined, - color: AppColor.disabled, - ), - selectedIcon: Icon(Icons.settings, color: AppColor.white), - label: Text('Pengaturan'), - padding: EdgeInsets.symmetric(vertical: 8), - ), - ], ), const VerticalDivider(thickness: 1, width: 1), // Main content area