6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 001c7792

AuthorNKL<nikolaj.king@gmail.com>
Date2024-11-15 12:53:37 +0100
added booking details page for past and cancelled bookings

Changed files

comwell_key_app/assets/icons/download_bill.svg     |   5 +
 comwell_key_app/assets/icons/maestro.svg           |   7 +
 comwell_key_app/assets/icons/mastercard.svg        |   7 +
 comwell_key_app/assets/icons/visa.svg              |   5 +
 comwell_key_app/assets/translations/da-DK.json     |  15 +-
 comwell_key_app/assets/translations/en-US.json     |  14 +-
 .../lib/components/comwell_app_bar.dart            |  52 +++---
 .../components/booking_list_item_view.dart         | 117 +++++++------
 .../lib/overview/components/bookings_tab_view.dart |   1 +
 comwell_key_app/lib/overview/models/booking.dart   |  37 +++-
 .../lib/overview/models/payment_details.dart       |  57 ++++++
 comwell_key_app/lib/overview/overview_page.dart    |   4 +-
 .../past_cancelled_booking_detail_page.dart        | 191 +++++++++++++++++++++
 .../overview/repository/overview_repository.dart   | 136 ++++++++++++---
 comwell_key_app/lib/routing/app_router.dart        |  77 +++++----
 comwell_key_app/lib/routing/app_routes.dart        |  19 +-
 comwell_key_app/pubspec.yaml                       |   2 +-
 17 files changed, 598 insertions(+), 148 deletions(-)

Diff

