settings / preferences upate

This commit is contained in:
Christien Rioux 2024-07-26 16:51:03 -04:00
parent 1455aabe6c
commit d962f98786
26 changed files with 1015 additions and 125 deletions

View file

@ -0,0 +1,2 @@
export 'notifications_preference.dart';
export 'notifications_state.dart';

View file

@ -0,0 +1,69 @@
import 'package:change_case/change_case.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'notifications_preference.freezed.dart';
part 'notifications_preference.g.dart';
@freezed
class NotificationsPreference with _$NotificationsPreference {
const factory NotificationsPreference({
@Default(true) bool displayBetaWarning,
@Default(true) bool enableBadge,
@Default(true) bool enableNotifications,
@Default(MessageNotificationContent.nameAndContent)
MessageNotificationContent messageNotificationContent,
@Default(NotificationMode.inAppOrPush)
NotificationMode onInvitationAcceptedMode,
@Default(SoundEffect.beepBaDeep) SoundEffect onInvitationAcceptedSound,
@Default(NotificationMode.inAppOrPush)
NotificationMode onMessageReceivedMode,
@Default(SoundEffect.boop) SoundEffect onMessageReceivedSound,
@Default(SoundEffect.bonk) SoundEffect onMessageSentSound,
}) = _NotificationsPreference;
factory NotificationsPreference.fromJson(dynamic json) =>
_$NotificationsPreferenceFromJson(json as Map<String, dynamic>);
static const NotificationsPreference defaults = NotificationsPreference();
}
enum NotificationMode {
none,
inApp,
push,
inAppOrPush;
factory NotificationMode.fromJson(dynamic j) =>
NotificationMode.values.byName((j as String).toCamelCase());
String toJson() => name.toPascalCase();
static const NotificationMode defaults = NotificationMode.none;
}
enum MessageNotificationContent {
nothing,
nameOnly,
nameAndContent;
factory MessageNotificationContent.fromJson(dynamic j) =>
MessageNotificationContent.values.byName((j as String).toCamelCase());
String toJson() => name.toPascalCase();
static const MessageNotificationContent defaults =
MessageNotificationContent.nothing;
}
enum SoundEffect {
none,
bonk,
boop,
baDeep,
beepBaDeep,
custom;
factory SoundEffect.fromJson(dynamic j) =>
SoundEffect.values.byName((j as String).toCamelCase());
String toJson() => name.toPascalCase();
static const SoundEffect defaults = SoundEffect.none;
}

View file

