6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 80b3657e
Changed files
comwell_key_app/assets/translations/da-DK.json | 9 +- comwell_key_app/assets/translations/en-US.json | 9 +- .../pregistration/bloc/preregistration_cubit.dart | 24 ++++- .../pregistration/bloc/preregistration_state.dart | 32 +++++- .../lib/pregistration/pages/edit_profile_page.dart | 20 ---- .../pages/prereg_confirmation_page.dart | 108 ++++++++++++++------- .../pages/prereg_information_page.dart | 1 - 7 files changed, 143 insertions(+), 60 deletions(-)
Diff
diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index 8b7b0e9f..1d7e154d 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -103,5 +103,12 @@
"preregistration_address_label_country": "Land",
"preregistration_payment_title": "Betalingskort",
"preregistration_payment_subtitle": "For at kunne overnatte på Comwell, skal vi bruge et betalingskort.",
- "preregistration_payment_add_card": "Tilføj kort"
+ "preregistration_payment_add_card": "Tilføj kort",
+ "preregistration_confirmation_title": "Registeringsinformation",
+ "preregistration_confirmation_profile_card_title": "Profilinformation",
+ "preregistration_confirmation_address_card_title": "Adresse",
+ "preregistration_confirmation_payment_card_title": "Betalingskort",
+ "preregistration_confirmation_extras_card_title_singular": "1 valgt Tilkøb",
+ "preregistration_confirmation_extras_card_title_plural": "{} valgte tilkøb",
+ "preregistration_confirmation_extras_card_subtitle": "Skrives på din værelsesregning"
}
\ 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 58e56ebc..e45b82f9 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -100,5 +100,12 @@
"preregistration_address_label_country": "Country",
"preregistration_payment_title": "Payment methods",
"preregistration_payment_subtitle": "To stay at Comwell, you need to add a payment method",
- "preregistration_payment_add_card": "Add card"
+ "preregistration_payment_add_card": "Add card",
+ "preregistration_confirmation_title": "Registration information",
+ "preregistration_confirmation_profile_card_title": "Profile information",
+ "preregistration_confirmation_address_card_title": "Address",
+ "preregistration_confirmation_payment_card_title": "Payment method",
+ "preregistration_confirmation_extras_card_title_singular": "1 extra purchase",
+ "preregistration_confirmation_extras_card_title_plural": "{} extra purchases",
+ "preregistration_confirmation_extras_card_subtitle": "Will be added to your bill"
}
\ No newline at end of file
diff --git a/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart b/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
index 49d26a8f..929097d7 100644
--- a/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
+++ b/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
@@ -79,7 +79,18 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
}
void onEditProfileClicked() {
- // TODO
+
+ }
+
+ void onEditAddressClicked() {
+ _navigateTo(PreregistrationPage.information);
+ }
+
+ void onEditPaymentMethodClicked() {
+ _navigateTo(PreregistrationPage.paymentMethod);
+ }
+
+ void onEditExtrasClicked() {
}
void onBackClicked() {
@@ -90,7 +101,17 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
}
}
+ void _navigateTo(PreregistrationPage page) async {
+ if(_isAnimating) return;
+ _isAnimating = true;
+ await pageController.animateToPage(page.index,
+ duration: const Duration(milliseconds: 500),
+ curve: Curves.fastOutSlowIn);
+ _isAnimating = false;
+ }
+
void _navigateNextPage() async {
+ if(_isAnimating) return;
_isAnimating = true;
await pageController.nextPage(
duration: const Duration(milliseconds: 500),
@@ -99,6 +120,7 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
}
void _navigatePreviousPage() async {
+ if(_isAnimating) return;
_isAnimating = true;
await pageController.previousPage(
duration: const Duration(milliseconds: 500),
diff --git a/comwell_key_app/lib/pregistration/bloc/preregistration_state.dart b/comwell_key_app/lib/pregistration/bloc/preregistration_state.dart
index c861da8e..ed6a3f95 100644
--- a/comwell_key_app/lib/pregistration/bloc/preregistration_state.dart
+++ b/comwell_key_app/lib/pregistration/bloc/preregistration_state.dart
@@ -9,6 +9,10 @@ class PreregistrationState extends Equatable {
final Exception? error;
final bool missingInformation;
final String buttonText;
+ final int numOfExtras;
+ final int extrasTotalPrice;
+ final String paymentMethodName;
+ final String paymentMethodLastFourDigits;
String get buttonTextLocalized => buttonText.tr();
@@ -19,25 +23,49 @@ class PreregistrationState extends Equatable {
required this.loading,
required this.missingInformation,
this.buttonText = "generic_continue",
+ this.numOfExtras = 0,
+ this.extrasTotalPrice = 0,
+ this.paymentMethodName = "Name Name",
+ this.paymentMethodLastFourDigits = "1234",
this.user,
this.error,
});
@override
- List<Object?> get props => [loading, user, error, missingInformation, buttonText];
+ List<Object?> get props => [
+ loading,
+ user,
+ error,
+ missingInformation,
+ buttonText,
+ numOfExtras,
+ extrasTotalPrice,
+ paymentMethodName,
+ paymentMethodLastFourDigits
+ ];
PreregistrationState copyWith({
bool? loading,
User? user,
Exception? error,
bool? missingInformation,
+ int? numOfExtras,
+ int? extrasTotalPrice,
+ String? paymentMethodName,
+ String? paymentMethodLastFourDigits,
String? buttonText,
}) {
return PreregistrationState(
loading: loading ?? this.loading,
missingInformation: missingInformation ?? this.missingInformation,
user: user ?? this.user,
- buttonText: buttonText ?? "generic_continue",
+ buttonText: buttonText ?? this.buttonText,
+ numOfExtras: numOfExtras ?? this.numOfExtras,
+ extrasTotalPrice: extrasTotalPrice ?? this.extrasTotalPrice,
+ paymentMethodName:
+ paymentMethodName ?? this.paymentMethodLastFourDigits,
+ paymentMethodLastFourDigits:
+ paymentMethodLastFourDigits ?? this.paymentMethodLastFourDigits,
error: error);
}
}
diff --git a/comwell_key_app/lib/pregistration/pages/edit_profile_page.dart b/comwell_key_app/lib/pregistration/pages/edit_profile_page.dart
deleted file mode 100644
index a2b13e78..00000000
--- a/comwell_key_app/lib/pregistration/pages/edit_profile_page.dart
+++ /dev/null
@@ -1,20 +0,0 @@
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flutter/material.dart';
-
-class EditProfilePage extends StatelessWidget {
- const EditProfilePage({super.key});
-
- @override
- Widget build(BuildContext context) {
- return Column(
- children: [
- const SizedBox(height: 40),
- Text("preregistration_confirmation_title".tr(),
- style: Theme.of(context).textTheme.headlineLarge),
- const SizedBox(height: 18),
- Text("preregistration_confirmation_subtitle".tr(),
- style: Theme.of(context).textTheme.bodySmall),
- ],
- );
- }
-}
diff --git a/comwell_key_app/lib/pregistration/pages/prereg_confirmation_page.dart b/comwell_key_app/lib/pregistration/pages/prereg_confirmation_page.dart
index e91ce262..076f4505 100644
--- a/comwell_key_app/lib/pregistration/pages/prereg_confirmation_page.dart
+++ b/comwell_key_app/lib/pregistration/pages/prereg_confirmation_page.dart
@@ -1,6 +1,8 @@
+import 'package:comwell_key_app/pregistration/bloc/preregistration_cubit.dart';
import 'package:comwell_key_app/pregistration/widgets/information_card.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
class PreregConfirmationPage extends StatelessWidget {
@@ -8,62 +10,88 @@ class PreregConfirmationPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
+ final cubit = context.read<PreregistrationCubit>();
+ final state = cubit.state;
+ final user = state.user!;
+
+ String extrasTitleText;
+ if (state.numOfExtras == 1) {
+ extrasTitleText =
+ "preregistration_confirmation_extras_card_title_singular".tr();
+ } else {
+ extrasTitleText =
+ "preregistration_confirmation_extras_card_title_plural".tr(
+ args: [state.numOfExtras.toString()]);
+ }
+
return ListView(
children: [
const SizedBox(height: 40),
Text("preregistration_confirmation_title".tr(),
- style: Theme.of(context).textTheme.headlineLarge),
- const SizedBox(height: 18),
- Text("preregistration_confirmation_subtitle".tr(),
- style: Theme.of(context).textTheme.bodySmall),
+ style: Theme
+ .of(context)
+ .textTheme
+ .headlineLarge),
const SizedBox(height: 40),
InformationCard(
- title: "Profilinformation",
- onEditClick: () {},
+ title: "preregistration_confirmation_profile_card_title".tr(),
+ onEditClick: cubit.onEditProfileClicked,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Jeppe Bjorholm Andersen",
- style: Theme.of(context).textTheme.bodyMedium,
- ),
- Text(
- "jad@dwarf.dk",
- style: Theme.of(context).textTheme.bodyMedium,
+ "${user.firstName} ${user.lastName}",
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodyMedium,
),
Text(
- "+45 21499736",
- style: Theme.of(context).textTheme.bodyMedium,
+ user.email,
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodyMedium,
),
Text(
- "23-08-1992",
- style: Theme.of(context).textTheme.bodyMedium,
+ "${user.countryCode} ${user.phone}",
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodyMedium,
),
],
),
),
const SizedBox(height: 12),
InformationCard(
- title: "Adresse",
- onEditClick: () {},
+ title: "preregistration_confirmation_address_card_title".tr(),
+ onEditClick: cubit.onEditAddressClicked,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Bernhard Bangs Allé 25",
- style: Theme.of(context).textTheme.bodyMedium,
+ user.address.street,
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodyMedium,
),
Text(
- "2000, Frederiksberg, Denmark",
- style: Theme.of(context).textTheme.bodyMedium,
+ "${user.address.zipCode}, ${user.address.city}, ${user.address
+ .country}",
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodyMedium,
),
],
),
),
const SizedBox(height: 12),
InformationCard(
- title: "Betalingskort",
- onEditClick: () {},
+ title: "preregistration_confirmation_payment_card_title".tr(),
+ onEditClick: cubit.onEditPaymentMethodClicked,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@@ -73,12 +101,18 @@ class PreregConfirmationPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Name",
- style: Theme.of(context).textTheme.bodySmall,
+ state.paymentMethodName,
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodySmall,
),
Text(
- "**** **** **** 1234",
- style: Theme.of(context).textTheme.bodyMedium,
+ "**** **** **** ${state.paymentMethodLastFourDigits}",
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodyMedium,
),
],
),
@@ -87,18 +121,24 @@ class PreregConfirmationPage extends StatelessWidget {
),
const SizedBox(height: 12),
InformationCard(
- title: "2 valgte tilkøb",
- onEditClick: () {},
+ title: extrasTitleText,
+ onEditClick: cubit.onEditExtrasClicked,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "600 kr.",
- style: Theme.of(context).textTheme.bodySmall,
+ "${state.extrasTotalPrice} kr.",
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodySmall,
),
Text(
- "Skrives på din værelsesregning",
- style: Theme.of(context).textTheme.bodyMedium,
+ "preregistration_confirmation_extras_card_subtitle".tr(),
+ style: Theme
+ .of(context)
+ .textTheme
+ .bodyMedium,
),
],
),
diff --git a/comwell_key_app/lib/pregistration/pages/prereg_information_page.dart b/comwell_key_app/lib/pregistration/pages/prereg_information_page.dart
index 5079941a..8ad06356 100644
--- a/comwell_key_app/lib/pregistration/pages/prereg_information_page.dart
+++ b/comwell_key_app/lib/pregistration/pages/prereg_information_page.dart
@@ -41,7 +41,6 @@ class PreregInformationPage extends StatelessWidget {
const SizedBox(height: 40),
Text("preregistration_address_title".tr(),
style: Theme.of(context).textTheme.headlineLarge),
- Text(state.missingInformation.toString()),
const SizedBox(height: 18),
Text("preregistration_address_subtitle".tr(),
style: Theme.of(context).textTheme.bodySmall),