6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit e91cba8f
Changed files
.../screens/onboarding/onboarding_routes.g.dart | 46 +++++++++++++++++++--- comwell_key_app/lib/comwell_app.dart | 5 +-- .../connection_state_listener.dart | 5 ++- .../transitions/slide_up_transition.dart | 2 +- .../presentation/screens/login/login_route.dart | 2 +- .../bluetooth/bluetooth_permission_cubit.dart | 7 ++-- .../bluetooth/bluetooth_permission_screen.dart | 26 +++++++----- .../screens/onboarding/onboarding_routes.dart | 34 +++++++++++----- .../lib/profile/cubit/profile_cubit.dart | 1 - comwell_key_app/lib/routing/app_router.dart | 12 ++++-- comwell_key_app/lib/routing/app_routes.dart | 1 + .../interceptors/response_handle_interceptor.dart | 3 +- 12 files changed, 104 insertions(+), 40 deletions(-)
Diff
diff --git a/comwell_key_app/lib/.generated/presentation/screens/onboarding/onboarding_routes.g.dart b/comwell_key_app/lib/.generated/presentation/screens/onboarding/onboarding_routes.g.dart
index c5df15a7..5be8d4b9 100644
--- a/comwell_key_app/lib/.generated/presentation/screens/onboarding/onboarding_routes.g.dart
+++ b/comwell_key_app/lib/.generated/presentation/screens/onboarding/onboarding_routes.g.dart
@@ -20,10 +20,26 @@ RouteBase get $bluetoothPermissionRoute => GoRouteData.$route(
mixin $BluetoothPermissionRoute on GoRouteData {
static BluetoothPermissionRoute _fromState(GoRouterState state) =>
- BluetoothPermissionRoute();
+ BluetoothPermissionRoute(
+ isOnboarding:
+ _$convertMapValue(
+ 'is-onboarding',
+ state.uri.queryParameters,
+ _$boolConverter,
+ ) ??
+ false,
+ );
+
+ BluetoothPermissionRoute get _self => this as BluetoothPermissionRoute;
@override
- String get location => GoRouteData.$location('/onboarding/bluetooth');
+ String get location => GoRouteData.$location(
+ '/onboarding/bluetooth',
+ queryParams: {
+ if (_self.isOnboarding != false)
+ 'is-onboarding': _self.isOnboarding.toString(),
+ },
+ );
@override
void go(BuildContext context) => context.go(location);
@@ -39,6 +55,26 @@ mixin $BluetoothPermissionRoute on GoRouteData {
void replace(BuildContext context) => context.replace(location);
}
+T? _$convertMapValue<T>(
+ String key,
+ Map<String, String> map,
+ T? Function(String) converter,
+) {
+ final value = map[key];
+ return value == null ? null : converter(value);
+}
+
+bool _$boolConverter(String value) {
+ switch (value) {
+ case 'true':
+ return true;
+ case 'false':
+ return false;
+ default:
+ throw UnsupportedError('Cannot convert "$value" into a bool.');
+ }
+}
+
RouteBase get $notificationPermissionRoute => GoRouteData.$route(
path: '/onboarding/notification',
factory: $NotificationPermissionRoute._fromState,
@@ -46,7 +82,7 @@ RouteBase get $notificationPermissionRoute => GoRouteData.$route(
mixin $NotificationPermissionRoute on GoRouteData {
static NotificationPermissionRoute _fromState(GoRouterState state) =>
- NotificationPermissionRoute();
+ const NotificationPermissionRoute();
@override
String get location => GoRouteData.$location('/onboarding/notification');
@@ -72,7 +108,7 @@ RouteBase get $usageTrackingPermissionRoute => GoRouteData.$route(
mixin $UsageTrackingPermissionRoute on GoRouteData {
static UsageTrackingPermissionRoute _fromState(GoRouterState state) =>
- UsageTrackingPermissionRoute();
+ const UsageTrackingPermissionRoute();
@override
String get location => GoRouteData.$location('/onboarding/usage-tracking');
@@ -98,7 +134,7 @@ RouteBase get $internetDisabledRoute => GoRouteData.$route(
mixin $InternetDisabledRoute on GoRouteData {
static InternetDisabledRoute _fromState(GoRouterState state) =>
- InternetDisabledRoute();
+ const InternetDisabledRoute();
@override
String get location => GoRouteData.$location('/internet-disabled');
diff --git a/comwell_key_app/lib/comwell_app.dart b/comwell_key_app/lib/comwell_app.dart
index 590cb385..ec79c103 100644
--- a/comwell_key_app/lib/comwell_app.dart
+++ b/comwell_key_app/lib/comwell_app.dart
@@ -81,11 +81,10 @@ class ComwellApp extends StatelessWidget {
),
BlocProvider<PaymentCubit>(
lazy: false,
- create: (context) => PaymentCubit(adyenRepository: locator<AdyenRepository>()),
+ create: (context) => PaymentCubit(adyenRepository: locator()),
),
BlocProvider<PaymentCardsCubit>(
- lazy: false,
- create: (context) => PaymentCardsCubit(adyenRepository: locator<AdyenRepository>()),
+ create: (context) => PaymentCardsCubit(adyenRepository: locator()),
),
],
child: MaterialApp.router(
diff --git a/comwell_key_app/lib/connection_state/connection_state_listener.dart b/comwell_key_app/lib/connection_state/connection_state_listener.dart
index e1477f7b..33984694 100644
--- a/comwell_key_app/lib/connection_state/connection_state_listener.dart
+++ b/comwell_key_app/lib/connection_state/connection_state_listener.dart
@@ -1,5 +1,6 @@
import 'package:comwell_key_app/connection_state/connection_state_cubit.dart';
import 'package:comwell_key_app/presentation/screens/onboarding/onboarding_routes.dart';
+import 'package:comwell_key_app/utils/context_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -51,13 +52,13 @@ class _ConnectionStateListenerState extends State<ConnectionStateListener> {
listenWhen: (prev, curr) => shouldShowBluetoothPermissionScreen(prev, curr),
listener: (context, state) async {
if (state.isBluetoothEnabled && state.isBluetoothPermissionGranted) return;
- await BluetoothPermissionRoute().push(context);
+ await const BluetoothPermissionRoute().push(context);
},
),
BlocListener<ConnectionStateCubit, AppConnectionState>(
listenWhen: (prev, curr) => shouldShowInternetPermissionScreen(prev, curr),
listener: (context, state) {
- InternetDisabledRoute().push(context);
+ const InternetDisabledRoute().push(context);
},
),
],
diff --git a/comwell_key_app/lib/presentation/navigation/transitions/slide_up_transition.dart b/comwell_key_app/lib/presentation/navigation/transitions/slide_up_transition.dart
index 76e450c2..6a9d02d8 100644
--- a/comwell_key_app/lib/presentation/navigation/transitions/slide_up_transition.dart
+++ b/comwell_key_app/lib/presentation/navigation/transitions/slide_up_transition.dart
@@ -14,7 +14,7 @@ Page<dynamic> SlideUpTransition({required GoRouterState state, required Widget c
begin: const Offset(0, 0.8),
end: Offset.zero,
).animate(animation),
- child: FadeTransition(opacity: animation, child: result),
+ child: result,
);
},
);
diff --git a/comwell_key_app/lib/presentation/screens/login/login_route.dart b/comwell_key_app/lib/presentation/screens/login/login_route.dart
index 5d14597c..c8c1b94e 100644
--- a/comwell_key_app/lib/presentation/screens/login/login_route.dart
+++ b/comwell_key_app/lib/presentation/screens/login/login_route.dart
@@ -15,7 +15,7 @@ class LoginRoute extends GoRouteData with $LoginRoute {
final bool forced;
final String redirectAfterLogin;
- LoginRoute({this.forced = false, this.redirectAfterLogin = ""});
+ const LoginRoute({this.forced = false, this.redirectAfterLogin = ""});
@override
Widget build(BuildContext context, GoRouterState state) {
diff --git a/comwell_key_app/lib/presentation/screens/onboarding/bluetooth/bluetooth_permission_cubit.dart b/comwell_key_app/lib/presentation/screens/onboarding/bluetooth/bluetooth_permission_cubit.dart
index b12b3b90..ec600847 100644
--- a/comwell_key_app/lib/presentation/screens/onboarding/bluetooth/bluetooth_permission_cubit.dart
+++ b/comwell_key_app/lib/presentation/screens/onboarding/bluetooth/bluetooth_permission_cubit.dart
@@ -10,18 +10,19 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part "../../../../.generated/presentation/screens/onboarding/bluetooth/bluetooth_permission_cubit.freezed.dart";
class BluetoothPermissionCubit extends BaseCubit<BluetoothPermissionState> {
- BluetoothPermissionCubit(this._bluetoothRepository, this._comwellPreferences)
+ BluetoothPermissionCubit(this._bluetoothRepository, this._comwellPreferences, {required this.isOnboarding})
: super(const BluetoothPermissionState()) {
init();
}
+ final bool isOnboarding;
final ComwellPreferences _comwellPreferences;
final BluetoothRepository _bluetoothRepository;
int _clickCount = 0;
- void init() {
- _comwellPreferences.setOnboardingHasSeenBluetooth();
+ void init() async {
+ await _comwellPreferences.setOnboardingHasSeenBluetooth();
}
Future<void> onEnabledPressed() async {
diff --git a/comwell_key_app/lib/presentation/screens/onboarding/bluetooth/bluetooth_permission_screen.dart b/comwell_key_app/lib/presentation/screens/onboarding/bluetooth/bluetooth_permission_screen.dart
index eb4fc2b1..8017098e 100644
--- a/comwell_key_app/lib/presentation/screens/onboarding/bluetooth/bluetooth_permission_screen.dart
+++ b/comwell_key_app/lib/presentation/screens/onboarding/bluetooth/bluetooth_permission_screen.dart
@@ -1,5 +1,6 @@
import 'package:comwell_key_app/.generated/assets/assets.gen.dart';
import 'package:comwell_key_app/connection_state/connection_state_cubit.dart';
+import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/themes/comwell_colors.dart';
import 'package:comwell_key_app/utils/l10n_utils.dart';
import 'package:flutter/material.dart';
@@ -51,18 +52,23 @@ class BluetoothPermissionScreen extends StatelessWidget {
image: Assets.icons.bluetoothCircled,
);
}
- return PermissionScreenTemplate(
- title: context.strings.bluetooth_permission_title,
- subtitle: context.strings.bluetooth_permission_description,
- primaryButtonText: context.strings.allow_bluetooth,
- primaryButtonOnClick: () async {
- final isGranted = await cubit.onRequestPermissionClicked();
- if (isGranted && context.mounted) {
+ return PermissionScreenTemplate(
+ title: context.strings.bluetooth_permission_title,
+ subtitle: context.strings.bluetooth_permission_description,
+ primaryButtonText: context.strings.allow_bluetooth,
+ primaryButtonOnClick: () async {
+ await cubit.onRequestPermissionClicked();
+ print("qqq cubit.isOnboarding=${cubit.isOnboarding}");
+ if (context.mounted) {
+ if (cubit.isOnboarding) {
+ context.go(AppRoutes.overview);
+ } else {
context.pop();
}
- },
- image: Assets.icons.bluetoothCircled,
- );
+ }
+ },
+ image: Assets.icons.bluetoothCircled,
+ );
},
),
);
diff --git a/comwell_key_app/lib/presentation/screens/onboarding/onboarding_routes.dart b/comwell_key_app/lib/presentation/screens/onboarding/onboarding_routes.dart
index 383fcebf..23e8d408 100644
--- a/comwell_key_app/lib/presentation/screens/onboarding/onboarding_routes.dart
+++ b/comwell_key_app/lib/presentation/screens/onboarding/onboarding_routes.dart
@@ -1,3 +1,4 @@
+import 'package:comwell_key_app/presentation/navigation/transitions/slide_in_transition.dart';
import 'package:comwell_key_app/presentation/navigation/transitions/slide_up_transition.dart';
import 'package:comwell_key_app/presentation/screens/onboarding/usage_tracking/usage_tracking_permission_cubit.dart';
import 'package:comwell_key_app/presentation/screens/onboarding/usage_tracking/usage_tracking_permission_screen.dart';
@@ -17,26 +18,37 @@ part '../../../.generated/presentation/screens/onboarding/onboarding_routes.g.da
@TypedGoRoute<BluetoothPermissionRoute>(path: AppRoutes.onboardingBluetooth)
class BluetoothPermissionRoute extends GoRouteData with $BluetoothPermissionRoute {
+ final bool isOnboarding;
+
+ const BluetoothPermissionRoute({this.isOnboarding = false});
+
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
+ final child = BlocProvider(
+ create: (context) =>
+ BluetoothPermissionCubit(locator.get(), locator.get(), isOnboarding: isOnboarding),
+ child: const BluetoothPermissionScreen(),
+ );
+ if (isOnboarding) {
+ return SlideInTransition(
+ state: state,
+ child: child,
+ );
+ }
return SlideUpTransition(
state: state,
- child: BlocProvider(
- create: (context) => BluetoothPermissionCubit(
- locator.get(),
- locator.get(),
- ),
- child: const BluetoothPermissionScreen(),
- ),
+ child: child,
);
}
}
@TypedGoRoute<NotificationPermissionRoute>(path: AppRoutes.onboardingNotification)
class NotificationPermissionRoute extends GoRouteData with $NotificationPermissionRoute {
+ const NotificationPermissionRoute();
+
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
- return SlideUpTransition(
+ return SlideInTransition(
state: state,
child: BlocProvider(
lazy: false,
@@ -51,9 +63,11 @@ class NotificationPermissionRoute extends GoRouteData with $NotificationPermissi
@TypedGoRoute<UsageTrackingPermissionRoute>(path: AppRoutes.onboardingUsageTracking)
class UsageTrackingPermissionRoute extends GoRouteData with $UsageTrackingPermissionRoute {
+ const UsageTrackingPermissionRoute();
+
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
- return SlideUpTransition(
+ return SlideInTransition(
state: state,
child: BlocProvider(
lazy: false,
@@ -66,6 +80,8 @@ class UsageTrackingPermissionRoute extends GoRouteData with $UsageTrackingPermis
@TypedGoRoute<InternetDisabledRoute>(path: AppRoutes.internetDisabled)
class InternetDisabledRoute extends GoRouteData with $InternetDisabledRoute {
+ const InternetDisabledRoute();
+
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return SlideUpTransition(
diff --git a/comwell_key_app/lib/profile/cubit/profile_cubit.dart b/comwell_key_app/lib/profile/cubit/profile_cubit.dart
index 84f6139a..4abefef6 100644
--- a/comwell_key_app/lib/profile/cubit/profile_cubit.dart
+++ b/comwell_key_app/lib/profile/cubit/profile_cubit.dart
@@ -66,7 +66,6 @@ class ProfileCubit extends Cubit<ProfileState> {
void init() async {
emit(const ProfileState(isLoading: true, user: null, error: null));
-
try {
final user = await _profileRepository.fetchProfileSettings();
sendPageViewEvent();
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 0a7c79f0..eda6bec9 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -63,12 +63,16 @@ final router = GoRouter(
}
}
- if (context.mounted && !context.prefs.onboardingHasSeenUsageTracking) {
- return AppRoutes.onboardingUsageTracking;
+ if (!context.prefs.onboardingHasSeenUsageTracking) {
+ return const UsageTrackingPermissionRoute().location;
}
- if (context.mounted && !context.prefs.onboardingHasSeenNotification) {
- return AppRoutes.onboardingNotification;
+ if (!context.prefs.onboardingHasSeenNotification) {
+ return const NotificationPermissionRoute().location;
+ }
+
+ if (!context.prefs.onboardingHasSeenBluetooth) {
+ return const BluetoothPermissionRoute(isOnboarding: true).location;
}
return null;
diff --git a/comwell_key_app/lib/routing/app_routes.dart b/comwell_key_app/lib/routing/app_routes.dart
index 806dded4..bc9214c5 100644
--- a/comwell_key_app/lib/routing/app_routes.dart
+++ b/comwell_key_app/lib/routing/app_routes.dart
@@ -14,6 +14,7 @@ abstract class AppRoutes {
static const onboardingUsageTracking = "/onboarding/usage-tracking";
static const receiveSharedBooking = "/share-room";
static const internetDisabled = "/internet-disabled";
+ static const bluetoothDisabled = "/bluetooth-disabled";
static const receivedSharedRoom = "/received-shared-room";
static const receivedSharedBooking = "/received-shared-booking";
static const checkOutSuccess = "/checkout-success";
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 d0c53d95..d37f86fd 100644
--- a/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
+++ b/comwell_key_app/lib/services/interceptors/response_handle_interceptor.dart
@@ -1,4 +1,5 @@
import 'package:comwell_key_app/data/remote/msal_service.dart';
+import 'package:comwell_key_app/presentation/screens/login/login_route.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/services/exceptions.dart';
import 'package:comwell_key_app/utils/env_utils.dart';
@@ -47,7 +48,7 @@ class ResponseHandleInterceptor extends Interceptor {
}
void logOut() {
- if (context != null) GoRouter.of(context!).go(AppRoutes.forceLogin);
+ if (context != null) const LoginRoute().go(context!);
}
@override