Приложение на флаторе, настройки
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'server_config.freezed.dart';
|
||||
part 'server_config.g.dart';
|
||||
|
||||
@freezed
|
||||
class ServerConfig with _$ServerConfig {
|
||||
const factory ServerConfig({
|
||||
required SystemConfig system,
|
||||
required StoriesConfig stories,
|
||||
required ChatsModuleConfig chats,
|
||||
required MessagesConfig messages,
|
||||
required WebRtcConfig webRtc,
|
||||
required KlipyConfig klipy,
|
||||
required ImportConfig import,
|
||||
required FederationConfig federation,
|
||||
}) = _ServerConfig;
|
||||
|
||||
factory ServerConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$ServerConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class SystemConfig with _$SystemConfig {
|
||||
const factory SystemConfig({
|
||||
required String domainUrl,
|
||||
required bool enableRegistration,
|
||||
}) = _SystemConfig;
|
||||
|
||||
factory SystemConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$SystemConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class StoriesConfig with _$StoriesConfig {
|
||||
const factory StoriesConfig({
|
||||
required bool enabled,
|
||||
required int maxStoriesPerPeriod,
|
||||
required int storyLifetimeHours,
|
||||
required bool textStoriesEnabled,
|
||||
required int textStoryDurationSeconds,
|
||||
required int mediaStoryMaxDurationSeconds,
|
||||
required int maxMediaSizeBytes,
|
||||
}) = _StoriesConfig;
|
||||
|
||||
factory StoriesConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$StoriesConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class ChatsModuleConfig with _$ChatsModuleConfig {
|
||||
const factory ChatsModuleConfig({
|
||||
required bool supportGroups,
|
||||
required int maxGroupParticipants,
|
||||
required bool allowChatToGroupConversion,
|
||||
required bool enableFolders,
|
||||
}) = _ChatsModuleConfig;
|
||||
|
||||
factory ChatsModuleConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$ChatsModuleConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class MessagesConfig with _$MessagesConfig {
|
||||
const factory MessagesConfig({
|
||||
required int dailyMessageLimitPerUser,
|
||||
required int chatMessageLimit,
|
||||
required bool allowMedia,
|
||||
required int maxMediaSizeBytes,
|
||||
required List<String> allowedMediaTypes,
|
||||
required bool allowVoiceMessages,
|
||||
required bool allowForwarding,
|
||||
required bool allowReactions,
|
||||
required bool allowReplies,
|
||||
required bool allowQuoting,
|
||||
required bool allowMessageDeletion,
|
||||
required bool forbidCopying,
|
||||
required bool allowLinks,
|
||||
required bool allowPolls,
|
||||
required bool allowPinning,
|
||||
}) = _MessagesConfig;
|
||||
|
||||
factory MessagesConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$MessagesConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class WebRtcConfig with _$WebRtcConfig {
|
||||
const factory WebRtcConfig({
|
||||
required bool enabled,
|
||||
required bool enableVoiceCalls,
|
||||
required bool enableVideoCalls,
|
||||
required bool enableScreenSharing,
|
||||
required String turnHost,
|
||||
required int turnPort,
|
||||
}) = _WebRtcConfig;
|
||||
|
||||
factory WebRtcConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$WebRtcConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class KlipyConfig with _$KlipyConfig {
|
||||
const factory KlipyConfig({
|
||||
required bool enabled,
|
||||
required String appName,
|
||||
}) = _KlipyConfig;
|
||||
|
||||
factory KlipyConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$KlipyConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class ImportConfig with _$ImportConfig {
|
||||
const factory ImportConfig({
|
||||
required bool enabled,
|
||||
}) = _ImportConfig;
|
||||
|
||||
factory ImportConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$ImportConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class FederationConfig with _$FederationConfig {
|
||||
const factory FederationConfig({
|
||||
required bool enabled,
|
||||
required String serverDescription,
|
||||
required List<FederationDomainConfig> allowedDomains,
|
||||
}) = _FederationConfig;
|
||||
|
||||
factory FederationConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$FederationConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: true)
|
||||
class FederationDomainConfig with _$FederationDomainConfig {
|
||||
const factory FederationDomainConfig({
|
||||
required String domain,
|
||||
required bool enabled,
|
||||
}) = _FederationDomainConfig;
|
||||
|
||||
factory FederationDomainConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$FederationDomainConfigFromJson(json);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,204 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'server_config.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ServerConfigImpl _$$ServerConfigImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ServerConfigImpl(
|
||||
system: SystemConfig.fromJson(json['system'] as Map<String, dynamic>),
|
||||
stories: StoriesConfig.fromJson(json['stories'] as Map<String, dynamic>),
|
||||
chats: ChatsModuleConfig.fromJson(json['chats'] as Map<String, dynamic>),
|
||||
messages:
|
||||
MessagesConfig.fromJson(json['messages'] as Map<String, dynamic>),
|
||||
webRtc: WebRtcConfig.fromJson(json['webRtc'] as Map<String, dynamic>),
|
||||
klipy: KlipyConfig.fromJson(json['klipy'] as Map<String, dynamic>),
|
||||
import: ImportConfig.fromJson(json['import'] as Map<String, dynamic>),
|
||||
federation:
|
||||
FederationConfig.fromJson(json['federation'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ServerConfigImplToJson(_$ServerConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'system': instance.system,
|
||||
'stories': instance.stories,
|
||||
'chats': instance.chats,
|
||||
'messages': instance.messages,
|
||||
'webRtc': instance.webRtc,
|
||||
'klipy': instance.klipy,
|
||||
'import': instance.import,
|
||||
'federation': instance.federation,
|
||||
};
|
||||
|
||||
_$SystemConfigImpl _$$SystemConfigImplFromJson(Map<String, dynamic> json) =>
|
||||
_$SystemConfigImpl(
|
||||
domainUrl: json['domainUrl'] as String,
|
||||
enableRegistration: json['enableRegistration'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SystemConfigImplToJson(_$SystemConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'domainUrl': instance.domainUrl,
|
||||
'enableRegistration': instance.enableRegistration,
|
||||
};
|
||||
|
||||
_$StoriesConfigImpl _$$StoriesConfigImplFromJson(Map<String, dynamic> json) =>
|
||||
_$StoriesConfigImpl(
|
||||
enabled: json['enabled'] as bool,
|
||||
maxStoriesPerPeriod: (json['maxStoriesPerPeriod'] as num).toInt(),
|
||||
storyLifetimeHours: (json['storyLifetimeHours'] as num).toInt(),
|
||||
textStoriesEnabled: json['textStoriesEnabled'] as bool,
|
||||
textStoryDurationSeconds:
|
||||
(json['textStoryDurationSeconds'] as num).toInt(),
|
||||
mediaStoryMaxDurationSeconds:
|
||||
(json['mediaStoryMaxDurationSeconds'] as num).toInt(),
|
||||
maxMediaSizeBytes: (json['maxMediaSizeBytes'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$StoriesConfigImplToJson(_$StoriesConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'enabled': instance.enabled,
|
||||
'maxStoriesPerPeriod': instance.maxStoriesPerPeriod,
|
||||
'storyLifetimeHours': instance.storyLifetimeHours,
|
||||
'textStoriesEnabled': instance.textStoriesEnabled,
|
||||
'textStoryDurationSeconds': instance.textStoryDurationSeconds,
|
||||
'mediaStoryMaxDurationSeconds': instance.mediaStoryMaxDurationSeconds,
|
||||
'maxMediaSizeBytes': instance.maxMediaSizeBytes,
|
||||
};
|
||||
|
||||
_$ChatsModuleConfigImpl _$$ChatsModuleConfigImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ChatsModuleConfigImpl(
|
||||
supportGroups: json['supportGroups'] as bool,
|
||||
maxGroupParticipants: (json['maxGroupParticipants'] as num).toInt(),
|
||||
allowChatToGroupConversion: json['allowChatToGroupConversion'] as bool,
|
||||
enableFolders: json['enableFolders'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ChatsModuleConfigImplToJson(
|
||||
_$ChatsModuleConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'supportGroups': instance.supportGroups,
|
||||
'maxGroupParticipants': instance.maxGroupParticipants,
|
||||
'allowChatToGroupConversion': instance.allowChatToGroupConversion,
|
||||
'enableFolders': instance.enableFolders,
|
||||
};
|
||||
|
||||
_$MessagesConfigImpl _$$MessagesConfigImplFromJson(Map<String, dynamic> json) =>
|
||||
_$MessagesConfigImpl(
|
||||
dailyMessageLimitPerUser:
|
||||
(json['dailyMessageLimitPerUser'] as num).toInt(),
|
||||
chatMessageLimit: (json['chatMessageLimit'] as num).toInt(),
|
||||
allowMedia: json['allowMedia'] as bool,
|
||||
maxMediaSizeBytes: (json['maxMediaSizeBytes'] as num).toInt(),
|
||||
allowedMediaTypes: (json['allowedMediaTypes'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
allowVoiceMessages: json['allowVoiceMessages'] as bool,
|
||||
allowForwarding: json['allowForwarding'] as bool,
|
||||
allowReactions: json['allowReactions'] as bool,
|
||||
allowReplies: json['allowReplies'] as bool,
|
||||
allowQuoting: json['allowQuoting'] as bool,
|
||||
allowMessageDeletion: json['allowMessageDeletion'] as bool,
|
||||
forbidCopying: json['forbidCopying'] as bool,
|
||||
allowLinks: json['allowLinks'] as bool,
|
||||
allowPolls: json['allowPolls'] as bool,
|
||||
allowPinning: json['allowPinning'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$MessagesConfigImplToJson(
|
||||
_$MessagesConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'dailyMessageLimitPerUser': instance.dailyMessageLimitPerUser,
|
||||
'chatMessageLimit': instance.chatMessageLimit,
|
||||
'allowMedia': instance.allowMedia,
|
||||
'maxMediaSizeBytes': instance.maxMediaSizeBytes,
|
||||
'allowedMediaTypes': instance.allowedMediaTypes,
|
||||
'allowVoiceMessages': instance.allowVoiceMessages,
|
||||
'allowForwarding': instance.allowForwarding,
|
||||
'allowReactions': instance.allowReactions,
|
||||
'allowReplies': instance.allowReplies,
|
||||
'allowQuoting': instance.allowQuoting,
|
||||
'allowMessageDeletion': instance.allowMessageDeletion,
|
||||
'forbidCopying': instance.forbidCopying,
|
||||
'allowLinks': instance.allowLinks,
|
||||
'allowPolls': instance.allowPolls,
|
||||
'allowPinning': instance.allowPinning,
|
||||
};
|
||||
|
||||
_$WebRtcConfigImpl _$$WebRtcConfigImplFromJson(Map<String, dynamic> json) =>
|
||||
_$WebRtcConfigImpl(
|
||||
enabled: json['enabled'] as bool,
|
||||
enableVoiceCalls: json['enableVoiceCalls'] as bool,
|
||||
enableVideoCalls: json['enableVideoCalls'] as bool,
|
||||
enableScreenSharing: json['enableScreenSharing'] as bool,
|
||||
turnHost: json['turnHost'] as String,
|
||||
turnPort: (json['turnPort'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$WebRtcConfigImplToJson(_$WebRtcConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'enabled': instance.enabled,
|
||||
'enableVoiceCalls': instance.enableVoiceCalls,
|
||||
'enableVideoCalls': instance.enableVideoCalls,
|
||||
'enableScreenSharing': instance.enableScreenSharing,
|
||||
'turnHost': instance.turnHost,
|
||||
'turnPort': instance.turnPort,
|
||||
};
|
||||
|
||||
_$KlipyConfigImpl _$$KlipyConfigImplFromJson(Map<String, dynamic> json) =>
|
||||
_$KlipyConfigImpl(
|
||||
enabled: json['enabled'] as bool,
|
||||
appName: json['appName'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$KlipyConfigImplToJson(_$KlipyConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'enabled': instance.enabled,
|
||||
'appName': instance.appName,
|
||||
};
|
||||
|
||||
_$ImportConfigImpl _$$ImportConfigImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ImportConfigImpl(
|
||||
enabled: json['enabled'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ImportConfigImplToJson(_$ImportConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'enabled': instance.enabled,
|
||||
};
|
||||
|
||||
_$FederationConfigImpl _$$FederationConfigImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$FederationConfigImpl(
|
||||
enabled: json['enabled'] as bool,
|
||||
serverDescription: json['serverDescription'] as String,
|
||||
allowedDomains: (json['allowedDomains'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => FederationDomainConfig.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$FederationConfigImplToJson(
|
||||
_$FederationConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'enabled': instance.enabled,
|
||||
'serverDescription': instance.serverDescription,
|
||||
'allowedDomains': instance.allowedDomains,
|
||||
};
|
||||
|
||||
_$FederationDomainConfigImpl _$$FederationDomainConfigImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$FederationDomainConfigImpl(
|
||||
domain: json['domain'] as String,
|
||||
enabled: json['enabled'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$FederationDomainConfigImplToJson(
|
||||
_$FederationDomainConfigImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'domain': instance.domain,
|
||||
'enabled': instance.enabled,
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'settings.freezed.dart';
|
||||
// part 'settings.g.dart';
|
||||
|
||||
@freezed
|
||||
class AppSettings with _$AppSettings {
|
||||
const factory AppSettings({
|
||||
required bool notificationsEnabled,
|
||||
required bool darkModeEnabled,
|
||||
required String language,
|
||||
bool? soundEnabled,
|
||||
bool? vibrationEnabled,
|
||||
String? themeColor,
|
||||
}) = _AppSettings;
|
||||
|
||||
// factory AppSettings.fromJson(Map<String, dynamic> json) => _$AppSettingsFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
// 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 'settings.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');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AppSettings {
|
||||
bool get notificationsEnabled => throw _privateConstructorUsedError;
|
||||
bool get darkModeEnabled => throw _privateConstructorUsedError;
|
||||
String get language => throw _privateConstructorUsedError;
|
||||
bool? get soundEnabled => throw _privateConstructorUsedError;
|
||||
bool? get vibrationEnabled => throw _privateConstructorUsedError;
|
||||
String? get themeColor => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$AppSettingsCopyWith<AppSettings> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AppSettingsCopyWith<$Res> {
|
||||
factory $AppSettingsCopyWith(
|
||||
AppSettings value, $Res Function(AppSettings) then) =
|
||||
_$AppSettingsCopyWithImpl<$Res, AppSettings>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool notificationsEnabled,
|
||||
bool darkModeEnabled,
|
||||
String language,
|
||||
bool? soundEnabled,
|
||||
bool? vibrationEnabled,
|
||||
String? themeColor});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
||||
implements $AppSettingsCopyWith<$Res> {
|
||||
_$AppSettingsCopyWithImpl(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? notificationsEnabled = null,
|
||||
Object? darkModeEnabled = null,
|
||||
Object? language = null,
|
||||
Object? soundEnabled = freezed,
|
||||
Object? vibrationEnabled = freezed,
|
||||
Object? themeColor = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
notificationsEnabled: null == notificationsEnabled
|
||||
? _value.notificationsEnabled
|
||||
: notificationsEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
darkModeEnabled: null == darkModeEnabled
|
||||
? _value.darkModeEnabled
|
||||
: darkModeEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
language: null == language
|
||||
? _value.language
|
||||
: language // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
soundEnabled: freezed == soundEnabled
|
||||
? _value.soundEnabled
|
||||
: soundEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
vibrationEnabled: freezed == vibrationEnabled
|
||||
? _value.vibrationEnabled
|
||||
: vibrationEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
themeColor: freezed == themeColor
|
||||
? _value.themeColor
|
||||
: themeColor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AppSettingsImplCopyWith<$Res>
|
||||
implements $AppSettingsCopyWith<$Res> {
|
||||
factory _$$AppSettingsImplCopyWith(
|
||||
_$AppSettingsImpl value, $Res Function(_$AppSettingsImpl) then) =
|
||||
__$$AppSettingsImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool notificationsEnabled,
|
||||
bool darkModeEnabled,
|
||||
String language,
|
||||
bool? soundEnabled,
|
||||
bool? vibrationEnabled,
|
||||
String? themeColor});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AppSettingsImplCopyWithImpl<$Res>
|
||||
extends _$AppSettingsCopyWithImpl<$Res, _$AppSettingsImpl>
|
||||
implements _$$AppSettingsImplCopyWith<$Res> {
|
||||
__$$AppSettingsImplCopyWithImpl(
|
||||
_$AppSettingsImpl _value, $Res Function(_$AppSettingsImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? notificationsEnabled = null,
|
||||
Object? darkModeEnabled = null,
|
||||
Object? language = null,
|
||||
Object? soundEnabled = freezed,
|
||||
Object? vibrationEnabled = freezed,
|
||||
Object? themeColor = freezed,
|
||||
}) {
|
||||
return _then(_$AppSettingsImpl(
|
||||
notificationsEnabled: null == notificationsEnabled
|
||||
? _value.notificationsEnabled
|
||||
: notificationsEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
darkModeEnabled: null == darkModeEnabled
|
||||
? _value.darkModeEnabled
|
||||
: darkModeEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
language: null == language
|
||||
? _value.language
|
||||
: language // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
soundEnabled: freezed == soundEnabled
|
||||
? _value.soundEnabled
|
||||
: soundEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
vibrationEnabled: freezed == vibrationEnabled
|
||||
? _value.vibrationEnabled
|
||||
: vibrationEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
themeColor: freezed == themeColor
|
||||
? _value.themeColor
|
||||
: themeColor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$AppSettingsImpl implements _AppSettings {
|
||||
const _$AppSettingsImpl(
|
||||
{required this.notificationsEnabled,
|
||||
required this.darkModeEnabled,
|
||||
required this.language,
|
||||
this.soundEnabled,
|
||||
this.vibrationEnabled,
|
||||
this.themeColor});
|
||||
|
||||
@override
|
||||
final bool notificationsEnabled;
|
||||
@override
|
||||
final bool darkModeEnabled;
|
||||
@override
|
||||
final String language;
|
||||
@override
|
||||
final bool? soundEnabled;
|
||||
@override
|
||||
final bool? vibrationEnabled;
|
||||
@override
|
||||
final String? themeColor;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppSettings(notificationsEnabled: $notificationsEnabled, darkModeEnabled: $darkModeEnabled, language: $language, soundEnabled: $soundEnabled, vibrationEnabled: $vibrationEnabled, themeColor: $themeColor)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AppSettingsImpl &&
|
||||
(identical(other.notificationsEnabled, notificationsEnabled) ||
|
||||
other.notificationsEnabled == notificationsEnabled) &&
|
||||
(identical(other.darkModeEnabled, darkModeEnabled) ||
|
||||
other.darkModeEnabled == darkModeEnabled) &&
|
||||
(identical(other.language, language) ||
|
||||
other.language == language) &&
|
||||
(identical(other.soundEnabled, soundEnabled) ||
|
||||
other.soundEnabled == soundEnabled) &&
|
||||
(identical(other.vibrationEnabled, vibrationEnabled) ||
|
||||
other.vibrationEnabled == vibrationEnabled) &&
|
||||
(identical(other.themeColor, themeColor) ||
|
||||
other.themeColor == themeColor));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, notificationsEnabled,
|
||||
darkModeEnabled, language, soundEnabled, vibrationEnabled, themeColor);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AppSettingsImplCopyWith<_$AppSettingsImpl> get copyWith =>
|
||||
__$$AppSettingsImplCopyWithImpl<_$AppSettingsImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _AppSettings implements AppSettings {
|
||||
const factory _AppSettings(
|
||||
{required final bool notificationsEnabled,
|
||||
required final bool darkModeEnabled,
|
||||
required final String language,
|
||||
final bool? soundEnabled,
|
||||
final bool? vibrationEnabled,
|
||||
final String? themeColor}) = _$AppSettingsImpl;
|
||||
|
||||
@override
|
||||
bool get notificationsEnabled;
|
||||
@override
|
||||
bool get darkModeEnabled;
|
||||
@override
|
||||
String get language;
|
||||
@override
|
||||
bool? get soundEnabled;
|
||||
@override
|
||||
bool? get vibrationEnabled;
|
||||
@override
|
||||
String? get themeColor;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$AppSettingsImplCopyWith<_$AppSettingsImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import '../../../../core/errors/result.dart';
|
||||
import '../entities/server_config.dart';
|
||||
|
||||
abstract class SettingsRepository {
|
||||
Future<String?> getApiUrl();
|
||||
Future<Result<void>> saveApiUrl(String url);
|
||||
Future<String?> getLanguageCode();
|
||||
Future<Result<void>> saveLanguageCode(String code);
|
||||
Future<Result<ServerConfig>> getServerConfig();
|
||||
Future<Result<void>> refreshServerConfig();
|
||||
Future<Result<bool>> getNotificationsEnabled();
|
||||
Future<Result<void>> setNotificationsEnabled(bool enabled);
|
||||
Future<Result<bool>> getDarkModeEnabled();
|
||||
Future<Result<void>> setDarkModeEnabled(bool enabled);
|
||||
Future<Result<void>> clearAllData();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import '../../../../core/errors/result.dart';
|
||||
import '../repositories/settings_repository.dart';
|
||||
|
||||
class GetSettingsUseCase {
|
||||
final SettingsRepository _repository;
|
||||
|
||||
GetSettingsUseCase(this._repository);
|
||||
|
||||
Future<Result<String?>> execute() async {
|
||||
final language = await _repository.getLanguageCode();
|
||||
return Result.success(language);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user