6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 59be7092

AuthorMikkel Thygesen<mth@dwarf.dk>
Date2025-02-14 14:21:03 +0100
549: Adjusted according to PR feedback

Changed files

comwell_key_app/assets/translations/da-DK.json     |  4 +-
 comwell_key_app/assets/translations/en-US.json     |  4 +-
 .../components/check_out_button.dart               |  5 +-
 .../lib/check_out/bloc/check_out_cubit.dart        | 37 +++++++++-----
 .../lib/check_out/bloc/check_out_state.dart        | 56 ++++++++++++----------
 .../check_out/components/accept_terms_toggle.dart  |  4 +-
 .../check_out/components/apply_club_points.dart    | 13 ++---
 .../components/check_out_bottom_sheet.dart         |  3 +-
 .../components/check_out_payment_card.dart         |  4 +-
 .../components/confirm_check_out_dialog.dart       |  4 +-
 .../lib/check_out/components/payment_button.dart   |  3 +-
 .../pages/check_out_confirmation_pages.dart        |  7 ++-
 .../lib/profile_settings/model/user.dart           |  2 +
 comwell_key_app/lib/themes/light_theme.dart        | 20 ++++----
 14 files changed, 98 insertions(+), 68 deletions(-)

Diff

diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index 618ce0c6..472a4ca3 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -139,6 +139,7 @@
"booking_details_page_practical_information": "Praktisk information",
"booking_details_page_checkout_title": "Check-out",
"booking_details_page_checkout_subtitle": "Start dit check-out her",
+ "booking_details_page_checkout_time": "10:00",
"need_help": "Har du brug for hjælp?",
"call_us": "Ring til os",
"call_us_description": "Har du brug for at komme i kontakt med et af vores hoteller? Benyt knappen nedenfor for at ringe op.",
@@ -154,11 +155,12 @@
"overview_page_check_in_button_subtitle": "Få dit digitale nøglekort med det samme",
"checkout_page_confirmation_title": "Check-out",
"checkout_page_confirmation_subtitle": "Når du bekræfter dit check-out har du 30 minutter til at forlade værelset før dit nøglekort vil stoppe med at virke.",
- "checkout_page_confirmation_deadline": "Dit check-out skal ske senest kl. {}",
+ "checkout_page_confirmation_deadline": "Dit check-out skal ske senest kl. 10:00",
"checkout_page_confirmation_price_title": "Til betaling",
"checkout_page_confirmation_continue": "Gå til betaling",
"checkout_page_payment_title": "Betalingsoversigt",
"checkout_page_payment_total": "Total",
+ "checkout_page_payment_price": "{} kr.",
"checkout_page_payment_club_points_title": "Brug Comwell Club Point",
"checkout_page_payment_club_points_subtitle": "Du har {} point, anvend og spar {} kr.",
"checkout_page_payment_payment_title": "Betal med {}",
diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index 13024b77..0e188f95 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -139,6 +139,7 @@
"booking_details_page_practical_information": "Practical information",
"booking_details_page_checkout_title": "Check-out",
"booking_details_page_checkout_subtitle": "Start your check-out here",
+ "booking_details_page_checkout_time": "10 AM",
"hotel_information_page_menu_restaurants_title": "Restaurants",
"hotel_information_page_menu_restaurants_subtitle": "Read about our restaurant",
"hotel_information_page_menu_spa_title": "Spa",
@@ -154,11 +155,12 @@
"restaurant_page_send_email": "Write an email",
"checkout_page_confirmation_title": "Check-out",
"checkout_page_confirmation_subtitle": "When you check out, you have 30 minutes to leave your room",
- "checkout_page_confirmation_deadline": "Check out latest at {}",
+ "checkout_page_confirmation_deadline": "Check out latest at 10 AM",
"checkout_page_confirmation_price_title": "To be payed",
"checkout_page_confirmation_continue": "Go to payment",
"checkout_page_payment_title": "Payment overview",
"checkout_page_payment_total": "Total",
+ "checkout_page_payment_price": "{} kr.",
"checkout_page_payment_club_points_title": "Use Comwell Club Points",
"checkout_page_payment_club_points_subtitle": "You have {} point, use them and save {} kr.",
"checkout_page_payment_payment_title": "Pay with {}",
diff --git a/comwell_key_app/lib/booking_details/components/check_out_button.dart b/comwell_key_app/lib/booking_details/components/check_out_button.dart
index c9e6445f..8fbc4187 100644
--- a/comwell_key_app/lib/booking_details/components/check_out_button.dart
+++ b/comwell_key_app/lib/booking_details/components/check_out_button.dart
@@ -1,11 +1,10 @@
import 'package:comwell_key_app/routing/app_routes.dart';
-import 'package:comwell_key_app/themes/dark_theme.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/svg.dart';
import 'package:go_router/go_router.dart';
-
class CheckOutButton extends StatelessWidget {
const CheckOutButton({super.key});
@@ -19,7 +18,7 @@ class CheckOutButton extends StatelessWidget {
child: Ink(
decoration: BoxDecoration(
border: Border.all(
- color: Colors.grey,
+ color: colorDivider,
),
borderRadius: BorderRadius.circular(10),
),
diff --git a/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart b/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
index 1ddf89d4..14e03239 100644
--- a/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
+++ b/comwell_key_app/lib/check_out/bloc/check_out_cubit.dart
@@ -3,9 +3,11 @@ import 'package:comwell_key_app/check_out/bloc/check_out_state.dart';
import 'package:comwell_key_app/check_out/models/check_out_item.dart';
import 'package:comwell_key_app/check_out/models/checkout_processing_state.dart';
import 'package:comwell_key_app/check_out/pages/check_out_page.dart';
+import 'package:comwell_key_app/profile_settings/repostiory/profile_settings_repository.dart';
import 'package:flutter/material.dart';
class CheckoutCubit extends Cubit<CheckoutState> {
+ late final ProfileSettingsRepository profileSettingsRepository;
final pageController = PageController();
final clubPoints = 200; // TODO Is this available on user object?
bool _isAnimating = false;
@@ -15,22 +17,31 @@ class CheckoutCubit extends Cubit<CheckoutState> {
CheckoutCubit() : super(CheckoutState.initial());
+ void init() async {
+ try {
+ final user = await profileSettingsRepository.fetchProfileSettings();
+ } catch (e) {}
+ }
+
void onApplyClubPointsClicked(bool value) {
- emit(state.setApplyClubPoints(value));
+ if (value) {
+ emit(state.termsAccepted());
+ } else {
+ emit(state.termsDenied());
+ }
}
- // TODO Where do we get the items from?
void setItems(Iterable<CheckoutItem> items) {
- emit(state.setItems(items));
+ emit(state.itemsUpdated(items));
}
// TODO connect to checkout endpoint, handle error state (missing in figma)
void processCheckout() async {
- emit(state.setProcessingState(CheckoutProcessingState.processing));
+ emit(state.processingStateUpdated(CheckoutProcessingState.processing));
await Future<void>.delayed(const Duration(seconds: 2));
- emit(state.setProcessingState(CheckoutProcessingState.success));
+ emit(state.processingStateUpdated(CheckoutProcessingState.success));
await Future<void>.delayed(const Duration(seconds: 2));
- emit(state.setProcessingState(CheckoutProcessingState.confirmed));
+ emit(state.processingStateUpdated(CheckoutProcessingState.confirmed));
}
void onContinueClicked() {
@@ -50,11 +61,11 @@ class CheckoutCubit extends Cubit<CheckoutState> {
_isAnimating = true;
pageController
.previousPage(
- duration: const Duration(milliseconds: 500),
- curve: Curves.fastOutSlowIn)
+ duration: const Duration(milliseconds: 500),
+ curve: Curves.fastOutSlowIn)
.then((_) {
_isAnimating = false;
- emit(state.setPage(currentPage));
+ emit(state.pageChanged(currentPage));
});
return true;
}
@@ -63,7 +74,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
await pageController.animateToPage(page.index,
duration: const Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn);
- emit(state.setPage(page));
+ emit(state.pageChanged(page));
_isAnimating = false;
}
@@ -78,6 +89,10 @@ class CheckoutCubit extends Cubit<CheckoutState> {
}
void onAcceptTermsChanged(bool value) {
- emit(state.setAcceptTerms(value));
+ if (value) {
+ emit(state.termsAccepted());
+ } else {
+ emit(state.termsDenied());
+ }
}
}
diff --git a/comwell_key_app/lib/check_out/bloc/check_out_state.dart b/comwell_key_app/lib/check_out/bloc/check_out_state.dart
index c2ac6acf..ac2dd7b4 100644
--- a/comwell_key_app/lib/check_out/bloc/check_out_state.dart
+++ b/comwell_key_app/lib/check_out/bloc/check_out_state.dart
@@ -1,14 +1,16 @@
import 'package:comwell_key_app/check_out/models/check_out_item.dart';
import 'package:comwell_key_app/check_out/models/checkout_processing_state.dart';
import 'package:comwell_key_app/check_out/pages/check_out_page.dart';
+import 'package:comwell_key_app/services/adyen/stored_payment_method.dart';
import 'package:equatable/equatable.dart';
class CheckoutState extends Equatable {
final Iterable<CheckoutItem> _items;
- final bool termsAccepted;
+ final bool isTermsAccepted;
final bool applyClubPoints;
final CheckoutProcessingState processingState;
final CheckoutPage page;
+ final StoredPaymentMethod? paymentMethod;
num get totalPrice {
if (_items.isEmpty) return 0;
@@ -24,46 +26,52 @@ class CheckoutState extends Equatable {
const CheckoutState({
required Iterable<CheckoutItem> items,
- required this.termsAccepted,
+ required this.isTermsAccepted,
required this.page,
required this.applyClubPoints,
required this.processingState,
+ this.paymentMethod,
}) : _items = items;
CheckoutState.initial()
: _items = _mockItems(),
- termsAccepted = false,
+ isTermsAccepted = false,
page = CheckoutPage.confirmation,
+ paymentMethod = const StoredPaymentMethod(expiryMonth: "12/12", expiryYear: "2004", holderName: "Mikke", id: "1234", lastFour: "1234", type: "visa"),
processingState = CheckoutProcessingState.notStarted,
applyClubPoints = false;
- CheckoutState setItems(Iterable<CheckoutItem> items) =>
+ CheckoutState itemsUpdated(Iterable<CheckoutItem> items) =>
_copyWith(items: items);
- CheckoutState setAcceptTerms(bool accept) => _copyWith(termsAccepted: accept);
+ CheckoutState termsAccepted() => _copyWith(termsAccepted: true);
- CheckoutState setApplyClubPoints(bool apply) =>
- _copyWith(applyClubPoints: apply);
+ CheckoutState termsDenied() => _copyWith(termsAccepted: false);
- CheckoutState setProcessingState(CheckoutProcessingState processingState) =>
- _copyWith(processingState: processingState);
+ CheckoutState clubPointsApplied() => _copyWith(applyClubPoints: true);
- CheckoutState setPage(CheckoutPage page) => _copyWith(page: page);
+ CheckoutState clubPointsRemoved() => _copyWith(applyClubPoints: false);
- CheckoutState _copyWith({
- Iterable<CheckoutItem>? items,
- bool? termsAccepted,
- bool? applyClubPoints,
- CheckoutProcessingState? processingState,
- CheckoutPage? page,
- }) {
+ CheckoutState processingStateUpdated(
+ CheckoutProcessingState processingState) =>
+ _copyWith(updateProcessingState: processingState);
+
+ CheckoutState pageChanged(CheckoutPage page) => _copyWith(page: page);
+
+ CheckoutState _copyWith(
+ {Iterable<CheckoutItem>? items,
+ bool? termsAccepted,
+ bool? applyClubPoints,
+ CheckoutProcessingState? updateProcessingState,
+ CheckoutPage? page,
+ StoredPaymentMethod? paymentMethod}) {
return CheckoutState(
- items: items ?? _items,
- page: page ?? this.page,
- processingState: processingState ?? this.processingState,
- termsAccepted: termsAccepted ?? this.termsAccepted,
- applyClubPoints: applyClubPoints ?? this.applyClubPoints,
- );
+ items: items ?? _items,
+ page: page ?? this.page,
+ processingState: updateProcessingState ?? processingState,
+ isTermsAccepted: termsAccepted ?? isTermsAccepted,
+ applyClubPoints: applyClubPoints ?? this.applyClubPoints,
+ paymentMethod: paymentMethod ?? this.paymentMethod);
}
static Iterable<CheckoutItem> _mockItems() =>
@@ -71,5 +79,5 @@ class CheckoutState extends Equatable {
@override
List<Object?> get props =>
- [_items, termsAccepted, applyClubPoints, processingState, page];
+ [_items, isTermsAccepted, applyClubPoints, processingState, page];
}
diff --git a/comwell_key_app/lib/check_out/components/accept_terms_toggle.dart b/comwell_key_app/lib/check_out/components/accept_terms_toggle.dart
index 65d7095a..592ae0c6 100644
--- a/comwell_key_app/lib/check_out/components/accept_terms_toggle.dart
+++ b/comwell_key_app/lib/check_out/components/accept_terms_toggle.dart
@@ -13,7 +13,7 @@ class AcceptTermsToggle extends StatelessWidget {
return Row(
children: [
Checkbox(
- value: cubit.state.termsAccepted,
+ value: cubit.state.isTermsAccepted,
visualDensity: VisualDensity.comfortable,
checkColor: Colors.white,
activeColor: sandColor[80],
@@ -24,7 +24,7 @@ class AcceptTermsToggle extends StatelessWidget {
const SizedBox(width: 4),
TextButton(
onPressed: () {
- cubit.onAcceptTermsChanged(!cubit.state.termsAccepted);
+ cubit.onAcceptTermsChanged(!cubit.state.isTermsAccepted);
},
child: Text("checkout_page_payment_accept_terms".tr())),
],
diff --git a/comwell_key_app/lib/check_out/components/apply_club_points.dart b/comwell_key_app/lib/check_out/components/apply_club_points.dart
index 0d6a527e..33c93f6f 100644
--- a/comwell_key_app/lib/check_out/components/apply_club_points.dart
+++ b/comwell_key_app/lib/check_out/components/apply_club_points.dart
@@ -23,18 +23,19 @@ class ApplyClubPoints extends StatelessWidget {
"checkout_page_payment_club_points_subtitle".tr(
args: ["${cubit.clubPoints}", "${cubit.clubPoints}"],
),
- style: const TextStyle(color: Color(0x55000000)),
+ style: TextStyle(color: colorBlack[65]),
),
],
),
),
const SizedBox(width: 20),
Switch(
- value: cubit.state.applyClubPoints,
- activeColor: sandColor[80],
- onChanged: (value) {
- cubit.onApplyClubPointsClicked(value);
- })
+ value: cubit.state.applyClubPoints,
+ activeColor: sandColor[80],
+ onChanged: (value) {
+ cubit.onApplyClubPointsClicked(value);
+ },
+ )
],
);
}
diff --git a/comwell_key_app/lib/check_out/components/check_out_bottom_sheet.dart b/comwell_key_app/lib/check_out/components/check_out_bottom_sheet.dart
index 6d938325..256a6e09 100644
--- a/comwell_key_app/lib/check_out/components/check_out_bottom_sheet.dart
+++ b/comwell_key_app/lib/check_out/components/check_out_bottom_sheet.dart
@@ -13,6 +13,7 @@ class CheckOutBottomSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cubit = context.read<CheckoutCubit>();
+ final paymentMethod = cubit.state.paymentMethod!;
return Container(
decoration:
const BoxDecoration(shape: BoxShape.rectangle, color: Colors.white),
@@ -53,7 +54,7 @@ class CheckOutBottomSheet extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 17.0),
child: Text("checkout_page_payment_payment_title"
- .tr(args: ["kreditkort"])),
+ .tr(args: [paymentMethod.type])),
));
}
}),
diff --git a/comwell_key_app/lib/check_out/components/check_out_payment_card.dart b/comwell_key_app/lib/check_out/components/check_out_payment_card.dart
index 191f1d82..de5e8d0b 100644
--- a/comwell_key_app/lib/check_out/components/check_out_payment_card.dart
+++ b/comwell_key_app/lib/check_out/components/check_out_payment_card.dart
@@ -30,10 +30,10 @@ class CheckOutPaymentCard extends StatelessWidget {
style: Theme.of(context)
.textTheme
.bodySmall
- ?.copyWith(color: const Color(0x55000000)),
+ ?.copyWith(color: colorBlack[65]),
),
const SizedBox(height: 4),
- Text("${cubit.state.totalPrice} kr.",
+ Text("checkout_page_payment_price".tr(args: ["${cubit.state.totalPrice}"]),
style: Theme.of(context).textTheme.displaySmall),
],
),
diff --git a/comwell_key_app/lib/check_out/components/confirm_check_out_dialog.dart b/comwell_key_app/lib/check_out/components/confirm_check_out_dialog.dart
index a9dacffc..de89d638 100644
--- a/comwell_key_app/lib/check_out/components/confirm_check_out_dialog.dart
+++ b/comwell_key_app/lib/check_out/components/confirm_check_out_dialog.dart
@@ -1,4 +1,4 @@
-import 'package:comwell_key_app/themes/dark_theme.dart';
+import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
@@ -28,7 +28,7 @@ class ConfirmCheckOutDialog extends StatelessWidget {
style: Theme.of(context)
.textTheme
.bodySmall
- ?.copyWith(color: const Color(0x55000000)),
+ ?.copyWith(color: colorBlack[65]),
),
const SizedBox(height: 32),
Row(
diff --git a/comwell_key_app/lib/check_out/components/payment_button.dart b/comwell_key_app/lib/check_out/components/payment_button.dart
index 9d16299c..4259e851 100644
--- a/comwell_key_app/lib/check_out/components/payment_button.dart
+++ b/comwell_key_app/lib/check_out/components/payment_button.dart
@@ -12,6 +12,7 @@ class PaymentButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cubit = context.read<CheckoutCubit>();
+ final paymentMethod = cubit.state.paymentMethod!;
return InkWell(
onTap: cubit.onChangePaymentClicked,
child: Container(
@@ -25,7 +26,7 @@ class PaymentButton extends StatelessWidget {
SvgPicture.asset("assets/icons/visa.svg"),
const SizedBox(width: 12),
Text(
- "checkout_page_payment_payment_title".tr(args: ["kreditkort"]),
+ "checkout_page_payment_payment_title".tr(args: [paymentMethod.type]),
style: Theme.of(context).textTheme.bodyMedium,
),
const Expanded(child: SizedBox()),
diff --git a/comwell_key_app/lib/check_out/pages/check_out_confirmation_pages.dart b/comwell_key_app/lib/check_out/pages/check_out_confirmation_pages.dart
index ba6e05ee..51c59292 100644
--- a/comwell_key_app/lib/check_out/pages/check_out_confirmation_pages.dart
+++ b/comwell_key_app/lib/check_out/pages/check_out_confirmation_pages.dart
@@ -14,7 +14,6 @@ class CheckOutConfirmationPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- CheckOutCountdown(),
const SizedBox(height: 40),
Text(
"checkout_page_confirmation_title".tr(),
@@ -25,16 +24,16 @@ class CheckOutConfirmationPage extends StatelessWidget {
style: Theme.of(context)
.textTheme
.bodySmall
- ?.copyWith(color: const Color(0x55000000)),
+ ?.copyWith(color: colorBlack[70]),
"checkout_page_confirmation_subtitle".tr(),
),
const SizedBox(height: 16),
Text(
- "checkout_page_confirmation_deadline".tr(args: ["10:00"]),
+ "checkout_page_confirmation_deadline".tr(),
style: Theme.of(context)
.textTheme
.bodySmall
- ?.copyWith(color: const Color(0x55000000)),
+ ?.copyWith(color: colorBlack[65]),
),
const SizedBox(height: 24),
const Divider(color: colorDivider),
diff --git a/comwell_key_app/lib/profile_settings/model/user.dart b/comwell_key_app/lib/profile_settings/model/user.dart
index d529e02a..1a36bb81 100644
--- a/comwell_key_app/lib/profile_settings/model/user.dart
+++ b/comwell_key_app/lib/profile_settings/model/user.dart
@@ -16,6 +16,7 @@ class User {
final Address address;
final DateTime birthday;
final String? shopperReference;
+ final int? points;
User({
required this.id,
@@ -27,6 +28,7 @@ class User {
required this.address,
required this.birthday,
this.shopperReference,
+ this.points,
});
factory User.fromJson(Json json) => _$UserFromJson(json);
diff --git a/comwell_key_app/lib/themes/light_theme.dart b/comwell_key_app/lib/themes/light_theme.dart
index 1e57a0b0..6065ca98 100644
--- a/comwell_key_app/lib/themes/light_theme.dart
+++ b/comwell_key_app/lib/themes/light_theme.dart
@@ -23,8 +23,6 @@ ThemeData lightTheme = ThemeData(
bodySmall: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500),
labelLarge: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600),
titleLarge: TextStyle(fontSize: 28.0, fontWeight: FontWeight.w600),
-
-
),
colorScheme: const ColorScheme(
primary: colorPrimary,
@@ -50,7 +48,7 @@ const colorPrimaryText = Color(0xFF000000);
const colorSecondaryText = Color(0xFF000000);
const colorOnPrimaryTextColor = Color(0xFFFFFFFF);
const colorPrimarySystem = Color(0xFF000000);
-const colorSecondarySystem =Color.fromARGB(237, 227, 216, 1);
+const colorSecondarySystem = Color.fromARGB(237, 227, 216, 1);
const colorTertiary = Color(0xFF000000);
const colorTertiaryText = Color(0xFF000000);
const colorTertiarySystem = Color(0xFF000000);
@@ -58,9 +56,13 @@ const colorShadow = Color(0xFF000000);
const colorDivider = Color(0xFFE0E0E0);
const disabledButtonColor = Color(0xFFF0F0F0);
+const colorBlack = MaterialColor(0xFF000000, {
+ 75: Color(0xB3000000),
+ 65: Color(0xA6000000),
+});
+
const int _earthColor = 0xFF677169;
-const earthColor = MaterialColor(_earthColor, <int,Color>
-{
+const earthColor = MaterialColor(_earthColor, <int, Color>{
100: Color(_earthColor),
80: Color.fromRGBO(128, 139, 130, 1.0),
60: Color.fromRGBO(160, 171, 163, 1.0),
@@ -69,14 +71,12 @@ const earthColor = MaterialColor(_earthColor, <int,Color>
10: Color.fromRGBO(238, 239, 238, 1.0),
});
-
const int _sandColor = 0xFFAA8D65;
-const sandColor = MaterialColor(_sandColor, <int,Color>
-{
+const sandColor = MaterialColor(_sandColor, <int, Color>{
100: Color(_sandColor),
80: Color.fromRGBO(190, 161, 121, 1.0),
60: Color.fromRGBO(215, 201, 185, 1.0),
40: Color.fromRGBO(237, 227, 216, 1.0),
20: Color.fromRGBO(240, 234, 226, 1.0),
- 10: Color(0xFFF9F6F2),
-});
\ No newline at end of file
+ 10: Color.fromRGBO(249, 246, 242, 1.0),
+});