diff --git a/comwell_key_app/assets/icons/download_bill.svg b/comwell_key_app/assets/icons/download_bill.svg
new file mode 100644
index 00000000..23f800b9
--- /dev/null
+++ b/comwell_key_app/assets/icons/download_bill.svg
@@ -0,0 +1,5 @@
+<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
+<circle cx="18" cy="18" r="18" fill="#F0EAE2"/>
+<rect width="20" height="20" transform="translate(8 8)" fill="#F0EAE2"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M11.75 17.375L12.6312 16.4938L17.375 21.2313V9.25H18.625V21.2313L23.3688 16.4938L24.25 17.375L18 23.625L11.75 17.375ZM11.75 23V25.5H24.25V23H25.5V25.5C25.5 26.1904 24.9404 26.75 24.25 26.75H11.75C11.0596 26.75 10.5 26.1904 10.5 25.5V23H11.75Z" fill="black"/>
+</svg>
diff --git a/comwell_key_app/assets/icons/maestro.svg b/comwell_key_app/assets/icons/maestro.svg
new file mode 100644
index 00000000..b2f13825
--- /dev/null
+++ b/comwell_key_app/assets/icons/maestro.svg
@@ -0,0 +1,7 @@
+<svg width="40" height="29" viewBox="0 0 40 29" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect x="0.5" y="1" width="39" height="27" rx="1.5" fill="white"/>
+<rect x="0.5" y="1" width="39" height="27" rx="1.5" stroke="#E0E0E0"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M20.0007 20.0166C18.7296 21.0974 17.0803 21.75 15.278 21.75C11.2585 21.75 8 18.5041 8 14.5C8 10.4959 11.2585 7.25 15.278 7.25C17.0803 7.25 18.7296 7.90256 20.0007 8.98344C21.2718 7.90256 22.9211 7.25 24.7233 7.25C28.7429 7.25 32.0014 10.4959 32.0014 14.5C32.0014 18.5041 28.7429 21.75 24.7233 21.75C22.9211 21.75 21.2718 21.0974 20.0007 20.0166Z" fill="#ED0006"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M20 20.0166C21.5638 18.6868 22.5554 16.7087 22.5554 14.5C22.5554 12.2913 21.5638 10.3132 20 8.98344C21.2711 7.90256 22.9204 7.25 24.7227 7.25C28.7422 7.25 32.0007 10.4959 32.0007 14.5C32.0007 18.5041 28.7422 21.75 24.7227 21.75C22.9204 21.75 21.2711 21.0974 20 20.0166Z" fill="#0099DF"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.9929 20.0165C21.5567 18.6868 22.5482 16.7087 22.5482 14.5C22.5482 12.2912 21.5567 10.3132 19.9929 8.9834C18.429 10.3132 17.4375 12.2912 17.4375 14.5C17.4375 16.7087 18.429 18.6868 19.9929 20.0165Z" fill="#6C6BBD"/>
+</svg>
diff --git a/comwell_key_app/assets/icons/mastercard.svg b/comwell_key_app/assets/icons/mastercard.svg
new file mode 100644
index 00000000..fabf6670
--- /dev/null
+++ b/comwell_key_app/assets/icons/mastercard.svg
@@ -0,0 +1,7 @@
+<svg width="45" height="32" viewBox="0 0 45 32" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect x="1.28627" y="1.14272" width="43.1429" height="29.7143" rx="1.42857" fill="white"/>
+<rect x="1.28627" y="1.14272" width="43.1429" height="29.7143" rx="1.42857" stroke="#E0E0E0" stroke-width="1.14286"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M22.8557 22.3042C21.403 23.5395 19.5181 24.2853 17.4584 24.2853C12.8646 24.2853 9.14062 20.5757 9.14062 15.9996C9.14062 11.4235 12.8646 7.71387 17.4584 7.71387C19.5181 7.71387 21.403 8.45965 22.8557 9.69494C24.3084 8.45965 26.1933 7.71387 28.253 7.71387C32.8468 7.71387 36.5708 11.4235 36.5708 15.9996C36.5708 20.5757 32.8468 24.2853 28.253 24.2853C26.1933 24.2853 24.3084 23.5395 22.8557 22.3042Z" fill="#ED0006"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M22.8555 22.3042C24.6427 20.7845 25.7759 18.5239 25.7759 15.9996C25.7759 13.4753 24.6427 11.2147 22.8555 9.69494C24.3082 8.45965 26.1931 7.71387 28.2528 7.71387C32.8466 7.71387 36.5705 11.4235 36.5705 15.9996C36.5705 20.5757 32.8466 24.2853 28.2528 24.2853C26.1931 24.2853 24.3082 23.5395 22.8555 22.3042Z" fill="#F9A000"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M22.8462 22.3041C24.6335 20.7844 25.7666 18.5237 25.7666 15.9995C25.7666 13.4752 24.6335 11.2146 22.8462 9.69482C21.059 11.2146 19.9258 13.4752 19.9258 15.9995C19.9258 18.5237 21.059 20.7844 22.8462 22.3041Z" fill="#FF5E00"/>
+</svg>
diff --git a/comwell_key_app/assets/icons/visa.svg b/comwell_key_app/assets/icons/visa.svg
new file mode 100644
index 00000000..2b852a9d
--- /dev/null
+++ b/comwell_key_app/assets/icons/visa.svg
@@ -0,0 +1,5 @@
+<svg width="40" height="28" viewBox="0 0 40 28" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect x="0.5" y="0.5" width="39" height="27" rx="1.5" fill="white"/>
+<rect x="0.5" y="0.5" width="39" height="27" rx="1.5" stroke="#E0E0E0"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12.0003 18.43H9.57707L7.75995 11.448C7.6737 11.1268 7.49057 10.8429 7.22119 10.7091C6.54893 10.3728 5.80814 10.1051 5 9.97016V9.70136H8.90362C9.44238 9.70136 9.84645 10.1051 9.91379 10.5741L10.8566 15.6104L13.2787 9.70136H15.6345L12.0003 18.43ZM16.9799 18.43H14.6914L16.5759 9.70136H18.8644L16.9799 18.43ZM21.8256 12.1194C21.8929 11.6493 22.297 11.3805 22.7684 11.3805C23.5092 11.313 24.3161 11.448 24.9896 11.7831L25.3937 9.90379C24.7202 9.63498 23.9794 9.5 23.3072 9.5C21.086 9.5 19.4697 10.709 19.4697 12.387C19.4697 13.6636 20.6146 14.3338 21.4227 14.7376C22.297 15.1402 22.6337 15.4091 22.5664 15.8117C22.5664 16.4156 21.8929 16.6844 21.2207 16.6844C20.4125 16.6844 19.6044 16.4831 18.8648 16.1468L18.4607 18.0273C19.2688 18.3624 20.1431 18.4974 20.9513 18.4974C23.4418 18.5637 24.9896 17.3559 24.9896 15.5429C24.9896 13.2598 21.8256 13.126 21.8256 12.1194ZM32.9985 18.43L31.1814 9.70136H29.2296C28.8255 9.70136 28.4214 9.97016 28.2867 10.3728L24.9219 18.43H27.2778L27.748 17.1546H30.6426L30.912 18.43H32.9985ZM29.5677 12.052L30.2399 15.3416H28.3555L29.5677 12.052Z" fill="#172B85"/>
+</svg>
diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index a4b625c3..e55ad5ed 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -49,5 +49,18 @@
"profil_settings_birthday": "Fødselsdag",
"profil_settings_edit_password": "Ret adgangskode",
"profile_settings_error": "Der skete en fejl. Prøv igen.",
- "delete_profile": "Slet profil"
+ "delete_profile": "Slet profil",
+ "my_booking": "Min booking",
+ "booking_reference": "Bookingreference",
+ "check_in": "Check-in",
+ "check_out": "Check-out",
+ "booking_details": "Booking",
+ "number_of_guests": "Personer",
+ "booker": "Booker",
+ "booking_date": "Booking dato",
+ "payment": "Betaling",
+ "payment_method": "Betalingsmetode",
+ "bill": "Kvittering",
+ "get_bill": "Hent kvittering"
+
}
\ No newline at end of file
diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index d1cca5a2..8f93b8f2 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -49,5 +49,17 @@
"profil_settings_birthday": "Birthday",
"profil_settings_edit_password": "Edit password",
"profile_settings_error": "An error occurred. Please try again later.",
- "delete_profile": "Delete profile"
+ "delete_profile": "Delete profile",
+ "my_booking": "My booking",
+ "booking_reference": "Bookingreference",
+ "check_in": "Check-in",
+ "check_out": "Check-out",
+ "booking_details": "Booking",
+ "number_of_guests": "Personer",
+ "booker": "Booker",
+ "booking_date": "Booking date",
+ "payment": "Payment",
+ "payment_method": "Payment method",
+ "bill": "Bill",
+ "get_bill": "Get bill"
}
\ No newline at end of file
diff --git a/comwell_key_app/lib/components/comwell_app_bar.dart b/comwell_key_app/lib/components/comwell_app_bar.dart
index ea428ac9..ce29531d 100644
--- a/comwell_key_app/lib/components/comwell_app_bar.dart
+++ b/comwell_key_app/lib/components/comwell_app_bar.dart
@@ -9,10 +9,11 @@ class ComwellAppBar extends StatelessWidget implements PreferredSizeWidget {
final bool shouldShowBackButton;
final bool shouldShowProfileButton;
- const ComwellAppBar({super.key,
- this.shouldShowAppBar = true,
- this.shouldShowBackButton = true,
- this.shouldShowProfileButton = true,
+ const ComwellAppBar({
+ super.key,
+ this.shouldShowAppBar = true,
+ this.shouldShowBackButton = true,
+ this.shouldShowProfileButton = true,
});
@override
@@ -26,25 +27,34 @@ class ComwellAppBar extends StatelessWidget implements PreferredSizeWidget {
),
),
height: 112,
- child: Padding(
-
+ child: Padding(
padding: const EdgeInsets.only(bottom: 10),
- child:Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.end,
-
- children: [
- if (shouldShowBackButton)
- RoundIconButton(icon: "assets/icons/arrow-right.svg", onPressed: () {
- Navigator.of(context).pop();
- }),
- if (shouldShowProfileButton)
- RoundIconButton(icon: "assets/icons/user-open.svg", onPressed: () {
- context.goNamed(AppRoutes.profile.name);
- }),
- ],
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Visibility(
+ visible: shouldShowBackButton,
+ child: RoundIconButton(
+ icon: "assets/icons/arrow-right.svg",
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ Visibility(
+ visible: shouldShowProfileButton,
+ child: RoundIconButton(
+ icon: "assets/icons/user-open.svg",
+ onPressed: () {
+ context.goNamed(AppRoutes.profile.name);
+ },
+ ),
+ ),
+ ],
+ ),
),
- ),);
+ );
}
@override
diff --git a/comwell_key_app/lib/overview/components/booking_list_item_view.dart b/comwell_key_app/lib/overview/components/booking_list_item_view.dart
index ce0b6fe6..2cfae4d2 100644
--- a/comwell_key_app/lib/overview/components/booking_list_item_view.dart
+++ b/comwell_key_app/lib/overview/components/booking_list_item_view.dart
@@ -1,7 +1,11 @@
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
+import 'package:go_router/go_router.dart';
class BookingListItemView extends StatelessWidget {
+ final Booking booking;
final String hotelName;
final DateTime startDate;
final DateTime endDate;
@@ -10,6 +14,7 @@ class BookingListItemView extends StatelessWidget {
const BookingListItemView({
super.key,
+ required this.booking,
required this.hotelName,
required this.startDate,
required this.endDate,
@@ -20,61 +25,71 @@ class BookingListItemView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
- return Container(
- height: 66,
- margin: const EdgeInsets.only(bottom: 8, left: 8, right: 8),
- decoration: BoxDecoration(
- border: Border.all(
- width: 1,
- color: Colors.grey.shade300,
+ return InkWell(
+ onTap: () => {context.pushNamed(AppRoutes.bookingDetails.name, extra: booking)},
+ child: Container(
+ height: 66,
+ margin: const EdgeInsets.only(bottom: 8, left: 8, right: 8),
+ decoration: BoxDecoration(
+ border: Border.all(
+ width: 1,
+ color: Colors.grey.shade300,
+ ),
+ borderRadius: BorderRadius.circular(6),
),
- borderRadius: BorderRadius.circular(6),
- ),
- child: Row(
- children: [
- Container(
- margin: const EdgeInsets.all(0),
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(6), bottomLeft: Radius.circular(6)),
+ child: Row(
+ children: [
+ Container(
+ margin: const EdgeInsets.all(0),
+ decoration: const BoxDecoration(
+ borderRadius: BorderRadius.only(
+ topLeft: Radius.circular(6),
+ bottomLeft: Radius.circular(6)),
+ ),
+ width: 84,
+ height: 66,
+ child: hotelImage,
),
- width: 84,
- height: 66,
- child: hotelImage,
- ),
- const SizedBox(width: 8),
- Padding(
- padding: const EdgeInsets.all(8),
- child:
- Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ const SizedBox(width: 8),
+ Padding(
+ padding: const EdgeInsets.all(8),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ hotelName,
+ style: theme.textTheme.headlineSmall,
+ ),
+ Row(
+ children: [
+ const Icon(Icons.calendar_today_outlined,
+ size: 16, color: Colors.black),
+ const SizedBox(width: 4),
+ Text(
+ DateFormat('d. MMM').format(startDate),
+ style: theme.textTheme.bodySmall,
+ ),
+ const SizedBox(width: 4),
+ const Icon(Icons.arrow_forward,
+ size: 16, color: Colors.black),
+ const SizedBox(width: 4),
+ Text(
+ DateFormat('d. MMM').format(endDate),
+ style: theme.textTheme.bodySmall,
+ ),
+ ],
+ )
+ ]),
+ ),
+ const Spacer(),
+ if (isCancelled)
Text(
- hotelName,
- style: theme.textTheme.headlineSmall,
+ "booking_annulled".tr(),
+ style: theme.textTheme.bodyMedium?.copyWith(color: Colors.red),
),
- Row(
- children: [
- const Icon(Icons.calendar_today_outlined, size: 16, color: Colors.black),
- const SizedBox(width: 4),
- Text(
- DateFormat('d. MMM').format(startDate),
- style: theme.textTheme.bodySmall,
- ),
- const SizedBox(width: 4),
- const Icon(Icons.arrow_forward, size: 16, color: Colors.black),
- const SizedBox(width: 4),
- Text(
- DateFormat('d. MMM').format(endDate),
- style: theme.textTheme.bodySmall,
- ),
- ],
- )
- ]),
- ),
- const Spacer(),
- if (isCancelled)
- Text("booking_annulled".tr(),style: theme.textTheme.bodyMedium?.copyWith(color: Colors.red),),
- const SizedBox(width: 16),
- ],
+ const SizedBox(width: 16),
+ ],
+ ),
),
);
}
diff --git a/comwell_key_app/lib/overview/components/bookings_tab_view.dart b/comwell_key_app/lib/overview/components/bookings_tab_view.dart
index 23e04f6b..35cd33b0 100644
--- a/comwell_key_app/lib/overview/components/bookings_tab_view.dart
+++ b/comwell_key_app/lib/overview/components/bookings_tab_view.dart
@@ -66,6 +66,7 @@ class BookingsTabView extends StatelessWidget {
shrinkWrap: true,
itemCount: bookings.length,
itemBuilder: (context, index) => BookingListItemView(
+ booking: bookings[index],
hotelName: bookings[index].hotelName,
startDate: bookings[index].startDate,
endDate: bookings[index].endDate,
diff --git a/comwell_key_app/lib/overview/models/booking.dart b/comwell_key_app/lib/overview/models/booking.dart
index f60350e2..5627da64 100644
--- a/comwell_key_app/lib/overview/models/booking.dart
+++ b/comwell_key_app/lib/overview/models/booking.dart
@@ -1,16 +1,21 @@
+import 'package:comwell_key_app/overview/models/payment_details.dart';
+
class Booking {
final String id;
final String userId;
final String roomNumber;
final DateTime startDate;
final DateTime endDate;
- final String status;
+ final BookingStatus status;
final String image;
final String hotelName;
final String hotelCode;
final String roomType;
final int adults;
final int children;
+ final String booker;
+ final DateTime bookingDate;
+ final PaymentDetails paymentDetails;
Booking({
@@ -26,6 +31,9 @@ class Booking {
required this.children,
required this.adults,
required this.hotelCode,
+ required this.booker,
+ required this.bookingDate,
+ required this.paymentDetails,
});
factory Booking.fromJson(dynamic json) {
@@ -35,13 +43,16 @@ class Booking {
roomNumber: json['roomNumber'] as String,
startDate: DateTime.parse(json['startDate'] as String),
endDate: DateTime.parse(json['endDate'] as String),
- status: json['status'] as String,
+ status: _parseBookingStatus(json['status'] as String),
image: json['image'] as String,
hotelName: json['hotelName'] as String,
roomType: json['roomType'] as String,
children: json['children'] as int,
adults: json['adults'] as int,
hotelCode: json['hotelCode'] as String,
+ booker: json['booker'] as String,
+ bookingDate: DateTime.parse(json['bookingDate'] as String),
+ paymentDetails: PaymentDetails.fromJson(json['paymentDetails'] as Map<String, dynamic>),
);
}
@@ -52,14 +63,34 @@ class Booking {
'roomId': roomNumber,
'startDate': startDate.toIso8601String(),
'endDate': endDate.toIso8601String(),
- 'status': status,
+ 'status': status.toString(),
'image': image,
'hotelName': hotelName,
'roomType': roomType,
'adults': adults,
'children': children,
'hotelCode': hotelCode,
+ 'booker': booker,
+ 'bookingDate': bookingDate.toIso8601String(),
};
}
+
+ static BookingStatus _parseBookingStatus(String status) {
+ switch (status) {
+ case 'current':
+ return BookingStatus.current;
+ case 'past':
+ return BookingStatus.past;
+ case 'cancelled':
+ return BookingStatus.cancelled;
+ default:
+ throw Exception('Unknown booking status: $status');
+ }
+ }
}
+enum BookingStatus {
+ current,
+ past,
+ cancelled,
+}
\ No newline at end of file
diff --git a/comwell_key_app/lib/overview/models/payment_details.dart b/comwell_key_app/lib/overview/models/payment_details.dart
new file mode 100644
index 00000000..0ad8587f
--- /dev/null
+++ b/comwell_key_app/lib/overview/models/payment_details.dart
@@ -0,0 +1,57 @@
+class PaymentDetails {
+ final String cardNumber;
+ final String cardHolder;
+ final String? expiryDate;
+ final String? cvc;
+ final CardType cardType;
+ final String? cardName;
+
+ PaymentDetails({
+ required this.cardNumber,
+ required this.cardHolder,
+ required this.expiryDate,
+ required this.cvc,
+ required this.cardType,
+ this.cardName,
+ });
+
+ factory PaymentDetails.fromJson(dynamic json) {
+ return PaymentDetails(
+ cardNumber: json['cardNumber'] as String,
+ cardHolder: json['cardHolder'] as String,
+ expiryDate: json['expiryDate'] as String,
+ cvc: json['cvc'] as String,
+ cardType: _parseCardType(json['cardType'] as String),
+ cardName: json['cardName'] as String,
+ );
+ }
+
+ Map<String, dynamic> toJson() {
+ return {
+ 'cardNumber': cardNumber,
+ 'cardHolder': cardHolder,
+ 'expiryDate': expiryDate,
+ 'cvc': cvc,
+ 'cardType': cardType.toString(),
+ };
+ }
+
+ static CardType _parseCardType(String type) {
+ switch (type) {
+ case 'visa':
+ return CardType.visa;
+ case 'mastercard':
+ return CardType.mastercard;
+ case 'maestro':
+ return CardType.maestro;
+ default:
+ throw Exception('Unknown card type: $type');
+ }
+ }
+}
+
+enum CardType {
+ visa,
+ mastercard,
+ maestro,
+}
diff --git a/comwell_key_app/lib/overview/overview_page.dart b/comwell_key_app/lib/overview/overview_page.dart
index 7ba52021..ca78314a 100644
--- a/comwell_key_app/lib/overview/overview_page.dart
+++ b/comwell_key_app/lib/overview/overview_page.dart
@@ -39,7 +39,9 @@ class OverviewTabViewState extends State<OverviewPage>
builder: (context, state) {
return Scaffold(
backgroundColor: Colors.white,
- appBar: const ComwellAppBar(),
+ appBar: const ComwellAppBar(
+ shouldShowBackButton: false,
+ ),
body: SafeArea(
child: Column(
children: [
diff --git a/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart b/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart
new file mode 100644
index 00000000..b70fc437
--- /dev/null
+++ b/comwell_key_app/lib/overview/past_cancelled_booking_detail_page.dart
@@ -0,0 +1,191 @@
+import 'package:comwell_key_app/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/overview/models/payment_details.dart';
+import 'package:comwell_key_app/themes/light_theme.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+
+class PastCancelledBookingDetailPage extends StatelessWidget {
+ final Booking booking;
+
+ const PastCancelledBookingDetailPage({super.key, required this.booking});
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = Theme.of(context);
+ return Scaffold(
+ appBar: const ComwellAppBar(
+ shouldShowProfileButton: false,
+ ),
+ backgroundColor: Colors.white,
+ body: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: ListView(
+ children: [
+ const SizedBox(height: 20),
+ Text(
+ 'my_booking'.tr(),
+ style: theme.textTheme.headlineLarge,
+ ),
+ const SizedBox(
+ height: 36,
+ ),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text('booking_reference'.tr(),
+ style: theme.textTheme.bodySmall
+ ?.copyWith(color: Colors.black.withOpacity(0.65))),
+ subtitle: Text(booking.id, style: theme.textTheme.headlineSmall),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ textAlign: TextAlign.start,
+ 'check_in'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: Colors.black.withOpacity(0.65))),
+ Text(
+ DateFormat('d. MMM yyyy')
+ .format(booking.startDate)
+ .toString(),
+ style: theme.textTheme.headlineSmall),
+ ],
+ ),
+ const SizedBox(width: 60),
+ const Icon(Icons.arrow_forward),
+ const SizedBox(width: 20),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('check_out'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: Colors.black.withOpacity(0.65))),
+ Text(
+ DateFormat('d. MMM yyyy')
+ .format(booking.endDate)
+ .toString(),
+ style: theme.textTheme.headlineSmall)
+ ],
+ ),
+ ],
+ )),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text('booking_details'.tr(),
+ style: theme.textTheme.bodySmall
+ ?.copyWith(color: Colors.black.withOpacity(0.65))),
+ subtitle: Text(
+ booking.roomType,
+ style: theme.textTheme.headlineSmall,
+ ),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text('number_of_guests'.tr(),
+ style: theme.textTheme.bodySmall
+ ?.copyWith(color: Colors.black.withOpacity(0.65))),
+ subtitle: Text(
+ "${booking.adults} ${booking.adults > 1 ? 'adults'.tr() : 'adult'.tr()}${booking.children >= 1 ? ', ${booking.children} ${booking.children > 1 ? 'children'.tr() : 'child'.tr()}' : ''}",
+ style: theme.textTheme.headlineSmall),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text('booker'.tr(),
+ style: theme.textTheme.bodySmall
+ ?.copyWith(color: Colors.black.withOpacity(0.65))),
+ subtitle:
+ Text(booking.booker, style: theme.textTheme.headlineSmall),
+ ),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Text('booking_date'.tr(),
+ style: theme.textTheme.bodySmall
+ ?.copyWith(color: Colors.black.withOpacity(0.65))),
+ subtitle: Text(
+ DateFormat('d. MMM yyyy')
+ .format(booking.bookingDate)
+ .toString(),
+ style: theme.textTheme.headlineSmall)),
+ const Divider(color: colorDivider),
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('payment'.tr(), style: theme.textTheme.headlineLarge),
+ const SizedBox(height: 20),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('payment_method'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: Colors.black.withOpacity(0.65))),
+ Text(booking.paymentDetails.cardNumber,
+ style: theme.textTheme.headlineSmall),
+ ]),
+ booking.status == BookingStatus.cancelled
+ ? Text('booking_annulled'.tr(),
+ style: theme.textTheme.headlineSmall
+ ?.copyWith(color: Colors.red))
+ : bookingCardImage(booking.paymentDetails.cardType),
+ ],
+ )
+ ],
+ )),
+ const Divider(color: colorDivider),
+ booking.status != BookingStatus.cancelled
+ ? ListTile(
+ contentPadding: const EdgeInsets.symmetric(horizontal: 0),
+ title: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('bill'.tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: Colors.black.withOpacity(0.65))),
+ Text('get_bill'.tr(),
+ style: theme.textTheme.headlineSmall),
+ ]),
+ SvgPicture.asset('assets/icons/download_bill.svg'),
+ ],
+ ))
+ : const SizedBox(),
+ booking.status != BookingStatus.cancelled
+ ? const Divider(color: colorDivider)
+ : const SizedBox(),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget bookingCardImage(CardType cardType) {
+ switch (cardType) {
+ case CardType.visa:
+ return SvgPicture.asset('assets/icons/visa.svg');
+ case CardType.mastercard:
+ return SvgPicture.asset('assets/icons/mastercard.svg');
+ case CardType.maestro:
+ return SvgPicture.asset('assets/icons/maestro.svg');
+ default:
+ return SvgPicture.asset('assets/icons/visa.svg');
+ }
+ }
+}
diff --git a/comwell_key_app/lib/overview/repository/overview_repository.dart b/comwell_key_app/lib/overview/repository/overview_repository.dart
index aabfb48d..1504374e 100644
--- a/comwell_key_app/lib/overview/repository/overview_repository.dart
+++ b/comwell_key_app/lib/overview/repository/overview_repository.dart
@@ -9,14 +9,13 @@ class OverviewRepository {
Future<Bookings> fetchAllBookingsForUser(String userId) async {
//final response = await api.fetchAllBookingsForUser(userId);
//if (response != null) {
- return Bookings.fromJson(response);
- // } else {
- // throw Exception('Failed to fetch bookings');
- // }
+ return Bookings.fromJson(response);
+ // } else {
+ // throw Exception('Failed to fetch bookings');
+ // }
}
}
-
final response = {
"current": [
{
@@ -25,13 +24,23 @@ final response = {
"roomNumber": "101",
"startDate": "2024-10-22T14:00:00",
"endDate": "2024-10-25T12:00:00",
- "status": "confirmed",
+ "status": "current",
"image": "assets/images/current_room.png",
"hotelName": "Seaside Resort",
"hotelCode": "SR001",
"roomType": "Deluxe",
"adults": 2,
- "children": 1
+ "children": 1,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "visa",
+ "cardName": " Doe Visa"
+ }
},
{
"id": "2",
@@ -39,13 +48,23 @@ final response = {
"roomNumber": "102",
"startDate": "2024-11-10T15:00:00",
"endDate": "2024-11-12T11:00:00",
- "status": "pending",
+ "status": "current",
"image": "assets/images/current_room.png",
"hotelName": "Mountain View Hotel",
"hotelCode": "MV002",
"roomType": "Suite",
"adults": 1,
- "children": 0
+ "children": 0,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "visa",
+ "cardName": " Doe Visa"
+ }
},
{
"id": "3",
@@ -53,13 +72,23 @@ final response = {
"roomNumber": "103",
"startDate": "2024-12-01T14:00:00",
"endDate": "2024-12-05T12:00:00",
- "status": "confirmed",
+ "status": "current",
"image": "assets/images/current_room.png",
"hotelName": "City Center Inn",
"hotelCode": "CCI003",
"roomType": "Standard",
"adults": 2,
- "children": 0
+ "children": 0,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "mastercard",
+ "cardName": " Doe mastercard"
+ }
}
],
"past": [
@@ -69,13 +98,23 @@ final response = {
"roomNumber": "104",
"startDate": "2024-09-25T14:00:00",
"endDate": "2024-09-28T12:00:00",
- "status": "confirmed",
+ "status": "past",
"image": "assets/images/portside.png",
"hotelName": "Luxury Suites",
"hotelCode": "LS004",
"roomType": "Executive",
"adults": 2,
- "children": 1
+ "children": 1,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "maestro",
+ "cardName": " Doe Maestro"
+ }
},
{
"id": "5",
@@ -83,13 +122,23 @@ final response = {
"roomNumber": "105",
"startDate": "2024-09-10T14:00:00",
"endDate": "2024-09-12T12:00:00",
- "status": "confirmed",
+ "status": "past",
"image": "assets/images/portside.png",
"hotelName": "Forest Retreat",
"hotelCode": "FR005",
"roomType": "Cottage",
"adults": 1,
- "children": 0
+ "children": 0,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "visa",
+ "cardName": " Doe Visa"
+ }
},
{
"id": "6",
@@ -97,13 +146,23 @@ final response = {
"roomNumber": "106",
"startDate": "2024-09-01T14:00:00",
"endDate": "2024-09-05T12:00:00",
- "status": "confirmed",
+ "status": "past",
"image": "assets/images/borupgaard.png",
"hotelName": "Beachfront Hotel",
"hotelCode": "BF006",
"roomType": "Suite",
"adults": 2,
- "children": 0
+ "children": 0,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "mastercard",
+ "cardName": " Doe master"
+ }
}
],
"cancelled": [
@@ -113,13 +172,23 @@ final response = {
"roomNumber": "107",
"startDate": "2024-10-15T14:00:00",
"endDate": "2024-10-17T12:00:00",
- "status": "canceled",
+ "status": "cancelled",
"image": "assets/images/borupgaard.png",
"hotelName": "Urban Lodge",
"hotelCode": "UL007",
"roomType": "Standard",
"adults": 1,
- "children": 0
+ "children": 0,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "visa",
+ "cardName": " Doe Visa"
+ }
},
{
"id": "8",
@@ -127,13 +196,23 @@ final response = {
"roomNumber": "108",
"startDate": "2024-10-10T14:00:00",
"endDate": "2024-10-12T12:00:00",
- "status": "canceled",
+ "status": "cancelled",
"image": "assets/images/koegestrand.png",
"hotelName": "Hilltop Cabins",
"hotelCode": "HC008",
"roomType": "Cabin",
"adults": 2,
- "children": 0
+ "children": 0,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "maestro",
+ "cardName": " Doe Maestro"
+ }
},
{
"id": "9",
@@ -141,14 +220,23 @@ final response = {
"roomNumber": "109",
"startDate": "2024-11-05T14:00:00",
"endDate": "2024-11-07T12:00:00",
- "status": "canceled",
+ "status": "cancelled",
"image": "assets/images/bygholmpark.png",
"hotelName": "Lakeside Bungalows",
"hotelCode": "LB009",
"roomType": "Bungalow",
"adults": 1,
- "children": 0
+ "children": 0,
+ "booker": "John Doe",
+ "bookingDate": "2024-10-15T14:00:00",
+ "paymentDetails": {
+ "cardHolder": "John Doe",
+ "cardNumber": "**** **** **** 1234",
+ "expiryDate": "12/24",
+ "cvc": "123",
+ "cardType": "visa",
+ "cardName": " Doe Visa"
+ }
}
]
};
-
\ No newline at end of file
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 5e6b968d..230285e2 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -3,7 +3,10 @@ import 'package:comwell_key_app/authentication/bloc/authentication_bloc.dart';
import 'package:comwell_key_app/home/home_page.dart';
import 'package:comwell_key_app/key/key_page.dart';
import 'package:comwell_key_app/login/login_page.dart';
+import 'package:comwell_key_app/overview/models/booking.dart';
+import 'package:comwell_key_app/overview/models/payment_details.dart';
import 'package:comwell_key_app/overview/overview_page.dart';
+import 'package:comwell_key_app/overview/past_cancelled_booking_detail_page.dart';
import 'package:comwell_key_app/profile/profile_page.dart';
import 'package:comwell_key_app/profile_settings/profile_settings_page.dart';
import 'package:comwell_key_app/redeem_debug/redeem_page.dart';
@@ -47,39 +50,47 @@ GoRouter goRouter(AuthenticationBloc authBloc) {
},
routes: <RouteBase>[
GoRoute(
- path: "/oauthredirect",
- name: AppRoutes.overview.name,
- builder: (context, state) => const OverviewPage(),
- routes: [
- GoRoute(
- path: "home",
- name: AppRoutes.home.name,
- builder: (context, state) => const HomeWidget(),
- routes: [
- GoRoute(
- path: "key",
- name: AppRoutes.key.name,
- builder: (context, state) {
- return const KeyPage(); //mobileKey: key);
- },
- ),
- GoRoute(
- path: "profile",
- name: AppRoutes.profile.name,
- builder: (context, state) {
- return ProfilePage(); //mobileKey: key);
- },
- routes: [
- GoRoute(
- path: "profilesettings",
- name: AppRoutes.profileSettings.name,
- builder: (context, state) =>
- const ProfileSettingsPage(),
- ),
- ],
- )
- ]),
- ]),
+ path: "/oauthredirect",
+ name: AppRoutes.overview.name,
+ builder: (context, state) => const OverviewPage(),
+ routes: [
+ GoRoute(
+ path: "profile",
+ name: AppRoutes.profile.name,
+ builder: (context, state) {
+ return ProfilePage(); //mobileKey: key);
+ },
+ routes: [
+ GoRoute(
+ path: "profilesettings",
+ name: AppRoutes.profileSettings.name,
+ builder: (context, state) => const ProfileSettingsPage(),
+ ),
+ ],
+ ),
+ GoRoute(
+ path: "booking_details",
+ name: AppRoutes.bookingDetails.name,
+ builder: (context, state) {
+ Booking booking = state.extra as Booking;
+ return PastCancelledBookingDetailPage(booking: booking);
+ }),
+ GoRoute(
+ path: "home",
+ name: AppRoutes.home.name,
+ builder: (context, state) => const HomeWidget(),
+ routes: [
+ GoRoute(
+ path: "key",
+ name: AppRoutes.key.name,
+ builder: (context, state) {
+ return const KeyPage(); //mobileKey: key);
+ },
+ ),
+ ],
+ ),
+ ],
+ ),
GoRoute(
path: "/login",
name: AppRoutes.login.name,
diff --git a/comwell_key_app/lib/routing/app_routes.dart b/comwell_key_app/lib/routing/app_routes.dart
index 59f3ec63..53c8738e 100644
--- a/comwell_key_app/lib/routing/app_routes.dart
+++ b/comwell_key_app/lib/routing/app_routes.dart
@@ -1,10 +1,3 @@
-/* class Routes {
- static const initial = '/';
- static const redeem = '/Redeem';
- static const credentials = '/Credentials';
- static const settings = '/Settings';
-} */
-
enum AppRoutes {
welcome,
home,
@@ -13,8 +6,10 @@ enum AppRoutes {
key,
keys,
settings,
- login,
- sheet,
- profile,
- overview, profileSettings,
-}
\ No newline at end of file
+ login,
+ sheet,
+ profile,
+ overview,
+ profileSettings,
+ bookingDetails,
+}
diff --git a/comwell_key_app/pubspec.yaml b/comwell_key_app/pubspec.yaml
index bb5dcdb4..f5db90f4 100644
--- a/comwell_key_app/pubspec.yaml
+++ b/comwell_key_app/pubspec.yaml
@@ -4,7 +4,7 @@ description: This app needs a description
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
-version: 0.0.1+5
+version: 0.0.1+6
environment:
sdk: '>=3.0.0 <3.25.0'