6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 332fcc1b

AuthorMikkel Thygesen<mikkelet@gmail.com>
Date2026-02-19 23:06:20 +0100
3672: Implemented permission overview screen

Changed files

comwell_key_app/assets/translations/intl_da.arb    |   3 +-
 comwell_key_app/assets/translations/intl_en.arb    |   5 +-
 .../lib/.generated/l10n/app_localizations.dart     |   8 +-
 .../lib/.generated/l10n/app_localizations_da.dart  |   3 +
 .../lib/.generated/l10n/app_localizations_en.dart  |   5 +-
 .../bloc/permission_overview_state.freezed.dart    |  51 ++++++----
 .../lib/database/daos/notifications_dao.dart       |  20 ++--
 .../domain/repositories/bluetooth_repository.dart  |   5 +-
 .../notifications/cubit/notifications_cubit.dart   |  10 +-
 .../models/notification_permission.dart            |   2 +-
 .../lib/notifications/notifications_page.dart      |  16 ++-
 .../notifications/notifications_repository.dart    |  59 ++++++-----
 .../lib/notifications/notifications_route.dart     |   4 +-
 .../bloc/permission_overview_cubit.dart            |  71 +++++++++++++-
 .../bloc/permission_overview_state.dart            |   5 +
 .../permission_overview_route.dart                 |  16 +--
 .../permission_overview_screen.dart                |  97 ++++++++++++++++--
 .../profile/components/comwell_club_container.dart |   1 -
 .../profile/components/profile_page_widget.dart    | 109 ++++++++++++---------
 comwell_key_app/lib/routing/app_router.dart        |   2 +
 comwell_key_app/lib/routing/app_routes.dart        |   1 +
 comwell_key_app/lib/utils/locator.dart             |   8 +-
 comwell_key_app/lib/utils/secure_storage.dart      |   7 ++
 23 files changed, 350 insertions(+), 158 deletions(-)

Diff

