6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 90346054

AuthorNKL<nikolaj.king@gmail.com>
Date2025-10-08 10:23:38 +0200
commit before clean symlinks

Changed files

.../authentication/authentication_repository.dart  | 22 ++++++++++++---
 .../lib/booking_details/booking_details_page.dart  |  2 +-
 .../lib/common/components/bottom_sheet_widget.dart |  2 +-
 .../hotel_information/components/image_widget.dart | 32 +++++++++-------------
 comwell_key_app/lib/main.dart                      |  7 +++--
 .../lib/notifications/notifications_page.dart      |  8 ++----
 comwell_key_app/lib/overview/overview_page.dart    |  6 +++-
 .../pregistration/cubit/preregistration_cubit.dart |  8 +++---
 .../pregistration/pages/prereg_profile_page.dart   |  6 ----
 .../interceptors/response_handle_interceptor.dart  | 22 +++++++++++----
 comwell_key_app/lib/utils/firebase.dart            |  8 +++---
 comwell_key_app/lib/utils/locator.dart             |  5 ++--
 comwell_key_app/pubspec.yaml                       |  3 +-
 13 files changed, 72 insertions(+), 59 deletions(-)

Diff

diff --git a/comwell_key_app/lib/authentication/authentication_repository.dart b/comwell_key_app/lib/authentication/authentication_repository.dart
index 732c73f4..b972c337 100644
--- a/comwell_key_app/lib/authentication/authentication_repository.dart
+++ b/comwell_key_app/lib/authentication/authentication_repository.dart
@@ -36,14 +36,14 @@ class AuthenticationRepository {
.env["ENTRA_ID_REDIRECT_URL"]!; // should probably be an env variable
- switch (appFlavor) {
- case "Develop":
+ switch (appFlavor?.toLowerCase()) {
+ case "develop":
configFilePath = 'assets/msal/msal_config_dev.json';
authorityUrl = dotenv.env["ENTRA_ID_AUTHORITY_URL"]!;
- case "Stage":
+ case "stage":
configFilePath = 'assets/msal/msal_config_stage.json';
authorityUrl = dotenv.env["ENTRA_ID_AUTHORITY_URL"]!;
- case "Prod":
+ case "prod":
configFilePath = 'assets/msal/msal_config_prod.json';
authorityUrl = dotenv.env["ENTRA_ID_AUTHORITY_URL"]!;
default:
@@ -191,4 +191,18 @@ class AuthenticationRepository {
throw Exception('No valid access token available');
}
}
+ Future<AuthenticationResult> acquireTokenSilent() async {
+ // Get the current account first
+ final accounts = await msAuth.getAccounts();
+ if (accounts.isEmpty) {
+ throw Exception('No accounts found');
+ }
+ // Use the first account's identifier
+ return await msAuth.acquireTokenSilent(
+ scopes: scopes,
+ authority: authorityUrl,
+ identifier: accounts.first.id,
+
+ );
+ }
}
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 eb65259d..38d32a43 100644
--- a/comwell_key_app/lib/booking_details/booking_details_page.dart
+++ b/comwell_key_app/lib/booking_details/booking_details_page.dart
@@ -110,7 +110,7 @@ class BookingDetailsPage extends StatelessWidget {
else
const SizedBox(),
const SizedBox(
- height: 100,
+ height: 200,
),
],
),
diff --git a/comwell_key_app/lib/common/components/bottom_sheet_widget.dart b/comwell_key_app/lib/common/components/bottom_sheet_widget.dart
index 936c25cb..8d9c447a 100644
--- a/comwell_key_app/lib/common/components/bottom_sheet_widget.dart
+++ b/comwell_key_app/lib/common/components/bottom_sheet_widget.dart
@@ -45,7 +45,7 @@ class _BottomSheetWidgetState extends State<BottomSheetWidget> {
final height = MediaQuery.of(context).size.height;
final padding = MediaQuery.of(context).padding;
final safeHeight = height - padding.top - padding.bottom;
- const grabbingHeight = 75.0;
+ const grabbingHeight = 200.0;
// Calculate the position factor that will maintain consistent visual position
// We want the sheet to take up roughly 90% of the safe area height
// We subtract the grabbing height (75) from the total height to get the actual content area
diff --git a/comwell_key_app/lib/hotel_information/components/image_widget.dart b/comwell_key_app/lib/hotel_information/components/image_widget.dart
index 1a28e6d5..6cfdda41 100644
--- a/comwell_key_app/lib/hotel_information/components/image_widget.dart
+++ b/comwell_key_app/lib/hotel_information/components/image_widget.dart
@@ -1,3 +1,4 @@
+import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
class ImageWidget extends StatelessWidget {
@@ -12,10 +13,19 @@ class ImageWidget extends StatelessWidget {
return SizedBox(
height: height * 0.4,
width: double.infinity,
- child: Image.network(
- image,
+ child: CachedNetworkImage(
+ imageUrl: image,
fit: BoxFit.cover,
- errorBuilder: (context, error, stackTrace) {
+ memCacheHeight: 400,
+ maxHeightDiskCache: 800,
+ progressIndicatorBuilder: (context, url, downloadProgress) =>
+ Container(
+ color: theme.colorScheme.surfaceContainerHighest,
+ child: Center(
+ child: CircularProgressIndicator(value: downloadProgress.progress),
+ ),
+ ),
+ errorWidget: (context, url, error) {
return Container(
color: theme.colorScheme.surfaceContainerHighest,
child: Center(
@@ -27,22 +37,6 @@ class ImageWidget extends StatelessWidget {
),
);
},
- loadingBuilder: (context, child, loadingProgress) {
- if (loadingProgress == null) return child;
- // This code makes the loading spinner show actual progress if possible,
- // or just spin if the total size is unknown, providing a better user experience while images load.
- final progress = loadingProgress.expectedTotalBytes != null
- ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
- : null;
- return Container(
- color: theme.colorScheme.surfaceContainerHighest,
- child: Center(
- child: CircularProgressIndicator(
- value: progress,
- ),
- ),
- );
- },
),
);
}
diff --git a/comwell_key_app/lib/main.dart b/comwell_key_app/lib/main.dart
index 9c6318d8..19a1a843 100644
--- a/comwell_key_app/lib/main.dart
+++ b/comwell_key_app/lib/main.dart
@@ -13,11 +13,12 @@ import 'firebase_options_stage.dart' as fb_stage;
import 'firebase_options_prod.dart' as fb_prod;
void main() async {
- if (appFlavor == 'Develop') {
+ final flavor = appFlavor?.toLowerCase();
+ if (flavor == 'develop') {
runMainApp(fb_dev.DefaultFirebaseOptions.currentPlatform, '.env.dev');
- } else if (appFlavor == 'Stage') {
+ } else if (flavor == 'stage') {
runMainApp(fb_stage.DefaultFirebaseOptions.currentPlatform, '.env.stage');
- } else if (appFlavor == 'Prod') {
+ } else if (flavor == 'prod') {
runMainApp(fb_prod.DefaultFirebaseOptions.currentPlatform, '.env.prod');
} else {
throw UnsupportedError('Invalid appFlavor: $appFlavor');
diff --git a/comwell_key_app/lib/notifications/notifications_page.dart b/comwell_key_app/lib/notifications/notifications_page.dart
index 4ea39e60..9cb94de3 100644
--- a/comwell_key_app/lib/notifications/notifications_page.dart
+++ b/comwell_key_app/lib/notifications/notifications_page.dart
@@ -93,7 +93,7 @@ class NotificationsPage extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Divider(
- color: Theme.of(context).colorScheme.onSurface,
+ color: Theme.of(context).colorScheme.outline,
thickness: 1,
height: 0,
),
@@ -111,11 +111,7 @@ class NotificationsPage extends StatelessWidget {
cubit.updatePreferences(
cubit.state.allNotifications, cubit.user.id);
},
- style: theme.elevatedButtonTheme.style?.copyWith(
- shape: WidgetStatePropertyAll(
- RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8))),
- ),
+ style: theme.elevatedButtonTheme.style,
child: Text(
'save'.tr(),
style: const TextStyle(
diff --git a/comwell_key_app/lib/overview/overview_page.dart b/comwell_key_app/lib/overview/overview_page.dart
index 34ce8aa7..22281e54 100644
--- a/comwell_key_app/lib/overview/overview_page.dart
+++ b/comwell_key_app/lib/overview/overview_page.dart
@@ -110,7 +110,11 @@ class OverviewTabViewState extends State<OverviewPage>
bookings:
const Bookings(cancelled: [], current: [], past: [])),
],
-
+ Divider(
+ color: theme.colorScheme.outline,
+ thickness: 1,
+ height: 0,
+ ),
Padding(
padding: const EdgeInsets.only(
left: 18.0, right: 18.0, bottom: 32.0, top: 16.0),
diff --git a/comwell_key_app/lib/pregistration/cubit/preregistration_cubit.dart b/comwell_key_app/lib/pregistration/cubit/preregistration_cubit.dart
index c4bd5f65..842f2bf3 100644
--- a/comwell_key_app/lib/pregistration/cubit/preregistration_cubit.dart
+++ b/comwell_key_app/lib/pregistration/cubit/preregistration_cubit.dart
@@ -220,7 +220,7 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
void _onConfirmPressed(BuildContext context) async {
emit(state.copyWith(isLoading: true));
try {
- final confirmationId = booking.confirmationId;
+ final confirmationId = booking.confirmationId;
final hasUpSales = state.addOnUpgrades.any((e) => e.isAddedToCart) ||
state.selectedRoomUpgrade.isNotEmpty;
@@ -239,12 +239,12 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
});
} else {
emit(state.setError(error: Error()));
- if (!context.mounted) return;
+ if (!context.mounted) return;
context.pop(null);
}
} catch (e) {
emit(state.setError(error: Error()));
- }
+ }
}
Future<void> addUpSalesToBooking() async {
@@ -375,7 +375,7 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
bool get isCityValid => cityTextController.text.isNotEmpty;
bool get isPhoneNumberValid =>
- phoneNumberTextController.text.length > 8 &&
+ phoneNumberTextController.text.length >= 8 &&
phoneNumberTextController.text.length < 16;
bool get isFirstNameValid => firstNameTextController.text.isNotEmpty;
diff --git a/comwell_key_app/lib/pregistration/pages/prereg_profile_page.dart b/comwell_key_app/lib/pregistration/pages/prereg_profile_page.dart
index 73acf024..db5d5fdd 100644
--- a/comwell_key_app/lib/pregistration/pages/prereg_profile_page.dart
+++ b/comwell_key_app/lib/pregistration/pages/prereg_profile_page.dart
@@ -56,12 +56,6 @@ class PreregProfilePage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- const SizedBox(height: 36),
- Text(
- "profile_settings".tr(),
- style: theme.textTheme.headlineLarge,
- textAlign: TextAlign.start,
- ),
const SizedBox(height: 36),
ComwellTextField(
key: const Key("firstName"),
diff --git a/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart b/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
index 12691194..b587ad4c 100644
--- a/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
+++ b/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
@@ -27,7 +27,6 @@ class ResponseHandleInterceptor extends Interceptor {
final String? accessToken =
await _secureStorageService.read(key: constants.accessToken);
-
if (accessToken == null) {
//logout user
options.extra["tokenErrorType"] = TokenErrorType.tokenNotFound;
@@ -37,8 +36,12 @@ class ResponseHandleInterceptor extends Interceptor {
error: 'Token not found');
return handler.reject(error);
}
+
+ // TEMP: Corrupt token to test 401 handling
+ final testToken = '${accessToken}INVALID';
+
options.headers.addAll({
- 'Authorization': accessToken,
+ 'Authorization': testToken,
'Ocp-Apim-Subscription-Key': dotenv.env['OCP_APIM_SUBSCRIPTION_KEY']!,
});
return handler.next(options);
@@ -69,9 +72,11 @@ class ResponseHandleInterceptor extends Interceptor {
break;
case 401:
retryCount++;
- //await _authenticationRepository.openAuth(Prompt.login);
+ try {
+ final authResult = await _authenticationRepository.acquireTokenSilent();
+
if (retryCount < 10) {
- final newToken = await _authenticationRepository.accessToken;
+ final newToken = authResult.accessToken;
if (newToken.isNotEmpty) {
// Retry the original request with the new token
final options = response.requestOptions;
@@ -86,12 +91,17 @@ class ResponseHandleInterceptor extends Interceptor {
queryParameters: response.requestOptions.queryParameters);
return handler.resolve(retryRequest);
+
}
+
} else {
retryCount = 0;
_authenticationRepository.logOut(forced: true);
return handler.reject(err);
}
+ } catch (e){
+ debugPrint('Error acquiring token silently: $e');
+ }
break;
case 500:
final errorMessage = response.data['detail'] as String;
@@ -109,7 +119,8 @@ class ResponseHandleInterceptor extends Interceptor {
}
final err = DioException(
- requestOptions: response.requestOptions, error: 'Update required');
+ requestOptions: response.requestOptions,
+ error: 'Update required');
handler.next(err);
break;
default:
@@ -135,5 +146,4 @@ class ResponseHandleInterceptor extends Interceptor {
) async {
return handler.next(response);
}
-
}
diff --git a/comwell_key_app/lib/utils/firebase.dart b/comwell_key_app/lib/utils/firebase.dart
index 1e006970..bbab8fd7 100644
--- a/comwell_key_app/lib/utils/firebase.dart
+++ b/comwell_key_app/lib/utils/firebase.dart
@@ -7,10 +7,10 @@ import '../firebase_options_stage.dart' as stage;
import '../firebase_options_dev.dart' as dev;
Future<void> configureFirebase() async {
- final firebaseOptions = switch (appFlavor) {
- 'Prod' => prod.DefaultFirebaseOptions.currentPlatform,
- 'Stage' => stage.DefaultFirebaseOptions.currentPlatform,
- 'Develop' => dev.DefaultFirebaseOptions.currentPlatform,
+ final firebaseOptions = switch (appFlavor?.toLowerCase()) {
+ 'prod' => prod.DefaultFirebaseOptions.currentPlatform,
+ 'stage' => stage.DefaultFirebaseOptions.currentPlatform,
+ 'develop' => dev.DefaultFirebaseOptions.currentPlatform,
_ => throw UnsupportedError('Invalid flavor: $appFlavor'),
};
await Firebase.initializeApp(name: appFlavor, options: firebaseOptions);
diff --git a/comwell_key_app/lib/utils/locator.dart b/comwell_key_app/lib/utils/locator.dart
index e333a70c..a04e915d 100644
--- a/comwell_key_app/lib/utils/locator.dart
+++ b/comwell_key_app/lib/utils/locator.dart
@@ -28,10 +28,9 @@ import '../booking_details/booking_details_repository.dart';
final locator = GetIt.I;
void registerDatabase() {
- if (locator.isRegistered<ComwellDatabase>()) {
- locator.unregister<ComwellDatabase>();
+ if (!locator.isRegistered<ComwellDatabase>()) {
+ locator.registerLazySingleton<ComwellDatabase>(() => ComwellDatabase());
}
- locator.registerSingleton<ComwellDatabase>(ComwellDatabase());
}
void setupLocator() {
diff --git a/comwell_key_app/pubspec.yaml b/comwell_key_app/pubspec.yaml
index 09c2b890..685c3d21 100644
--- a/comwell_key_app/pubspec.yaml
+++ b/comwell_key_app/pubspec.yaml
@@ -40,7 +40,7 @@ dependencies:
flutter_launcher_icons: ^0.14.1
slider_button: ^2.1.0
country_code_picker: ^3.1.0
- adyen_checkout: ^1.2.0
+ adyen_checkout: ^1.6.0
json_annotation: ^4.9.0
firebase_core: ^3.14.0
firebase_analytics: ^11.5.0
@@ -61,6 +61,7 @@ dependencies:
uri: ^1.0.0
pretty_dio_logger: ^1.4.0
msal_auth: ^3.3.0
+ cached_network_image: ^3.4.1
dependency_overrides: