6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 898c5fb4
Changed files
comwell_key_app/assets/translations/da-DK.json | 3 +- comwell_key_app/assets/translations/en-US.json | 3 +- comwell_key_app/ios/Runner/Info.plist | 10 - .../lib/.generated/database/comwell_db.g.dart | 384 +++++++++++++++++++-- .../database/daos/notifications_dao.g.dart | 9 + .../models/notification_permission.g.dart | 22 ++ .../lib/.generated/overview/models/booking.g.dart | 5 +- .../.generated/profile_settings/model/user.g.dart | 17 +- .../services/adyen/payment_methods.g.dart | 25 -- comwell_key_app/lib/database/comwell_db.dart | 7 +- .../lib/database/daos/notifications_dao.dart | 44 +++ comwell_key_app/lib/database/daos/user_dao.dart | 7 + .../lib/database/tables/notification_table.dart | 8 + .../lib/database/tables/user_table.dart | 2 +- .../notifications/cubit/notifications_cubit.dart | 67 ++++ .../notifications/cubit/notifications_state.dart | 44 +++ .../models/notification_permission.dart | 96 ++++++ .../lib/notifications/notifications_page.dart | 109 +++--- .../notifications/notifications_repository.dart | 58 ++++ .../pregistration/bloc/preregistration_cubit.dart | 11 +- .../pages/prereg_confirmation_page.dart | 4 +- .../lib/profile/profile_repository.dart | 33 +- .../components/address_bottom_sheet.dart | 17 +- .../lib/profile_settings/model/user.dart | 16 +- .../profile_settings/profile_settings_page.dart | 29 +- .../repostiory/profile_settings_repository.dart | 7 +- comwell_key_app/lib/routing/app_router.dart | 12 +- comwell_key_app/lib/services/api.dart | 79 +++-- comwell_key_app/lib/utils/locator.dart | 12 +- .../profile_settings_cubit_test.dart | 17 +- 30 files changed, 947 insertions(+), 210 deletions(-)
Diff
diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index 5a7257ea..33706074 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -208,5 +208,6 @@
"digital_media": "Digital media",
"digital_media_subtitle": "Ja, jeg vil gerne se personligt tilpassede digitale reklamer med nyheder, inspiration og invitationer til events. Jeg kan til enhver tid, afslutte min tilmelding.",
"sms": "SMS",
- "sms_subtitle": "Ja, jeg vil gerne modtage SMS med nyheder, inspiration og invitationer til events. Jeg kan til enhver tid, afslutte min tilmelding."
+ "sms_subtitle": "Ja, jeg vil gerne modtage SMS med nyheder, inspiration og invitationer til events. Jeg kan til enhver tid, afslutte min tilmelding.",
+ "notifications_error": "Der skete en fejl. Prøv igen."
}
\ 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 3ec77278..0ecd71ff 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -208,5 +208,6 @@
"digital_media": "Digital media",
"digital_media_subtitle": "Yes, I would like see personalized digital media advertising with news, inspiration and invitations to events. I can at any time, unsubscribe.",
"sms": "SMS",
- "sms_subtitle": "Yes, I would like to recieve SMS with news, inspiration and invitations to events. I can at any time, unsubscribe."
+ "sms_subtitle": "Yes, I would like to recieve SMS with news, inspiration and invitations to events. I can at any time, unsubscribe.",
+ "notifications_error": "An error occurred. Please try again later."
}
diff --git a/comwell_key_app/ios/Runner/Info.plist b/comwell_key_app/ios/Runner/Info.plist
index 4e6c7b49..0c5bcc58 100644
--- a/comwell_key_app/ios/Runner/Info.plist
+++ b/comwell_key_app/ios/Runner/Info.plist
@@ -41,16 +41,6 @@
<string>seosmobileaccess</string>
</array>
</dict>
- <dict>
- <key>CFBundleTypeRole</key>
- <string>Editor</string>
- <key>CFBundleURLName</key>
- <string>com.comwell.phoenix</string>
- <key>CFBundleURLSchemes</key>
- <array>
- <string>comwell</string>
- </array>
- </dict>
</array>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
diff --git a/comwell_key_app/lib/.generated/database/comwell_db.g.dart b/comwell_key_app/lib/.generated/database/comwell_db.g.dart
index 99db1942..256d56c9 100644
--- a/comwell_key_app/lib/.generated/database/comwell_db.g.dart
+++ b/comwell_key_app/lib/.generated/database/comwell_db.g.dart
@@ -238,9 +238,9 @@ class $UserEntityTable extends UserEntity
$UserEntityTable(this.attachedDatabase, [this._alias]);
static const VerificationMeta _idMeta = const VerificationMeta('id');
@override
- late final GeneratedColumn<String> id = GeneratedColumn<String>(
+ late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
- type: DriftSqlType.string,
+ type: DriftSqlType.int,
requiredDuringInsert: true,
defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE'));
static const VerificationMeta _jsonMeta = const VerificationMeta('json');
@@ -281,7 +281,7 @@ class $UserEntityTable extends UserEntity
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UserDb(
id: attachedDatabase.typeMapping
- .read(DriftSqlType.string, data['${effectivePrefix}id'])!,
+ .read(DriftSqlType.int, data['${effectivePrefix}id'])!,
json: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}json'])!,
);
@@ -294,13 +294,13 @@ class $UserEntityTable extends UserEntity
}
class UserDb extends DataClass implements Insertable<UserDb> {
- final String id;
+ final int id;
final String json;
const UserDb({required this.id, required this.json});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
- map['id'] = Variable<String>(id);
+ map['id'] = Variable<int>(id);
map['json'] = Variable<String>(json);
return map;
}
@@ -316,7 +316,7 @@ class UserDb extends DataClass implements Insertable<UserDb> {
{ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return UserDb(
- id: serializer.fromJson<String>(json['id']),
+ id: serializer.fromJson<int>(json['id']),
json: serializer.fromJson<String>(json['json']),
);
}
@@ -324,12 +324,12 @@ class UserDb extends DataClass implements Insertable<UserDb> {
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return <String, dynamic>{
- 'id': serializer.toJson<String>(id),
+ 'id': serializer.toJson<int>(id),
'json': serializer.toJson<String>(json),
};
}
- UserDb copyWith({String? id, String? json}) => UserDb(
+ UserDb copyWith({int? id, String? json}) => UserDb(
id: id ?? this.id,
json: json ?? this.json,
);
@@ -358,7 +358,7 @@ class UserDb extends DataClass implements Insertable<UserDb> {
}
class UserEntityCompanion extends UpdateCompanion<UserDb> {
- final Value<String> id;
+ final Value<int> id;
final Value<String> json;
final Value<int> rowid;
const UserEntityCompanion({
@@ -367,13 +367,13 @@ class UserEntityCompanion extends UpdateCompanion<UserDb> {
this.rowid = const Value.absent(),
});
UserEntityCompanion.insert({
- required String id,
+ required int id,
required String json,
this.rowid = const Value.absent(),
}) : id = Value(id),
json = Value(json);
static Insertable<UserDb> custom({
- Expression<String>? id,
+ Expression<int>? id,
Expression<String>? json,
Expression<int>? rowid,
}) {
@@ -385,7 +385,7 @@ class UserEntityCompanion extends UpdateCompanion<UserDb> {
}
UserEntityCompanion copyWith(
- {Value<String>? id, Value<String>? json, Value<int>? rowid}) {
+ {Value<int>? id, Value<String>? json, Value<int>? rowid}) {
return UserEntityCompanion(
id: id ?? this.id,
json: json ?? this.json,
@@ -397,7 +397,7 @@ class UserEntityCompanion extends UpdateCompanion<UserDb> {
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
if (id.present) {
- map['id'] = Variable<String>(id.value);
+ map['id'] = Variable<int>(id.value);
}
if (json.present) {
map['json'] = Variable<String>(json.value);
@@ -419,19 +419,222 @@ class UserEntityCompanion extends UpdateCompanion<UserDb> {
}
}
+class $NotificationPermissionEntityTable extends NotificationPermissionEntity
+ with
+ TableInfo<$NotificationPermissionEntityTable,
+ NotificationPermissionDb> {
+ @override
+ final GeneratedDatabase attachedDatabase;
+ final String? _alias;
+ $NotificationPermissionEntityTable(this.attachedDatabase, [this._alias]);
+ static const VerificationMeta _idMeta = const VerificationMeta('id');
+ @override
+ late final GeneratedColumn<int> id = GeneratedColumn<int>(
+ 'id', aliasedName, false,
+ type: DriftSqlType.int,
+ requiredDuringInsert: true,
+ defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE'));
+ static const VerificationMeta _jsonMeta = const VerificationMeta('json');
+ @override
+ late final GeneratedColumn<String> json = GeneratedColumn<String>(
+ 'json', aliasedName, false,
+ type: DriftSqlType.string, requiredDuringInsert: true);
+ @override
+ List<GeneratedColumn> get $columns => [id, json];
+ @override
+ String get aliasedName => _alias ?? actualTableName;
+ @override
+ String get actualTableName => $name;
+ static const String $name = 'notification_permission_entity';
+ @override
+ VerificationContext validateIntegrity(
+ Insertable<NotificationPermissionDb> instance,
+ {bool isInserting = false}) {
+ final context = VerificationContext();
+ final data = instance.toColumns(true);
+ if (data.containsKey('id')) {
+ context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
+ } else if (isInserting) {
+ context.missing(_idMeta);
+ }
+ if (data.containsKey('json')) {
+ context.handle(
+ _jsonMeta, json.isAcceptableOrUnknown(data['json']!, _jsonMeta));
+ } else if (isInserting) {
+ context.missing(_jsonMeta);
+ }
+ return context;
+ }
+
+ @override
+ Set<GeneratedColumn> get $primaryKey => const {};
+ @override
+ NotificationPermissionDb map(Map<String, dynamic> data,
+ {String? tablePrefix}) {
+ final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
+ return NotificationPermissionDb(
+ id: attachedDatabase.typeMapping
+ .read(DriftSqlType.int, data['${effectivePrefix}id'])!,
+ json: attachedDatabase.typeMapping
+ .read(DriftSqlType.string, data['${effectivePrefix}json'])!,
+ );
+ }
+
+ @override
+ $NotificationPermissionEntityTable createAlias(String alias) {
+ return $NotificationPermissionEntityTable(attachedDatabase, alias);
+ }
+}
+
+class NotificationPermissionDb extends DataClass
+ implements Insertable<NotificationPermissionDb> {
+ final int id;
+ final String json;
+ const NotificationPermissionDb({required this.id, required this.json});
+ @override
+ Map<String, Expression> toColumns(bool nullToAbsent) {
+ final map = <String, Expression>{};
+ map['id'] = Variable<int>(id);
+ map['json'] = Variable<String>(json);
+ return map;
+ }
+
+ NotificationPermissionEntityCompanion toCompanion(bool nullToAbsent) {
+ return NotificationPermissionEntityCompanion(
+ id: Value(id),
+ json: Value(json),
+ );
+ }
+
+ factory NotificationPermissionDb.fromJson(Map<String, dynamic> json,
+ {ValueSerializer? serializer}) {
+ serializer ??= driftRuntimeOptions.defaultSerializer;
+ return NotificationPermissionDb(
+ id: serializer.fromJson<int>(json['id']),
+ json: serializer.fromJson<String>(json['json']),
+ );
+ }
+ @override
+ Map<String, dynamic> toJson({ValueSerializer? serializer}) {
+ serializer ??= driftRuntimeOptions.defaultSerializer;
+ return <String, dynamic>{
+ 'id': serializer.toJson<int>(id),
+ 'json': serializer.toJson<String>(json),
+ };
+ }
+
+ NotificationPermissionDb copyWith({int? id, String? json}) =>
+ NotificationPermissionDb(
+ id: id ?? this.id,
+ json: json ?? this.json,
+ );
+ NotificationPermissionDb copyWithCompanion(
+ NotificationPermissionEntityCompanion data) {
+ return NotificationPermissionDb(
+ id: data.id.present ? data.id.value : this.id,
+ json: data.json.present ? data.json.value : this.json,
+ );
+ }
+
+ @override
+ String toString() {
+ return (StringBuffer('NotificationPermissionDb(')
+ ..write('id: $id, ')
+ ..write('json: $json')
+ ..write(')'))
+ .toString();
+ }
+
+ @override
+ int get hashCode => Object.hash(id, json);
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ (other is NotificationPermissionDb &&
+ other.id == this.id &&
+ other.json == this.json);
+}
+
+class NotificationPermissionEntityCompanion
+ extends UpdateCompanion<NotificationPermissionDb> {
+ final Value<int> id;
+ final Value<String> json;
+ final Value<int> rowid;
+ const NotificationPermissionEntityCompanion({
+ this.id = const Value.absent(),
+ this.json = const Value.absent(),
+ this.rowid = const Value.absent(),
+ });
+ NotificationPermissionEntityCompanion.insert({
+ required int id,
+ required String json,
+ this.rowid = const Value.absent(),
+ }) : id = Value(id),
+ json = Value(json);
+ static Insertable<NotificationPermissionDb> custom({
+ Expression<int>? id,
+ Expression<String>? json,
+ Expression<int>? rowid,
+ }) {
+ return RawValuesInsertable({
+ if (id != null) 'id': id,
+ if (json != null) 'json': json,
+ if (rowid != null) 'rowid': rowid,
+ });
+ }
+
+ NotificationPermissionEntityCompanion copyWith(
+ {Value<int>? id, Value<String>? json, Value<int>? rowid}) {
+ return NotificationPermissionEntityCompanion(
+ id: id ?? this.id,
+ json: json ?? this.json,
+ rowid: rowid ?? this.rowid,
+ );
+ }
+
+ @override
+ Map<String, Expression> toColumns(bool nullToAbsent) {
+ final map = <String, Expression>{};
+ if (id.present) {
+ map['id'] = Variable<int>(id.value);
+ }
+ if (json.present) {
+ map['json'] = Variable<String>(json.value);
+ }
+ if (rowid.present) {
+ map['rowid'] = Variable<int>(rowid.value);
+ }
+ return map;
+ }
+
+ @override
+ String toString() {
+ return (StringBuffer('NotificationPermissionEntityCompanion(')
+ ..write('id: $id, ')
+ ..write('json: $json, ')
+ ..write('rowid: $rowid')
+ ..write(')'))
+ .toString();
+ }
+}
+
abstract class _$ComwellDatabase extends GeneratedDatabase {
_$ComwellDatabase(QueryExecutor e) : super(e);
$ComwellDatabaseManager get managers => $ComwellDatabaseManager(this);
late final $BookingEntityTable bookingEntity = $BookingEntityTable(this);
late final $UserEntityTable userEntity = $UserEntityTable(this);
+ late final $NotificationPermissionEntityTable notificationPermissionEntity =
+ $NotificationPermissionEntityTable(this);
late final BookingsDao bookingsDao = BookingsDao(this as ComwellDatabase);
late final UserDAO userDAO = UserDAO(this as ComwellDatabase);
+ late final NotificationPermissionDAO notificationPermissionDAO =
+ NotificationPermissionDAO(this as ComwellDatabase);
@override
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>
- [bookingEntity, userEntity];
+ [bookingEntity, userEntity, notificationPermissionEntity];
}
typedef $$BookingEntityTableCreateCompanionBuilder = BookingEntityCompanion
@@ -579,12 +782,12 @@ typedef $$BookingEntityTableProcessedTableManager = ProcessedTableManager<
BookingDb,
PrefetchHooks Function()>;
typedef $$UserEntityTableCreateCompanionBuilder = UserEntityCompanion Function({
- required String id,
+ required int id,
required String json,
Value<int> rowid,
});
typedef $$UserEntityTableUpdateCompanionBuilder = UserEntityCompanion Function({
- Value<String> id,
+ Value<int> id,
Value<String> json,
Value<int> rowid,
});
@@ -598,7 +801,7 @@ class $$UserEntityTableFilterComposer
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
- ColumnFilters<String> get id => $composableBuilder(
+ ColumnFilters<int> get id => $composableBuilder(
column: $table.id, builder: (column) => ColumnFilters(column));
ColumnFilters<String> get json => $composableBuilder(
@@ -614,7 +817,7 @@ class $$UserEntityTableOrderingComposer
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
- ColumnOrderings<String> get id => $composableBuilder(
+ ColumnOrderings<int> get id => $composableBuilder(
column: $table.id, builder: (column) => ColumnOrderings(column));
ColumnOrderings<String> get json => $composableBuilder(
@@ -630,7 +833,7 @@ class $$UserEntityTableAnnotationComposer
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
- GeneratedColumn<String> get id =>
+ GeneratedColumn<int> get id =>
$composableBuilder(column: $table.id, builder: (column) => column);
GeneratedColumn<String> get json =>
@@ -660,7 +863,7 @@ class $$UserEntityTableTableManager extends RootTableManager<
createComputedFieldComposer: () =>
$$UserEntityTableAnnotationComposer($db: db, $table: table),
updateCompanionCallback: ({
- Value<String> id = const Value.absent(),
+ Value<int> id = const Value.absent(),
Value<String> json = const Value.absent(),
Value<int> rowid = const Value.absent(),
}) =>
@@ -670,7 +873,7 @@ class $$UserEntityTableTableManager extends RootTableManager<
rowid: rowid,
),
createCompanionCallback: ({
- required String id,
+ required int id,
required String json,
Value<int> rowid = const Value.absent(),
}) =>
@@ -698,6 +901,141 @@ typedef $$UserEntityTableProcessedTableManager = ProcessedTableManager<
(UserDb, BaseReferences<_$ComwellDatabase, $UserEntityTable, UserDb>),
UserDb,
PrefetchHooks Function()>;
+typedef $$NotificationPermissionEntityTableCreateCompanionBuilder
+ = NotificationPermissionEntityCompanion Function({
+ required int id,
+ required String json,
+ Value<int> rowid,
+});
+typedef $$NotificationPermissionEntityTableUpdateCompanionBuilder
+ = NotificationPermissionEntityCompanion Function({
+ Value<int> id,
+ Value<String> json,
+ Value<int> rowid,
+});
+
+class $$NotificationPermissionEntityTableFilterComposer
+ extends Composer<_$ComwellDatabase, $NotificationPermissionEntityTable> {
+ $$NotificationPermissionEntityTableFilterComposer({
+ required super.$db,
+ required super.$table,
+ super.joinBuilder,
+ super.$addJoinBuilderToRootComposer,
+ super.$removeJoinBuilderFromRootComposer,
+ });
+ ColumnFilters<int> get id => $composableBuilder(
+ column: $table.id, builder: (column) => ColumnFilters(column));
+
+ ColumnFilters<String> get json => $composableBuilder(
+ column: $table.json, builder: (column) => ColumnFilters(column));
+}
+
+class $$NotificationPermissionEntityTableOrderingComposer
+ extends Composer<_$ComwellDatabase, $NotificationPermissionEntityTable> {
+ $$NotificationPermissionEntityTableOrderingComposer({
+ required super.$db,
+ required super.$table,
+ super.joinBuilder,
+ super.$addJoinBuilderToRootComposer,
+ super.$removeJoinBuilderFromRootComposer,
+ });
+ ColumnOrderings<int> get id => $composableBuilder(
+ column: $table.id, builder: (column) => ColumnOrderings(column));
+
+ ColumnOrderings<String> get json => $composableBuilder(
+ column: $table.json, builder: (column) => ColumnOrderings(column));
+}
+
+class $$NotificationPermissionEntityTableAnnotationComposer
+ extends Composer<_$ComwellDatabase, $NotificationPermissionEntityTable> {
+ $$NotificationPermissionEntityTableAnnotationComposer({
+ required super.$db,
+ required super.$table,
+ super.joinBuilder,
+ super.$addJoinBuilderToRootComposer,
+ super.$removeJoinBuilderFromRootComposer,
+ });
+ GeneratedColumn<int> get id =>
+ $composableBuilder(column: $table.id, builder: (column) => column);
+
+ GeneratedColumn<String> get json =>
+ $composableBuilder(column: $table.json, builder: (column) => column);
+}
+
+class $$NotificationPermissionEntityTableTableManager extends RootTableManager<
+ _$ComwellDatabase,
+ $NotificationPermissionEntityTable,
+ NotificationPermissionDb,
+ $$NotificationPermissionEntityTableFilterComposer,
+ $$NotificationPermissionEntityTableOrderingComposer,
+ $$NotificationPermissionEntityTableAnnotationComposer,
+ $$NotificationPermissionEntityTableCreateCompanionBuilder,
+ $$NotificationPermissionEntityTableUpdateCompanionBuilder,
+ (
+ NotificationPermissionDb,
+ BaseReferences<_$ComwellDatabase, $NotificationPermissionEntityTable,
+ NotificationPermissionDb>
+ ),
+ NotificationPermissionDb,
+ PrefetchHooks Function()> {
+ $$NotificationPermissionEntityTableTableManager(
+ _$ComwellDatabase db, $NotificationPermissionEntityTable table)
+ : super(TableManagerState(
+ db: db,
+ table: table,
+ createFilteringComposer: () =>
+ $$NotificationPermissionEntityTableFilterComposer(
+ $db: db, $table: table),
+ createOrderingComposer: () =>
+ $$NotificationPermissionEntityTableOrderingComposer(
+ $db: db, $table: table),
+ createComputedFieldComposer: () =>
+ $$NotificationPermissionEntityTableAnnotationComposer(
+ $db: db, $table: table),
+ updateCompanionCallback: ({
+ Value<int> id = const Value.absent(),
+ Value<String> json = const Value.absent(),
+ Value<int> rowid = const Value.absent(),
+ }) =>
+ NotificationPermissionEntityCompanion(
+ id: id,
+ json: json,
+ rowid: rowid,
+ ),
+ createCompanionCallback: ({
+ required int id,
+ required String json,
+ Value<int> rowid = const Value.absent(),
+ }) =>
+ NotificationPermissionEntityCompanion.insert(
+ id: id,
+ json: json,
+ rowid: rowid,
+ ),
+ withReferenceMapper: (p0) => p0
+ .map((e) => (e.readTable(table), BaseReferences(db, table, e)))
+ .toList(),
+ prefetchHooksCallback: null,
+ ));
+}
+
+typedef $$NotificationPermissionEntityTableProcessedTableManager
+ = ProcessedTableManager<
+ _$ComwellDatabase,
+ $NotificationPermissionEntityTable,
+ NotificationPermissionDb,
+ $$NotificationPermissionEntityTableFilterComposer,
+ $$NotificationPermissionEntityTableOrderingComposer,
+ $$NotificationPermissionEntityTableAnnotationComposer,
+ $$NotificationPermissionEntityTableCreateCompanionBuilder,
+ $$NotificationPermissionEntityTableUpdateCompanionBuilder,
+ (
+ NotificationPermissionDb,
+ BaseReferences<_$ComwellDatabase, $NotificationPermissionEntityTable,
+ NotificationPermissionDb>
+ ),
+ NotificationPermissionDb,
+ PrefetchHooks Function()>;
class $ComwellDatabaseManager {
final _$ComwellDatabase _db;
@@ -706,4 +1044,8 @@ class $ComwellDatabaseManager {
$$BookingEntityTableTableManager(_db, _db.bookingEntity);
$$UserEntityTableTableManager get userEntity =>
$$UserEntityTableTableManager(_db, _db.userEntity);
+ $$NotificationPermissionEntityTableTableManager
+ get notificationPermissionEntity =>
+ $$NotificationPermissionEntityTableTableManager(
+ _db, _db.notificationPermissionEntity);
}
diff --git a/comwell_key_app/lib/.generated/database/daos/notifications_dao.g.dart b/comwell_key_app/lib/.generated/database/daos/notifications_dao.g.dart
new file mode 100644
index 00000000..67ad6db4
--- /dev/null
+++ b/comwell_key_app/lib/.generated/database/daos/notifications_dao.g.dart
@@ -0,0 +1,9 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of '../../../database/daos/notifications_dao.dart';
+
+// ignore_for_file: type=lint
+mixin _$NotificationPermissionDAOMixin on DatabaseAccessor<ComwellDatabase> {
+ $NotificationPermissionEntityTable get notificationPermissionEntity =>
+ attachedDatabase.notificationPermissionEntity;
+}
diff --git a/comwell_key_app/lib/.generated/notifications/models/notification_permission.g.dart b/comwell_key_app/lib/.generated/notifications/models/notification_permission.g.dart
new file mode 100644
index 00000000..959a65f7
--- /dev/null
+++ b/comwell_key_app/lib/.generated/notifications/models/notification_permission.g.dart
@@ -0,0 +1,22 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of '../../../notifications/models/notification_permission.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+NotificationPermission _$NotificationPermissionFromJson(Map json) =>
+ NotificationPermission(
+ id: (json['id'] as num).toInt(),
+ name: json['name'] as String,
+ allowed: json['allowed'] as bool,
+ );
+
+Map<String, dynamic> _$NotificationPermissionToJson(
+ NotificationPermission instance) =>
+ <String, dynamic>{
+ 'id': instance.id,
+ 'name': instance.name,
+ 'allowed': instance.allowed,
+ };
diff --git a/comwell_key_app/lib/.generated/overview/models/booking.g.dart b/comwell_key_app/lib/.generated/overview/models/booking.g.dart
index 4a9f50c8..5e20d985 100644
--- a/comwell_key_app/lib/.generated/overview/models/booking.g.dart
+++ b/comwell_key_app/lib/.generated/overview/models/booking.g.dart
@@ -25,8 +25,7 @@ Booking _$BookingFromJson(Map json) => Booking(
paymentDetails: PaymentDetails.fromJson(
Map<String, dynamic>.from(json['paymentDetails'] as Map)),
guests: (json['guests'] as List<dynamic>?)
- ?.map((e) => Guest.fromJson(Map<String, dynamic>.from(e as Map)))
- .toList(),
+ ?.map((e) => Guest.fromJson(Map<String, dynamic>.from(e as Map))),
);
Map<String, dynamic> _$BookingToJson(Booking instance) => <String, dynamic>{
@@ -46,7 +45,7 @@ Map<String, dynamic> _$BookingToJson(Booking instance) => <String, dynamic>{
'bookingDate': instance.bookingDate.toIso8601String(),
'paymentDetails': instance.paymentDetails.toJson(),
'confirmationId': instance.confirmationId,
- 'guests': instance.guests?.map((e) => e.toJson()).toList(),
+ 'guests': instance.guests.map((e) => e.toJson()).toList(),
};
const _$BookingStatusEnumMap = {
diff --git a/comwell_key_app/lib/.generated/profile_settings/model/user.g.dart b/comwell_key_app/lib/.generated/profile_settings/model/user.g.dart
index af56c714..cea1d8e1 100644
--- a/comwell_key_app/lib/.generated/profile_settings/model/user.g.dart
+++ b/comwell_key_app/lib/.generated/profile_settings/model/user.g.dart
@@ -7,15 +7,16 @@ part of '../../../profile_settings/model/user.dart';
// **************************************************************************
User _$UserFromJson(Map json) => User(
- id: json['id'] as String,
+ id: (json['id'] as num).toInt(),
firstName: json['firstName'] as String,
lastName: json['lastName'] as String,
- countryCode: json['countryCode'] as String,
- phone: json['phone'] as String,
+ countryCode: json['countryCode'] as String?,
+ phone: json['phone'] as String?,
email: json['email'] as String,
- address:
- Address.fromJson(Map<String, dynamic>.from(json['address'] as Map)),
- birthday: DateTime.parse(json['birthday'] as String),
+ address: json['address'] == null
+ ? null
+ : Address.fromJson(Map<String, dynamic>.from(json['address'] as Map)),
+ birthDate: DateTime.parse(json['birthDate'] as String),
shopperReference: json['shopperReference'] as String?,
points: (json['points'] as num?)?.toInt(),
);
@@ -27,8 +28,8 @@ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
'countryCode': instance.countryCode,
'phone': instance.phone,
'email': instance.email,
- 'address': instance.address.toJson(),
- 'birthday': instance.birthday.toIso8601String(),
+ 'address': instance.address?.toJson(),
+ 'birthDate': instance.birthDate.toIso8601String(),
'shopperReference': instance.shopperReference,
'points': instance.points,
};
diff --git a/comwell_key_app/lib/.generated/services/adyen/payment_methods.g.dart b/comwell_key_app/lib/.generated/services/adyen/payment_methods.g.dart
deleted file mode 100644
index 22556332..00000000
--- a/comwell_key_app/lib/.generated/services/adyen/payment_methods.g.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-part of '../../../services/adyen/stored_payment_methods_response.dart';
-
-// **************************************************************************
-// JsonSerializableGenerator
-// **************************************************************************
-
-StoredPaymentsResponse _$StoredPaymentsResponseFromJson(Map json) =>
- StoredPaymentsResponse(
- merchantId: json['MerchantAccount'] as String,
- shopperReference: json['ShopperReference'] as String,
- storedPaymentMethods: (json['storedPaymentMethods'] as List<dynamic>).map(
- (e) => StoredPaymentMethod.fromJson(
- Map<String, dynamic>.from(e as Map))),
- );
-
-Map<String, dynamic> _$StoredPaymentsResponseToJson(
- StoredPaymentsResponse instance) =>
- <String, dynamic>{
- 'MerchantAccount': instance.merchantId,
- 'ShopperReference': instance.shopperReference,
- 'storedPaymentMethods':
- instance.storedPaymentMethods.map((e) => e.toJson()).toList(),
- };
diff --git a/comwell_key_app/lib/database/comwell_db.dart b/comwell_key_app/lib/database/comwell_db.dart
index e540f6c4..0f884433 100644
--- a/comwell_key_app/lib/database/comwell_db.dart
+++ b/comwell_key_app/lib/database/comwell_db.dart
@@ -1,6 +1,8 @@
import 'dart:io';
+import 'package:comwell_key_app/database/daos/notifications_dao.dart';
import 'package:comwell_key_app/database/tables/booking_table.dart';
+import 'package:comwell_key_app/database/tables/notification_table.dart';
import 'package:comwell_key_app/database/tables/user_table.dart';
import 'package:comwell_key_app/utils/secure_storage.dart';
import 'package:drift/drift.dart';
@@ -20,7 +22,8 @@ part '../.generated/database/comwell_db.g.dart';
final secureStorage = SecureStorage();
@DriftDatabase(
- tables: [BookingEntity, UserEntity], daos: [BookingsDao, UserDAO])
+ tables: [BookingEntity, UserEntity, NotificationPermissionEntity],
+ daos: [BookingsDao, UserDAO, NotificationPermissionDAO])
class ComwellDatabase extends _$ComwellDatabase {
static const String _cipherKey = "sql_cipher";
static const String _dbFileName = "comwell.db.enc";
@@ -51,6 +54,7 @@ class ComwellDatabase extends _$ComwellDatabase {
} else {
return cipher;
}
+ print('cipher: $cipher');
return getCipher();
}
@@ -59,6 +63,7 @@ class ComwellDatabase extends _$ComwellDatabase {
final path = await getApplicationSupportDirectory();
final file = File(p.join(path.path, _dbFileName));
final cipher = await getCipher();
+ print('cipher: $cipher');
Future<void> isolateSetup() async {
await applyWorkaroundToOpenSqlCipherOnOldAndroidVersions();
open.overrideFor(OperatingSystem.android, openCipherOnAndroid);
diff --git a/comwell_key_app/lib/database/daos/notifications_dao.dart b/comwell_key_app/lib/database/daos/notifications_dao.dart
new file mode 100644
index 00000000..d9d0f697
--- /dev/null
+++ b/comwell_key_app/lib/database/daos/notifications_dao.dart
@@ -0,0 +1,44 @@
+import 'dart:convert';
+
+import 'package:comwell_key_app/database/comwell_db.dart';
+import 'package:comwell_key_app/database/tables/notification_table.dart';
+import 'package:comwell_key_app/notifications/models/notification_permission.dart';
+import 'package:comwell_key_app/utils/json.dart';
+import 'package:drift/drift.dart';
+
+part '../../.generated/database/daos/notifications_dao.g.dart';
+
+@DriftAccessor(tables: [NotificationPermissionEntity])
+class NotificationPermissionDAO extends DatabaseAccessor<ComwellDatabase>
+ with _$NotificationPermissionDAOMixin {
+ NotificationPermissionDAO(super.attachedDatabase);
+
+ Future<void> saveNotificationPermission(
+ Iterable<NotificationPermission> permissions) async {
+ final permissionsList = permissions.toList();
+ final json = jsonEncode(
+ permissionsList.map((permission) => permission.toJson()).toList());
+ final insertOp = NotificationPermissionEntityCompanion.insert(
+ id: permissionsList.first.id, json: json);
+ await insert(permissionsList, insertOp);
+ await getNotificationPermissions();
+ }
+
+ Future<void> insert(Iterable<NotificationPermission> permissions,
+ NotificationPermissionEntityCompanion insertOp) async {
+ final entities = permissions.map((permission) {
+ final json = jsonEncode(permission.toJson());
+ return NotificationPermissionEntityCompanion.insert(
+ id: permission.id, json: json);
+ });
+ await batch((batch) => batch.insertAll(
+ notificationPermissionEntity, entities,
+ mode: InsertMode.insertOrReplace));
+ }
+
+ Future<Iterable<NotificationPermission>> getNotificationPermissions() async {
+ final permissions = await select(notificationPermissionEntity).get();
+ return permissions.map((permission) =>
+ NotificationPermission.fromJson(jsonDecode(permission.json) as Json));
+ }
+}
diff --git a/comwell_key_app/lib/database/daos/user_dao.dart b/comwell_key_app/lib/database/daos/user_dao.dart
index 0b1bf0db..a0494163 100644
--- a/comwell_key_app/lib/database/daos/user_dao.dart
+++ b/comwell_key_app/lib/database/daos/user_dao.dart
@@ -20,6 +20,13 @@ class UserDAO extends DatabaseAccessor<ComwellDatabase> with _$UserDAOMixin {
.write(insertOp);
}
+ Future<User> getUser(int id) async {
+ final user =
+ await (select(userEntity)..where((table) => table.id.equals(id))).get();
+ final json = jsonDecode(user.first.json) as Json;
+ return User.fromJson(json);
+ }
+
Stream<User> watchUser() {
return (select(userEntity).watch()).map((users) {
final userTable = users.first;
diff --git a/comwell_key_app/lib/database/tables/notification_table.dart b/comwell_key_app/lib/database/tables/notification_table.dart
new file mode 100644
index 00000000..2aa988d2
--- /dev/null
+++ b/comwell_key_app/lib/database/tables/notification_table.dart
@@ -0,0 +1,8 @@
+import 'package:drift/drift.dart';
+
+@DataClassName('NotificationPermissionDb')
+class NotificationPermissionEntity extends Table {
+ IntColumn get id => integer().unique()();
+
+ TextColumn get json => text()();
+}
diff --git a/comwell_key_app/lib/database/tables/user_table.dart b/comwell_key_app/lib/database/tables/user_table.dart
index dd8d37e9..23224edc 100644
--- a/comwell_key_app/lib/database/tables/user_table.dart
+++ b/comwell_key_app/lib/database/tables/user_table.dart
@@ -2,7 +2,7 @@ import 'package:drift/drift.dart';
@DataClassName('UserDb')
class UserEntity extends Table {
- TextColumn get id => text().unique()();
+ IntColumn get id => integer().unique()();
TextColumn get json => text()();
}
diff --git a/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart b/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
index e69de29b..8aadee87 100644
--- a/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
+++ b/comwell_key_app/lib/notifications/cubit/notifications_cubit.dart
@@ -0,0 +1,67 @@
+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/notifications/notifications_repository.dart';
+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;
+ NotificationsCubit(this.notificationsRepository)
+ : super(const NotificationsState(allNotifications: []));
+
+ Iterable<NotificationPermission> notificationPermissions = [];
+ User? user;
+
+ void init() async {
+ emit(NotificationsLoading(allNotifications: notificationPermissions));
+ user = await notificationsRepository.fetchUser();
+ notificationPermissions =
+ await notificationsRepository.getNotificationPermissionsFromDb();
+
+ if (notificationPermissions.isEmpty) {
+ try {
+ fetchNotificationPermissions(user!.id);
+ } catch (e) {
+ emit(NotificationsError(allNotifications: notificationPermissions));
+ }
+ } else if (user != null) {
+ emit(NotificationsLoaded(allNotifications: notificationPermissions));
+ } else {
+ emit(NotificationsError(allNotifications: notificationPermissions));
+ }
+ }
+
+ void onNotificationPermissionClicked(String name) {
+ notificationPermissions = notificationPermissions
+ .map((permission) => permission.name == name
+ ? permission.copyWith(allowed: !permission.allowed)
+ : permission)
+ .toList();
+
+ emit(NotificationsLoaded(allNotifications: notificationPermissions));
+ }
+
+ void updateAllPermissionsUI(bool value) {
+ notificationPermissions = notificationPermissions
+ .map((permission) => permission.copyWith(allowed: value))
+ .toList();
+
+ emit(NotificationsLoaded(allNotifications: notificationPermissions));
+ }
+
+ void updatePreferences(
+ Iterable<NotificationPermission> notificationPermissions,
+ int guestId) async {
+ await notificationsRepository.updateNotificationPreferences(
+ guestId, notificationPermissions);
+
+ emit(NotificationsLoaded(allNotifications: notificationPermissions));
+ }
+
+ void fetchNotificationPermissions(int guestId) async {
+ notificationPermissions =
+ await notificationsRepository.fetchNotificationPermissions(guestId);
+
+ emit(NotificationsState(allNotifications: notificationPermissions));
+ }
+}
diff --git a/comwell_key_app/lib/notifications/cubit/notifications_state.dart b/comwell_key_app/lib/notifications/cubit/notifications_state.dart
index e69de29b..1b4828a0 100644
--- a/comwell_key_app/lib/notifications/cubit/notifications_state.dart
+++ b/comwell_key_app/lib/notifications/cubit/notifications_state.dart
@@ -0,0 +1,44 @@
+import 'package:comwell_key_app/notifications/models/notification_permission.dart';
+import 'package:equatable/equatable.dart';
+
+class NotificationsState extends Equatable {
+ final Iterable<NotificationPermission> allNotifications;
+
+ const NotificationsState({required this.allNotifications});
+
+ NotificationsState.initial() : allNotifications = [];
+
+ NotificationsState notificationSelected({
+ required NotificationPermission notificationPermission,
+ }) =>
+ _copyWith(allNotifications: allNotifications);
+
+ NotificationsState _copyWith({
+ Iterable<NotificationPermission>? allNotifications,
+ }) {
+ return NotificationsState(
+ allNotifications: allNotifications ?? this.allNotifications,
+ );
+ }
+
+ @override
+ List<Object> get props => [allNotifications];
+}
+
+final class NotificationsLoading extends NotificationsState {
+ const NotificationsLoading({required super.allNotifications});
+
+ @override
+ List<Object> get props => [allNotifications];
+}
+
+final class NotificationsLoaded extends NotificationsState {
+ const NotificationsLoaded({required super.allNotifications});
+
+ @override
+ List<Object> get props => [allNotifications];
+}
+
+final class NotificationsError extends NotificationsState {
+ const NotificationsError({required super.allNotifications});
+}
diff --git a/comwell_key_app/lib/notifications/models/notification_permission.dart b/comwell_key_app/lib/notifications/models/notification_permission.dart
new file mode 100644
index 00000000..af3246a0
--- /dev/null
+++ b/comwell_key_app/lib/notifications/models/notification_permission.dart
@@ -0,0 +1,96 @@
+import 'package:comwell_key_app/utils/json.dart';
+import 'package:json_annotation/json_annotation.dart';
+
+part '../../.generated/notifications/models/notification_permission.g.dart';
+
+enum NotificationPermissionType {
+ b2bNewsletter,
+ ccEmail,
+ ccDigital,
+ ccSms,
+ b2bDigital,
+ companyEmail,
+ companyNotifications,
+ stayEmails,
+ appNotifications,
+ similarProducts;
+
+ int get notificationPermissionId {
+ switch (this) {
+ case NotificationPermissionType.b2bNewsletter:
+ return 1400;
+ case NotificationPermissionType.ccEmail:
+ return 1405;
+ case NotificationPermissionType.ccDigital:
+ return 1406;
+ case NotificationPermissionType.ccSms:
+ return 1407;
+ case NotificationPermissionType.b2bDigital:
+ return 1408;
+ case NotificationPermissionType.companyEmail:
+ return 1409;
+ case NotificationPermissionType.companyNotifications:
+ return 1410;
+ case NotificationPermissionType.stayEmails:
+ return 1411;
+ case NotificationPermissionType.appNotifications:
+ return 1412;
+ case NotificationPermissionType.similarProducts:
+ return 1413;
+ }
+ }
+
+ String get displayName {
+ switch (this) {
+ case NotificationPermissionType.b2bNewsletter:
+ return 'B2B Newsletter Permission';
+ case NotificationPermissionType.ccEmail:
+ return 'CC Email Permission';
+ case NotificationPermissionType.ccDigital:
+ return 'CC Digital Permission';
+ case NotificationPermissionType.ccSms:
+ return 'CC SMS Permission';
+ case NotificationPermissionType.b2bDigital:
+ return 'B2B Digital permission';
+ case NotificationPermissionType.companyEmail:
+ return 'Company Email permission';
+ case NotificationPermissionType.companyNotifications:
+ return 'Comm. Pref: Company Notifications';
+ case NotificationPermissionType.stayEmails:
+ return 'Comm. Pref: Stay Emails';
+ case NotificationPermissionType.appNotifications:
+ return 'Comm. Pref: App notifications';
+ case NotificationPermissionType.similarProducts:
+ return 'Similar products permissions';
+ }
+ }
+}
+
+@JsonSerializable()
+class NotificationPermission {
+ final int id;
+ final String name;
+ bool allowed;
+
+ NotificationPermission({
+ required this.id,
+ required this.name,
+ required this.allowed,
+ });
+
+ factory NotificationPermission.fromJson(Json json) =>
+ _$NotificationPermissionFromJson(json);
+
+ Json toJson() => _$NotificationPermissionToJson(this);
+
+ NotificationPermission copyWith({bool? allowed}) => NotificationPermission(
+ id: id,
+ name: name,
+ allowed: allowed ?? this.allowed,
+ );
+
+ @override
+ String toString() {
+ return 'NotificationPermission{id: $id, name: $name, allowed: $allowed}';
+ }
+}
diff --git a/comwell_key_app/lib/notifications/notifications_page.dart b/comwell_key_app/lib/notifications/notifications_page.dart
index f9858527..1ea96c51 100644
--- a/comwell_key_app/lib/notifications/notifications_page.dart
+++ b/comwell_key_app/lib/notifications/notifications_page.dart
@@ -1,24 +1,43 @@
import 'package:comwell_key_app/common/components/comwell_app_bar.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:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:comwell_key_app/notifications/cubit/notifications_cubit.dart';
class NotificationsPage extends StatefulWidget {
- const NotificationsPage({super.key});
+ final Iterable<NotificationPermission> notificationPermissions;
+ const NotificationsPage({super.key, required this.notificationPermissions});
@override
State<NotificationsPage> createState() => _NotificationsPageState();
}
class _NotificationsPageState extends State<NotificationsPage> {
- bool allNotifications = false;
- bool smsNotifications = false;
- bool personalOffers = false;
- bool clubNewsletter = false;
- bool companyDeal = false;
-
@override
Widget build(BuildContext context) {
+ final cubit = context.read<NotificationsCubit>();
+ return BlocBuilder<NotificationsCubit, NotificationsState>(
+ builder: (context, state) {
+ if (state is NotificationsLoading) {
+ return const Scaffold(
+ backgroundColor: Colors.white,
+ appBar: ComwellAppBar(),
+ body: Center(child: CircularProgressIndicator()));
+ } else if (state is NotificationsLoaded) {
+ return _buildNotificationsPage(cubit);
+ } else {
+ return Scaffold(
+ backgroundColor: Colors.white,
+ appBar: const ComwellAppBar(),
+ body: Center(child: Text("notifications_error".tr())));
+ }
+ });
+ }
+
+ Widget _buildNotificationsPage(NotificationsCubit cubit) {
return Scaffold(
backgroundColor: Colors.white,
appBar: const ComwellAppBar(),
@@ -45,15 +64,9 @@ class _NotificationsPageState extends State<NotificationsPage> {
'subscribe_all'.tr(),
style: const TextStyle(fontSize: 16),
),
- value: allNotifications,
+ value: cubit.state.allNotifications.every((e) => e.allowed),
onChanged: (bool value) {
- setState(() {
- allNotifications = value;
- smsNotifications = value;
- personalOffers = value;
- clubNewsletter = value;
- companyDeal = value;
- });
+ cubit.updateAllPermissionsUI(value);
},
contentPadding: EdgeInsets.zero,
),
@@ -80,12 +93,16 @@ class _NotificationsPageState extends State<NotificationsPage> {
color: Colors.grey,
fontWeight: FontWeight.w400),
),
- value: clubNewsletter,
+ value: cubit.state.allNotifications
+ .firstWhere((permission) =>
+ permission.name ==
+ NotificationPermissionType
+ .b2bNewsletter.displayName)
+ .allowed,
onChanged: (bool value) {
- setState(() {
- clubNewsletter = value;
- _updateAllNotificationsState();
- });
+ cubit.onNotificationPermissionClicked(
+ NotificationPermissionType
+ .b2bNewsletter.displayName);
},
contentPadding: EdgeInsets.zero,
),
@@ -106,12 +123,15 @@ class _NotificationsPageState extends State<NotificationsPage> {
color: Colors.grey,
fontWeight: FontWeight.w400),
),
- value: personalOffers,
+ value: cubit.state.allNotifications
+ .firstWhere((permission) =>
+ permission.name ==
+ NotificationPermissionType
+ .ccDigital.displayName)
+ .allowed,
onChanged: (bool value) {
- setState(() {
- personalOffers = value;
- _updateAllNotificationsState();
- });
+ cubit.onNotificationPermissionClicked(
+ NotificationPermissionType.ccDigital.displayName);
},
contentPadding: EdgeInsets.zero,
),
@@ -132,12 +152,14 @@ class _NotificationsPageState extends State<NotificationsPage> {
color: Colors.grey,
fontWeight: FontWeight.w400),
),
- value: smsNotifications,
+ value: cubit.state.allNotifications
+ .firstWhere((permission) =>
+ permission.name ==
+ NotificationPermissionType.ccSms.displayName)
+ .allowed,
onChanged: (bool value) {
- setState(() {
- smsNotifications = value;
- _updateAllNotificationsState();
- });
+ cubit.onNotificationPermissionClicked(
+ NotificationPermissionType.ccSms.displayName);
},
contentPadding: EdgeInsets.zero,
),
@@ -158,12 +180,16 @@ class _NotificationsPageState extends State<NotificationsPage> {
color: Colors.grey,
fontWeight: FontWeight.w400),
),
- value: companyDeal,
+ value: cubit.state.allNotifications
+ .firstWhere((permission) =>
+ permission.name ==
+ NotificationPermissionType
+ .companyNotifications.displayName)
+ .allowed,
onChanged: (bool value) {
- setState(() {
- companyDeal = value;
- _updateAllNotificationsState();
- });
+ cubit.onNotificationPermissionClicked(
+ NotificationPermissionType
+ .companyNotifications.displayName);
},
contentPadding: EdgeInsets.zero,
),
@@ -176,10 +202,11 @@ class _NotificationsPageState extends State<NotificationsPage> {
height: 50,
child: ElevatedButton(
onPressed: () {
- // Handle save action
+ cubit.updatePreferences(
+ cubit.state.allNotifications, cubit.user!.id);
},
style: ElevatedButton.styleFrom(
- backgroundColor: const Color(0xFFB39B7D),
+ backgroundColor: sandColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
@@ -199,12 +226,4 @@ class _NotificationsPageState extends State<NotificationsPage> {
),
);
}
-
- void _updateAllNotificationsState() {
- if (smsNotifications && personalOffers && clubNewsletter) {
- allNotifications = true;
- } else {
- allNotifications = false;
- }
- }
}
diff --git a/comwell_key_app/lib/notifications/notifications_repository.dart b/comwell_key_app/lib/notifications/notifications_repository.dart
new file mode 100644
index 00000000..a5076f86
--- /dev/null
+++ b/comwell_key_app/lib/notifications/notifications_repository.dart
@@ -0,0 +1,58 @@
+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_settings/repostiory/profile_settings_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';
+
+class NotificationsRepository {
+ final Api api = Api();
+ final db = locator<ComwellDatabase>();
+ final ProfileSettingsRepository profileSettingsRepository =
+ locator<ProfileSettingsRepository>();
+ User? user;
+
+ Future<User?> fetchUser() async {
+ user = await profileSettingsRepository.fetchProfileSettings();
+ return user;
+ }
+
+ Future<void> updatePreferences(int guestId,
+ Iterable<NotificationPermission> notificationPermissions) async {
+ return api.updateNotificationPreferences(guestId, notificationPermissions);
+ }
+
+ Future<Iterable<NotificationPermission>> fetchNotificationPermissions(
+ int guestId) async {
+ final response = await api.getNotificationPermissions(guestId);
+
+ if (response.statusCode == 200) {
+ final data = response.data as Map<String, dynamic>;
+ final permissions = (data['permissions'] as List<dynamic>)
+ .map((json) => NotificationPermission.fromJson(json as Json))
+ .toList();
+ await db.notificationPermissionDAO
+ .saveNotificationPermission(permissions);
+
+ await db.notificationPermissionDAO.getNotificationPermissions();
+ return permissions;
+ }
+ return [];
+ }
+
+ Future<dynamic> updateNotificationPreferences(int guestId,
+ Iterable<NotificationPermission> notificationPermissions) async {
+ await db.notificationPermissionDAO
+ .saveNotificationPermission(notificationPermissions);
+
+ return api.updateNotificationPreferences(guestId, notificationPermissions);
+ }
+
+ Future<Iterable<NotificationPermission>>
+ getNotificationPermissionsFromDb() async {
+ final permissions =
+ await db.notificationPermissionDAO.getNotificationPermissions();
+ return permissions;
+ }
+}
diff --git a/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart b/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
index 9fb08f85..82daba1f 100644
--- a/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
+++ b/comwell_key_app/lib/pregistration/bloc/preregistration_cubit.dart
@@ -1,4 +1,3 @@
-
import 'package:adyen_checkout/src/common/model/payment_result.dart';
import 'package:bloc/bloc.dart';
import 'package:comwell_key_app/pregistration/bloc/preregistration_state.dart';
@@ -36,10 +35,10 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
try {
final user = await _profileSettingsRepository.fetchProfileSettings();
if (user != null) {
- addressTextController.text = user.address.street;
- postalCodeTextController.text = user.address.zipCode;
- cityTextController.text = user.address.city;
- countryTextController.text = user.address.country;
+ addressTextController.text = user.address?.street ?? "";
+ postalCodeTextController.text = user.address?.zipCode ?? "";
+ cityTextController.text = user.address?.city ?? "";
+ countryTextController.text = user.address?.country ?? "";
} else {
emit(state.copyWith(
loading: false, error: Exception("Der skete en fejl")));
@@ -215,4 +214,4 @@ class PreregistrationCubit extends Cubit<PreregistrationState> {
void onTermsAndConditionsToggled(bool toggle) {
emit(state.copyWith(termsAndConditionsAccepted: toggle));
}
-}
\ No newline at end of file
+}
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 80b3b0c2..eb7fdf1f 100644
--- a/comwell_key_app/lib/pregistration/pages/prereg_confirmation_page.dart
+++ b/comwell_key_app/lib/pregistration/pages/prereg_confirmation_page.dart
@@ -57,11 +57,11 @@ class PreregConfirmationPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- user.address.street,
+ user.address?.street ?? "",
style: Theme.of(context).textTheme.bodyMedium,
),
Text(
- "${user.address.zipCode}, ${user.address.city}, ${user.address.country}",
+ "${user.address?.zipCode}, ${user.address?.city}, ${user.address?.country}",
style: Theme.of(context).textTheme.bodyMedium,
),
],
diff --git a/comwell_key_app/lib/profile/profile_repository.dart b/comwell_key_app/lib/profile/profile_repository.dart
index 040fe097..e9e5074a 100644
--- a/comwell_key_app/lib/profile/profile_repository.dart
+++ b/comwell_key_app/lib/profile/profile_repository.dart
@@ -1,15 +1,34 @@
+import 'package:comwell_key_app/database/comwell_db.dart';
+import 'package:comwell_key_app/notifications/models/notification_permission.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:comwell_key_app/utils/secure_storage.dart';
import 'package:comwell_key_app/utils/seos_repository.dart';
import 'package:seos_mobile_keys_plugin/seos_mobile_keys_plugin.dart';
class ProfileRepository {
final SecureStorage secureStorage = SecureStorage();
- final SeosMobileKeysPlugin seosMobileKeysPlugin = SeosRepository().seosMobileKeysPlugin;
+ final SeosMobileKeysPlugin seosMobileKeysPlugin =
+ SeosRepository().seosMobileKeysPlugin;
+ final Api api = Api();
+ final db = locator<ComwellDatabase>();
- ProfileRepository() {
- // Constructor
- }
+ Future<Iterable<NotificationPermission>> fetchNotificationPermissions(
+ int guestId) async {
+ final response = await api.getNotificationPermissions(guestId);
+
+ if (response.statusCode == 200) {
+ final data = response.data as Map<String, dynamic>;
+ final permissions = (data['permissions'] as List<dynamic>)
+ .map((json) => NotificationPermission.fromJson(json as Json))
+ .toList();
+ await db.notificationPermissionDAO
+ .saveNotificationPermission(permissions);
- // Example method
-
-}
\ No newline at end of file
+ await db.notificationPermissionDAO.getNotificationPermissions();
+ return permissions;
+ }
+ return [];
+ }
+}
diff --git a/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart b/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
index e3988dfc..e42444ad 100644
--- a/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
+++ b/comwell_key_app/lib/profile_settings/components/address_bottom_sheet.dart
@@ -1,4 +1,3 @@
-
import 'package:comwell_key_app/common/components/round_icon_button.dart';
import 'package:comwell_key_app/profile_settings/components/comwell_text_field.dart';
import 'package:comwell_key_app/profile_settings/cubit/profile_settings_cubit.dart';
@@ -26,10 +25,10 @@ class AddressBottomSheet extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
- _addressController.text = user.address.street;
- _zipCodeController.text = user.address.zipCode;
- _cityController.text = user.address.city;
- _countryController.text = user.address.country;
+ _addressController.text = user.address?.street ?? "";
+ _zipCodeController.text = user.address?.zipCode ?? "";
+ _cityController.text = user.address?.city ?? "";
+ _countryController.text = user.address?.country ?? "";
return Wrap(children: [
Container(
decoration: const BoxDecoration(
@@ -70,7 +69,7 @@ class AddressBottomSheet extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ComwellTextField(
fieldName: "profil_settings_address".tr(),
- initialValue: user.address.street,
+ initialValue: user.address?.street ?? "",
readOnly: false,
controller: _addressController)),
const SizedBox(height: 8),
@@ -78,7 +77,7 @@ class AddressBottomSheet extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ComwellTextField(
fieldName: "zipCode".tr(),
- initialValue: user.address.zipCode,
+ initialValue: user.address?.zipCode ?? "",
readOnly: false,
controller: _zipCodeController)),
const SizedBox(height: 8),
@@ -86,7 +85,7 @@ class AddressBottomSheet extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ComwellTextField(
fieldName: "city".tr(),
- initialValue: user.address.city,
+ initialValue: user.address?.city ?? "",
readOnly: false,
controller: _cityController)),
const SizedBox(height: 8),
@@ -94,7 +93,7 @@ class AddressBottomSheet extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ComwellTextField(
fieldName: "country".tr(),
- initialValue: user.address.country,
+ initialValue: user.address?.country ?? "",
readOnly: false,
controller: _countryController)),
const Spacer(),
diff --git a/comwell_key_app/lib/profile_settings/model/user.dart b/comwell_key_app/lib/profile_settings/model/user.dart
index 1a36bb81..1d3e007f 100644
--- a/comwell_key_app/lib/profile_settings/model/user.dart
+++ b/comwell_key_app/lib/profile_settings/model/user.dart
@@ -7,14 +7,14 @@ part '../../.generated/profile_settings/model/user.g.dart';
@JsonSerializable()
class User {
- final String id;
+ final int id;
final String firstName;
final String lastName;
- final String countryCode;
- final String phone;
+ final String? countryCode;
+ final String? phone;
final String email;
- final Address address;
- final DateTime birthday;
+ final Address? address;
+ final DateTime birthDate;
final String? shopperReference;
final int? points;
@@ -26,7 +26,7 @@ class User {
required this.phone,
required this.email,
required this.address,
- required this.birthday,
+ required this.birthDate,
this.shopperReference,
this.points,
});
@@ -36,7 +36,7 @@ class User {
Json toJson() => _$UserToJson(this);
User copyWith({
- String? id,
+ int? id,
String? firstName,
String? lastName,
String? countryCode,
@@ -54,7 +54,7 @@ class User {
phone: phone ?? this.phone,
email: email ?? this.email,
address: address ?? this.address,
- birthday: birthday ?? this.birthday,
+ birthDate: birthDate ?? this.birthDate,
shopperReference: shopperReference ?? this.shopperReference,
);
}
diff --git a/comwell_key_app/lib/profile_settings/profile_settings_page.dart b/comwell_key_app/lib/profile_settings/profile_settings_page.dart
index 43f3479c..69b438ea 100644
--- a/comwell_key_app/lib/profile_settings/profile_settings_page.dart
+++ b/comwell_key_app/lib/profile_settings/profile_settings_page.dart
@@ -13,7 +13,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
-
class ProfileSettingsPage extends StatelessWidget {
const ProfileSettingsPage({super.key});
@@ -88,13 +87,13 @@ class ProfileSettingsPage extends StatelessWidget {
const SizedBox(height: 8),
IntlPhoneField(
title: "profil_settings_phone".tr(),
- phoneNumber: loadedState.user.phone,
+ phoneNumber: loadedState.user.phone ?? "",
),
const SizedBox(height: 8),
TextFieldWithTrailingIcon(
title: "profil_settings_address".tr(),
text:
- "${loadedState.user.address.street}, ${loadedState.user.address.city}, ${loadedState.user.address.zipCode}, ${loadedState.user.address.country}",
+ "${loadedState.user.address?.street}, ${loadedState.user.address?.city}, ${loadedState.user.address?.zipCode}, ${loadedState.user.address?.country}",
trailingIcon: "assets/icons/edit-alt.svg",
onTap: () {
showModalBottomSheet<Address>(
@@ -108,7 +107,7 @@ class ProfileSettingsPage extends StatelessWidget {
const SizedBox(height: 8),
DateTimePicker(
title: "profil_settings_birthday".tr(),
- initialValue: loadedState.user.birthday,
+ initialValue: loadedState.user.birthDate,
),
const SizedBox(height: 8),
TextFieldWithTrailingIcon(
@@ -121,7 +120,6 @@ class ProfileSettingsPage extends StatelessWidget {
Center(
child: OutlinedButton(
onPressed: () {
-
showDeleteProfileDialog(context);
},
style: OutlinedButton.styleFrom(
@@ -167,7 +165,6 @@ class ProfileSettingsPage extends StatelessWidget {
cancelButtonText: 'delete_profile_cancel'.tr(),
onConfirm: () => {
context.read<ProfileSettingsCubit>().deleteProfile(),
-
},
onCancel: () => Navigator.of(context).pop());
},
@@ -195,18 +192,14 @@ class DeleteProfileButton extends StatelessWidget {
minimumSize: const Size(135, 40),
maximumSize: const Size(155, 40),
),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- SvgPicture.asset("assets/icons/trash-can.svg",
- height: 16),
- const SizedBox(width: 4),
- Text(
- "delete_profile".tr(),
- style: theme.textTheme.labelLarge
- ?.copyWith(color: Colors.red),
- ),
- ]),
+ child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
+ SvgPicture.asset("assets/icons/trash-can.svg", height: 16),
+ const SizedBox(width: 4),
+ Text(
+ "delete_profile".tr(),
+ style: theme.textTheme.labelLarge?.copyWith(color: Colors.red),
+ ),
+ ]),
),
);
}
diff --git a/comwell_key_app/lib/profile_settings/repostiory/profile_settings_repository.dart b/comwell_key_app/lib/profile_settings/repostiory/profile_settings_repository.dart
index 5f929183..42fbcb75 100644
--- a/comwell_key_app/lib/profile_settings/repostiory/profile_settings_repository.dart
+++ b/comwell_key_app/lib/profile_settings/repostiory/profile_settings_repository.dart
@@ -11,9 +11,10 @@ class ProfileSettingsRepository {
final db = locator<ComwellDatabase>();
Future<User?> fetchProfileSettings() async {
- final userJson = await api.fetchProfileSettings();
- if (userJson != null) {
- final user = User.fromJson(jsonDecode(userJson as String) as Json);
+ final response = await api.fetchProfileSettings();
+ final data = response.data as Map<String, dynamic>;
+ if (data != null) {
+ final user = User.fromJson(data);
db.userDAO.saveUser(user);
return user;
}
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index f56c9b9b..0f4311e1 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -15,7 +15,10 @@ import 'package:comwell_key_app/hotel_information/hotel_information_page.dart';
import 'package:comwell_key_app/housekeeping/housekeeping_page.dart';
import 'package:comwell_key_app/key/key_page.dart';
import 'package:comwell_key_app/login/login_page.dart';
+import 'package:comwell_key_app/notifications/cubit/notifications_cubit.dart';
+import 'package:comwell_key_app/notifications/models/notification_permission.dart';
import 'package:comwell_key_app/notifications/notifications_page.dart';
+import 'package:comwell_key_app/notifications/notifications_repository.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/overview/overview_page.dart';
import 'package:comwell_key_app/overview/past_cancelled_booking_detail_page.dart';
@@ -288,7 +291,14 @@ GoRouter goRouter(AuthenticationBloc authBloc) {
path: "/${AppRoutes.notifications.name}",
name: AppRoutes.notifications.name,
builder: (context, state) {
- return const NotificationsPage();
+ return BlocProvider(
+ create: (context) =>
+ NotificationsCubit(locator<NotificationsRepository>())
+ ..init(),
+ child: const NotificationsPage(
+ notificationPermissions: [],
+ ),
+ );
},
),
diff --git a/comwell_key_app/lib/services/api.dart b/comwell_key_app/lib/services/api.dart
index a4a63032..7b5e583e 100644
--- a/comwell_key_app/lib/services/api.dart
+++ b/comwell_key_app/lib/services/api.dart
@@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:adyen_checkout/adyen_checkout.dart';
import 'package:comwell_key_app/hotel_information/models/hotel.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/services/http_client.dart';
import 'package:comwell_key_app/utils/json.dart';
@@ -46,7 +47,8 @@ class Api {
return response.data;
}
- Future<Json> submitPayment(Json paymentResult, String shopperReference) async {
+ Future<Json> submitPayment(
+ Json paymentResult, String shopperReference) async {
final Json headers = {
"content-type": "application/json",
"x-API-key":
@@ -72,42 +74,56 @@ class Api {
return response.data!;
}
- Future<dynamic> fetchProfileSettings() async {
- await Future<void>.delayed(const Duration(seconds: 2));
-
- // Return the mock JSON data
- return '''
- {
- "id": "1",
- "firstName": "John",
- "lastName": "Doe",
- "countryCode": "+45",
- "phone": "12345678",
- "email": "john.doe@example.com",
- "address": {
- "street": "123 Main St",
- "city": "Copenhagen",
- "state": "Capital Region",
- "zipCode": "1000",
- "country": "Denmark"
- },
- "birthday": "1989-08-24T00:00:00.000Z"
- }
- ''';
+ Future<Response<dynamic>> fetchProfileSettings() async {
+ return await dio.get('/Members/v1/GetGuestProfile');
}
Future<void> deleteProfile() {
return dio.delete<void>('/Members/v1/DeleteGuest');
}
+ // TODO: Remove guestId when backend is updated
+ Future<Response<dynamic>> getNotificationPermissions(int guestId) async {
+ final body = {
+ "permissions": [
+ {"id": 0, "allowed": false},
+ ]
+ };
+ return await dio.put(
+ '/Members/v1/guests/$guestId/communication-preference',
+ data: body,
+ options: Options(
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ ),
+ );
+ }
+
+ // TODO: Remove guestId when backend is updated
+ Future<dynamic> updateNotificationPreferences(
+ int guestId, Iterable<NotificationPermission> notificationPermissions) {
+ final body = {
+ "permissions": notificationPermissions
+ .map((permission) =>
+ {"id": permission.id, "allowed": permission.allowed})
+ .toList()
+ };
+ final json = jsonEncode(body);
+ final response = dio.put<void>(
+ '/Members/v1/guests/$guestId/communication-preference',
+ data: json);
+ return response;
+ }
+
Future<void> updateUser(User updatedUser) {
return dio.post<void>(
'/Members/v1/UpdateGuestData',
data: {
- 'addressStreet': updatedUser.address.street,
- 'adressCity': updatedUser.address.city,
- 'addressCountry': updatedUser.address.country,
- 'addressZip': updatedUser.address.zipCode,
+ 'addressStreet': updatedUser.address?.street,
+ 'adressCity': updatedUser.address?.city,
+ 'addressCountry': updatedUser.address?.country,
+ 'addressZip': updatedUser.address?.zipCode,
},
);
}
@@ -130,7 +146,7 @@ class Api {
final Json headers = {
"content-type": "application/json",
"x-API-key":
- "AQEohmfuXNWTK0Qc+iSTnWkvouiXYIRZCJ9ZsI49DtvZ0d3gjdIA7pissxDBXVsNvuR83LVYjEgiTGAH-4HQnMZXxLZfhge7EdwYZZW0ynntChj41ziiKl6D1Glo=-.\$>;9&L_t@^g7[IR"
+ "AQEohmfuXNWTK0Qc+iSTnWkvouiXYIRZCJ9ZsI49DtvZ0d3gjdIA7pissxDBXVsNvuR83LVYjEgiTGAH-4HQnMZXxLZfhge7EdwYZZW0ynntChj41ziiKl6D1Glo=-.\$>;9&L_t@^g7[IR"
};
final Map<String, dynamic> data = {
"shopperReference": "Test reference",
@@ -143,17 +159,18 @@ class Api {
};
data.addAll(body);
data.remove("storePaymentMethod");
- final response = await dio.post<Json>("https://checkout-test.adyen.com/v71/payments/details",
+ final response = await dio.post<Json>(
+ "https://checkout-test.adyen.com/v71/payments/details",
data: data,
options: Options(
headers: headers,
- )) ;
+ ));
return response.data!;
}
Future<String> createEndpointRegistration() async {
final response =
- await dio.post<String>('/keys/v1/CreateEndpointRegistration');
+ await dio.post<String>('/keys/v1/CreateEndpointRegistration');
final json = jsonDecode(response.data!) as Map<String, dynamic>;
return json["InvitationCode"]! as String;
}
diff --git a/comwell_key_app/lib/utils/locator.dart b/comwell_key_app/lib/utils/locator.dart
index 91d8087c..7c72b707 100644
--- a/comwell_key_app/lib/utils/locator.dart
+++ b/comwell_key_app/lib/utils/locator.dart
@@ -2,6 +2,7 @@ import 'package:comwell_key_app/authentication/authentication_repository.dart';
import 'package:comwell_key_app/database/comwell_db.dart';
import 'package:comwell_key_app/hotel_information/repository/hotel_information_repository.dart';
import 'package:comwell_key_app/key/repository/key_repository.dart';
+import 'package:comwell_key_app/notifications/notifications_repository.dart';
import 'package:comwell_key_app/overview/repository/overview_repository.dart';
import 'package:comwell_key_app/pregistration/pregistration_repository.dart';
import 'package:comwell_key_app/profile/profile_repository.dart';
@@ -30,11 +31,16 @@ void setupLocator() {
locator.registerFactory<OverviewRepository>(() => OverviewRepository());
locator.registerFactory<ProfileSettingsRepository>(
() => ProfileSettingsRepository());
- locator.registerSingleton<AuthenticationRepository>(AuthenticationRepository());
- locator.registerFactory<BookingDetailsRepository>(() => BookingDetailsRepository());
+ locator.registerSingleton<AuthenticationRepository>(
+ AuthenticationRepository());
+ locator.registerFactory<BookingDetailsRepository>(
+ () => BookingDetailsRepository());
locator.registerFactory<ProfileRepository>(() => ProfileRepository());
locator.registerFactory<PreregistrationRepository>(
() => PreregistrationRepository());
- locator.registerFactory<HotelInformationRepository>(() => HotelInformationRepository());
+ locator.registerFactory<HotelInformationRepository>(
+ () => HotelInformationRepository());
+ locator.registerFactory<NotificationsRepository>(
+ () => NotificationsRepository());
}
}
diff --git a/comwell_key_app/test/profile_settings_test/profile_settings_cubit_test.dart b/comwell_key_app/test/profile_settings_test/profile_settings_cubit_test.dart
index dcb3501e..e249e3f2 100644
--- a/comwell_key_app/test/profile_settings_test/profile_settings_cubit_test.dart
+++ b/comwell_key_app/test/profile_settings_test/profile_settings_cubit_test.dart
@@ -7,9 +7,11 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:comwell_key_app/profile_settings/cubit/profile_settings_cubit.dart';
+class MockProfileSettingsRepository extends Mock
+ implements ProfileSettingsRepository {}
-class MockProfileSettingsRepository extends Mock implements ProfileSettingsRepository {}
-class MockAuthenticationRepository extends Mock implements AuthenticationRepository {}
+class MockAuthenticationRepository extends Mock
+ implements AuthenticationRepository {}
void main() {
late ProfileSettingsCubit profileSettingsCubit;
@@ -19,7 +21,9 @@ void main() {
setUp(() {
mockProfileSettingsRepository = MockProfileSettingsRepository();
mockAuthenticationRepository = MockAuthenticationRepository();
- profileSettingsCubit = ProfileSettingsCubit(profileSettingsRepository: mockProfileSettingsRepository, authenticationRepository: mockAuthenticationRepository);
+ profileSettingsCubit = ProfileSettingsCubit(
+ profileSettingsRepository: mockProfileSettingsRepository,
+ authenticationRepository: mockAuthenticationRepository);
});
tearDown(() {
@@ -28,7 +32,7 @@ void main() {
group('ProfileSettingsCubit', () {
final user = User(
- id: '1',
+ id: 1,
firstName: 'John',
lastName: 'Doe',
email: 'john.doe@example.com',
@@ -39,7 +43,8 @@ void main() {
zipCode: '12345',
country: 'USA',
),
- birthday: DateTime(1990, 1, 1), countryCode: '',
+ birthday: DateTime(1990, 1, 1),
+ countryCode: '',
);
blocTest<ProfileSettingsCubit, ProfileSettingsState>(
@@ -98,4 +103,4 @@ void main() {
],
);
});
-}
\ No newline at end of file
+}