Приложение на флаторе, настройки
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../domain/repositories/settings_repository.dart';
|
||||
import 'settings_event.dart';
|
||||
import 'settings_state.dart';
|
||||
|
||||
class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
|
||||
final SettingsRepository _repository;
|
||||
|
||||
SettingsBloc(this._repository) : super(const SettingsState.initial()) {
|
||||
on<SettingsStarted>(_onStarted);
|
||||
on<SettingsConfigRequested>(_onConfigRequested);
|
||||
on<SettingsApiUrlChanged>(_onApiUrlChanged);
|
||||
on<SettingsApiUrlSaved>(_onApiUrlSaved);
|
||||
on<SettingsLanguageChanged>(_onLanguageChanged);
|
||||
on<SettingsRefreshConfig>(_onRefreshConfig);
|
||||
}
|
||||
|
||||
Future<void> _onStarted(SettingsStarted event, emit) async {
|
||||
emit(const SettingsState.loading());
|
||||
|
||||
final apiUrl = await _repository.getApiUrl() ?? '';
|
||||
final languageCode = await _repository.getLanguageCode() ?? 'ru';
|
||||
final configResult = await _repository.getServerConfig();
|
||||
|
||||
configResult.when(
|
||||
onSuccess: (config) {
|
||||
emit(SettingsState.loaded(
|
||||
apiUrl: apiUrl,
|
||||
serverConfig: config,
|
||||
languageCode: languageCode,
|
||||
));
|
||||
},
|
||||
onFailure: (error) {
|
||||
emit(SettingsState.loaded(
|
||||
apiUrl: apiUrl,
|
||||
serverConfig: null,
|
||||
languageCode: languageCode,
|
||||
error: 'Failed to load server config',
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onConfigRequested(SettingsConfigRequested event, emit) async {
|
||||
if (state is! SettingsLoaded) return;
|
||||
final currentState = state as SettingsLoaded;
|
||||
|
||||
emit(const SettingsState.loading());
|
||||
final configResult = await _repository.getServerConfig();
|
||||
|
||||
configResult.when(
|
||||
onSuccess: (config) {
|
||||
emit(SettingsState.loaded(
|
||||
apiUrl: currentState.apiUrl,
|
||||
serverConfig: config,
|
||||
languageCode: currentState.languageCode,
|
||||
));
|
||||
},
|
||||
onFailure: (error) {
|
||||
emit(SettingsState.loaded(
|
||||
apiUrl: currentState.apiUrl,
|
||||
serverConfig: null,
|
||||
languageCode: currentState.languageCode,
|
||||
error: 'Failed to refresh config',
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _onApiUrlChanged(SettingsApiUrlChanged event, emit) {
|
||||
if (state is! SettingsLoaded) return;
|
||||
final currentState = state as SettingsLoaded;
|
||||
emit(SettingsState.loaded(
|
||||
apiUrl: event.url,
|
||||
serverConfig: currentState.serverConfig,
|
||||
languageCode: currentState.languageCode,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> _onApiUrlSaved(SettingsApiUrlSaved event, emit) async {
|
||||
if (state is! SettingsLoaded) return;
|
||||
final currentState = state as SettingsLoaded;
|
||||
|
||||
await _repository.saveApiUrl(event.url);
|
||||
|
||||
emit(SettingsState.loaded(
|
||||
apiUrl: event.url,
|
||||
serverConfig: currentState.serverConfig,
|
||||
languageCode: currentState.languageCode,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> _onLanguageChanged(SettingsLanguageChanged event, emit) async {
|
||||
if (state is! SettingsLoaded) return;
|
||||
final currentState = state as SettingsLoaded;
|
||||
|
||||
await _repository.saveLanguageCode(event.code);
|
||||
|
||||
emit(SettingsState.loaded(
|
||||
apiUrl: currentState.apiUrl,
|
||||
serverConfig: currentState.serverConfig,
|
||||
languageCode: event.code,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> _onRefreshConfig(SettingsRefreshConfig event, emit) async {
|
||||
add(const SettingsConfigRequested());
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'settings_event.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class SettingsEvent with _$SettingsEvent {
|
||||
const factory SettingsEvent.started() = SettingsStarted;
|
||||
const factory SettingsEvent.configRequested() = SettingsConfigRequested;
|
||||
const factory SettingsEvent.apiUrlChanged(String url) = SettingsApiUrlChanged;
|
||||
const factory SettingsEvent.apiUrlSaved(String url) = SettingsApiUrlSaved;
|
||||
const factory SettingsEvent.languageChanged(String code) = SettingsLanguageChanged;
|
||||
const factory SettingsEvent.refreshConfig() = SettingsRefreshConfig;
|
||||
}
|
||||
@@ -0,0 +1,962 @@
|
||||
// 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_event.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 _$SettingsEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() started,
|
||||
required TResult Function() configRequested,
|
||||
required TResult Function(String url) apiUrlChanged,
|
||||
required TResult Function(String url) apiUrlSaved,
|
||||
required TResult Function(String code) languageChanged,
|
||||
required TResult Function() refreshConfig,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? started,
|
||||
TResult? Function()? configRequested,
|
||||
TResult? Function(String url)? apiUrlChanged,
|
||||
TResult? Function(String url)? apiUrlSaved,
|
||||
TResult? Function(String code)? languageChanged,
|
||||
TResult? Function()? refreshConfig,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? started,
|
||||
TResult Function()? configRequested,
|
||||
TResult Function(String url)? apiUrlChanged,
|
||||
TResult Function(String url)? apiUrlSaved,
|
||||
TResult Function(String code)? languageChanged,
|
||||
TResult Function()? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsStarted value) started,
|
||||
required TResult Function(SettingsConfigRequested value) configRequested,
|
||||
required TResult Function(SettingsApiUrlChanged value) apiUrlChanged,
|
||||
required TResult Function(SettingsApiUrlSaved value) apiUrlSaved,
|
||||
required TResult Function(SettingsLanguageChanged value) languageChanged,
|
||||
required TResult Function(SettingsRefreshConfig value) refreshConfig,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsStarted value)? started,
|
||||
TResult? Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult? Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult? Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsStarted value)? started,
|
||||
TResult Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $SettingsEventCopyWith<$Res> {
|
||||
factory $SettingsEventCopyWith(
|
||||
SettingsEvent value, $Res Function(SettingsEvent) then) =
|
||||
_$SettingsEventCopyWithImpl<$Res, SettingsEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$SettingsEventCopyWithImpl<$Res, $Val extends SettingsEvent>
|
||||
implements $SettingsEventCopyWith<$Res> {
|
||||
_$SettingsEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsStartedImplCopyWith<$Res> {
|
||||
factory _$$SettingsStartedImplCopyWith(_$SettingsStartedImpl value,
|
||||
$Res Function(_$SettingsStartedImpl) then) =
|
||||
__$$SettingsStartedImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsStartedImplCopyWithImpl<$Res>
|
||||
extends _$SettingsEventCopyWithImpl<$Res, _$SettingsStartedImpl>
|
||||
implements _$$SettingsStartedImplCopyWith<$Res> {
|
||||
__$$SettingsStartedImplCopyWithImpl(
|
||||
_$SettingsStartedImpl _value, $Res Function(_$SettingsStartedImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsStartedImpl implements SettingsStarted {
|
||||
const _$SettingsStartedImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsEvent.started()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$SettingsStartedImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() started,
|
||||
required TResult Function() configRequested,
|
||||
required TResult Function(String url) apiUrlChanged,
|
||||
required TResult Function(String url) apiUrlSaved,
|
||||
required TResult Function(String code) languageChanged,
|
||||
required TResult Function() refreshConfig,
|
||||
}) {
|
||||
return started();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? started,
|
||||
TResult? Function()? configRequested,
|
||||
TResult? Function(String url)? apiUrlChanged,
|
||||
TResult? Function(String url)? apiUrlSaved,
|
||||
TResult? Function(String code)? languageChanged,
|
||||
TResult? Function()? refreshConfig,
|
||||
}) {
|
||||
return started?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? started,
|
||||
TResult Function()? configRequested,
|
||||
TResult Function(String url)? apiUrlChanged,
|
||||
TResult Function(String url)? apiUrlSaved,
|
||||
TResult Function(String code)? languageChanged,
|
||||
TResult Function()? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (started != null) {
|
||||
return started();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsStarted value) started,
|
||||
required TResult Function(SettingsConfigRequested value) configRequested,
|
||||
required TResult Function(SettingsApiUrlChanged value) apiUrlChanged,
|
||||
required TResult Function(SettingsApiUrlSaved value) apiUrlSaved,
|
||||
required TResult Function(SettingsLanguageChanged value) languageChanged,
|
||||
required TResult Function(SettingsRefreshConfig value) refreshConfig,
|
||||
}) {
|
||||
return started(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsStarted value)? started,
|
||||
TResult? Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult? Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult? Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
}) {
|
||||
return started?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsStarted value)? started,
|
||||
TResult Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (started != null) {
|
||||
return started(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsStarted implements SettingsEvent {
|
||||
const factory SettingsStarted() = _$SettingsStartedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsConfigRequestedImplCopyWith<$Res> {
|
||||
factory _$$SettingsConfigRequestedImplCopyWith(
|
||||
_$SettingsConfigRequestedImpl value,
|
||||
$Res Function(_$SettingsConfigRequestedImpl) then) =
|
||||
__$$SettingsConfigRequestedImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsConfigRequestedImplCopyWithImpl<$Res>
|
||||
extends _$SettingsEventCopyWithImpl<$Res, _$SettingsConfigRequestedImpl>
|
||||
implements _$$SettingsConfigRequestedImplCopyWith<$Res> {
|
||||
__$$SettingsConfigRequestedImplCopyWithImpl(
|
||||
_$SettingsConfigRequestedImpl _value,
|
||||
$Res Function(_$SettingsConfigRequestedImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsConfigRequestedImpl implements SettingsConfigRequested {
|
||||
const _$SettingsConfigRequestedImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsEvent.configRequested()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SettingsConfigRequestedImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() started,
|
||||
required TResult Function() configRequested,
|
||||
required TResult Function(String url) apiUrlChanged,
|
||||
required TResult Function(String url) apiUrlSaved,
|
||||
required TResult Function(String code) languageChanged,
|
||||
required TResult Function() refreshConfig,
|
||||
}) {
|
||||
return configRequested();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? started,
|
||||
TResult? Function()? configRequested,
|
||||
TResult? Function(String url)? apiUrlChanged,
|
||||
TResult? Function(String url)? apiUrlSaved,
|
||||
TResult? Function(String code)? languageChanged,
|
||||
TResult? Function()? refreshConfig,
|
||||
}) {
|
||||
return configRequested?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? started,
|
||||
TResult Function()? configRequested,
|
||||
TResult Function(String url)? apiUrlChanged,
|
||||
TResult Function(String url)? apiUrlSaved,
|
||||
TResult Function(String code)? languageChanged,
|
||||
TResult Function()? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (configRequested != null) {
|
||||
return configRequested();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsStarted value) started,
|
||||
required TResult Function(SettingsConfigRequested value) configRequested,
|
||||
required TResult Function(SettingsApiUrlChanged value) apiUrlChanged,
|
||||
required TResult Function(SettingsApiUrlSaved value) apiUrlSaved,
|
||||
required TResult Function(SettingsLanguageChanged value) languageChanged,
|
||||
required TResult Function(SettingsRefreshConfig value) refreshConfig,
|
||||
}) {
|
||||
return configRequested(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsStarted value)? started,
|
||||
TResult? Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult? Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult? Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
}) {
|
||||
return configRequested?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsStarted value)? started,
|
||||
TResult Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (configRequested != null) {
|
||||
return configRequested(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsConfigRequested implements SettingsEvent {
|
||||
const factory SettingsConfigRequested() = _$SettingsConfigRequestedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsApiUrlChangedImplCopyWith<$Res> {
|
||||
factory _$$SettingsApiUrlChangedImplCopyWith(
|
||||
_$SettingsApiUrlChangedImpl value,
|
||||
$Res Function(_$SettingsApiUrlChangedImpl) then) =
|
||||
__$$SettingsApiUrlChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String url});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsApiUrlChangedImplCopyWithImpl<$Res>
|
||||
extends _$SettingsEventCopyWithImpl<$Res, _$SettingsApiUrlChangedImpl>
|
||||
implements _$$SettingsApiUrlChangedImplCopyWith<$Res> {
|
||||
__$$SettingsApiUrlChangedImplCopyWithImpl(_$SettingsApiUrlChangedImpl _value,
|
||||
$Res Function(_$SettingsApiUrlChangedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? url = null,
|
||||
}) {
|
||||
return _then(_$SettingsApiUrlChangedImpl(
|
||||
null == url
|
||||
? _value.url
|
||||
: url // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsApiUrlChangedImpl implements SettingsApiUrlChanged {
|
||||
const _$SettingsApiUrlChangedImpl(this.url);
|
||||
|
||||
@override
|
||||
final String url;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsEvent.apiUrlChanged(url: $url)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SettingsApiUrlChangedImpl &&
|
||||
(identical(other.url, url) || other.url == url));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, url);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SettingsApiUrlChangedImplCopyWith<_$SettingsApiUrlChangedImpl>
|
||||
get copyWith => __$$SettingsApiUrlChangedImplCopyWithImpl<
|
||||
_$SettingsApiUrlChangedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() started,
|
||||
required TResult Function() configRequested,
|
||||
required TResult Function(String url) apiUrlChanged,
|
||||
required TResult Function(String url) apiUrlSaved,
|
||||
required TResult Function(String code) languageChanged,
|
||||
required TResult Function() refreshConfig,
|
||||
}) {
|
||||
return apiUrlChanged(url);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? started,
|
||||
TResult? Function()? configRequested,
|
||||
TResult? Function(String url)? apiUrlChanged,
|
||||
TResult? Function(String url)? apiUrlSaved,
|
||||
TResult? Function(String code)? languageChanged,
|
||||
TResult? Function()? refreshConfig,
|
||||
}) {
|
||||
return apiUrlChanged?.call(url);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? started,
|
||||
TResult Function()? configRequested,
|
||||
TResult Function(String url)? apiUrlChanged,
|
||||
TResult Function(String url)? apiUrlSaved,
|
||||
TResult Function(String code)? languageChanged,
|
||||
TResult Function()? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (apiUrlChanged != null) {
|
||||
return apiUrlChanged(url);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsStarted value) started,
|
||||
required TResult Function(SettingsConfigRequested value) configRequested,
|
||||
required TResult Function(SettingsApiUrlChanged value) apiUrlChanged,
|
||||
required TResult Function(SettingsApiUrlSaved value) apiUrlSaved,
|
||||
required TResult Function(SettingsLanguageChanged value) languageChanged,
|
||||
required TResult Function(SettingsRefreshConfig value) refreshConfig,
|
||||
}) {
|
||||
return apiUrlChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsStarted value)? started,
|
||||
TResult? Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult? Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult? Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
}) {
|
||||
return apiUrlChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsStarted value)? started,
|
||||
TResult Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (apiUrlChanged != null) {
|
||||
return apiUrlChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsApiUrlChanged implements SettingsEvent {
|
||||
const factory SettingsApiUrlChanged(final String url) =
|
||||
_$SettingsApiUrlChangedImpl;
|
||||
|
||||
String get url;
|
||||
@JsonKey(ignore: true)
|
||||
_$$SettingsApiUrlChangedImplCopyWith<_$SettingsApiUrlChangedImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsApiUrlSavedImplCopyWith<$Res> {
|
||||
factory _$$SettingsApiUrlSavedImplCopyWith(_$SettingsApiUrlSavedImpl value,
|
||||
$Res Function(_$SettingsApiUrlSavedImpl) then) =
|
||||
__$$SettingsApiUrlSavedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String url});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsApiUrlSavedImplCopyWithImpl<$Res>
|
||||
extends _$SettingsEventCopyWithImpl<$Res, _$SettingsApiUrlSavedImpl>
|
||||
implements _$$SettingsApiUrlSavedImplCopyWith<$Res> {
|
||||
__$$SettingsApiUrlSavedImplCopyWithImpl(_$SettingsApiUrlSavedImpl _value,
|
||||
$Res Function(_$SettingsApiUrlSavedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? url = null,
|
||||
}) {
|
||||
return _then(_$SettingsApiUrlSavedImpl(
|
||||
null == url
|
||||
? _value.url
|
||||
: url // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsApiUrlSavedImpl implements SettingsApiUrlSaved {
|
||||
const _$SettingsApiUrlSavedImpl(this.url);
|
||||
|
||||
@override
|
||||
final String url;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsEvent.apiUrlSaved(url: $url)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SettingsApiUrlSavedImpl &&
|
||||
(identical(other.url, url) || other.url == url));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, url);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SettingsApiUrlSavedImplCopyWith<_$SettingsApiUrlSavedImpl> get copyWith =>
|
||||
__$$SettingsApiUrlSavedImplCopyWithImpl<_$SettingsApiUrlSavedImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() started,
|
||||
required TResult Function() configRequested,
|
||||
required TResult Function(String url) apiUrlChanged,
|
||||
required TResult Function(String url) apiUrlSaved,
|
||||
required TResult Function(String code) languageChanged,
|
||||
required TResult Function() refreshConfig,
|
||||
}) {
|
||||
return apiUrlSaved(url);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? started,
|
||||
TResult? Function()? configRequested,
|
||||
TResult? Function(String url)? apiUrlChanged,
|
||||
TResult? Function(String url)? apiUrlSaved,
|
||||
TResult? Function(String code)? languageChanged,
|
||||
TResult? Function()? refreshConfig,
|
||||
}) {
|
||||
return apiUrlSaved?.call(url);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? started,
|
||||
TResult Function()? configRequested,
|
||||
TResult Function(String url)? apiUrlChanged,
|
||||
TResult Function(String url)? apiUrlSaved,
|
||||
TResult Function(String code)? languageChanged,
|
||||
TResult Function()? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (apiUrlSaved != null) {
|
||||
return apiUrlSaved(url);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsStarted value) started,
|
||||
required TResult Function(SettingsConfigRequested value) configRequested,
|
||||
required TResult Function(SettingsApiUrlChanged value) apiUrlChanged,
|
||||
required TResult Function(SettingsApiUrlSaved value) apiUrlSaved,
|
||||
required TResult Function(SettingsLanguageChanged value) languageChanged,
|
||||
required TResult Function(SettingsRefreshConfig value) refreshConfig,
|
||||
}) {
|
||||
return apiUrlSaved(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsStarted value)? started,
|
||||
TResult? Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult? Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult? Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
}) {
|
||||
return apiUrlSaved?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsStarted value)? started,
|
||||
TResult Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (apiUrlSaved != null) {
|
||||
return apiUrlSaved(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsApiUrlSaved implements SettingsEvent {
|
||||
const factory SettingsApiUrlSaved(final String url) =
|
||||
_$SettingsApiUrlSavedImpl;
|
||||
|
||||
String get url;
|
||||
@JsonKey(ignore: true)
|
||||
_$$SettingsApiUrlSavedImplCopyWith<_$SettingsApiUrlSavedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsLanguageChangedImplCopyWith<$Res> {
|
||||
factory _$$SettingsLanguageChangedImplCopyWith(
|
||||
_$SettingsLanguageChangedImpl value,
|
||||
$Res Function(_$SettingsLanguageChangedImpl) then) =
|
||||
__$$SettingsLanguageChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String code});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsLanguageChangedImplCopyWithImpl<$Res>
|
||||
extends _$SettingsEventCopyWithImpl<$Res, _$SettingsLanguageChangedImpl>
|
||||
implements _$$SettingsLanguageChangedImplCopyWith<$Res> {
|
||||
__$$SettingsLanguageChangedImplCopyWithImpl(
|
||||
_$SettingsLanguageChangedImpl _value,
|
||||
$Res Function(_$SettingsLanguageChangedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? code = null,
|
||||
}) {
|
||||
return _then(_$SettingsLanguageChangedImpl(
|
||||
null == code
|
||||
? _value.code
|
||||
: code // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsLanguageChangedImpl implements SettingsLanguageChanged {
|
||||
const _$SettingsLanguageChangedImpl(this.code);
|
||||
|
||||
@override
|
||||
final String code;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsEvent.languageChanged(code: $code)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SettingsLanguageChangedImpl &&
|
||||
(identical(other.code, code) || other.code == code));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, code);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SettingsLanguageChangedImplCopyWith<_$SettingsLanguageChangedImpl>
|
||||
get copyWith => __$$SettingsLanguageChangedImplCopyWithImpl<
|
||||
_$SettingsLanguageChangedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() started,
|
||||
required TResult Function() configRequested,
|
||||
required TResult Function(String url) apiUrlChanged,
|
||||
required TResult Function(String url) apiUrlSaved,
|
||||
required TResult Function(String code) languageChanged,
|
||||
required TResult Function() refreshConfig,
|
||||
}) {
|
||||
return languageChanged(code);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? started,
|
||||
TResult? Function()? configRequested,
|
||||
TResult? Function(String url)? apiUrlChanged,
|
||||
TResult? Function(String url)? apiUrlSaved,
|
||||
TResult? Function(String code)? languageChanged,
|
||||
TResult? Function()? refreshConfig,
|
||||
}) {
|
||||
return languageChanged?.call(code);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? started,
|
||||
TResult Function()? configRequested,
|
||||
TResult Function(String url)? apiUrlChanged,
|
||||
TResult Function(String url)? apiUrlSaved,
|
||||
TResult Function(String code)? languageChanged,
|
||||
TResult Function()? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (languageChanged != null) {
|
||||
return languageChanged(code);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsStarted value) started,
|
||||
required TResult Function(SettingsConfigRequested value) configRequested,
|
||||
required TResult Function(SettingsApiUrlChanged value) apiUrlChanged,
|
||||
required TResult Function(SettingsApiUrlSaved value) apiUrlSaved,
|
||||
required TResult Function(SettingsLanguageChanged value) languageChanged,
|
||||
required TResult Function(SettingsRefreshConfig value) refreshConfig,
|
||||
}) {
|
||||
return languageChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsStarted value)? started,
|
||||
TResult? Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult? Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult? Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
}) {
|
||||
return languageChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsStarted value)? started,
|
||||
TResult Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (languageChanged != null) {
|
||||
return languageChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsLanguageChanged implements SettingsEvent {
|
||||
const factory SettingsLanguageChanged(final String code) =
|
||||
_$SettingsLanguageChangedImpl;
|
||||
|
||||
String get code;
|
||||
@JsonKey(ignore: true)
|
||||
_$$SettingsLanguageChangedImplCopyWith<_$SettingsLanguageChangedImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsRefreshConfigImplCopyWith<$Res> {
|
||||
factory _$$SettingsRefreshConfigImplCopyWith(
|
||||
_$SettingsRefreshConfigImpl value,
|
||||
$Res Function(_$SettingsRefreshConfigImpl) then) =
|
||||
__$$SettingsRefreshConfigImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsRefreshConfigImplCopyWithImpl<$Res>
|
||||
extends _$SettingsEventCopyWithImpl<$Res, _$SettingsRefreshConfigImpl>
|
||||
implements _$$SettingsRefreshConfigImplCopyWith<$Res> {
|
||||
__$$SettingsRefreshConfigImplCopyWithImpl(_$SettingsRefreshConfigImpl _value,
|
||||
$Res Function(_$SettingsRefreshConfigImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsRefreshConfigImpl implements SettingsRefreshConfig {
|
||||
const _$SettingsRefreshConfigImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsEvent.refreshConfig()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SettingsRefreshConfigImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() started,
|
||||
required TResult Function() configRequested,
|
||||
required TResult Function(String url) apiUrlChanged,
|
||||
required TResult Function(String url) apiUrlSaved,
|
||||
required TResult Function(String code) languageChanged,
|
||||
required TResult Function() refreshConfig,
|
||||
}) {
|
||||
return refreshConfig();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? started,
|
||||
TResult? Function()? configRequested,
|
||||
TResult? Function(String url)? apiUrlChanged,
|
||||
TResult? Function(String url)? apiUrlSaved,
|
||||
TResult? Function(String code)? languageChanged,
|
||||
TResult? Function()? refreshConfig,
|
||||
}) {
|
||||
return refreshConfig?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? started,
|
||||
TResult Function()? configRequested,
|
||||
TResult Function(String url)? apiUrlChanged,
|
||||
TResult Function(String url)? apiUrlSaved,
|
||||
TResult Function(String code)? languageChanged,
|
||||
TResult Function()? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (refreshConfig != null) {
|
||||
return refreshConfig();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsStarted value) started,
|
||||
required TResult Function(SettingsConfigRequested value) configRequested,
|
||||
required TResult Function(SettingsApiUrlChanged value) apiUrlChanged,
|
||||
required TResult Function(SettingsApiUrlSaved value) apiUrlSaved,
|
||||
required TResult Function(SettingsLanguageChanged value) languageChanged,
|
||||
required TResult Function(SettingsRefreshConfig value) refreshConfig,
|
||||
}) {
|
||||
return refreshConfig(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsStarted value)? started,
|
||||
TResult? Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult? Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult? Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
}) {
|
||||
return refreshConfig?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsStarted value)? started,
|
||||
TResult Function(SettingsConfigRequested value)? configRequested,
|
||||
TResult Function(SettingsApiUrlChanged value)? apiUrlChanged,
|
||||
TResult Function(SettingsApiUrlSaved value)? apiUrlSaved,
|
||||
TResult Function(SettingsLanguageChanged value)? languageChanged,
|
||||
TResult Function(SettingsRefreshConfig value)? refreshConfig,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (refreshConfig != null) {
|
||||
return refreshConfig(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsRefreshConfig implements SettingsEvent {
|
||||
const factory SettingsRefreshConfig() = _$SettingsRefreshConfigImpl;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import '../../domain/entities/server_config.dart';
|
||||
|
||||
part 'settings_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class SettingsState with _$SettingsState {
|
||||
const factory SettingsState.initial() = SettingsInitial;
|
||||
const factory SettingsState.loading() = SettingsLoading;
|
||||
const factory SettingsState.loaded({
|
||||
required String apiUrl,
|
||||
required ServerConfig? serverConfig,
|
||||
required String languageCode,
|
||||
String? error,
|
||||
}) = SettingsLoaded;
|
||||
const factory SettingsState.error(String message) = SettingsError;
|
||||
}
|
||||
@@ -0,0 +1,692 @@
|
||||
// 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_state.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 _$SettingsState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)
|
||||
loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsInitial value) initial,
|
||||
required TResult Function(SettingsLoading value) loading,
|
||||
required TResult Function(SettingsLoaded value) loaded,
|
||||
required TResult Function(SettingsError value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsInitial value)? initial,
|
||||
TResult? Function(SettingsLoading value)? loading,
|
||||
TResult? Function(SettingsLoaded value)? loaded,
|
||||
TResult? Function(SettingsError value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsInitial value)? initial,
|
||||
TResult Function(SettingsLoading value)? loading,
|
||||
TResult Function(SettingsLoaded value)? loaded,
|
||||
TResult Function(SettingsError value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $SettingsStateCopyWith<$Res> {
|
||||
factory $SettingsStateCopyWith(
|
||||
SettingsState value, $Res Function(SettingsState) then) =
|
||||
_$SettingsStateCopyWithImpl<$Res, SettingsState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$SettingsStateCopyWithImpl<$Res, $Val extends SettingsState>
|
||||
implements $SettingsStateCopyWith<$Res> {
|
||||
_$SettingsStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsInitialImplCopyWith<$Res> {
|
||||
factory _$$SettingsInitialImplCopyWith(_$SettingsInitialImpl value,
|
||||
$Res Function(_$SettingsInitialImpl) then) =
|
||||
__$$SettingsInitialImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsInitialImplCopyWithImpl<$Res>
|
||||
extends _$SettingsStateCopyWithImpl<$Res, _$SettingsInitialImpl>
|
||||
implements _$$SettingsInitialImplCopyWith<$Res> {
|
||||
__$$SettingsInitialImplCopyWithImpl(
|
||||
_$SettingsInitialImpl _value, $Res Function(_$SettingsInitialImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsInitialImpl implements SettingsInitial {
|
||||
const _$SettingsInitialImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsState.initial()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$SettingsInitialImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)
|
||||
loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return initial?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsInitial value) initial,
|
||||
required TResult Function(SettingsLoading value) loading,
|
||||
required TResult Function(SettingsLoaded value) loaded,
|
||||
required TResult Function(SettingsError value) error,
|
||||
}) {
|
||||
return initial(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsInitial value)? initial,
|
||||
TResult? Function(SettingsLoading value)? loading,
|
||||
TResult? Function(SettingsLoaded value)? loaded,
|
||||
TResult? Function(SettingsError value)? error,
|
||||
}) {
|
||||
return initial?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsInitial value)? initial,
|
||||
TResult Function(SettingsLoading value)? loading,
|
||||
TResult Function(SettingsLoaded value)? loaded,
|
||||
TResult Function(SettingsError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsInitial implements SettingsState {
|
||||
const factory SettingsInitial() = _$SettingsInitialImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsLoadingImplCopyWith<$Res> {
|
||||
factory _$$SettingsLoadingImplCopyWith(_$SettingsLoadingImpl value,
|
||||
$Res Function(_$SettingsLoadingImpl) then) =
|
||||
__$$SettingsLoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsLoadingImplCopyWithImpl<$Res>
|
||||
extends _$SettingsStateCopyWithImpl<$Res, _$SettingsLoadingImpl>
|
||||
implements _$$SettingsLoadingImplCopyWith<$Res> {
|
||||
__$$SettingsLoadingImplCopyWithImpl(
|
||||
_$SettingsLoadingImpl _value, $Res Function(_$SettingsLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsLoadingImpl implements SettingsLoading {
|
||||
const _$SettingsLoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$SettingsLoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)
|
||||
loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsInitial value) initial,
|
||||
required TResult Function(SettingsLoading value) loading,
|
||||
required TResult Function(SettingsLoaded value) loaded,
|
||||
required TResult Function(SettingsError value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsInitial value)? initial,
|
||||
TResult? Function(SettingsLoading value)? loading,
|
||||
TResult? Function(SettingsLoaded value)? loaded,
|
||||
TResult? Function(SettingsError value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsInitial value)? initial,
|
||||
TResult Function(SettingsLoading value)? loading,
|
||||
TResult Function(SettingsLoaded value)? loaded,
|
||||
TResult Function(SettingsError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsLoading implements SettingsState {
|
||||
const factory SettingsLoading() = _$SettingsLoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsLoadedImplCopyWith<$Res> {
|
||||
factory _$$SettingsLoadedImplCopyWith(_$SettingsLoadedImpl value,
|
||||
$Res Function(_$SettingsLoadedImpl) then) =
|
||||
__$$SettingsLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{String apiUrl,
|
||||
ServerConfig? serverConfig,
|
||||
String languageCode,
|
||||
String? error});
|
||||
|
||||
$ServerConfigCopyWith<$Res>? get serverConfig;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsLoadedImplCopyWithImpl<$Res>
|
||||
extends _$SettingsStateCopyWithImpl<$Res, _$SettingsLoadedImpl>
|
||||
implements _$$SettingsLoadedImplCopyWith<$Res> {
|
||||
__$$SettingsLoadedImplCopyWithImpl(
|
||||
_$SettingsLoadedImpl _value, $Res Function(_$SettingsLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? apiUrl = null,
|
||||
Object? serverConfig = freezed,
|
||||
Object? languageCode = null,
|
||||
Object? error = freezed,
|
||||
}) {
|
||||
return _then(_$SettingsLoadedImpl(
|
||||
apiUrl: null == apiUrl
|
||||
? _value.apiUrl
|
||||
: apiUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
serverConfig: freezed == serverConfig
|
||||
? _value.serverConfig
|
||||
: serverConfig // ignore: cast_nullable_to_non_nullable
|
||||
as ServerConfig?,
|
||||
languageCode: null == languageCode
|
||||
? _value.languageCode
|
||||
: languageCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
error: freezed == error
|
||||
? _value.error
|
||||
: error // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ServerConfigCopyWith<$Res>? get serverConfig {
|
||||
if (_value.serverConfig == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ServerConfigCopyWith<$Res>(_value.serverConfig!, (value) {
|
||||
return _then(_value.copyWith(serverConfig: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsLoadedImpl implements SettingsLoaded {
|
||||
const _$SettingsLoadedImpl(
|
||||
{required this.apiUrl,
|
||||
required this.serverConfig,
|
||||
required this.languageCode,
|
||||
this.error});
|
||||
|
||||
@override
|
||||
final String apiUrl;
|
||||
@override
|
||||
final ServerConfig? serverConfig;
|
||||
@override
|
||||
final String languageCode;
|
||||
@override
|
||||
final String? error;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsState.loaded(apiUrl: $apiUrl, serverConfig: $serverConfig, languageCode: $languageCode, error: $error)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SettingsLoadedImpl &&
|
||||
(identical(other.apiUrl, apiUrl) || other.apiUrl == apiUrl) &&
|
||||
(identical(other.serverConfig, serverConfig) ||
|
||||
other.serverConfig == serverConfig) &&
|
||||
(identical(other.languageCode, languageCode) ||
|
||||
other.languageCode == languageCode) &&
|
||||
(identical(other.error, error) || other.error == error));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, apiUrl, serverConfig, languageCode, error);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SettingsLoadedImplCopyWith<_$SettingsLoadedImpl> get copyWith =>
|
||||
__$$SettingsLoadedImplCopyWithImpl<_$SettingsLoadedImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)
|
||||
loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loaded(apiUrl, serverConfig, languageCode, this.error);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loaded?.call(apiUrl, serverConfig, languageCode, this.error);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(apiUrl, serverConfig, languageCode, this.error);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsInitial value) initial,
|
||||
required TResult Function(SettingsLoading value) loading,
|
||||
required TResult Function(SettingsLoaded value) loaded,
|
||||
required TResult Function(SettingsError value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsInitial value)? initial,
|
||||
TResult? Function(SettingsLoading value)? loading,
|
||||
TResult? Function(SettingsLoaded value)? loaded,
|
||||
TResult? Function(SettingsError value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsInitial value)? initial,
|
||||
TResult Function(SettingsLoading value)? loading,
|
||||
TResult Function(SettingsLoaded value)? loaded,
|
||||
TResult Function(SettingsError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsLoaded implements SettingsState {
|
||||
const factory SettingsLoaded(
|
||||
{required final String apiUrl,
|
||||
required final ServerConfig? serverConfig,
|
||||
required final String languageCode,
|
||||
final String? error}) = _$SettingsLoadedImpl;
|
||||
|
||||
String get apiUrl;
|
||||
ServerConfig? get serverConfig;
|
||||
String get languageCode;
|
||||
String? get error;
|
||||
@JsonKey(ignore: true)
|
||||
_$$SettingsLoadedImplCopyWith<_$SettingsLoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SettingsErrorImplCopyWith<$Res> {
|
||||
factory _$$SettingsErrorImplCopyWith(
|
||||
_$SettingsErrorImpl value, $Res Function(_$SettingsErrorImpl) then) =
|
||||
__$$SettingsErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String message});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SettingsErrorImplCopyWithImpl<$Res>
|
||||
extends _$SettingsStateCopyWithImpl<$Res, _$SettingsErrorImpl>
|
||||
implements _$$SettingsErrorImplCopyWith<$Res> {
|
||||
__$$SettingsErrorImplCopyWithImpl(
|
||||
_$SettingsErrorImpl _value, $Res Function(_$SettingsErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? message = null,
|
||||
}) {
|
||||
return _then(_$SettingsErrorImpl(
|
||||
null == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsErrorImpl implements SettingsError {
|
||||
const _$SettingsErrorImpl(this.message);
|
||||
|
||||
@override
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SettingsState.error(message: $message)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SettingsErrorImpl &&
|
||||
(identical(other.message, message) || other.message == message));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, message);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SettingsErrorImplCopyWith<_$SettingsErrorImpl> get copyWith =>
|
||||
__$$SettingsErrorImplCopyWithImpl<_$SettingsErrorImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)
|
||||
loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return error(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return error?.call(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String apiUrl, ServerConfig? serverConfig,
|
||||
String languageCode, String? error)?
|
||||
loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(message);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(SettingsInitial value) initial,
|
||||
required TResult Function(SettingsLoading value) loading,
|
||||
required TResult Function(SettingsLoaded value) loaded,
|
||||
required TResult Function(SettingsError value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(SettingsInitial value)? initial,
|
||||
TResult? Function(SettingsLoading value)? loading,
|
||||
TResult? Function(SettingsLoaded value)? loaded,
|
||||
TResult? Function(SettingsError value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(SettingsInitial value)? initial,
|
||||
TResult Function(SettingsLoading value)? loading,
|
||||
TResult Function(SettingsLoaded value)? loaded,
|
||||
TResult Function(SettingsError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SettingsError implements SettingsState {
|
||||
const factory SettingsError(final String message) = _$SettingsErrorImpl;
|
||||
|
||||
String get message;
|
||||
@JsonKey(ignore: true)
|
||||
_$$SettingsErrorImplCopyWith<_$SettingsErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
|
||||
import 'app_localizations_en.dart';
|
||||
import 'app_localizations_ru.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// Callers can lookup localized strings with an instance of AppLocalizations
|
||||
/// returned by `AppLocalizations.of(context)`.
|
||||
///
|
||||
/// Applications need to include `AppLocalizations.delegate()` in their app's
|
||||
/// `localizationDelegates` list, and the locales they support in the app's
|
||||
/// `supportedLocales` list. For example:
|
||||
///
|
||||
/// ```dart
|
||||
/// import 'l10n/app_localizations.dart';
|
||||
///
|
||||
/// return MaterialApp(
|
||||
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
/// supportedLocales: AppLocalizations.supportedLocales,
|
||||
/// home: MyApplicationHome(),
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
/// ## Update pubspec.yaml
|
||||
///
|
||||
/// Please make sure to update your pubspec.yaml to include the following
|
||||
/// packages:
|
||||
///
|
||||
/// ```yaml
|
||||
/// dependencies:
|
||||
/// # Internationalization support.
|
||||
/// flutter_localizations:
|
||||
/// sdk: flutter
|
||||
/// intl: any # Use the pinned version from flutter_localizations
|
||||
///
|
||||
/// # Rest of dependencies
|
||||
/// ```
|
||||
///
|
||||
/// ## iOS Applications
|
||||
///
|
||||
/// iOS applications define key application metadata, including supported
|
||||
/// locales, in an Info.plist file that is built into the application bundle.
|
||||
/// To configure the locales supported by your app, you’ll need to edit this
|
||||
/// file.
|
||||
///
|
||||
/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
|
||||
/// Then, in the Project Navigator, open the Info.plist file under the Runner
|
||||
/// project’s Runner folder.
|
||||
///
|
||||
/// Next, select the Information Property List item, select Add Item from the
|
||||
/// Editor menu, then select Localizations from the pop-up menu.
|
||||
///
|
||||
/// Select and expand the newly-created Localizations item then, for each
|
||||
/// locale your application supports, add a new item and select the locale
|
||||
/// you wish to add from the pop-up menu in the Value field. This list should
|
||||
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
|
||||
/// property.
|
||||
abstract class AppLocalizations {
|
||||
AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
|
||||
|
||||
final String localeName;
|
||||
|
||||
static AppLocalizations? of(BuildContext context) {
|
||||
return Localizations.of<AppLocalizations>(context, AppLocalizations);
|
||||
}
|
||||
|
||||
static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();
|
||||
|
||||
/// A list of this localizations delegate along with the default localizations
|
||||
/// delegates.
|
||||
///
|
||||
/// Returns a list of localizations delegates containing this delegate along with
|
||||
/// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
|
||||
/// and GlobalWidgetsLocalizations.delegate.
|
||||
///
|
||||
/// Additional delegates can be added by appending to this list in
|
||||
/// MaterialApp. This list does not have to be used at all if a custom list
|
||||
/// of delegates is preferred or required.
|
||||
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
|
||||
delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
];
|
||||
|
||||
/// A list of this localizations delegate's supported locales.
|
||||
static const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
Locale('ru')
|
||||
];
|
||||
|
||||
/// No description provided for @appTitle.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Messenger'**
|
||||
String get appTitle;
|
||||
|
||||
/// No description provided for @chats.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Chats'**
|
||||
String get chats;
|
||||
|
||||
/// No description provided for @contacts.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Contacts'**
|
||||
String get contacts;
|
||||
|
||||
/// No description provided for @settings.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Settings'**
|
||||
String get settings;
|
||||
|
||||
/// No description provided for @login.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Login'**
|
||||
String get login;
|
||||
|
||||
/// No description provided for @email.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Email'**
|
||||
String get email;
|
||||
|
||||
/// No description provided for @password.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Password'**
|
||||
String get password;
|
||||
|
||||
/// No description provided for @name.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Name'**
|
||||
String get name;
|
||||
|
||||
/// No description provided for @loginButton.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Sign In'**
|
||||
String get loginButton;
|
||||
|
||||
/// No description provided for @register.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Register'**
|
||||
String get register;
|
||||
|
||||
/// No description provided for @noAccount.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'No account? Sign up'**
|
||||
String get noAccount;
|
||||
|
||||
/// No description provided for @logout.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Sign Out'**
|
||||
String get logout;
|
||||
|
||||
/// No description provided for @serverSettings.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Server Settings'**
|
||||
String get serverSettings;
|
||||
|
||||
/// No description provided for @apiUrl.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'API URL'**
|
||||
String get apiUrl;
|
||||
|
||||
/// No description provided for @apiUrlHint.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'https://api.example.com'**
|
||||
String get apiUrlHint;
|
||||
|
||||
/// No description provided for @save.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Save'**
|
||||
String get save;
|
||||
|
||||
/// No description provided for @serverConfig.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Server Configuration'**
|
||||
String get serverConfig;
|
||||
|
||||
/// No description provided for @system.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'System'**
|
||||
String get system;
|
||||
|
||||
/// No description provided for @stories.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Stories'**
|
||||
String get stories;
|
||||
|
||||
/// No description provided for @chatsModule.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Chats'**
|
||||
String get chatsModule;
|
||||
|
||||
/// No description provided for @messages.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Messages'**
|
||||
String get messages;
|
||||
|
||||
/// No description provided for @calls.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Calls'**
|
||||
String get calls;
|
||||
|
||||
/// No description provided for @klipy.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Klipy'**
|
||||
String get klipy;
|
||||
|
||||
/// No description provided for @import.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Import'**
|
||||
String get import;
|
||||
|
||||
/// No description provided for @federation.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Federation'**
|
||||
String get federation;
|
||||
|
||||
/// No description provided for @domainUrl.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Domain'**
|
||||
String get domainUrl;
|
||||
|
||||
/// No description provided for @enableRegistration.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Registration Enabled'**
|
||||
String get enableRegistration;
|
||||
|
||||
/// No description provided for @enabled.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Enabled'**
|
||||
String get enabled;
|
||||
|
||||
/// No description provided for @disabled.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Disabled'**
|
||||
String get disabled;
|
||||
|
||||
/// No description provided for @language.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Language'**
|
||||
String get language;
|
||||
|
||||
/// No description provided for @russian.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Русский'**
|
||||
String get russian;
|
||||
|
||||
/// No description provided for @english.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'English'**
|
||||
String get english;
|
||||
|
||||
/// No description provided for @notifications.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Notifications'**
|
||||
String get notifications;
|
||||
|
||||
/// No description provided for @privacy.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Privacy'**
|
||||
String get privacy;
|
||||
|
||||
/// No description provided for @soundsAndVibration.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Sounds & Vibration'**
|
||||
String get soundsAndVibration;
|
||||
|
||||
/// No description provided for @dataAndStorage.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Data & Storage'**
|
||||
String get dataAndStorage;
|
||||
|
||||
/// No description provided for @aboutApp.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'About App'**
|
||||
String get aboutApp;
|
||||
|
||||
/// No description provided for @help.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Help'**
|
||||
String get help;
|
||||
|
||||
/// No description provided for @version.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Version'**
|
||||
String get version;
|
||||
|
||||
/// No description provided for @loading.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Loading...'**
|
||||
String get loading;
|
||||
|
||||
/// No description provided for @error.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Error'**
|
||||
String get error;
|
||||
|
||||
/// No description provided for @retry.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Retry'**
|
||||
String get retry;
|
||||
|
||||
/// No description provided for @noChats.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'No chats yet'**
|
||||
String get noChats;
|
||||
|
||||
/// No description provided for @inDevelopment.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'In development'**
|
||||
String get inDevelopment;
|
||||
|
||||
/// No description provided for @user.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'User'**
|
||||
String get user;
|
||||
|
||||
/// No description provided for @edit.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Edit'**
|
||||
String get edit;
|
||||
|
||||
/// No description provided for @serverConnectionError.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Server connection error'**
|
||||
String get serverConnectionError;
|
||||
|
||||
/// No description provided for @settingsSaved.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Settings saved'**
|
||||
String get settingsSaved;
|
||||
}
|
||||
|
||||
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
|
||||
const _AppLocalizationsDelegate();
|
||||
|
||||
@override
|
||||
Future<AppLocalizations> load(Locale locale) {
|
||||
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
|
||||
}
|
||||
|
||||
@override
|
||||
bool isSupported(Locale locale) => <String>['en', 'ru'].contains(locale.languageCode);
|
||||
|
||||
@override
|
||||
bool shouldReload(_AppLocalizationsDelegate old) => false;
|
||||
}
|
||||
|
||||
AppLocalizations lookupAppLocalizations(Locale locale) {
|
||||
|
||||
|
||||
// Lookup logic when only language code is specified.
|
||||
switch (locale.languageCode) {
|
||||
case 'en': return AppLocalizationsEn();
|
||||
case 'ru': return AppLocalizationsRu();
|
||||
}
|
||||
|
||||
throw FlutterError(
|
||||
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
|
||||
'an issue with the localizations generation tool. Please file an issue '
|
||||
'on GitHub with a reproducible sample app and the gen-l10n configuration '
|
||||
'that was used.'
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// ignore: unused_import
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
import 'app_localizations.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for English (`en`).
|
||||
class AppLocalizationsEn extends AppLocalizations {
|
||||
AppLocalizationsEn([String locale = 'en']) : super(locale);
|
||||
|
||||
@override
|
||||
String get appTitle => 'Messenger';
|
||||
|
||||
@override
|
||||
String get chats => 'Chats';
|
||||
|
||||
@override
|
||||
String get contacts => 'Contacts';
|
||||
|
||||
@override
|
||||
String get settings => 'Settings';
|
||||
|
||||
@override
|
||||
String get login => 'Login';
|
||||
|
||||
@override
|
||||
String get email => 'Email';
|
||||
|
||||
@override
|
||||
String get password => 'Password';
|
||||
|
||||
@override
|
||||
String get name => 'Name';
|
||||
|
||||
@override
|
||||
String get loginButton => 'Sign In';
|
||||
|
||||
@override
|
||||
String get register => 'Register';
|
||||
|
||||
@override
|
||||
String get noAccount => 'No account? Sign up';
|
||||
|
||||
@override
|
||||
String get logout => 'Sign Out';
|
||||
|
||||
@override
|
||||
String get serverSettings => 'Server Settings';
|
||||
|
||||
@override
|
||||
String get apiUrl => 'API URL';
|
||||
|
||||
@override
|
||||
String get apiUrlHint => 'https://api.example.com';
|
||||
|
||||
@override
|
||||
String get save => 'Save';
|
||||
|
||||
@override
|
||||
String get serverConfig => 'Server Configuration';
|
||||
|
||||
@override
|
||||
String get system => 'System';
|
||||
|
||||
@override
|
||||
String get stories => 'Stories';
|
||||
|
||||
@override
|
||||
String get chatsModule => 'Chats';
|
||||
|
||||
@override
|
||||
String get messages => 'Messages';
|
||||
|
||||
@override
|
||||
String get calls => 'Calls';
|
||||
|
||||
@override
|
||||
String get klipy => 'Klipy';
|
||||
|
||||
@override
|
||||
String get import => 'Import';
|
||||
|
||||
@override
|
||||
String get federation => 'Federation';
|
||||
|
||||
@override
|
||||
String get domainUrl => 'Domain';
|
||||
|
||||
@override
|
||||
String get enableRegistration => 'Registration Enabled';
|
||||
|
||||
@override
|
||||
String get enabled => 'Enabled';
|
||||
|
||||
@override
|
||||
String get disabled => 'Disabled';
|
||||
|
||||
@override
|
||||
String get language => 'Language';
|
||||
|
||||
@override
|
||||
String get russian => 'Русский';
|
||||
|
||||
@override
|
||||
String get english => 'English';
|
||||
|
||||
@override
|
||||
String get notifications => 'Notifications';
|
||||
|
||||
@override
|
||||
String get privacy => 'Privacy';
|
||||
|
||||
@override
|
||||
String get soundsAndVibration => 'Sounds & Vibration';
|
||||
|
||||
@override
|
||||
String get dataAndStorage => 'Data & Storage';
|
||||
|
||||
@override
|
||||
String get aboutApp => 'About App';
|
||||
|
||||
@override
|
||||
String get help => 'Help';
|
||||
|
||||
@override
|
||||
String get version => 'Version';
|
||||
|
||||
@override
|
||||
String get loading => 'Loading...';
|
||||
|
||||
@override
|
||||
String get error => 'Error';
|
||||
|
||||
@override
|
||||
String get retry => 'Retry';
|
||||
|
||||
@override
|
||||
String get noChats => 'No chats yet';
|
||||
|
||||
@override
|
||||
String get inDevelopment => 'In development';
|
||||
|
||||
@override
|
||||
String get user => 'User';
|
||||
|
||||
@override
|
||||
String get edit => 'Edit';
|
||||
|
||||
@override
|
||||
String get serverConnectionError => 'Server connection error';
|
||||
|
||||
@override
|
||||
String get settingsSaved => 'Settings saved';
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// ignore: unused_import
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
import 'app_localizations.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for Russian (`ru`).
|
||||
class AppLocalizationsRu extends AppLocalizations {
|
||||
AppLocalizationsRu([String locale = 'ru']) : super(locale);
|
||||
|
||||
@override
|
||||
String get appTitle => 'Мессенджер';
|
||||
|
||||
@override
|
||||
String get chats => 'Чаты';
|
||||
|
||||
@override
|
||||
String get contacts => 'Контакты';
|
||||
|
||||
@override
|
||||
String get settings => 'Настройки';
|
||||
|
||||
@override
|
||||
String get login => 'Вход';
|
||||
|
||||
@override
|
||||
String get email => 'Email';
|
||||
|
||||
@override
|
||||
String get password => 'Пароль';
|
||||
|
||||
@override
|
||||
String get name => 'Имя';
|
||||
|
||||
@override
|
||||
String get loginButton => 'Войти';
|
||||
|
||||
@override
|
||||
String get register => 'Зарегистрироваться';
|
||||
|
||||
@override
|
||||
String get noAccount => 'Нет аккаунта? Зарегистрироваться';
|
||||
|
||||
@override
|
||||
String get logout => 'Выйти из аккаунта';
|
||||
|
||||
@override
|
||||
String get serverSettings => 'Настройки сервера';
|
||||
|
||||
@override
|
||||
String get apiUrl => 'Адрес API';
|
||||
|
||||
@override
|
||||
String get apiUrlHint => 'https://api.example.com';
|
||||
|
||||
@override
|
||||
String get save => 'Сохранить';
|
||||
|
||||
@override
|
||||
String get serverConfig => 'Конфигурация сервера';
|
||||
|
||||
@override
|
||||
String get system => 'Система';
|
||||
|
||||
@override
|
||||
String get stories => 'Истории';
|
||||
|
||||
@override
|
||||
String get chatsModule => 'Чаты';
|
||||
|
||||
@override
|
||||
String get messages => 'Сообщения';
|
||||
|
||||
@override
|
||||
String get calls => 'Звонки';
|
||||
|
||||
@override
|
||||
String get klipy => 'Клипы';
|
||||
|
||||
@override
|
||||
String get import => 'Импорт';
|
||||
|
||||
@override
|
||||
String get federation => 'Федерация';
|
||||
|
||||
@override
|
||||
String get domainUrl => 'Домен';
|
||||
|
||||
@override
|
||||
String get enableRegistration => 'Регистрация включена';
|
||||
|
||||
@override
|
||||
String get enabled => 'Включено';
|
||||
|
||||
@override
|
||||
String get disabled => 'Отключено';
|
||||
|
||||
@override
|
||||
String get language => 'Язык';
|
||||
|
||||
@override
|
||||
String get russian => 'Русский';
|
||||
|
||||
@override
|
||||
String get english => 'English';
|
||||
|
||||
@override
|
||||
String get notifications => 'Уведомления';
|
||||
|
||||
@override
|
||||
String get privacy => 'Конфиденциальность';
|
||||
|
||||
@override
|
||||
String get soundsAndVibration => 'Звуки и вибрация';
|
||||
|
||||
@override
|
||||
String get dataAndStorage => 'Данные и память';
|
||||
|
||||
@override
|
||||
String get aboutApp => 'О приложении';
|
||||
|
||||
@override
|
||||
String get help => 'Помощь';
|
||||
|
||||
@override
|
||||
String get version => 'Версия';
|
||||
|
||||
@override
|
||||
String get loading => 'Загрузка...';
|
||||
|
||||
@override
|
||||
String get error => 'Ошибка';
|
||||
|
||||
@override
|
||||
String get retry => 'Повторить';
|
||||
|
||||
@override
|
||||
String get noChats => 'У вас пока нет чатов';
|
||||
|
||||
@override
|
||||
String get inDevelopment => 'Функция в разработке';
|
||||
|
||||
@override
|
||||
String get user => 'Пользователь';
|
||||
|
||||
@override
|
||||
String get edit => 'Редактировать';
|
||||
|
||||
@override
|
||||
String get serverConnectionError => 'Ошибка подключения к серверу';
|
||||
|
||||
@override
|
||||
String get settingsSaved => 'Настройки сохранены';
|
||||
}
|
||||
@@ -0,0 +1,424 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../../domain/entities/server_config.dart';
|
||||
import '../bloc/settings_bloc.dart';
|
||||
import '../bloc/settings_event.dart';
|
||||
import '../bloc/settings_state.dart';
|
||||
|
||||
class SettingsPage extends StatelessWidget {
|
||||
const SettingsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<SettingsBloc, SettingsState>(
|
||||
builder: (context, state) {
|
||||
return state.when(
|
||||
initial: () => const Center(child: CircularProgressIndicator()),
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
loaded: (apiUrl, serverConfig, languageCode, error) => _SettingsContent(
|
||||
apiUrl: apiUrl,
|
||||
serverConfig: serverConfig,
|
||||
languageCode: languageCode,
|
||||
error: error,
|
||||
),
|
||||
error: (message) => Center(child: Text(message)),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SettingsContent extends StatelessWidget {
|
||||
final String apiUrl;
|
||||
final ServerConfig? serverConfig;
|
||||
final String languageCode;
|
||||
final String? error;
|
||||
|
||||
const _SettingsContent({
|
||||
required this.apiUrl,
|
||||
required this.serverConfig,
|
||||
required this.languageCode,
|
||||
this.error,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
return ListView(
|
||||
children: [
|
||||
_SectionHeader(title: l10n.serverSettings),
|
||||
_ApiUrlTile(
|
||||
apiUrl: apiUrl,
|
||||
onSave: (url) {
|
||||
context.read<SettingsBloc>().add(SettingsApiUrlSaved(url));
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
_SectionHeader(title: l10n.language),
|
||||
_LanguageTile(
|
||||
currentCode: languageCode,
|
||||
onChanged: (code) {
|
||||
context.read<SettingsBloc>().add(SettingsLanguageChanged(code));
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
if (serverConfig != null) ...[
|
||||
_SectionHeader(title: l10n.serverConfig),
|
||||
_ConfigModuleCard(
|
||||
title: l10n.system,
|
||||
icon: Icons.computer,
|
||||
children: [
|
||||
_ConfigItem(label: l10n.domainUrl, value: serverConfig!.system.domainUrl),
|
||||
_ConfigItem(label: l10n.enableRegistration, value: serverConfig!.system.enableRegistration ? l10n.enabled : l10n.disabled),
|
||||
],
|
||||
),
|
||||
_ConfigModuleCard(
|
||||
title: l10n.messages,
|
||||
icon: Icons.message,
|
||||
children: [
|
||||
_ConfigItem(label: l10n.enabled, value: serverConfig!.messages.allowMedia ? l10n.enabled : l10n.disabled),
|
||||
_ConfigItem(label: 'Max media size', value: '${(serverConfig!.messages.maxMediaSizeBytes / 1024 / 1024).toStringAsFixed(1)} MB'),
|
||||
],
|
||||
),
|
||||
_ConfigModuleCard(
|
||||
title: l10n.calls,
|
||||
icon: Icons.call,
|
||||
children: [
|
||||
_ConfigItem(label: l10n.enabled, value: serverConfig!.webRtc.enabled ? l10n.enabled : l10n.disabled),
|
||||
_ConfigItem(label: 'Voice calls', value: serverConfig!.webRtc.enableVoiceCalls ? l10n.enabled : l10n.disabled),
|
||||
_ConfigItem(label: 'Video calls', value: serverConfig!.webRtc.enableVideoCalls ? l10n.enabled : l10n.disabled),
|
||||
],
|
||||
),
|
||||
_ConfigModuleCard(
|
||||
title: l10n.stories,
|
||||
icon: Icons.auto_stories,
|
||||
children: [
|
||||
_ConfigItem(label: l10n.enabled, value: serverConfig!.stories.enabled ? l10n.enabled : l10n.disabled),
|
||||
_ConfigItem(label: 'Lifetime', value: '${serverConfig!.stories.storyLifetimeHours}h'),
|
||||
],
|
||||
),
|
||||
_ConfigModuleCard(
|
||||
title: l10n.chatsModule,
|
||||
icon: Icons.chat_bubble,
|
||||
children: [
|
||||
_ConfigItem(label: 'Groups', value: serverConfig!.chats.supportGroups ? l10n.enabled : l10n.disabled),
|
||||
_ConfigItem(label: 'Max participants', value: '${serverConfig!.chats.maxGroupParticipants}'),
|
||||
],
|
||||
),
|
||||
if (serverConfig!.federation.enabled)
|
||||
_ConfigModuleCard(
|
||||
title: l10n.federation,
|
||||
icon: Icons.public,
|
||||
children: [
|
||||
_ConfigItem(label: 'Description', value: serverConfig!.federation.serverDescription),
|
||||
],
|
||||
),
|
||||
const Divider(),
|
||||
],
|
||||
|
||||
if (serverConfig == null)
|
||||
ListTile(
|
||||
leading: const Icon(Icons.refresh),
|
||||
title: Text(l10n.retry),
|
||||
onTap: () {
|
||||
context.read<SettingsBloc>().add(const SettingsRefreshConfig());
|
||||
},
|
||||
),
|
||||
|
||||
_SectionHeader(title: l10n.settings),
|
||||
_SettingsTile(
|
||||
icon: Icons.notifications_outlined,
|
||||
title: l10n.notifications,
|
||||
onTap: () {},
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.security,
|
||||
title: l10n.privacy,
|
||||
onTap: () {},
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.volume_up,
|
||||
title: l10n.soundsAndVibration,
|
||||
onTap: () {},
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.storage,
|
||||
title: l10n.dataAndStorage,
|
||||
onTap: () {},
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
_SettingsTile(
|
||||
icon: Icons.info_outline,
|
||||
title: l10n.aboutApp,
|
||||
subtitle: '${l10n.version} 1.0.0',
|
||||
onTap: () {},
|
||||
),
|
||||
_SettingsTile(
|
||||
icon: Icons.help_outline,
|
||||
title: l10n.help,
|
||||
onTap: () {},
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: OutlinedButton(
|
||||
onPressed: () {},
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Colors.red,
|
||||
side: const BorderSide(color: Colors.red),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Text(l10n.logout),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SectionHeader extends StatelessWidget {
|
||||
final String title;
|
||||
|
||||
const _SectionHeader({required this.title});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
|
||||
child: Text(
|
||||
title.toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ApiUrlTile extends StatefulWidget {
|
||||
final String apiUrl;
|
||||
final ValueChanged<String> onSave;
|
||||
|
||||
const _ApiUrlTile({
|
||||
required this.apiUrl,
|
||||
required this.onSave,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_ApiUrlTile> createState() => _ApiUrlTileState();
|
||||
}
|
||||
|
||||
class _ApiUrlTileState extends State<_ApiUrlTile> {
|
||||
late final TextEditingController _controller;
|
||||
bool _isEditing = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = TextEditingController(text: widget.apiUrl);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant _ApiUrlTile oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.apiUrl != widget.apiUrl) {
|
||||
_controller.text = widget.apiUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
if (_isEditing) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.apiUrl,
|
||||
hintText: l10n.apiUrlHint,
|
||||
border: const OutlineInputBorder(),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
),
|
||||
keyboardType: TextInputType.url,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.check, color: Colors.green),
|
||||
onPressed: () {
|
||||
widget.onSave(_controller.text.trim());
|
||||
setState(() => _isEditing = false);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.red),
|
||||
onPressed: () {
|
||||
_controller.text = widget.apiUrl;
|
||||
setState(() => _isEditing = false);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.link),
|
||||
title: Text(l10n.apiUrl),
|
||||
subtitle: Text(
|
||||
widget.apiUrl.isEmpty ? l10n.apiUrlHint : widget.apiUrl,
|
||||
style: TextStyle(
|
||||
color: widget.apiUrl.isEmpty ? Colors.grey : null,
|
||||
),
|
||||
),
|
||||
trailing: const Icon(Icons.edit),
|
||||
onTap: () => setState(() => _isEditing = true),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LanguageTile extends StatelessWidget {
|
||||
final String currentCode;
|
||||
final ValueChanged<String> onChanged;
|
||||
|
||||
const _LanguageTile({
|
||||
required this.currentCode,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.language),
|
||||
title: Text(l10n.language),
|
||||
subtitle: Text(currentCode == 'ru' ? l10n.russian : l10n.english),
|
||||
trailing: DropdownButton<String>(
|
||||
value: currentCode,
|
||||
underline: const SizedBox(),
|
||||
items: [
|
||||
DropdownMenuItem(value: 'ru', child: Text(l10n.russian)),
|
||||
DropdownMenuItem(value: 'en', child: Text(l10n.english)),
|
||||
],
|
||||
onChanged: (value) {
|
||||
if (value != null) onChanged(value);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ConfigModuleCard extends StatelessWidget {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final List<Widget> children;
|
||||
|
||||
const _ConfigModuleCard({
|
||||
required this.title,
|
||||
required this.icon,
|
||||
required this.children,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
child: ExpansionTile(
|
||||
leading: Icon(icon, color: Theme.of(context).colorScheme.primary),
|
||||
title: Text(title),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
||||
child: Column(
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ConfigItem extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
const _ConfigItem({
|
||||
required this.label,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600],
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SettingsTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _SettingsTile({
|
||||
required this.icon,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: Icon(icon),
|
||||
title: Text(title),
|
||||
subtitle: subtitle != null ? Text(subtitle!) : null,
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user