@ -0,0 +1,358 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'notifications_preference.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
NotificationsPreference _$NotificationsPreferenceFromJson(
Map<String, dynamic> json) {
return _NotificationsPreference.fromJson(json);
}
/// @nodoc
mixin _$NotificationsPreference {
bool get displayBetaWarning => throw _privateConstructorUsedError;
bool get enableBadge => throw _privateConstructorUsedError;
bool get enableNotifications => throw _privateConstructorUsedError;
MessageNotificationContent get messageNotificationContent =>
throw _privateConstructorUsedError;
NotificationMode get onInvitationAcceptedMode =>
throw _privateConstructorUsedError;
SoundEffect get onInvitationAcceptedSound =>
throw _privateConstructorUsedError;
NotificationMode get onMessageReceivedMode =>
throw _privateConstructorUsedError;
SoundEffect get onMessageReceivedSound => throw _privateConstructorUsedError;
SoundEffect get onMessageSentSound => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$NotificationsPreferenceCopyWith<NotificationsPreference> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $NotificationsPreferenceCopyWith<$Res> {
factory $NotificationsPreferenceCopyWith(NotificationsPreference value,
$Res Function(NotificationsPreference) then) =
_$NotificationsPreferenceCopyWithImpl<$Res, NotificationsPreference>;
@useResult
$Res call(
{bool displayBetaWarning,
bool enableBadge,
bool enableNotifications,
MessageNotificationContent messageNotificationContent,
NotificationMode onInvitationAcceptedMode,
SoundEffect onInvitationAcceptedSound,
NotificationMode onMessageReceivedMode,
SoundEffect onMessageReceivedSound,
SoundEffect onMessageSentSound});
}
/// @nodoc
class _$NotificationsPreferenceCopyWithImpl<$Res,
$Val extends NotificationsPreference>
implements $NotificationsPreferenceCopyWith<$Res> {
_$NotificationsPreferenceCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? displayBetaWarning = null,
Object? enableBadge = null,
Object? enableNotifications = null,
Object? messageNotificationContent = null,
Object? onInvitationAcceptedMode = null,
Object? onInvitationAcceptedSound = null,
Object? onMessageReceivedMode = null,
Object? onMessageReceivedSound = null,
Object? onMessageSentSound = null,
}) {
return _then(_value.copyWith(
displayBetaWarning: null == displayBetaWarning
? _value.displayBetaWarning
: displayBetaWarning // ignore: cast_nullable_to_non_nullable
as bool,
enableBadge: null == enableBadge
? _value.enableBadge
: enableBadge // ignore: cast_nullable_to_non_nullable
as bool,
enableNotifications: null == enableNotifications
? _value.enableNotifications
: enableNotifications // ignore: cast_nullable_to_non_nullable
as bool,
messageNotificationContent: null == messageNotificationContent
? _value.messageNotificationContent
: messageNotificationContent // ignore: cast_nullable_to_non_nullable
as MessageNotificationContent,
onInvitationAcceptedMode: null == onInvitationAcceptedMode
? _value.onInvitationAcceptedMode
: onInvitationAcceptedMode // ignore: cast_nullable_to_non_nullable
as NotificationMode,
onInvitationAcceptedSound: null == onInvitationAcceptedSound
? _value.onInvitationAcceptedSound
: onInvitationAcceptedSound // ignore: cast_nullable_to_non_nullable
as SoundEffect,
onMessageReceivedMode: null == onMessageReceivedMode
? _value.onMessageReceivedMode
: onMessageReceivedMode // ignore: cast_nullable_to_non_nullable
as NotificationMode,
onMessageReceivedSound: null == onMessageReceivedSound
? _value.onMessageReceivedSound
: onMessageReceivedSound // ignore: cast_nullable_to_non_nullable
as SoundEffect,
onMessageSentSound: null == onMessageSentSound
? _value.onMessageSentSound
: onMessageSentSound // ignore: cast_nullable_to_non_nullable
as SoundEffect,
) as $Val);
}
}
/// @nodoc
abstract class _$$NotificationsPreferenceImplCopyWith<$Res>
implements $NotificationsPreferenceCopyWith<$Res> {
factory _$$NotificationsPreferenceImplCopyWith(
_$NotificationsPreferenceImpl value,
$Res Function(_$NotificationsPreferenceImpl) then) =
__$$NotificationsPreferenceImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{bool displayBetaWarning,
bool enableBadge,
bool enableNotifications,
MessageNotificationContent messageNotificationContent,
NotificationMode onInvitationAcceptedMode,
SoundEffect onInvitationAcceptedSound,
NotificationMode onMessageReceivedMode,
SoundEffect onMessageReceivedSound,
SoundEffect onMessageSentSound});
}
/// @nodoc
class __$$NotificationsPreferenceImplCopyWithImpl<$Res>
extends _$NotificationsPreferenceCopyWithImpl<$Res,
_$NotificationsPreferenceImpl>
implements _$$NotificationsPreferenceImplCopyWith<$Res> {
__$$NotificationsPreferenceImplCopyWithImpl(
_$NotificationsPreferenceImpl _value,
$Res Function(_$NotificationsPreferenceImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? displayBetaWarning = null,
Object? enableBadge = null,
Object? enableNotifications = null,
Object? messageNotificationContent = null,
Object? onInvitationAcceptedMode = null,
Object? onInvitationAcceptedSound = null,
Object? onMessageReceivedMode = null,
Object? onMessageReceivedSound = null,
Object? onMessageSentSound = null,
}) {
return _then(_$NotificationsPreferenceImpl(
displayBetaWarning: null == displayBetaWarning
? _value.displayBetaWarning
: displayBetaWarning // ignore: cast_nullable_to_non_nullable
as bool,
enableBadge: null == enableBadge
? _value.enableBadge
: enableBadge // ignore: cast_nullable_to_non_nullable
as bool,
enableNotifications: null == enableNotifications
? _value.enableNotifications
: enableNotifications // ignore: cast_nullable_to_non_nullable
as bool,
messageNotificationContent: null == messageNotificationContent
? _value.messageNotificationContent
: messageNotificationContent // ignore: cast_nullable_to_non_nullable
as MessageNotificationContent,
onInvitationAcceptedMode: null == onInvitationAcceptedMode
? _value.onInvitationAcceptedMode
: onInvitationAcceptedMode // ignore: cast_nullable_to_non_nullable
as NotificationMode,
onInvitationAcceptedSound: null == onInvitationAcceptedSound
? _value.onInvitationAcceptedSound
: onInvitationAcceptedSound // ignore: cast_nullable_to_non_nullable
as SoundEffect,
onMessageReceivedMode: null == onMessageReceivedMode
? _value.onMessageReceivedMode
: onMessageReceivedMode // ignore: cast_nullable_to_non_nullable
as NotificationMode,
onMessageReceivedSound: null == onMessageReceivedSound
? _value.onMessageReceivedSound
: onMessageReceivedSound // ignore: cast_nullable_to_non_nullable
as SoundEffect,
onMessageSentSound: null == onMessageSentSound
? _value.onMessageSentSound
: onMessageSentSound // ignore: cast_nullable_to_non_nullable
as SoundEffect,
));
}
}
/// @nodoc
@JsonSerializable()
class _$NotificationsPreferenceImpl implements _NotificationsPreference {
const _$NotificationsPreferenceImpl(
{this.displayBetaWarning = true,
this.enableBadge = true,
this.enableNotifications = true,
this.messageNotificationContent =
MessageNotificationContent.nameAndContent,
this.onInvitationAcceptedMode = NotificationMode.inAppOrPush,
this.onInvitationAcceptedSound = SoundEffect.beepBaDeep,
this.onMessageReceivedMode = NotificationMode.inAppOrPush,
this.onMessageReceivedSound = SoundEffect.boop,
this.onMessageSentSound = SoundEffect.bonk});
factory _$NotificationsPreferenceImpl.fromJson(Map<String, dynamic> json) =>
_$$NotificationsPreferenceImplFromJson(json);
@override
@JsonKey()
final bool displayBetaWarning;
@override
@JsonKey()
final bool enableBadge;
@override
@JsonKey()
final bool enableNotifications;
@override
@JsonKey()
final MessageNotificationContent messageNotificationContent;
@override
@JsonKey()
final NotificationMode onInvitationAcceptedMode;
@override
@JsonKey()
final SoundEffect onInvitationAcceptedSound;
@override
@JsonKey()
final NotificationMode onMessageReceivedMode;
@override
@JsonKey()
final SoundEffect onMessageReceivedSound;
@override
@JsonKey()
final SoundEffect onMessageSentSound;
@override
String toString() {
return 'NotificationsPreference(displayBetaWarning: $displayBetaWarning, enableBadge: $enableBadge, enableNotifications: $enableNotifications, messageNotificationContent: $messageNotificationContent, onInvitationAcceptedMode: $onInvitationAcceptedMode, onInvitationAcceptedSound: $onInvitationAcceptedSound, onMessageReceivedMode: $onMessageReceivedMode, onMessageReceivedSound: $onMessageReceivedSound, onMessageSentSound: $onMessageSentSound)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$NotificationsPreferenceImpl &&
(identical(other.displayBetaWarning, displayBetaWarning) ||
other.displayBetaWarning == displayBetaWarning) &&
(identical(other.enableBadge, enableBadge) ||
other.enableBadge == enableBadge) &&
(identical(other.enableNotifications, enableNotifications) ||
other.enableNotifications == enableNotifications) &&
(identical(other.messageNotificationContent,
messageNotificationContent) ||
other.messageNotificationContent ==
messageNotificationContent) &&
(identical(
other.onInvitationAcceptedMode, onInvitationAcceptedMode) ||
other.onInvitationAcceptedMode == onInvitationAcceptedMode) &&
(identical(other.onInvitationAcceptedSound,
onInvitationAcceptedSound) ||
other.onInvitationAcceptedSound == onInvitationAcceptedSound) &&
(identical(other.onMessageReceivedMode, onMessageReceivedMode) ||
other.onMessageReceivedMode == onMessageReceivedMode) &&
(identical(other.onMessageReceivedSound, onMessageReceivedSound) ||
other.onMessageReceivedSound == onMessageReceivedSound) &&
(identical(other.onMessageSentSound, onMessageSentSound) ||
other.onMessageSentSound == onMessageSentSound));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
displayBetaWarning,
enableBadge,
enableNotifications,
messageNotificationContent,
onInvitationAcceptedMode,
onInvitationAcceptedSound,
onMessageReceivedMode,
onMessageReceivedSound,
onMessageSentSound);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$NotificationsPreferenceImplCopyWith<_$NotificationsPreferenceImpl>
get copyWith => __$$NotificationsPreferenceImplCopyWithImpl<
_$NotificationsPreferenceImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$NotificationsPreferenceImplToJson(
this,
);
}
}
abstract class _NotificationsPreference implements NotificationsPreference {
const factory _NotificationsPreference(
{final bool displayBetaWarning,
final bool enableBadge,
final bool enableNotifications,
final MessageNotificationContent messageNotificationContent,
final NotificationMode onInvitationAcceptedMode,
final SoundEffect onInvitationAcceptedSound,
final NotificationMode onMessageReceivedMode,
final SoundEffect onMessageReceivedSound,
final SoundEffect onMessageSentSound}) = _$NotificationsPreferenceImpl;
factory _NotificationsPreference.fromJson(Map<String, dynamic> json) =
_$NotificationsPreferenceImpl.fromJson;
@override
bool get displayBetaWarning;
@override
bool get enableBadge;
@override
bool get enableNotifications;
@override
MessageNotificationContent get messageNotificationContent;
@override
NotificationMode get onInvitationAcceptedMode;
@override
SoundEffect get onInvitationAcceptedSound;
@override
NotificationMode get onMessageReceivedMode;
@override
SoundEffect get onMessageReceivedSound;
@override
SoundEffect get onMessageSentSound;
@override
@JsonKey(ignore: true)
_$$NotificationsPreferenceImplCopyWith<_$NotificationsPreferenceImpl>
get copyWith => throw _privateConstructorUsedError;
}

