From 59a0193af1d05a8172bede5f6e4a9c626348e5bd Mon Sep 17 00:00:00 2001 From: orangdeso Date: Wed, 19 Mar 2025 00:54:04 +0700 Subject: [PATCH] Feat: add slicing page Print Boarding Pass --- .dart_tool/package_config.json | 20 ++++++- .dart_tool/package_config_subset | 12 ++++ .../pages/print_boarding_pass_screen.dart | 59 +++++++++++++++++- .../screens/home/component/card_tickets.dart | 60 +++++++++---------- .../home/pages/search_tickets_screen.dart | 1 - pubspec.lock | 24 ++++++++ pubspec.yaml | 1 + 7 files changed, 142 insertions(+), 35 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index f1f95db..d540ae2 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -19,6 +19,18 @@ "packageUri": "lib/", "languageVersion": "2.18" }, + { + "name": "barcode", + "rootUri": "file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/barcode-2.2.9", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "barcode_widget", + "rootUri": "file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/barcode_widget-2.0.4", + "packageUri": "lib/", + "languageVersion": "2.12" + }, { "name": "boolean_selector", "rootUri": "file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/boolean_selector-2.1.1", @@ -325,6 +337,12 @@ "packageUri": "lib/", "languageVersion": "3.0" }, + { + "name": "qr", + "rootUri": "file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/qr-3.0.2", + "packageUri": "lib/", + "languageVersion": "3.4" + }, { "name": "shared_preferences", "rootUri": "file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/shared_preferences-2.5.2", @@ -482,7 +500,7 @@ "languageVersion": "3.4" } ], - "generated": "2025-03-18T16:43:58.907612Z", + "generated": "2025-03-18T17:25:46.276961Z", "generator": "pub", "generatorVersion": "3.5.0", "flutterRoot": "file:///D:/Flutter/flutter_sdk/flutter_3.24.0", diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset index 898398e..acbc230 100644 --- a/.dart_tool/package_config_subset +++ b/.dart_tool/package_config_subset @@ -10,6 +10,14 @@ async 2.18 file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/async-2.11.0/ file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/async-2.11.0/lib/ +barcode +2.12 +file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/barcode-2.2.9/ +file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/barcode-2.2.9/lib/ +barcode_widget +2.12 +file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/barcode_widget-2.0.4/ +file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/barcode_widget-2.0.4/lib/ boolean_selector 2.17 file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/boolean_selector-2.1.1/ @@ -202,6 +210,10 @@ plugin_platform_interface 3.0 file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/plugin_platform_interface-2.1.8/ file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/plugin_platform_interface-2.1.8/lib/ +qr +3.4 +file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/qr-3.0.2/ +file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/qr-3.0.2/lib/ shared_preferences 3.5 file:///C:/Users/ASUS/AppData/Local/Pub/Cache/hosted/pub.dev/shared_preferences-2.5.2/ diff --git a/lib/presentation/screens/boarding_pass/pages/print_boarding_pass_screen.dart b/lib/presentation/screens/boarding_pass/pages/print_boarding_pass_screen.dart index f1e2e22..d666259 100644 --- a/lib/presentation/screens/boarding_pass/pages/print_boarding_pass_screen.dart +++ b/lib/presentation/screens/boarding_pass/pages/print_boarding_pass_screen.dart @@ -1,4 +1,6 @@ +import 'package:barcode_widget/barcode_widget.dart'; import 'package:e_porter/_core/component/card/custome_shadow_cotainner.dart'; +import 'package:e_porter/_core/component/dotted/dashed_line_component.dart'; import 'package:e_porter/_core/constants/colors.dart'; import 'package:e_porter/_core/constants/typography.dart'; import 'package:e_porter/presentation/screens/home/component/card_tickets.dart'; @@ -16,7 +18,7 @@ class PrintBoardingPassScreen extends StatelessWidget { return Scaffold( backgroundColor: GrayColors.gray50, appBar: DefaultAppbarComponent( - title: 'Detail Tiket', + title: 'Cetak Boarding Pass', textColor: Colors.white, backgroundColors: PrimaryColors.primary800, onTab: () { @@ -49,6 +51,7 @@ class PrintBoardingPassScreen extends StatelessWidget { ), CardTickets( withContainer: false, + showFooter: false, departureCity: 'departureCity', date: 'date', arrivalCity: 'arrivalCity', @@ -59,8 +62,25 @@ class PrintBoardingPassScreen extends StatelessWidget { duration: 'duration', seatClass: 'seatClass', price: 'price', - onTap: () {}, - ) + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 10), + child: Divider(thickness: 1, color: GrayColors.gray200), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _buildColumnText(context, label: 'Layanan', value: 'value'), + _buildColumnText(context, label: 'Class', value: 'value'), + _buildColumnText(context, label: 'Gate', value: 'value'), + _buildColumnText(context, label: 'Seat', value: 'value'), + ], + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 20.h), + child: CustomDashedLine(), + ), + _buildBarcode(context, barcodeData: 'PK230222BE143') ], ), ) @@ -71,4 +91,37 @@ class PrintBoardingPassScreen extends StatelessWidget { ), ); } + + Widget _buildColumnText( + BuildContext context, { + required String label, + required String value, + }) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TypographyStyles.small(label, color: GrayColors.gray500, fontWeight: FontWeight.w400), + TypographyStyles.caption( + value, + color: GrayColors.gray800, + maxlines: 1, + ) + ], + ); + } + + Widget _buildBarcode(BuildContext context, {required String barcodeData}) { + return Column( + children: [ + BarcodeWidget( + barcode: Barcode.code128(), + data: barcodeData, + height: 80.h, + drawText: false, + ), + SizedBox(height: 10.h), + TypographyStyles.small(barcodeData, color: GrayColors.gray800, fontWeight: FontWeight.w400) + ], + ); + } } diff --git a/lib/presentation/screens/home/component/card_tickets.dart b/lib/presentation/screens/home/component/card_tickets.dart index dca3170..f67f568 100644 --- a/lib/presentation/screens/home/component/card_tickets.dart +++ b/lib/presentation/screens/home/component/card_tickets.dart @@ -18,8 +18,9 @@ class CardTickets extends StatelessWidget { final String duration; final String seatClass; final String price; - final VoidCallback onTap; + final VoidCallback? onTap; final bool withContainer; + final bool showFooter; const CardTickets({ Key? key, @@ -33,13 +34,13 @@ class CardTickets extends StatelessWidget { required this.duration, required this.seatClass, required this.price, - required this.onTap, - required this.withContainer, + this.onTap, + this.withContainer = true, + this.showFooter = true, }); @override Widget build(BuildContext context) { - // Konten utama card Widget content = Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -77,35 +78,34 @@ class CardTickets extends StatelessWidget { TypographyStyles.small(arrivalTime, color: GrayColors.gray600, fontWeight: FontWeight.w400), ], ), - SizedBox(height: 16.h), - SvgPicture.asset('assets/images/divider_custome.svg', width: 348.w), - SizedBox(height: 6.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - CustomeIcons.FlightSeatFilled(), - SizedBox(width: 6.w), - TypographyStyles.caption(seatClass, color: GrayColors.gray800), - ], - ), - Row( - children: [ - TypographyStyles.body(price, color: PrimaryColors.primary800), - SizedBox(width: 2.w), - TypographyStyles.small('/orang', color: GrayColors.gray600, fontWeight: FontWeight.w400), - ], - ), - ], - ) + if (showFooter) ...[ + SizedBox(height: 16.h), + SvgPicture.asset('assets/images/divider_custome.svg', width: 348.w), + SizedBox(height: 6.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + CustomeIcons.FlightSeatFilled(), + SizedBox(width: 6.w), + TypographyStyles.caption(seatClass, color: GrayColors.gray800), + ], + ), + Row( + children: [ + TypographyStyles.body(price, color: PrimaryColors.primary800), + SizedBox(width: 2.w), + TypographyStyles.small('/orang', color: GrayColors.gray600, fontWeight: FontWeight.w400), + ], + ), + ], + ) + ] ], ); - // Jika withShadow = true, bungkus konten dengan CustomeShadowCotainner - Widget finalWidget = withContainer - ? CustomeShadowCotainner(child: content) - : content; + Widget finalWidget = withContainer ? CustomeShadowCotainner(child: content) : content; return ZoomTapAnimation( child: GestureDetector( diff --git a/lib/presentation/screens/home/pages/search_tickets_screen.dart b/lib/presentation/screens/home/pages/search_tickets_screen.dart index 43343af..f713c0a 100644 --- a/lib/presentation/screens/home/pages/search_tickets_screen.dart +++ b/lib/presentation/screens/home/pages/search_tickets_screen.dart @@ -124,7 +124,6 @@ class _SearchTicketsScreenState extends State { return Padding( padding: EdgeInsets.only(bottom: 16.h), child: CardTickets( - withContainer: true, departureCity: '${flight.cityDeparture} (${flight.codeDeparture})', date: ticketDate, arrivalCity: '${flight.cityArrival} (${flight.codeArrival})', diff --git a/pubspec.lock b/pubspec.lock index 147783d..88a2393 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -25,6 +25,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + barcode: + dependency: transitive + description: + name: barcode + sha256: "7b6729c37e3b7f34233e2318d866e8c48ddb46c1f7ad01ff7bb2a8de1da2b9f4" + url: "https://pub.dev" + source: hosted + version: "2.2.9" + barcode_widget: + dependency: "direct main" + description: + name: barcode_widget + sha256: "6f2c5b08659b1a5f4d88d183e6007133ea2f96e50e7b8bb628f03266c3931427" + url: "https://pub.dev" + source: hosted + version: "2.0.4" boolean_selector: dependency: transitive description: @@ -424,6 +440,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + qr: + dependency: transitive + description: + name: qr + sha256: "5a1d2586170e172b8a8c8470bbbffd5eb0cd38a66c0d77155ea138d3af3a4445" + url: "https://pub.dev" + source: hosted + version: "3.0.2" shared_preferences: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index b8f90ac..f8ceb5c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,6 +52,7 @@ dependencies: dropdown_button2: ^2.3.9 google_fonts: ^6.2.1 dotted_dashed_line: ^0.0.3 + barcode_widget: ^2.0.4 # pin_code_fields: ^8.0.1 # dio: ^5.8.0+1