diff --git a/comwell_key_app/assets/translations/intl_da.arb b/comwell_key_app/assets/translations/intl_da.arb
index e24ae20a..e8fa69f0 100644
--- a/comwell_key_app/assets/translations/intl_da.arb
+++ b/comwell_key_app/assets/translations/intl_da.arb
@@ -403,5 +403,6 @@
"find_booking_subtitle_mvp": "Vi arbejder i øjeblikket på at gøre det muligt at finde din booking digitalt her i appen.",
"bluetooth_permission_title": "Tillad Bluetooth til for at låse dit værelse op",
"bluetooth_permission_description": "For at kunne åbne døren til dit hotelværelse skal du give tilladelse til at vi må bruge bluetooth på din telefon.",
- "allow_bluetooth": "Tillad bluetooth"
+ "allow_bluetooth": "Tillad bluetooth",
+ "permissions": "tilladelser"
}
\ No newline at end of file
diff --git a/comwell_key_app/assets/translations/intl_en.arb b/comwell_key_app/assets/translations/intl_en.arb
index d9ab29a2..8572f43b 100644
--- a/comwell_key_app/assets/translations/intl_en.arb
+++ b/comwell_key_app/assets/translations/intl_en.arb
@@ -389,7 +389,7 @@
"received_shared_booking_page_title": "",
"received_shared_booking_page_subtitle": "text {name}",
"accept_notifications": "Allow notifications",
- "accept_notifications_rationale": "To get the latest updates about your booking, please allow notifications",
+ "accept_notifications_rationale": "To get the latest updates about your booking, please allow notifications.",
"allow": "Allow",
"skip": "Skip",
"internet_disabled": "The Internet is down.",
@@ -403,5 +403,6 @@
"find_booking_subtitle_mvp": "We are currently working on making it possible to find your booking digitally here in the app.",
"bluetooth_permission_title": "Allow Bluetooth to unlock your room",
"bluetooth_permission_description": "In order to open the door to your hotel room, you must give us permission to use Bluetooth on your phone.",
- "allow_bluetooth": "Allow Bluetooth"
+ "allow_bluetooth": "Allow Bluetooth",
+ "permissions": "Permissions"
}
\ No newline at end of file
diff --git a/comwell_key_app/lib/.generated/l10n/app_localizations.dart b/comwell_key_app/lib/.generated/l10n/app_localizations.dart
index d78e9925..8b0ffd5c 100644
--- a/comwell_key_app/lib/.generated/l10n/app_localizations.dart
+++ b/comwell_key_app/lib/.generated/l10n/app_localizations.dart
@@ -2430,7 +2430,7 @@ abstract class AppLocalizations {
/// No description provided for @accept_notifications_rationale.
///
/// In en, this message translates to:
- /// **'To get the latest updates about your booking, please allow notifications'**
+ /// **'To get the latest updates about your booking, please allow notifications.'**
String get accept_notifications_rationale;
/// No description provided for @allow.
@@ -2516,6 +2516,12 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Allow Bluetooth'**
String get allow_bluetooth;
+
+ /// No description provided for @permissions.
+ ///
+ /// In en, this message translates to:
+ /// **'Permissions'**
+ String get permissions;
}
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
diff --git a/comwell_key_app/lib/.generated/l10n/app_localizations_da.dart b/comwell_key_app/lib/.generated/l10n/app_localizations_da.dart
index 250bd811..53e25aff 100644
--- a/comwell_key_app/lib/.generated/l10n/app_localizations_da.dart
+++ b/comwell_key_app/lib/.generated/l10n/app_localizations_da.dart
@@ -1303,4 +1303,7 @@ class AppLocalizationsDa extends AppLocalizations {
@override
String get allow_bluetooth => 'Tillad bluetooth';
+
+ @override
+ String get permissions => 'tilladelser';
}
diff --git a/comwell_key_app/lib/.generated/l10n/app_localizations_en.dart b/comwell_key_app/lib/.generated/l10n/app_localizations_en.dart
index cae52235..85fe2e23 100644
--- a/comwell_key_app/lib/.generated/l10n/app_localizations_en.dart
+++ b/comwell_key_app/lib/.generated/l10n/app_localizations_en.dart
@@ -1259,7 +1259,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get accept_notifications_rationale =>
- 'To get the latest updates about your booking, please allow notifications';
+ 'To get the latest updates about your booking, please allow notifications.';
@override
String get allow => 'Allow';
@@ -1306,4 +1306,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get allow_bluetooth => 'Allow Bluetooth';
+
+ @override
+ String get permissions => 'Permissions';
}
diff --git a/comwell_key_app/lib/.generated/presentation/screens/permission_overview/bloc/permission_overview_state.freezed.dart b/comwell_key_app/lib/.generated/presentation/screens/permission_overview/bloc/permission_overview_state.freezed.dart
index da85962a..1ffddb6b 100644
--- a/comwell_key_app/lib/.generated/presentation/screens/permission_overview/bloc/permission_overview_state.freezed.dart
+++ b/comwell_key_app/lib/.generated/presentation/screens/permission_overview/bloc/permission_overview_state.freezed.dart
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$PermissionOverviewState {
- bool get isLoading; AppError get error;
+ bool get isLoading; AppError get error; bool get allowUsageTracking; bool get allowBluetooth; bool get allowPushNotifications;
/// Create a copy of PermissionOverviewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $PermissionOverviewStateCopyWith<PermissionOverviewState> get copyWith => _$Perm
@override
bool operator ==(Object other) {
- return identical(this, other) || (other.runtimeType == runtimeType&&other is PermissionOverviewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error));
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is PermissionOverviewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error)&&(identical(other.allowUsageTracking, allowUsageTracking) || other.allowUsageTracking == allowUsageTracking)&&(identical(other.allowBluetooth, allowBluetooth) || other.allowBluetooth == allowBluetooth)&&(identical(other.allowPushNotifications, allowPushNotifications) || other.allowPushNotifications == allowPushNotifications));
}
@override
-int get hashCode => Object.hash(runtimeType,isLoading,error);
+int get hashCode => Object.hash(runtimeType,isLoading,error,allowUsageTracking,allowBluetooth,allowPushNotifications);
@override
String toString() {
- return 'PermissionOverviewState(isLoading: $isLoading, error: $error)';
+ return 'PermissionOverviewState(isLoading: $isLoading, error: $error, allowUsageTracking: $allowUsageTracking, allowBluetooth: $allowBluetooth, allowPushNotifications: $allowPushNotifications)';
}
@@ -45,7 +45,7 @@ abstract mixin class $PermissionOverviewStateCopyWith<$Res> {
factory $PermissionOverviewStateCopyWith(PermissionOverviewState value, $Res Function(PermissionOverviewState) _then) = _$PermissionOverviewStateCopyWithImpl;
@useResult
$Res call({
- bool isLoading, AppError error
+ bool isLoading, AppError error, bool allowUsageTracking, bool allowBluetooth, bool allowPushNotifications
});
@@ -62,11 +62,14 @@ class _$PermissionOverviewStateCopyWithImpl<$Res>
/// Create a copy of PermissionOverviewState
/// with the given fields replaced by the non-null parameter values.
-@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? error = null,}) {
+@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? error = null,Object? allowUsageTracking = null,Object? allowBluetooth = null,Object? allowPushNotifications = null,}) {
return _then(_self.copyWith(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,error: null == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
-as AppError,
+as AppError,allowUsageTracking: null == allowUsageTracking ? _self.allowUsageTracking : allowUsageTracking // ignore: cast_nullable_to_non_nullable
+as bool,allowBluetooth: null == allowBluetooth ? _self.allowBluetooth : allowBluetooth // ignore: cast_nullable_to_non_nullable
+as bool,allowPushNotifications: null == allowPushNotifications ? _self.allowPushNotifications : allowPushNotifications // ignore: cast_nullable_to_non_nullable
+as bool,
));
}
@@ -151,10 +154,10 @@ return $default(_that);case _:
/// }
/// ```
-@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, AppError error)? $default,{required TResult orElse(),}) {final _that = this;
+@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, AppError error, bool allowUsageTracking, bool allowBluetooth, bool allowPushNotifications)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PermissionOverviewState() when $default != null:
-return $default(_that.isLoading,_that.error);case _:
+return $default(_that.isLoading,_that.error,_that.allowUsageTracking,_that.allowBluetooth,_that.allowPushNotifications);case _:
return orElse();
}
@@ -172,10 +175,10 @@ return $default(_that.isLoading,_that.error);case _:
/// }
/// ```
-@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, AppError error) $default,) {final _that = this;
+@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, AppError error, bool allowUsageTracking, bool allowBluetooth, bool allowPushNotifications) $default,) {final _that = this;
switch (_that) {
case _PermissionOverviewState():
-return $default(_that.isLoading,_that.error);case _:
+return $default(_that.isLoading,_that.error,_that.allowUsageTracking,_that.allowBluetooth,_that.allowPushNotifications);case _:
throw StateError('Unexpected subclass');
}
@@ -192,10 +195,10 @@ return $default(_that.isLoading,_that.error);case _:
/// }
/// ```
-@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, AppError error)? $default,) {final _that = this;
+@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, AppError error, bool allowUsageTracking, bool allowBluetooth, bool allowPushNotifications)? $default,) {final _that = this;
switch (_that) {
case _PermissionOverviewState() when $default != null:
-return $default(_that.isLoading,_that.error);case _:
+return $default(_that.isLoading,_that.error,_that.allowUsageTracking,_that.allowBluetooth,_that.allowPushNotifications);case _:
return null;
}
@@ -206,12 +209,15 @@ return $default(_that.isLoading,_that.error);case _:
/// @nodoc
-class _PermissionOverviewState implements PermissionOverviewState {
- const _PermissionOverviewState({this.isLoading = false, this.error = AppError.none});
+class _PermissionOverviewState extends PermissionOverviewState {
+ const _PermissionOverviewState({this.isLoading = false, this.error = AppError.none, this.allowUsageTracking = false, this.allowBluetooth = false, this.allowPushNotifications = false}): super._();
@override@JsonKey() final bool isLoading;
@override@JsonKey() final AppError error;
+@override@JsonKey() final bool allowUsageTracking;
+@override@JsonKey() final bool allowBluetooth;
+@override@JsonKey() final bool allowPushNotifications;
/// Create a copy of PermissionOverviewState
/// with the given fields replaced by the non-null parameter values.
@@ -223,16 +229,16 @@ _$PermissionOverviewStateCopyWith<_PermissionOverviewState> get copyWith => __$P
@override
bool operator ==(Object other) {
- return identical(this, other) || (other.runtimeType == runtimeType&&other is _PermissionOverviewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error));
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is _PermissionOverviewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error)&&(identical(other.allowUsageTracking, allowUsageTracking) || other.allowUsageTracking == allowUsageTracking)&&(identical(other.allowBluetooth, allowBluetooth) || other.allowBluetooth == allowBluetooth)&&(identical(other.allowPushNotifications, allowPushNotifications) || other.allowPushNotifications == allowPushNotifications));
}
@override
-int get hashCode => Object.hash(runtimeType,isLoading,error);
+int get hashCode => Object.hash(runtimeType,isLoading,error,allowUsageTracking,allowBluetooth,allowPushNotifications);
@override
String toString() {
- return 'PermissionOverviewState(isLoading: $isLoading, error: $error)';
+ return 'PermissionOverviewState(isLoading: $isLoading, error: $error, allowUsageTracking: $allowUsageTracking, allowBluetooth: $allowBluetooth, allowPushNotifications: $allowPushNotifications)';
}
@@ -243,7 +249,7 @@ abstract mixin class _$PermissionOverviewStateCopyWith<$Res> implements $Permiss
factory _$PermissionOverviewStateCopyWith(_PermissionOverviewState value, $Res Function(_PermissionOverviewState) _then) = __$PermissionOverviewStateCopyWithImpl;
@override @useResult
$Res call({
- bool isLoading, AppError error
+ bool isLoading, AppError error, bool allowUsageTracking, bool allowBluetooth, bool allowPushNotifications
});
@@ -260,11 +266,14 @@ class __$PermissionOverviewStateCopyWithImpl<$Res>
/// Create a copy of PermissionOverviewState
/// with the given fields replaced by the non-null parameter values.
-@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? error = null,}) {
+@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? error = null,Object? allowUsageTracking = null,Object? allowBluetooth = null,Object? allowPushNotifications = null,}) {
return _then(_PermissionOverviewState(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,error: null == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
-as AppError,
+as AppError,allowUsageTracking: null == allowUsageTracking ? _self.allowUsageTracking : allowUsageTracking // ignore: cast_nullable_to_non_nullable
+as bool,allowBluetooth: null == allowBluetooth ? _self.allowBluetooth : allowBluetooth // ignore: cast_nullable_to_non_nullable
+as bool,allowPushNotifications: null == allowPushNotifications ? _self.allowPushNotifications : allowPushNotifications // ignore: cast_nullable_to_non_nullable
+as bool,
));
}
diff --git a/comwell_key_app/lib/database/daos/notifications_dao.dart b/comwell_key_app/lib/database/daos/notifications_dao.dart
index be55d7e0..481d1c7c 100644
--- a/comwell_key_app/lib/database/daos/notifications_dao.dart
+++ b/comwell_key_app/lib/database/daos/notifications_dao.dart
@@ -13,8 +13,7 @@ class NotificationPermissionDAO extends DatabaseAccessor<ComwellDatabase>
with _$NotificationPermissionDAOMixin {
NotificationPermissionDAO(super.attachedDatabase);
- Future<void> saveNotificationPermission(
- Iterable<NotificationPermission> permissions) async {
+ Future<void> saveNotificationPermission(Iterable<NotificationPermission> permissions) async {
final permissionsList = permissions.toList();
await insert(permissionsList);
}
@@ -22,17 +21,18 @@ class NotificationPermissionDAO extends DatabaseAccessor<ComwellDatabase>
Future<void> insert(Iterable<NotificationPermission> permissions) async {
final entities = permissions.map((permission) {
final json = jsonEncode(permission.toJson());
- return NotificationPermissionEntityCompanion.insert(
- code: permission.code, json: json);
+ return NotificationPermissionEntityCompanion.insert(code: permission.code, json: json);
});
- await batch((batch) => batch.insertAll(
- notificationPermissionEntity, entities,
- mode: InsertMode.insertOrReplace));
+ await batch(
+ (batch) =>
+ batch.insertAll(notificationPermissionEntity, entities, mode: InsertMode.insertOrReplace),
+ );
}
- Future<Iterable<NotificationPermission>> getNotificationPermissions() async {
+ Future<List<NotificationPermission>> getNotificationPermissions() async {
final permissions = await select(notificationPermissionEntity).get();
- return permissions.map((permission) =>
- NotificationPermission.fromJson(jsonDecode(permission.json) as Json));
+ return permissions
+ .map((permission) => NotificationPermission.fromJson(jsonDecode(permission.json) as Json))
+ .toList();
}
}
diff --git a/comwell_key_app/lib/domain/repositories/bluetooth_repository.dart b/comwell_key_app/lib/domain/repositories/bluetooth_repository.dart
index 837152b5..f59ff27e 100644
--- a/comwell_key_app/lib/domain/repositories/bluetooth_repository.dart
+++ b/comwell_key_app/lib/domain/repositories/bluetooth_repository.dart
@@ -14,13 +14,12 @@ class BluetoothRepository {
// app does not require bluetooth permission (yet).
// Consider remove when app is released and still not needed
Future<bool> isPermissionGranted() async {
- return true;
- final status = await Permission.bluetooth.status;
+ final status = await Permission.bluetoothAdvertise.status;
return status == PermissionStatus.granted;
}
Future<bool> request() async {
- final status = await Permission.bluetooth.request();
+ final status = await Permission.bluetoothAdvertise.request();
return status == PermissionStatus.granted;
}
diff --git a/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart b/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
index ca0499fd..fdc1f2f7 100644
--- a/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
+++ b/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
@@ -5,9 +5,9 @@ import 'package:comwell_key_app/profile_settings/model/user.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class NotificationsCubit extends Cubit<NotificationsState> {
- final NotificationsRepository notificationsRepository;
+ final NotificationsRepository _notificationsRepository;
- NotificationsCubit(this.notificationsRepository)
+ NotificationsCubit(this._notificationsRepository)
: super(
const NotificationsState(
allNotifications: [],
@@ -50,7 +50,7 @@ class NotificationsCubit extends Cubit<NotificationsState> {
),
);
try {
- notificationPermissions = await notificationsRepository.fetchNotificationPermissions();
+ notificationPermissions = await _notificationsRepository.fetchNotificationPermissions();
notificationPermissions = _filterVisiblePermissions(notificationPermissions);
emit(
@@ -112,7 +112,7 @@ class NotificationsCubit extends Cubit<NotificationsState> {
}
void updatePreferences(List<NotificationPermission> notificationPermissions) async {
- await notificationsRepository.updateNotificationPreferences(notificationPermissions);
+ await _notificationsRepository.updateNotificationPreferences(notificationPermissions);
emit(
NotificationsState(
@@ -124,7 +124,7 @@ class NotificationsCubit extends Cubit<NotificationsState> {
}
void fetchNotificationPermissions() async {
- notificationPermissions = await notificationsRepository.fetchNotificationPermissions();
+ notificationPermissions = await _notificationsRepository.fetchNotificationPermissions();
emit(
NotificationsState(
diff --git a/comwell_key_app/lib/notifications/models/notification_permission.dart b/comwell_key_app/lib/notifications/models/notification_permission.dart
index f7ecf0af..08532ab8 100644
--- a/comwell_key_app/lib/notifications/models/notification_permission.dart
+++ b/comwell_key_app/lib/notifications/models/notification_permission.dart
@@ -103,7 +103,7 @@ class NotificationPermission {
final NotificationPermissionType? notificationPermissionDescription;
final bool given;
- NotificationPermission({
+ const NotificationPermission({
required this.code,
required this.displayName,
this.notificationPermissionDescription,
diff --git a/comwell_key_app/lib/notifications/notifications_page.dart b/comwell_key_app/lib/notifications/notifications_page.dart
index 75bfb670..ee3a89cd 100644
--- a/comwell_key_app/lib/notifications/notifications_page.dart
+++ b/comwell_key_app/lib/notifications/notifications_page.dart
@@ -1,7 +1,6 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
import 'package:comwell_key_app/common/components/comwell_error_widget.dart';
import 'package:comwell_key_app/notifications/cubit/notifications_state.dart';
-import 'package:comwell_key_app/notifications/models/notification_permission.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:comwell_key_app/utils/l10n_utils.dart';
import 'package:flutter/material.dart';
@@ -11,8 +10,7 @@ import 'components/communications_list.dart';
import '../common/components/shimmer_loader/notifications_shimmer_loader.dart';
class NotificationsPage extends StatelessWidget {
- final Iterable<NotificationPermission> notificationPermissions;
- const NotificationsPage({super.key, required this.notificationPermissions});
+ const NotificationsPage({super.key});
@override
Widget build(BuildContext context) {
@@ -44,8 +42,7 @@ class NotificationsPage extends StatelessWidget {
);
}
- Widget _buildNotificationsPage(
- BuildContext context, NotificationsCubit cubit) {
+ Widget _buildNotificationsPage(BuildContext context, NotificationsCubit cubit) {
final theme = Theme.of(context);
return SafeArea(
child: Column(
@@ -82,9 +79,9 @@ class NotificationsPage extends StatelessWidget {
return null;
}),
trackOutlineColor: WidgetStatePropertyAll(
- Theme.of(context).colorScheme.surface),
- value: cubit.state.allNotifications
- .every((e) => e.given),
+ Theme.of(context).colorScheme.surface,
+ ),
+ value: cubit.state.allNotifications.every((e) => e.given),
onChanged: (bool value) {
cubit.updateAllPermissionsUI(value);
},
@@ -127,8 +124,7 @@ class NotificationsPage extends StatelessWidget {
height: 50,
child: ElevatedButton(
onPressed: () {
- cubit.updatePreferences(
- cubit.state.allNotifications);
+ cubit.updatePreferences(cubit.state.allNotifications);
},
style: theme.elevatedButtonTheme.style,
child: Text(
diff --git a/comwell_key_app/lib/notifications/notifications_repository.dart b/comwell_key_app/lib/notifications/notifications_repository.dart
index 3aeb72ab..bcb2817a 100644
--- a/comwell_key_app/lib/notifications/notifications_repository.dart
+++ b/comwell_key_app/lib/notifications/notifications_repository.dart
@@ -1,54 +1,44 @@
import 'package:comwell_key_app/database/comwell_db.dart';
import 'package:comwell_key_app/notifications/models/notification_permission.dart';
-import 'package:comwell_key_app/profile_settings/model/user.dart';
-import 'package:comwell_key_app/profile/profile_repository.dart';
import 'package:comwell_key_app/services/api.dart';
import 'package:comwell_key_app/utils/json.dart';
import 'package:comwell_key_app/utils/locator.dart';
+import 'package:permission_handler/permission_handler.dart';
class NotificationsRepository {
- final Api api = Api();
- final ProfileRepository profileRepository = locator<ProfileRepository>();
- late User user;
- late Iterable<NotificationPermission> notificationPermissions;
+ final Api _api;
+ final ComwellDatabase _comwellDatabase;
- Future<User> fetchUser() async {
- user = await profileRepository.fetchProfileSettings();
- return user;
- }
+ const NotificationsRepository(this._api, this._comwellDatabase);
- Future<void> updatePreferences(Iterable<NotificationPermission> notificationPermissions) async {
- return api.updateNotificationPreferences(notificationPermissions);
+ Future<void> updatePreferences(List<NotificationPermission> notificationPermissions) async {
+ return _api.updateNotificationPreferences(notificationPermissions);
}
Future<List<NotificationPermission>> fetchNotificationPermissions() async {
- notificationPermissions = await locator<ComwellDatabase>().notificationPermissionDAO
+ final notificationPermissions = await _comwellDatabase.notificationPermissionDAO
.getNotificationPermissions();
-
if (notificationPermissions.isEmpty) {
- final response = await api.getNotificationPermissions();
-
- final data = response.data as Map<String, dynamic>;
-
- notificationPermissions = (data['codes'] as List<dynamic>)
+ final response = await _api.getNotificationPermissions();
+ final data = response.data as Json;
+ final notificationPermissions = (data['codes'] as List<dynamic>)
.map((json) => NotificationPermission.fromJson(json as Json))
.toList();
- notificationPermissions = addDescriptionsToPermissions(notificationPermissions);
-
- await locator<ComwellDatabase>().notificationPermissionDAO.saveNotificationPermission(
+ final notificationPermissionsWithDescription = addDescriptionsToPermissions(
notificationPermissions,
);
- return notificationPermissions.toList();
- } else {
- notificationPermissions = addDescriptionsToPermissions(notificationPermissions);
- return notificationPermissions.toList();
+ await _comwellDatabase.notificationPermissionDAO.saveNotificationPermission(
+ notificationPermissionsWithDescription,
+ );
+ return notificationPermissionsWithDescription;
}
+ return addDescriptionsToPermissions(notificationPermissions);
}
- Iterable<NotificationPermission> addDescriptionsToPermissions(
- Iterable<NotificationPermission> permissions,
+ List<NotificationPermission> addDescriptionsToPermissions(
+ List<NotificationPermission> permissions,
) {
return permissions.map((permission) {
final enumValue = NotificationPermissionType.values.firstWhere(
@@ -60,13 +50,22 @@ class NotificationsRepository {
}).toList();
}
+ Future<bool> isPushNotificationPermissionGranted() async {
+ return Permission.notification.isGranted;
+ }
+
+ Future<bool> requestPushNotificationPermission() async {
+ await Permission.notification.request();
+ return isPushNotificationPermissionGranted();
+ }
+
Future<dynamic> updateNotificationPreferences(
- Iterable<NotificationPermission> notificationPermissions,
+ List<NotificationPermission> notificationPermissions,
) async {
await locator<ComwellDatabase>().notificationPermissionDAO.saveNotificationPermission(
notificationPermissions,
);
- return api.updateNotificationPreferences(notificationPermissions);
+ return _api.updateNotificationPreferences(notificationPermissions);
}
}
diff --git a/comwell_key_app/lib/notifications/notifications_route.dart b/comwell_key_app/lib/notifications/notifications_route.dart
index 7a49e1cd..52ee4795 100644
--- a/comwell_key_app/lib/notifications/notifications_route.dart
+++ b/comwell_key_app/lib/notifications/notifications_route.dart
@@ -10,9 +10,7 @@ final notificationsRoute = GoRoute(
builder: (context, state) {
return BlocProvider(
create: (context) => NotificationsCubit(locator()),
- child: const NotificationsPage(
- notificationPermissions: [],
- ),
+ child: const NotificationsPage(),
);
},
);
diff --git a/comwell_key_app/lib/presentation/screens/permission_overview/bloc/permission_overview_cubit.dart b/comwell_key_app/lib/presentation/screens/permission_overview/bloc/permission_overview_cubit.dart
index f961b458..314dd960 100644
--- a/comwell_key_app/lib/presentation/screens/permission_overview/bloc/permission_overview_cubit.dart
+++ b/comwell_key_app/lib/presentation/screens/permission_overview/bloc/permission_overview_cubit.dart
@@ -1,21 +1,82 @@
+import 'dart:io';
+
+import 'package:app_settings/app_settings.dart';
+import 'package:app_tracking_transparency/app_tracking_transparency.dart';
import 'package:comwell_key_app/domain/models/app_error.dart';
+import 'package:comwell_key_app/domain/repositories/bluetooth_repository.dart';
import 'package:comwell_key_app/presentation/base/base_cubit.dart';
import 'package:comwell_key_app/presentation/screens/permission_overview/bloc/permission_overview_state.dart';
+import 'package:comwell_key_app/utils/secure_storage.dart';
+
+import '../../../../notifications/notifications_repository.dart';
class PermissionOverviewCubit extends BaseCubit<PermissionOverviewState> {
- PermissionOverviewCubit() : super(const PermissionOverviewState()) {
+ PermissionOverviewCubit(
+ this._comwellPreferences,
+ this._notificationsRepository,
+ this._bluetoothRepository,
+ ) : super(const PermissionOverviewState()) {
init();
}
- Future<void> init() async {
+ final ComwellPreferences _comwellPreferences;
+ final NotificationsRepository _notificationsRepository;
+ final BluetoothRepository _bluetoothRepository;
+
+ void init() async {
try {
safeEmit(state.loading());
- // await Function();
+ await Future.wait([
+ _checkAllowUsageTracking(),
+ _checkBluetooth(),
+ _checkPushNotificationPermission(),
+ ]);
} catch (e, st) {
- logError(e, st);
safeEmit(state.copyWith(error: AppError.unknown(e.toString())));
} finally {
safeEmit(state.copyWith(isLoading: false));
}
}
-}
\ No newline at end of file
+
+ Future<void> _checkBluetooth() async {
+ final bluetoothIsGranted = await _bluetoothRepository.isPermissionGranted();
+ safeEmit(state.copyWith(allowBluetooth: bluetoothIsGranted));
+ }
+
+ Future<void> _checkPushNotificationPermission() async {
+ final notificationPermissionGranted = await _notificationsRepository
+ .isPushNotificationPermissionGranted();
+ safeEmit(state.copyWith(allowPushNotifications: notificationPermissionGranted));
+ }
+
+ Future<void> _checkAllowUsageTracking() async {
+ safeEmit(state.copyWith(allowUsageTracking: _comwellPreferences.allowUsageTracking));
+ }
+
+ Future<void> onTogglePushNotifications() async {
+ await AppSettings.openAppSettings(type: AppSettingsType.notification);
+ await _checkPushNotificationPermission();
+ }
+
+ Future<void> onToggleUsageTracking() async {
+ if (Platform.isAndroid) {
+ await _comwellPreferences.setAllowUsageTracking(!_comwellPreferences.allowUsageTracking);
+ _checkAllowUsageTracking();
+ } else {
+ final initialStatus = await AppTrackingTransparency.trackingAuthorizationStatus;
+ if (initialStatus != TrackingStatus.authorized) {
+ await AppTrackingTransparency.requestTrackingAuthorization();
+ }
+ await _checkAllowUsageTracking();
+ }
+ }
+
+ Future<void> onToggleBluetoothPermission() async {
+ await AppSettings.openAppSettings(type: AppSettingsType.settings);
+ _checkBluetooth();
+ }
+
+ void disableUsageTracking() async {
+ await _comwellPreferences.setAllowUsageTracking(false);
+ }
+}
diff --git a/comwell_key_app/lib/presentation/screens/permission_overview/bloc/permission_overview_state.dart b/comwell_key_app/lib/presentation/screens/permission_overview/bloc/permission_overview_state.dart
index 713230a9..99a552db 100644
--- a/comwell_key_app/lib/presentation/screens/permission_overview/bloc/permission_overview_state.dart
+++ b/comwell_key_app/lib/presentation/screens/permission_overview/bloc/permission_overview_state.dart
@@ -8,7 +8,12 @@ abstract class PermissionOverviewState with _$PermissionOverviewState {
const factory PermissionOverviewState({
@Default(false) bool isLoading,
@Default(AppError.none) AppError error,
+ @Default(false) bool allowUsageTracking,
+ @Default(false) bool allowBluetooth,
+ @Default(false) bool allowPushNotifications,
}) = _PermissionOverviewState;
+
+ const PermissionOverviewState._();
PermissionOverviewState loading() => copyWith(isLoading: true, error: AppError.none);
}
\ No newline at end of file
diff --git a/comwell_key_app/lib/presentation/screens/permission_overview/permission_overview_route.dart b/comwell_key_app/lib/presentation/screens/permission_overview/permission_overview_route.dart
index 000be38b..52579f03 100644
--- a/comwell_key_app/lib/presentation/screens/permission_overview/permission_overview_route.dart
+++ b/comwell_key_app/lib/presentation/screens/permission_overview/permission_overview_route.dart
@@ -1,3 +1,4 @@
+import 'package:comwell_key_app/utils/locator.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
@@ -5,21 +6,24 @@ import 'package:comwell_key_app/presentation/navigation/transitions/slide_in_tra
import 'package:comwell_key_app/presentation/screens/permission_overview/bloc/permission_overview_cubit.dart';
import 'package:comwell_key_app/presentation/screens/permission_overview/permission_overview_screen.dart';
+import '../../../routing/app_routes.dart';
+
part '../../../.generated/presentation/screens/permission_overview/permission_overview_route.g.dart';
-@TypedGoRoute<PermissionOverviewRoute>(
- path: "/permission-overview", // add me to AppRoutes: static const permissionOverview = "/permission-overview";
-)
+@TypedGoRoute<PermissionOverviewRoute>(path: AppRoutes.permissionOverview)
class PermissionOverviewRoute extends GoRouteData with $PermissionOverviewRoute {
-
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return SlideInTransition(
state: state,
child: BlocProvider(
- create: (context) => PermissionOverviewCubit(),
+ create: (context) => PermissionOverviewCubit(
+ locator(),
+ locator(),
+ locator(),
+ ),
child: const PermissionOverviewScreen(),
),
);
}
-}
\ No newline at end of file
+}
diff --git a/comwell_key_app/lib/presentation/screens/permission_overview/permission_overview_screen.dart b/comwell_key_app/lib/presentation/screens/permission_overview/permission_overview_screen.dart
index 09e3f126..b5233040 100644
--- a/comwell_key_app/lib/presentation/screens/permission_overview/permission_overview_screen.dart
+++ b/comwell_key_app/lib/presentation/screens/permission_overview/permission_overview_screen.dart
@@ -1,3 +1,7 @@
+import 'package:comwell_key_app/common/components/comwell_app_bar.dart';
+import 'package:comwell_key_app/themes/app_spaces.dart';
+import 'package:comwell_key_app/utils/l10n_utils.dart';
+import 'package:concierge/presentation/theme/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:comwell_key_app/presentation/screens/permission_overview/bloc/permission_overview_cubit.dart';
@@ -11,22 +15,95 @@ class PermissionOverviewScreen extends StatelessWidget {
return BlocBuilder<PermissionOverviewCubit, PermissionOverviewState>(
builder: (context, state) {
final cubit = context.read<PermissionOverviewCubit>();
+ final List<(String, String, bool, VoidCallback)> permissions = [
+ (
+ context.strings.bluetooth_permission_title,
+ context.strings.bluetooth_permission_description,
+ state.allowBluetooth,
+ cubit.onToggleBluetoothPermission,
+ ),
+ (
+ context.strings.accept_notifications,
+ context.strings.accept_notifications_rationale,
+ state.allowPushNotifications,
+ cubit.onTogglePushNotifications,
+ ),
+ (
+ context.strings.allow_usage_tracking,
+ context.strings.usage_tracking_rationale,
+ state.allowUsageTracking,
+ cubit.onToggleUsageTracking,
+ ),
+ ];
+ final theme = Theme.of(context);
return MultiBlocListener(
listeners: [
BlocListener<PermissionOverviewCubit, PermissionOverviewState>(
- listenWhen: (prev, curr) =>
- prev.isLoading && !curr.isLoading && curr.error.isError,
+ listenWhen: (prev, curr) => prev.isLoading && !curr.isLoading && curr.error.isError,
listener: (context, state) {
// context.showErrorSnackBar(state.errorMessage);
},
- )
+ ),
],
child: Scaffold(
- appBar: AppBar(),
- body: Center(
- child: Column(
- children: [
- Text("PermissionOverview"),
+ appBar: const ComwellAppBar(shouldShowProfileButton: false),
+ body: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: CustomScrollView(
+ slivers: [
+ SliverToBoxAdapter(
+ child: Text(
+ context.strings.permissions,
+ style: const TextStyle(
+ fontSize: 28,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ const SliverToBoxAdapter(child: AppSpaces.gap16),
+ SliverList.builder(
+ itemCount: permissions.length,
+ itemBuilder: (context, index) {
+ final (title, rationale, allowed, onToggle) = permissions[index];
+ return SwitchListTile(
+ thumbColor: WidgetStateProperty.resolveWith((states) {
+ if (states.contains(WidgetState.selected)) {
+ return AppColors.sandColor;
+ }
+ return Colors.white;
+ }),
+ trackColor: WidgetStateProperty.resolveWith((states) {
+ if (!states.contains(WidgetState.selected)) {
+ return Colors.grey[200];
+ }
+ return null;
+ }),
+ trackOutlineColor: WidgetStatePropertyAll(
+ Theme.of(context).colorScheme.surface,
+ ),
+ title: Text(
+ title,
+ style: theme.textTheme.titleMedium?.copyWith(
+ color: Theme.of(context).colorScheme.onSurface,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ subtitle: Text(
+ rationale,
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: Theme.of(context).colorScheme.surfaceTint,
+ fontSize: 12,
+ fontWeight: FontWeight.w400,
+ ),
+ ),
+ value: allowed,
+ onChanged: (bool value) {
+ onToggle();
+ },
+ contentPadding: EdgeInsets.zero,
+ );
+ },
+ ),
],
),
),
@@ -34,5 +111,5 @@ class PermissionOverviewScreen extends StatelessWidget {
);
},
);
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/comwell_key_app/lib/profile/components/comwell_club_container.dart b/comwell_key_app/lib/profile/components/comwell_club_container.dart
index 6fc6c6e3..72e89bd8 100644
--- a/comwell_key_app/lib/profile/components/comwell_club_container.dart
+++ b/comwell_key_app/lib/profile/components/comwell_club_container.dart
@@ -22,7 +22,6 @@ class ComwellClubContainer extends StatelessWidget {
color: sandColor[10],
borderRadius: const BorderRadius.all(Radius.circular(10)),
),
- height: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
diff --git a/comwell_key_app/lib/profile/components/profile_page_widget.dart b/comwell_key_app/lib/profile/components/profile_page_widget.dart
index e2223c33..7139a688 100644
--- a/comwell_key_app/lib/profile/components/profile_page_widget.dart
+++ b/comwell_key_app/lib/profile/components/profile_page_widget.dart
@@ -1,16 +1,18 @@
+import 'package:comwell_key_app/.generated/assets/assets.gen.dart';
import 'package:comwell_key_app/common/components/comwell_card_component.dart';
import 'package:comwell_key_app/common/components/round_icon_button.dart';
+import 'package:comwell_key_app/presentation/screens/permission_overview/permission_overview_route.dart';
import 'package:comwell_key_app/profile/components/card_content_widget.dart';
import 'package:comwell_key_app/profile/components/comwell_club_container.dart';
import 'package:comwell_key_app/profile/components/logout_dialog_widget.dart';
import 'package:comwell_key_app/profile/components/profile_settings_item.dart';
import 'package:comwell_key_app/profile/cubit/profile_cubit.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/themes/app_spaces.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:comwell_key_app/utils/l10n_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -24,37 +26,38 @@ class ProfilePageWidget extends StatelessWidget {
final user = cubit.state.user;
final isActive = cubit.state.user?.isClubMember == true;
- return Column(
- children: [
- Padding(
- padding: const EdgeInsets.only(top: 60, right: 10),
- child: Container(
- alignment: Alignment.centerRight,
- child: RoundIconButton(
- icon: "assets/icons/close-icon.svg",
- color: Colors.white,
- onPressed: () {
- context.pop();
- },
+ return SingleChildScrollView(
+ child: Column(
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(top: 60, right: 10),
+ child: Container(
+ alignment: Alignment.centerRight,
+ child: RoundIconButton(
+ icon: "assets/icons/close-icon.svg",
+ color: Colors.white,
+ onPressed: () {
+ context.pop();
+ },
+ ),
),
),
- ),
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: Column(
- children: [
- ComwellCard(
- content: CardContentWidget(cubit: cubit, isActive: isActive),
- backgroundColor: isActive ? sandColor : sandColor[10]!,
- ),
- ],
+ Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ children: [
+ ComwellCard(
+ content: CardContentWidget(cubit: cubit, isActive: isActive),
+ backgroundColor: isActive ? sandColor : sandColor[10]!,
+ ),
+ ],
+ ),
),
- ),
- const SizedBox(height: 10),
- Expanded(
- child: Container(
+ const SizedBox(height: 10),
+ Container(
color: Colors.white,
child: Column(
+ mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 10),
!isActive
@@ -68,7 +71,7 @@ class ProfilePageWidget extends StatelessWidget {
const SizedBox(height: 10),
profileSettingsItem(
context,
- icon: Image.asset('assets/icons/user-circle.png'),
+ icon: Assets.icons.userCircleSvg.svg(),
text: context.strings.profile_settings_profile_menu,
trailingIcon: Icons.chevron_right,
onTap: () async {
@@ -82,7 +85,7 @@ class ProfilePageWidget extends StatelessWidget {
),
profileSettingsItem(
context,
- icon: Image.asset('assets/icons/card.png'),
+ icon: Assets.icons.calendarPng.image(),
text: context.strings.payment_card_profile_menu,
trailingIcon: Icons.chevron_right,
onTap: () {
@@ -95,7 +98,20 @@ class ProfilePageWidget extends StatelessWidget {
),
profileSettingsItem(
context,
- icon: Image.asset('assets/icons/bell.png'),
+ icon: const Icon(Icons.check),
+ trailingIcon: Icons.chevron_right,
+ text: context.strings.permissions,
+ onTap: () {
+ PermissionOverviewRoute().push(context);
+ },
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(horizontal: 16.0),
+ child: Divider(color: colorDivider),
+ ),
+ profileSettingsItem(
+ context,
+ icon: Assets.icons.bell.image(),
trailingIcon: Icons.chevron_right,
text: context.strings.notifications_profile_menu,
onTap: () {
@@ -110,7 +126,7 @@ class ProfilePageWidget extends StatelessWidget {
if (isActive) ...[
profileSettingsItem(
context,
- icon: SvgPicture.asset('assets/icons/c_logo.svg'),
+ icon: Assets.icons.cLogo.svg(),
text: "Comwell Club",
trailingIcon: Icons.open_in_new,
onTap: () {
@@ -142,25 +158,26 @@ class ProfilePageWidget extends StatelessWidget {
),
),
),
- Expanded(
- child: FutureBuilder<String>(
- future: context.read<ProfileCubit>().getVersion(),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- return Text(
- snapshot.requireData,
- style: TextStyle(color: Colors.grey[500]),
- );
- }
- return const SizedBox.shrink();
- },
- ),
+ AppSpaces.gap16,
+ FutureBuilder<String>(
+ future: context.read<ProfileCubit>().getVersion(),
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ return Text(
+ snapshot.requireData,
+ style: TextStyle(color: Colors.grey[500]),
+ );
+ }
+ return const SizedBox.shrink();
+ },
),
+ AppSpaces.gap40,
+
],
),
),
- ),
- ],
+ ],
+ ),
);
}
}
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 3301cac1..06c88814 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -11,6 +11,7 @@ import 'package:comwell_key_app/presentation/screens/booking_details/booking_det
import 'package:comwell_key_app/presentation/screens/change_password/change_password_route.dart';
import 'package:comwell_key_app/presentation/screens/concierge/concierge_route.dart';
import 'package:comwell_key_app/presentation/screens/payment_processing/payment_processing_route.dart';
+import 'package:comwell_key_app/presentation/screens/permission_overview/permission_overview_route.dart';
import 'package:comwell_key_app/presentation/screens/room_info/room_info_route.dart';
import 'package:comwell_key_app/contact/contact_route.dart';
import 'package:comwell_key_app/find_booking/find_booking_route.dart';
@@ -78,6 +79,7 @@ final router = GoRouter(
$notificationPermissionRoute,
$usageTrackingPermissionRoute,
$internetDisabledRoute,
+ $permissionOverviewRoute,
overviewRoute,
profileRoute,
profileSettingsRoute,
diff --git a/comwell_key_app/lib/routing/app_routes.dart b/comwell_key_app/lib/routing/app_routes.dart
index d0540520..806dded4 100644
--- a/comwell_key_app/lib/routing/app_routes.dart
+++ b/comwell_key_app/lib/routing/app_routes.dart
@@ -49,4 +49,5 @@ abstract class AppRoutes {
static const sharedBooking = "/shared-booking";
static const payMyBooking = "/pay-my-booking";
static const checkOutError = "/check-out-error";
+ static const permissionOverview = "/permission-overview";
}
diff --git a/comwell_key_app/lib/utils/locator.dart b/comwell_key_app/lib/utils/locator.dart
index a88bff99..01d6cbf4 100644
--- a/comwell_key_app/lib/utils/locator.dart
+++ b/comwell_key_app/lib/utils/locator.dart
@@ -32,7 +32,6 @@ import 'package:get_it/get_it.dart';
import 'package:payment_plugin/domain/repositories/adyen_repository.dart';
import 'package:seos_mobile_keys_plugin/seos_mobile_keys_plugin.dart';
-
final locator = GetIt.I;
void registerDatabase() {
@@ -77,7 +76,12 @@ void setupLocator() {
locator.registerFactory(() => ProfileRepository(locator.get(), locator.get()));
locator.registerFactory(() => PreregistrationRepository());
locator.registerFactory(() => HotelInformationRepository());
- locator.registerFactory(() => NotificationsRepository());
+ locator.registerFactory(
+ () => NotificationsRepository(
+ locator(),
+ locator(),
+ ),
+ );
locator.registerFactory(() => ContactRepository());
locator.registerFactory(() => UpSalesRepository());
locator.registerFactory(() => ChooseShareRoomRepository());
diff --git a/comwell_key_app/lib/utils/secure_storage.dart b/comwell_key_app/lib/utils/secure_storage.dart
index ccdbb29c..3d1d8677 100644
--- a/comwell_key_app/lib/utils/secure_storage.dart
+++ b/comwell_key_app/lib/utils/secure_storage.dart
@@ -70,6 +70,12 @@ class ComwellPreferences {
await _sharedPreferences.setBool(_keyOnboardingHasSeenUsageTracking, true);
}
+ bool get allowUsageTracking => _sharedPreferences.getBool(_keyAllowUsageTracking) ?? false;
+
+ Future<void> setAllowUsageTracking(bool allow) async {
+ await _sharedPreferences.setBool(_keyAllowUsageTracking, allow);
+ }
+
Future<void> clear() async {
await _sharedPreferences.clear();
}
@@ -77,5 +83,6 @@ class ComwellPreferences {
static const _keyOnboardingHasSeenBluetooth = "_keyOnboardingHasSeenBluetooth";
static const _keyOnboardingHasSeenNotification = "_keyOnboardingHasSeenNotification";
static const _keyOnboardingHasSeenUsageTracking = "_keyOnboardingHasSeenUsageTracking";
+ static const _keyAllowUsageTracking = "_keyAllowUsageTracking";
static const _keyIsLoggedIn = "_keyIsLoggedIn";
}