View file

@ -0,0 +1,50 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'notifications_preference.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$NotificationsPreferenceImpl _$$NotificationsPreferenceImplFromJson(
Map<String, dynamic> json) =>
_$NotificationsPreferenceImpl(
displayBetaWarning: json['display_beta_warning'] as bool? ?? true,
enableBadge: json['enable_badge'] as bool? ?? true,
enableNotifications: json['enable_notifications'] as bool? ?? true,
messageNotificationContent: json['message_notification_content'] == null
? MessageNotificationContent.nameAndContent
: MessageNotificationContent.fromJson(
json['message_notification_content']),
onInvitationAcceptedMode: json['on_invitation_accepted_mode'] == null
? NotificationMode.inAppOrPush
: NotificationMode.fromJson(json['on_invitation_accepted_mode']),
onInvitationAcceptedSound: json['on_invitation_accepted_sound'] == null
? SoundEffect.beepBaDeep
: SoundEffect.fromJson(json['on_invitation_accepted_sound']),
onMessageReceivedMode: json['on_message_received_mode'] == null
? NotificationMode.inAppOrPush
: NotificationMode.fromJson(json['on_message_received_mode']),
onMessageReceivedSound: json['on_message_received_sound'] == null
? SoundEffect.boop
: SoundEffect.fromJson(json['on_message_received_sound']),
onMessageSentSound: json['on_message_sent_sound'] == null
? SoundEffect.bonk
: SoundEffect.fromJson(json['on_message_sent_sound']),
);
Map<String, dynamic> _$$NotificationsPreferenceImplToJson(
_$NotificationsPreferenceImpl instance) =>
<String, dynamic>{
'display_beta_warning': instance.displayBetaWarning,
'enable_badge': instance.enableBadge,
'enable_notifications': instance.enableNotifications,
'message_notification_content':
instance.messageNotificationContent.toJson(),
'on_invitation_accepted_mode': instance.onInvitationAcceptedMode.toJson(),
'on_invitation_accepted_sound':
instance.onInvitationAcceptedSound.toJson(),
'on_message_received_mode': instance.onMessageReceivedMode.toJson(),
'on_message_received_sound': instance.onMessageReceivedSound.toJson(),
'on_message_sent_sound': instance.onMessageSentSound.toJson(),
};