6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 353811e5
Changed files
comwell_key_app/assets/translations/da-DK.json | 1 + comwell_key_app/assets/translations/en-US.json | 1 + .../xcshareddata/xcschemes/debugtest.xcscheme | 20 ++++++++++ .../lib/booking_details/booking_details_page.dart | 1 + .../lib/check_out/bloc/check_out_cubit.dart | 16 +++++++- .../lib/check_out/bloc/check_out_state.dart | 12 ++++-- .../check_out/components/accept_terms_toggle.dart | 33 ++++++++++++----- .../check_out/components/apply_club_points.dart | 9 +++-- .../components/check_out_payment_card.dart | 2 +- .../components/checkout_itemized_bill.dart | 43 ++++++++-------------- .../lib/check_out/models/check_out_item.dart | 5 +++ comwell_key_app/lib/profile/utils/urls.dart | 1 + .../up_sales/pages/up_sale_confirmation_page.dart | 2 +- 13 files changed, 100 insertions(+), 46 deletions(-)
Diff
diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index 4d4ccc8b..91f9b298 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -170,6 +170,7 @@
"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_club_points_subtitle_zero": "Du har ingen point at anvende",
"checkout_page_payment_payment_title": "Betal med {}",
"accept_terms": "Accepter betingelserne",
"checkout_page_payment_dialog_title": "Er du sikker på du vil checke ud af hotellet?",
diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index 5c081c8a..55b48090 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -169,6 +169,7 @@
"checkout_page_payment_price": "{} kr.",
"checkout_page_payment_club_points_title": "Use Comwell Club Points",
"checkout_page_payment_club_points_subtitle": "You have {} points, use them and save {} kr.",
+ "checkout_page_payment_club_points_subtitle_zero": "You have no points to use",
"checkout_page_payment_payment_title": "Pay with {}",
"accept_terms": "Accept terms and conditions",
"checkout_page_payment_dialog_title": "Are you sure you want to check out?",
diff --git a/comwell_key_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/debugtest.xcscheme b/comwell_key_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/debugtest.xcscheme
index db3ca262..443f4bc9 100644
--- a/comwell_key_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/debugtest.xcscheme
+++ b/comwell_key_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/debugtest.xcscheme
@@ -6,6 +6,24 @@
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
+ <PreActions>
+ <ExecutionAction
+ ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
+ <ActionContent
+ title = "Run Prepare Flutter Framework Script"
+ scriptText = "/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" prepare ">
+ <EnvironmentBuildable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "97C146ED1CF9000F007C117D"
+ BuildableName = "Runner.app"
+ BlueprintName = "Runner"
+ ReferencedContainer = "container:Runner.xcodeproj">
+ </BuildableReference>
+ </EnvironmentBuildable>
+ </ActionContent>
+ </ExecutionAction>
+ </PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
@@ -27,6 +45,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
@@ -34,6 +53,7 @@
buildConfiguration = "Debug-debugtest"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/comwell_key_app/lib/booking_details/booking_details_page.dart b/comwell_key_app/lib/booking_details/booking_details_page.dart
index 0d0b0b55..27a44b93 100644
--- a/comwell_key_app/lib/booking_details/booking_details_page.dart
+++ b/comwell_key_app/lib/booking_details/booking_details_page.dart
@@ -53,6 +53,7 @@ class BookingDetailsPage extends StatelessWidget {
Widget _buildBookingDetailsPage(BuildContext context,
BookingDetailsState state, BookingDetailsBloc cubit) {
final theme = Theme.of(context);
+
return Stack(
children: [
Container(
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 1798587f..d9a129e5 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
@@ -10,10 +10,12 @@ import 'package:comwell_key_app/check_out/utils/constants.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/pregistration/pregistration_repository.dart';
import 'package:comwell_key_app/profile/profile_repository.dart';
+import 'package:comwell_key_app/profile/utils/urls.dart';
import 'package:comwell_key_app/tracking/comwell_tracking.dart';
import 'package:comwell_key_app/tracking/models/analytics_event_item.dart';
import 'package:comwell_key_app/utils/locator.dart';
import 'package:flutter/material.dart';
+import 'package:url_launcher/url_launcher.dart';
class CheckoutCubit extends Cubit<CheckoutState> {
final ProfileRepository profileRepository = locator<ProfileRepository>();
@@ -34,6 +36,7 @@ class CheckoutCubit extends Cubit<CheckoutState> {
try {
final user = await profileRepository.fetchProfileSettings();
emit(state.clubPointsFetched(user.points));
+ setItems([...state.items, CheckoutItem("Körv", 500)]);
} catch (e) {
// Todo handle error
@@ -175,6 +178,17 @@ class CheckoutCubit extends Cubit<CheckoutState> {
}
void showTermsAndConditions() {
- // TODO
+ launchUrl(Uri.parse(ComwellUrls.termsAndConditions));
+ }
+
+ //Removes the decimal point from the balance if it is .0
+ String get trimmedBalance {
+ final balance = booking.balance;
+ if (balance == null) return '';
+ if (balance == balance.toInt()) {
+ return balance.toInt().toString();
+ } else {
+ return balance.toStringAsFixed(2);
+ }
}
}
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 f41a71f2..f712298c 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
@@ -16,7 +16,9 @@ class CheckoutState extends Equatable {
int get totalPriceBeforeDiscount => _sumOfList(_items);
- int get totalPriceAfterDiscount => _sumOfList(items);
+ int get totalPriceAfterDiscount => _sumOfList(items) - clubPoints;
+
+ int get totalPrice => _sumOfList(_items);
Iterable<CheckoutItem> get items {
if (applyClubPoints) {
@@ -26,6 +28,7 @@ class CheckoutState extends Equatable {
}
int _sumOfList(Iterable<CheckoutItem> list) {
+
if (list.isEmpty) return 0;
return list
.map((item) => item.price)
@@ -48,7 +51,7 @@ class CheckoutState extends Equatable {
isTermsAccepted = false,
page = CheckoutPage.confirmation,
showTermsError = false,
- clubPoints = 0,
+ clubPoints = 500,
paymentMethod = CheckoutPaymentMethod.creditCard,
processingState = CheckoutProcessingStateNotStarted(),
applyClubPoints = false;
@@ -113,6 +116,9 @@ class CheckoutState extends Equatable {
processingState,
page,
showTermsError,
- paymentMethod
+ paymentMethod,
+ totalPriceBeforeDiscount,
+ totalPriceAfterDiscount,
+ totalPrice,
];
}
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 3ef7810f..22c6ce7d 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
@@ -11,6 +11,7 @@ class AcceptTermsToggle extends StatelessWidget {
Widget build(BuildContext context) {
final cubit = context.read<CheckoutCubit>();
final showError = cubit.state.showTermsError;
+ final theme = Theme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -29,17 +30,29 @@ class AcceptTermsToggle extends StatelessWidget {
},
),
const SizedBox(width: 4),
- TextButton(
- onPressed: () {
- cubit.showTermsAndConditions();
- },
- child: Text(
- "accept_terms".tr(),
- style: TextStyle(
- color: sandColor[80],
- decoration: TextDecoration.underline,
+ Row(
+ children: [
+ Text(
+ "approve_conditions_title".tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: colorHeadlineText,
+ ),
+ ),
+ const SizedBox(width: 4),
+ GestureDetector(
+ onTap: () {
+ cubit.showTermsAndConditions();
+ },
+ child: Text(
+ "approve_conditions_subtitle".tr(),
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: sandColor[80],
+ decoration: TextDecoration.underline,
+ decorationColor: sandColor[80],
+ ),
+ ),
),
- ),
+ ],
),
const SizedBox(height: 4),
],
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 d1b3c0d8..6557cf91 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
@@ -20,15 +20,18 @@ class ApplyClubPoints extends StatelessWidget {
children: [
Text("checkout_page_payment_club_points_title".tr()),
Text(
- "checkout_page_payment_club_points_subtitle".tr(
- args: ["${cubit.state.clubPoints}", "${cubit.state.clubPoints}"],
- ),
+ cubit.state.clubPoints > 0
+ ? "checkout_page_payment_club_points_subtitle".tr(
+ args: ["${cubit.state.clubPoints}", "${cubit.state.clubPoints}"],
+ )
+ : "checkout_page_payment_club_points_subtitle_zero".tr(),
style: TextStyle(color: colorBlack[65]),
),
],
),
),
const SizedBox(width: 20),
+ if (cubit.state.clubPoints > 0)
Switch(
value: cubit.state.applyClubPoints,
activeColor: sandColor[80],
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 0539001b..2d926d20 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
@@ -31,7 +31,7 @@ class CheckOutPaymentCard extends StatelessWidget {
style: theme.textTheme.bodySmall?.copyWith(color: colorBlack[65]),
),
const SizedBox(height: 4),
- Text("checkout_page_payment_price".tr(args: ["${cubit.booking.balance}"]),
+ Text("checkout_page_payment_price".tr(args: [(cubit.trimmedBalance)]),
style: theme.textTheme.displaySmall),
],
),
diff --git a/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart b/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
index a377fdfe..9eecbd81 100644
--- a/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
+++ b/comwell_key_app/lib/check_out/components/checkout_itemized_bill.dart
@@ -12,6 +12,9 @@ class CheckoutItemizedBill extends StatelessWidget {
Widget build(BuildContext context) {
final cubit = context.read<CheckoutCubit>();
final items = cubit.state.items;
+
+ print("discount ${cubit.state.totalPriceBeforeDiscount}");
+ print("discount ${cubit.state.totalPriceAfterDiscount}");
return Column(
children: [
...items.map((item) => Column(
@@ -28,35 +31,21 @@ class CheckoutItemizedBill extends StatelessWidget {
children: [
Text("checkout_page_payment_total".tr()),
if (cubit.state.applyClubPoints)
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 350),
- transitionBuilder: (Widget child, Animation<double> animation) {
- final slide = Tween<Offset>(
- begin: const Offset(0, 1),
- end: Offset.zero,
- ).animate(animation);
- return SlideTransition(
- position: slide,
- child: FadeTransition(opacity: animation, child: child),
- );
- },
- child: Row(
- key: ValueKey(cubit.state.applyClubPoints),
- children: [
- Text(
- "${cubit.state.totalPriceBeforeDiscount}",
- style: const TextStyle(
- decoration: TextDecoration.lineThrough,
- decorationColor: colorDivider,
- color: colorDivider),
- ),
- const SizedBox(width: 4),
- Text("${cubit.booking.balance! - cubit.state.clubPoints}"),
- ],
- ),
+ Row(
+ children: [
+ Text(
+ cubit.state.totalPriceBeforeDiscount.toString(),
+ style: const TextStyle(
+ decoration: TextDecoration.lineThrough,
+ decorationColor: colorDivider,
+ color: colorDivider),
+ ),
+ const SizedBox(width: 4),
+ Text("${cubit.state.totalPriceAfterDiscount.toInt()}"),
+ ],
)
else
- Text("${cubit.booking.balance}"),
+ Text(cubit.trimmedBalance),
],
),
const SizedBox(height: 12),
diff --git a/comwell_key_app/lib/check_out/models/check_out_item.dart b/comwell_key_app/lib/check_out/models/check_out_item.dart
index a6dcdd44..96547382 100644
--- a/comwell_key_app/lib/check_out/models/check_out_item.dart
+++ b/comwell_key_app/lib/check_out/models/check_out_item.dart
@@ -3,4 +3,9 @@ class CheckoutItem {
final int price;
CheckoutItem(this.name, this.price);
+
+ @override
+ String toString() {
+ return 'CheckoutItem{name: $name, price: $price}';
+ }
}
\ No newline at end of file
diff --git a/comwell_key_app/lib/profile/utils/urls.dart b/comwell_key_app/lib/profile/utils/urls.dart
index f83a686e..9270906a 100644
--- a/comwell_key_app/lib/profile/utils/urls.dart
+++ b/comwell_key_app/lib/profile/utils/urls.dart
@@ -2,4 +2,5 @@ class ComwellUrls {
static const String clubRules = 'https://comwell.com/club/club-regler';
static const String clubPermission = 'https://comwell.com/club/club-permission';
static const String comwellWebsite = 'https://comwell.com/';
+ static const String termsAndConditions = 'https://comwell.com/en/about-comwell/trade-conditions';
}
diff --git a/comwell_key_app/lib/up_sales/pages/up_sale_confirmation_page.dart b/comwell_key_app/lib/up_sales/pages/up_sale_confirmation_page.dart
index 1e46dc8d..442bc7db 100644
--- a/comwell_key_app/lib/up_sales/pages/up_sale_confirmation_page.dart
+++ b/comwell_key_app/lib/up_sales/pages/up_sale_confirmation_page.dart
@@ -109,7 +109,7 @@ class UpSaleConfirmationPage extends StatelessWidget {
)),
GestureDetector(
onTap: () {
- launchUrl(Uri.parse(ComwellUrls.clubRules));
+ launchUrl(Uri.parse(ComwellUrls.termsAndConditions));
},
child: Text(
'approve_conditions_subtitle'.tr(),