mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
一堆乱七八糟的修改
播放页面增加桌面版
This commit is contained in:
parent
aee1fbde88
commit
3ba35b31b8
116 changed files with 1238 additions and 2592 deletions
23
lib/features/settings/models/api_settings.dart
Normal file
23
lib/features/settings/models/api_settings.dart
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// a freezed class to store the settings of the app
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:vaani/features/settings/models/audiobookshelf_server.dart';
|
||||
import 'package:vaani/features/settings/models/authenticated_user.dart';
|
||||
|
||||
part 'api_settings.freezed.dart';
|
||||
part 'api_settings.g.dart';
|
||||
|
||||
/// stores the settings for the active server and user
|
||||
///
|
||||
/// all settings that are needed to interact with the server are stored here
|
||||
@freezed
|
||||
class ApiSettings with _$ApiSettings {
|
||||
const factory ApiSettings({
|
||||
AudiobookShelfServer? activeServer,
|
||||
AuthenticatedUser? activeUser,
|
||||
String? activeLibraryId,
|
||||
}) = _ApiSettings;
|
||||
|
||||
factory ApiSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$ApiSettingsFromJson(json);
|
||||
}
|
||||
246
lib/features/settings/models/api_settings.freezed.dart
Normal file
246
lib/features/settings/models/api_settings.freezed.dart
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
// 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 'api_settings.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
ApiSettings _$ApiSettingsFromJson(Map<String, dynamic> json) {
|
||||
return _ApiSettings.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ApiSettings {
|
||||
AudiobookShelfServer? get activeServer => throw _privateConstructorUsedError;
|
||||
AuthenticatedUser? get activeUser => throw _privateConstructorUsedError;
|
||||
String? get activeLibraryId => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this ApiSettings to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ApiSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ApiSettingsCopyWith<ApiSettings> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ApiSettingsCopyWith<$Res> {
|
||||
factory $ApiSettingsCopyWith(
|
||||
ApiSettings value, $Res Function(ApiSettings) then) =
|
||||
_$ApiSettingsCopyWithImpl<$Res, ApiSettings>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{AudiobookShelfServer? activeServer,
|
||||
AuthenticatedUser? activeUser,
|
||||
String? activeLibraryId});
|
||||
|
||||
$AudiobookShelfServerCopyWith<$Res>? get activeServer;
|
||||
$AuthenticatedUserCopyWith<$Res>? get activeUser;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ApiSettingsCopyWithImpl<$Res, $Val extends ApiSettings>
|
||||
implements $ApiSettingsCopyWith<$Res> {
|
||||
_$ApiSettingsCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ApiSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? activeServer = freezed,
|
||||
Object? activeUser = freezed,
|
||||
Object? activeLibraryId = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
activeServer: freezed == activeServer
|
||||
? _value.activeServer
|
||||
: activeServer // ignore: cast_nullable_to_non_nullable
|
||||
as AudiobookShelfServer?,
|
||||
activeUser: freezed == activeUser
|
||||
? _value.activeUser
|
||||
: activeUser // ignore: cast_nullable_to_non_nullable
|
||||
as AuthenticatedUser?,
|
||||
activeLibraryId: freezed == activeLibraryId
|
||||
? _value.activeLibraryId
|
||||
: activeLibraryId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
/// Create a copy of ApiSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AudiobookShelfServerCopyWith<$Res>? get activeServer {
|
||||
if (_value.activeServer == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AudiobookShelfServerCopyWith<$Res>(_value.activeServer!, (value) {
|
||||
return _then(_value.copyWith(activeServer: value) as $Val);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of ApiSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AuthenticatedUserCopyWith<$Res>? get activeUser {
|
||||
if (_value.activeUser == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $AuthenticatedUserCopyWith<$Res>(_value.activeUser!, (value) {
|
||||
return _then(_value.copyWith(activeUser: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ApiSettingsImplCopyWith<$Res>
|
||||
implements $ApiSettingsCopyWith<$Res> {
|
||||
factory _$$ApiSettingsImplCopyWith(
|
||||
_$ApiSettingsImpl value, $Res Function(_$ApiSettingsImpl) then) =
|
||||
__$$ApiSettingsImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{AudiobookShelfServer? activeServer,
|
||||
AuthenticatedUser? activeUser,
|
||||
String? activeLibraryId});
|
||||
|
||||
@override
|
||||
$AudiobookShelfServerCopyWith<$Res>? get activeServer;
|
||||
@override
|
||||
$AuthenticatedUserCopyWith<$Res>? get activeUser;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ApiSettingsImplCopyWithImpl<$Res>
|
||||
extends _$ApiSettingsCopyWithImpl<$Res, _$ApiSettingsImpl>
|
||||
implements _$$ApiSettingsImplCopyWith<$Res> {
|
||||
__$$ApiSettingsImplCopyWithImpl(
|
||||
_$ApiSettingsImpl _value, $Res Function(_$ApiSettingsImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ApiSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? activeServer = freezed,
|
||||
Object? activeUser = freezed,
|
||||
Object? activeLibraryId = freezed,
|
||||
}) {
|
||||
return _then(_$ApiSettingsImpl(
|
||||
activeServer: freezed == activeServer
|
||||
? _value.activeServer
|
||||
: activeServer // ignore: cast_nullable_to_non_nullable
|
||||
as AudiobookShelfServer?,
|
||||
activeUser: freezed == activeUser
|
||||
? _value.activeUser
|
||||
: activeUser // ignore: cast_nullable_to_non_nullable
|
||||
as AuthenticatedUser?,
|
||||
activeLibraryId: freezed == activeLibraryId
|
||||
? _value.activeLibraryId
|
||||
: activeLibraryId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ApiSettingsImpl implements _ApiSettings {
|
||||
const _$ApiSettingsImpl(
|
||||
{this.activeServer, this.activeUser, this.activeLibraryId});
|
||||
|
||||
factory _$ApiSettingsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ApiSettingsImplFromJson(json);
|
||||
|
||||
@override
|
||||
final AudiobookShelfServer? activeServer;
|
||||
@override
|
||||
final AuthenticatedUser? activeUser;
|
||||
@override
|
||||
final String? activeLibraryId;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ApiSettings(activeServer: $activeServer, activeUser: $activeUser, activeLibraryId: $activeLibraryId)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ApiSettingsImpl &&
|
||||
(identical(other.activeServer, activeServer) ||
|
||||
other.activeServer == activeServer) &&
|
||||
(identical(other.activeUser, activeUser) ||
|
||||
other.activeUser == activeUser) &&
|
||||
(identical(other.activeLibraryId, activeLibraryId) ||
|
||||
other.activeLibraryId == activeLibraryId));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, activeServer, activeUser, activeLibraryId);
|
||||
|
||||
/// Create a copy of ApiSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ApiSettingsImplCopyWith<_$ApiSettingsImpl> get copyWith =>
|
||||
__$$ApiSettingsImplCopyWithImpl<_$ApiSettingsImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ApiSettingsImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ApiSettings implements ApiSettings {
|
||||
const factory _ApiSettings(
|
||||
{final AudiobookShelfServer? activeServer,
|
||||
final AuthenticatedUser? activeUser,
|
||||
final String? activeLibraryId}) = _$ApiSettingsImpl;
|
||||
|
||||
factory _ApiSettings.fromJson(Map<String, dynamic> json) =
|
||||
_$ApiSettingsImpl.fromJson;
|
||||
|
||||
@override
|
||||
AudiobookShelfServer? get activeServer;
|
||||
@override
|
||||
AuthenticatedUser? get activeUser;
|
||||
@override
|
||||
String? get activeLibraryId;
|
||||
|
||||
/// Create a copy of ApiSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ApiSettingsImplCopyWith<_$ApiSettingsImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
27
lib/features/settings/models/api_settings.g.dart
Normal file
27
lib/features/settings/models/api_settings.g.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'api_settings.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ApiSettingsImpl _$$ApiSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ApiSettingsImpl(
|
||||
activeServer: json['activeServer'] == null
|
||||
? null
|
||||
: AudiobookShelfServer.fromJson(
|
||||
json['activeServer'] as Map<String, dynamic>),
|
||||
activeUser: json['activeUser'] == null
|
||||
? null
|
||||
: AuthenticatedUser.fromJson(
|
||||
json['activeUser'] as Map<String, dynamic>),
|
||||
activeLibraryId: json['activeLibraryId'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ApiSettingsImplToJson(_$ApiSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'activeServer': instance.activeServer,
|
||||
'activeUser': instance.activeUser,
|
||||
'activeLibraryId': instance.activeLibraryId,
|
||||
};
|
||||
247
lib/features/settings/models/app_settings.dart
Normal file
247
lib/features/settings/models/app_settings.dart
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
// a freezed class to store the settings of the app
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'app_settings.freezed.dart';
|
||||
part 'app_settings.g.dart';
|
||||
|
||||
/// stores the settings of the app
|
||||
///
|
||||
/// only the visual settings are stored here
|
||||
@freezed
|
||||
class AppSettings with _$AppSettings {
|
||||
const factory AppSettings({
|
||||
@Default('zh') String language,
|
||||
@Default(ThemeSettings()) ThemeSettings themeSettings,
|
||||
@Default(PlayerSettings()) PlayerSettings playerSettings,
|
||||
@Default(SleepTimerSettings()) SleepTimerSettings sleepTimerSettings,
|
||||
@Default(DownloadSettings()) DownloadSettings downloadSettings,
|
||||
@Default(NotificationSettings()) NotificationSettings notificationSettings,
|
||||
@Default(ShakeDetectionSettings())
|
||||
ShakeDetectionSettings shakeDetectionSettings,
|
||||
@Default(HomePageSettings()) HomePageSettings homePageSettings,
|
||||
}) = _AppSettings;
|
||||
|
||||
factory AppSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$AppSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ThemeSettings with _$ThemeSettings {
|
||||
const factory ThemeSettings({
|
||||
@Default(ThemeMode.system) ThemeMode themeMode,
|
||||
@Default(false) bool highContrast,
|
||||
@Default(false) bool useMaterialThemeFromSystem,
|
||||
@Default('#FF311B92') String customThemeColor,
|
||||
@Default(true) bool useMaterialThemeOnItemPage,
|
||||
@Default(true) bool useCurrentPlayerThemeThroughoutApp,
|
||||
}) = _ThemeSettings;
|
||||
|
||||
factory ThemeSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$ThemeSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PlayerSettings with _$PlayerSettings {
|
||||
const factory PlayerSettings({
|
||||
@Default(MinimizedPlayerSettings())
|
||||
MinimizedPlayerSettings miniPlayerSettings,
|
||||
@Default(ExpandedPlayerSettings())
|
||||
ExpandedPlayerSettings expandedPlayerSettings,
|
||||
@Default(1) double preferredDefaultVolume,
|
||||
@Default(1) double preferredDefaultSpeed,
|
||||
@Default([1, 1.25, 1.5, 1.75, 2]) List<double> speedOptions,
|
||||
@Default(0.05) double speedIncrement,
|
||||
@Default(0.1) double minSpeed,
|
||||
@Default(4) double maxSpeed,
|
||||
@Default(Duration(seconds: 10)) Duration minimumPositionForReporting,
|
||||
@Default(Duration(seconds: 10)) Duration playbackReportInterval,
|
||||
@Default(Duration(seconds: 15)) Duration markCompleteWhenTimeLeft,
|
||||
@Default(true) bool configurePlayerForEveryBook,
|
||||
}) = _PlayerSettings;
|
||||
|
||||
factory PlayerSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$PlayerSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class ExpandedPlayerSettings with _$ExpandedPlayerSettings {
|
||||
const factory ExpandedPlayerSettings({
|
||||
@Default(false) bool showTotalProgress,
|
||||
@Default(true) bool showChapterProgress,
|
||||
}) = _ExpandedPlayerSettings;
|
||||
|
||||
factory ExpandedPlayerSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$ExpandedPlayerSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class MinimizedPlayerSettings with _$MinimizedPlayerSettings {
|
||||
const factory MinimizedPlayerSettings({
|
||||
@Default(false) bool useChapterInfo,
|
||||
}) = _MinimizedPlayerSettings;
|
||||
|
||||
factory MinimizedPlayerSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$MinimizedPlayerSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SleepTimerSettings with _$SleepTimerSettings {
|
||||
const factory SleepTimerSettings({
|
||||
@Default(Duration(minutes: 15)) Duration defaultDuration,
|
||||
@Default(
|
||||
[
|
||||
Duration(minutes: 5),
|
||||
Duration(minutes: 10),
|
||||
Duration(minutes: 15),
|
||||
Duration(minutes: 20),
|
||||
Duration(minutes: 30),
|
||||
],
|
||||
)
|
||||
List<Duration> presetDurations,
|
||||
@Default(Duration(minutes: 100)) Duration maxDuration,
|
||||
@Default(false) bool fadeOutAudio,
|
||||
@Default(Duration(seconds: 20)) Duration fadeOutDuration,
|
||||
|
||||
/// if true, the player will automatically rewind the audio when the sleep timer is stopped
|
||||
@Default(false) bool autoRewindWhenStopped,
|
||||
|
||||
/// the key is the duration in minutes
|
||||
@Default({
|
||||
5: Duration(seconds: 10),
|
||||
15: Duration(seconds: 30),
|
||||
45: Duration(seconds: 45),
|
||||
60: Duration(minutes: 1),
|
||||
120: Duration(minutes: 2),
|
||||
})
|
||||
Map<int, Duration> autoRewindDurations,
|
||||
|
||||
/// auto turn on timer settings
|
||||
@Default(false) bool autoTurnOnTimer,
|
||||
|
||||
/// always auto turn on timer settings or during specific times
|
||||
@Default(false) bool alwaysAutoTurnOnTimer,
|
||||
|
||||
/// auto timer settings, only used if [alwaysAutoTurnOnTimer] is false
|
||||
///
|
||||
/// duration is the time from 00:00
|
||||
@Default(Duration(hours: 22, minutes: 0)) Duration autoTurnOnTime,
|
||||
@Default(Duration(hours: 6, minutes: 0)) Duration autoTurnOffTime,
|
||||
}) = _SleepTimerSettings;
|
||||
|
||||
factory SleepTimerSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$SleepTimerSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class DownloadSettings with _$DownloadSettings {
|
||||
const factory DownloadSettings({
|
||||
@Default(true) bool requiresWiFi,
|
||||
@Default(3) int retries,
|
||||
@Default(true) bool allowPause,
|
||||
@Default(3) int maxConcurrent,
|
||||
@Default(3) int maxConcurrentByHost,
|
||||
@Default(3) int maxConcurrentByGroup,
|
||||
}) = _DownloadSettings;
|
||||
|
||||
factory DownloadSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$DownloadSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class NotificationSettings with _$NotificationSettings {
|
||||
const factory NotificationSettings({
|
||||
@Default(Duration(seconds: 30)) Duration fastForwardInterval,
|
||||
@Default(Duration(seconds: 10)) Duration rewindInterval,
|
||||
@Default(true) bool progressBarIsChapterProgress,
|
||||
@Default('\$bookTitle') String primaryTitle,
|
||||
@Default('\$author') String secondaryTitle,
|
||||
@Default(
|
||||
[
|
||||
NotificationMediaControl.rewind,
|
||||
NotificationMediaControl.fastForward,
|
||||
NotificationMediaControl.skipToPreviousChapter,
|
||||
NotificationMediaControl.skipToNextChapter,
|
||||
],
|
||||
)
|
||||
List<NotificationMediaControl> mediaControls,
|
||||
}) = _NotificationSettings;
|
||||
|
||||
factory NotificationSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$NotificationSettingsFromJson(json);
|
||||
}
|
||||
|
||||
enum NotificationTitleType {
|
||||
chapterTitle,
|
||||
bookTitle,
|
||||
author,
|
||||
subtitle,
|
||||
series,
|
||||
narrator,
|
||||
year,
|
||||
}
|
||||
|
||||
enum NotificationMediaControl {
|
||||
fastForward(Icons.fast_forward),
|
||||
rewind(Icons.fast_rewind),
|
||||
speedToggle(Icons.speed),
|
||||
stop(Icons.stop),
|
||||
skipToNextChapter(Icons.skip_next),
|
||||
skipToPreviousChapter(Icons.skip_previous);
|
||||
|
||||
const NotificationMediaControl(this.icon);
|
||||
|
||||
final IconData icon;
|
||||
}
|
||||
|
||||
/// Shake Detection Settings
|
||||
@freezed
|
||||
class ShakeDetectionSettings with _$ShakeDetectionSettings {
|
||||
const factory ShakeDetectionSettings({
|
||||
@Default(true) bool isEnabled,
|
||||
@Default(ShakeDirection.horizontal) ShakeDirection direction,
|
||||
@Default(5) double threshold,
|
||||
@Default(ShakeAction.resetSleepTimer) ShakeAction shakeAction,
|
||||
@Default({ShakeDetectedFeedback.vibrate})
|
||||
Set<ShakeDetectedFeedback> feedback,
|
||||
@Default(0.5) double beepVolume,
|
||||
|
||||
/// the duration to wait before the shake detection is enabled again
|
||||
@Default(Duration(seconds: 2)) Duration shakeTriggerCoolDown,
|
||||
|
||||
/// the number of shakes required to trigger the action
|
||||
@Default(2) int shakeTriggerCount,
|
||||
|
||||
/// acceleration sampling interval
|
||||
@Default(Duration(milliseconds: 100)) Duration samplingPeriod,
|
||||
}) = _ShakeDetectionSettings;
|
||||
|
||||
factory ShakeDetectionSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$ShakeDetectionSettingsFromJson(json);
|
||||
}
|
||||
|
||||
enum ShakeDirection { horizontal, vertical }
|
||||
|
||||
enum ShakeAction {
|
||||
none,
|
||||
playPause,
|
||||
resetSleepTimer,
|
||||
fastForward,
|
||||
rewind,
|
||||
}
|
||||
|
||||
enum ShakeDetectedFeedback { vibrate, beep }
|
||||
|
||||
@freezed
|
||||
class HomePageSettings with _$HomePageSettings {
|
||||
const factory HomePageSettings({
|
||||
@Default(true) bool showPlayButtonOnContinueListeningShelf,
|
||||
@Default(false) bool showPlayButtonOnContinueSeriesShelf,
|
||||
@Default(false) bool showPlayButtonOnAllRemainingShelves,
|
||||
@Default(false) bool showPlayButtonOnListenAgainShelf,
|
||||
}) = _HomePageSettings;
|
||||
|
||||
factory HomePageSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$HomePageSettingsFromJson(json);
|
||||
}
|
||||
3133
lib/features/settings/models/app_settings.freezed.dart
Normal file
3133
lib/features/settings/models/app_settings.freezed.dart
Normal file
File diff suppressed because it is too large
Load diff
386
lib/features/settings/models/app_settings.g.dart
Normal file
386
lib/features/settings/models/app_settings.g.dart
Normal file
|
|
@ -0,0 +1,386 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'app_settings.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AppSettingsImpl _$$AppSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||
_$AppSettingsImpl(
|
||||
language: json['language'] as String? ?? 'zh',
|
||||
themeSettings: json['themeSettings'] == null
|
||||
? const ThemeSettings()
|
||||
: ThemeSettings.fromJson(
|
||||
json['themeSettings'] as Map<String, dynamic>),
|
||||
playerSettings: json['playerSettings'] == null
|
||||
? const PlayerSettings()
|
||||
: PlayerSettings.fromJson(
|
||||
json['playerSettings'] as Map<String, dynamic>),
|
||||
sleepTimerSettings: json['sleepTimerSettings'] == null
|
||||
? const SleepTimerSettings()
|
||||
: SleepTimerSettings.fromJson(
|
||||
json['sleepTimerSettings'] as Map<String, dynamic>),
|
||||
downloadSettings: json['downloadSettings'] == null
|
||||
? const DownloadSettings()
|
||||
: DownloadSettings.fromJson(
|
||||
json['downloadSettings'] as Map<String, dynamic>),
|
||||
notificationSettings: json['notificationSettings'] == null
|
||||
? const NotificationSettings()
|
||||
: NotificationSettings.fromJson(
|
||||
json['notificationSettings'] as Map<String, dynamic>),
|
||||
shakeDetectionSettings: json['shakeDetectionSettings'] == null
|
||||
? const ShakeDetectionSettings()
|
||||
: ShakeDetectionSettings.fromJson(
|
||||
json['shakeDetectionSettings'] as Map<String, dynamic>),
|
||||
homePageSettings: json['homePageSettings'] == null
|
||||
? const HomePageSettings()
|
||||
: HomePageSettings.fromJson(
|
||||
json['homePageSettings'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AppSettingsImplToJson(_$AppSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'language': instance.language,
|
||||
'themeSettings': instance.themeSettings,
|
||||
'playerSettings': instance.playerSettings,
|
||||
'sleepTimerSettings': instance.sleepTimerSettings,
|
||||
'downloadSettings': instance.downloadSettings,
|
||||
'notificationSettings': instance.notificationSettings,
|
||||
'shakeDetectionSettings': instance.shakeDetectionSettings,
|
||||
'homePageSettings': instance.homePageSettings,
|
||||
};
|
||||
|
||||
_$ThemeSettingsImpl _$$ThemeSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||
_$ThemeSettingsImpl(
|
||||
themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']) ??
|
||||
ThemeMode.system,
|
||||
highContrast: json['highContrast'] as bool? ?? false,
|
||||
useMaterialThemeFromSystem:
|
||||
json['useMaterialThemeFromSystem'] as bool? ?? false,
|
||||
customThemeColor: json['customThemeColor'] as String? ?? '#FF311B92',
|
||||
useMaterialThemeOnItemPage:
|
||||
json['useMaterialThemeOnItemPage'] as bool? ?? true,
|
||||
useCurrentPlayerThemeThroughoutApp:
|
||||
json['useCurrentPlayerThemeThroughoutApp'] as bool? ?? true,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ThemeSettingsImplToJson(_$ThemeSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'themeMode': _$ThemeModeEnumMap[instance.themeMode]!,
|
||||
'highContrast': instance.highContrast,
|
||||
'useMaterialThemeFromSystem': instance.useMaterialThemeFromSystem,
|
||||
'customThemeColor': instance.customThemeColor,
|
||||
'useMaterialThemeOnItemPage': instance.useMaterialThemeOnItemPage,
|
||||
'useCurrentPlayerThemeThroughoutApp':
|
||||
instance.useCurrentPlayerThemeThroughoutApp,
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
ThemeMode.system: 'system',
|
||||
ThemeMode.light: 'light',
|
||||
ThemeMode.dark: 'dark',
|
||||
};
|
||||
|
||||
_$PlayerSettingsImpl _$$PlayerSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||
_$PlayerSettingsImpl(
|
||||
miniPlayerSettings: json['miniPlayerSettings'] == null
|
||||
? const MinimizedPlayerSettings()
|
||||
: MinimizedPlayerSettings.fromJson(
|
||||
json['miniPlayerSettings'] as Map<String, dynamic>),
|
||||
expandedPlayerSettings: json['expandedPlayerSettings'] == null
|
||||
? const ExpandedPlayerSettings()
|
||||
: ExpandedPlayerSettings.fromJson(
|
||||
json['expandedPlayerSettings'] as Map<String, dynamic>),
|
||||
preferredDefaultVolume:
|
||||
(json['preferredDefaultVolume'] as num?)?.toDouble() ?? 1,
|
||||
preferredDefaultSpeed:
|
||||
(json['preferredDefaultSpeed'] as num?)?.toDouble() ?? 1,
|
||||
speedOptions: (json['speedOptions'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toDouble())
|
||||
.toList() ??
|
||||
const [1, 1.25, 1.5, 1.75, 2],
|
||||
speedIncrement: (json['speedIncrement'] as num?)?.toDouble() ?? 0.05,
|
||||
minSpeed: (json['minSpeed'] as num?)?.toDouble() ?? 0.1,
|
||||
maxSpeed: (json['maxSpeed'] as num?)?.toDouble() ?? 4,
|
||||
minimumPositionForReporting: json['minimumPositionForReporting'] == null
|
||||
? const Duration(seconds: 10)
|
||||
: Duration(
|
||||
microseconds:
|
||||
(json['minimumPositionForReporting'] as num).toInt()),
|
||||
playbackReportInterval: json['playbackReportInterval'] == null
|
||||
? const Duration(seconds: 10)
|
||||
: Duration(
|
||||
microseconds: (json['playbackReportInterval'] as num).toInt()),
|
||||
markCompleteWhenTimeLeft: json['markCompleteWhenTimeLeft'] == null
|
||||
? const Duration(seconds: 15)
|
||||
: Duration(
|
||||
microseconds: (json['markCompleteWhenTimeLeft'] as num).toInt()),
|
||||
configurePlayerForEveryBook:
|
||||
json['configurePlayerForEveryBook'] as bool? ?? true,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PlayerSettingsImplToJson(
|
||||
_$PlayerSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'miniPlayerSettings': instance.miniPlayerSettings,
|
||||
'expandedPlayerSettings': instance.expandedPlayerSettings,
|
||||
'preferredDefaultVolume': instance.preferredDefaultVolume,
|
||||
'preferredDefaultSpeed': instance.preferredDefaultSpeed,
|
||||
'speedOptions': instance.speedOptions,
|
||||
'speedIncrement': instance.speedIncrement,
|
||||
'minSpeed': instance.minSpeed,
|
||||
'maxSpeed': instance.maxSpeed,
|
||||
'minimumPositionForReporting':
|
||||
instance.minimumPositionForReporting.inMicroseconds,
|
||||
'playbackReportInterval': instance.playbackReportInterval.inMicroseconds,
|
||||
'markCompleteWhenTimeLeft':
|
||||
instance.markCompleteWhenTimeLeft.inMicroseconds,
|
||||
'configurePlayerForEveryBook': instance.configurePlayerForEveryBook,
|
||||
};
|
||||
|
||||
_$ExpandedPlayerSettingsImpl _$$ExpandedPlayerSettingsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ExpandedPlayerSettingsImpl(
|
||||
showTotalProgress: json['showTotalProgress'] as bool? ?? false,
|
||||
showChapterProgress: json['showChapterProgress'] as bool? ?? true,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ExpandedPlayerSettingsImplToJson(
|
||||
_$ExpandedPlayerSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'showTotalProgress': instance.showTotalProgress,
|
||||
'showChapterProgress': instance.showChapterProgress,
|
||||
};
|
||||
|
||||
_$MinimizedPlayerSettingsImpl _$$MinimizedPlayerSettingsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$MinimizedPlayerSettingsImpl(
|
||||
useChapterInfo: json['useChapterInfo'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$MinimizedPlayerSettingsImplToJson(
|
||||
_$MinimizedPlayerSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'useChapterInfo': instance.useChapterInfo,
|
||||
};
|
||||
|
||||
_$SleepTimerSettingsImpl _$$SleepTimerSettingsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$SleepTimerSettingsImpl(
|
||||
defaultDuration: json['defaultDuration'] == null
|
||||
? const Duration(minutes: 15)
|
||||
: Duration(microseconds: (json['defaultDuration'] as num).toInt()),
|
||||
presetDurations: (json['presetDurations'] as List<dynamic>?)
|
||||
?.map((e) => Duration(microseconds: (e as num).toInt()))
|
||||
.toList() ??
|
||||
const [
|
||||
Duration(minutes: 5),
|
||||
Duration(minutes: 10),
|
||||
Duration(minutes: 15),
|
||||
Duration(minutes: 20),
|
||||
Duration(minutes: 30)
|
||||
],
|
||||
maxDuration: json['maxDuration'] == null
|
||||
? const Duration(minutes: 100)
|
||||
: Duration(microseconds: (json['maxDuration'] as num).toInt()),
|
||||
fadeOutAudio: json['fadeOutAudio'] as bool? ?? false,
|
||||
fadeOutDuration: json['fadeOutDuration'] == null
|
||||
? const Duration(seconds: 20)
|
||||
: Duration(microseconds: (json['fadeOutDuration'] as num).toInt()),
|
||||
autoRewindWhenStopped: json['autoRewindWhenStopped'] as bool? ?? false,
|
||||
autoRewindDurations:
|
||||
(json['autoRewindDurations'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(
|
||||
int.parse(k), Duration(microseconds: (e as num).toInt())),
|
||||
) ??
|
||||
const {
|
||||
5: Duration(seconds: 10),
|
||||
15: Duration(seconds: 30),
|
||||
45: Duration(seconds: 45),
|
||||
60: Duration(minutes: 1),
|
||||
120: Duration(minutes: 2)
|
||||
},
|
||||
autoTurnOnTimer: json['autoTurnOnTimer'] as bool? ?? false,
|
||||
alwaysAutoTurnOnTimer: json['alwaysAutoTurnOnTimer'] as bool? ?? false,
|
||||
autoTurnOnTime: json['autoTurnOnTime'] == null
|
||||
? const Duration(hours: 22, minutes: 0)
|
||||
: Duration(microseconds: (json['autoTurnOnTime'] as num).toInt()),
|
||||
autoTurnOffTime: json['autoTurnOffTime'] == null
|
||||
? const Duration(hours: 6, minutes: 0)
|
||||
: Duration(microseconds: (json['autoTurnOffTime'] as num).toInt()),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SleepTimerSettingsImplToJson(
|
||||
_$SleepTimerSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'defaultDuration': instance.defaultDuration.inMicroseconds,
|
||||
'presetDurations':
|
||||
instance.presetDurations.map((e) => e.inMicroseconds).toList(),
|
||||
'maxDuration': instance.maxDuration.inMicroseconds,
|
||||
'fadeOutAudio': instance.fadeOutAudio,
|
||||
'fadeOutDuration': instance.fadeOutDuration.inMicroseconds,
|
||||
'autoRewindWhenStopped': instance.autoRewindWhenStopped,
|
||||
'autoRewindDurations': instance.autoRewindDurations
|
||||
.map((k, e) => MapEntry(k.toString(), e.inMicroseconds)),
|
||||
'autoTurnOnTimer': instance.autoTurnOnTimer,
|
||||
'alwaysAutoTurnOnTimer': instance.alwaysAutoTurnOnTimer,
|
||||
'autoTurnOnTime': instance.autoTurnOnTime.inMicroseconds,
|
||||
'autoTurnOffTime': instance.autoTurnOffTime.inMicroseconds,
|
||||
};
|
||||
|
||||
_$DownloadSettingsImpl _$$DownloadSettingsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$DownloadSettingsImpl(
|
||||
requiresWiFi: json['requiresWiFi'] as bool? ?? true,
|
||||
retries: (json['retries'] as num?)?.toInt() ?? 3,
|
||||
allowPause: json['allowPause'] as bool? ?? true,
|
||||
maxConcurrent: (json['maxConcurrent'] as num?)?.toInt() ?? 3,
|
||||
maxConcurrentByHost: (json['maxConcurrentByHost'] as num?)?.toInt() ?? 3,
|
||||
maxConcurrentByGroup:
|
||||
(json['maxConcurrentByGroup'] as num?)?.toInt() ?? 3,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$DownloadSettingsImplToJson(
|
||||
_$DownloadSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'requiresWiFi': instance.requiresWiFi,
|
||||
'retries': instance.retries,
|
||||
'allowPause': instance.allowPause,
|
||||
'maxConcurrent': instance.maxConcurrent,
|
||||
'maxConcurrentByHost': instance.maxConcurrentByHost,
|
||||
'maxConcurrentByGroup': instance.maxConcurrentByGroup,
|
||||
};
|
||||
|
||||
_$NotificationSettingsImpl _$$NotificationSettingsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$NotificationSettingsImpl(
|
||||
fastForwardInterval: json['fastForwardInterval'] == null
|
||||
? const Duration(seconds: 30)
|
||||
: Duration(
|
||||
microseconds: (json['fastForwardInterval'] as num).toInt()),
|
||||
rewindInterval: json['rewindInterval'] == null
|
||||
? const Duration(seconds: 10)
|
||||
: Duration(microseconds: (json['rewindInterval'] as num).toInt()),
|
||||
progressBarIsChapterProgress:
|
||||
json['progressBarIsChapterProgress'] as bool? ?? true,
|
||||
primaryTitle: json['primaryTitle'] as String? ?? '\$bookTitle',
|
||||
secondaryTitle: json['secondaryTitle'] as String? ?? '\$author',
|
||||
mediaControls: (json['mediaControls'] as List<dynamic>?)
|
||||
?.map((e) => $enumDecode(_$NotificationMediaControlEnumMap, e))
|
||||
.toList() ??
|
||||
const [
|
||||
NotificationMediaControl.rewind,
|
||||
NotificationMediaControl.fastForward,
|
||||
NotificationMediaControl.skipToPreviousChapter,
|
||||
NotificationMediaControl.skipToNextChapter
|
||||
],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$NotificationSettingsImplToJson(
|
||||
_$NotificationSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'fastForwardInterval': instance.fastForwardInterval.inMicroseconds,
|
||||
'rewindInterval': instance.rewindInterval.inMicroseconds,
|
||||
'progressBarIsChapterProgress': instance.progressBarIsChapterProgress,
|
||||
'primaryTitle': instance.primaryTitle,
|
||||
'secondaryTitle': instance.secondaryTitle,
|
||||
'mediaControls': instance.mediaControls
|
||||
.map((e) => _$NotificationMediaControlEnumMap[e]!)
|
||||
.toList(),
|
||||
};
|
||||
|
||||
const _$NotificationMediaControlEnumMap = {
|
||||
NotificationMediaControl.fastForward: 'fastForward',
|
||||
NotificationMediaControl.rewind: 'rewind',
|
||||
NotificationMediaControl.speedToggle: 'speedToggle',
|
||||
NotificationMediaControl.stop: 'stop',
|
||||
NotificationMediaControl.skipToNextChapter: 'skipToNextChapter',
|
||||
NotificationMediaControl.skipToPreviousChapter: 'skipToPreviousChapter',
|
||||
};
|
||||
|
||||
_$ShakeDetectionSettingsImpl _$$ShakeDetectionSettingsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$ShakeDetectionSettingsImpl(
|
||||
isEnabled: json['isEnabled'] as bool? ?? true,
|
||||
direction:
|
||||
$enumDecodeNullable(_$ShakeDirectionEnumMap, json['direction']) ??
|
||||
ShakeDirection.horizontal,
|
||||
threshold: (json['threshold'] as num?)?.toDouble() ?? 5,
|
||||
shakeAction:
|
||||
$enumDecodeNullable(_$ShakeActionEnumMap, json['shakeAction']) ??
|
||||
ShakeAction.resetSleepTimer,
|
||||
feedback: (json['feedback'] as List<dynamic>?)
|
||||
?.map((e) => $enumDecode(_$ShakeDetectedFeedbackEnumMap, e))
|
||||
.toSet() ??
|
||||
const {ShakeDetectedFeedback.vibrate},
|
||||
beepVolume: (json['beepVolume'] as num?)?.toDouble() ?? 0.5,
|
||||
shakeTriggerCoolDown: json['shakeTriggerCoolDown'] == null
|
||||
? const Duration(seconds: 2)
|
||||
: Duration(
|
||||
microseconds: (json['shakeTriggerCoolDown'] as num).toInt()),
|
||||
shakeTriggerCount: (json['shakeTriggerCount'] as num?)?.toInt() ?? 2,
|
||||
samplingPeriod: json['samplingPeriod'] == null
|
||||
? const Duration(milliseconds: 100)
|
||||
: Duration(microseconds: (json['samplingPeriod'] as num).toInt()),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ShakeDetectionSettingsImplToJson(
|
||||
_$ShakeDetectionSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'isEnabled': instance.isEnabled,
|
||||
'direction': _$ShakeDirectionEnumMap[instance.direction]!,
|
||||
'threshold': instance.threshold,
|
||||
'shakeAction': _$ShakeActionEnumMap[instance.shakeAction]!,
|
||||
'feedback': instance.feedback
|
||||
.map((e) => _$ShakeDetectedFeedbackEnumMap[e]!)
|
||||
.toList(),
|
||||
'beepVolume': instance.beepVolume,
|
||||
'shakeTriggerCoolDown': instance.shakeTriggerCoolDown.inMicroseconds,
|
||||
'shakeTriggerCount': instance.shakeTriggerCount,
|
||||
'samplingPeriod': instance.samplingPeriod.inMicroseconds,
|
||||
};
|
||||
|
||||
const _$ShakeDirectionEnumMap = {
|
||||
ShakeDirection.horizontal: 'horizontal',
|
||||
ShakeDirection.vertical: 'vertical',
|
||||
};
|
||||
|
||||
const _$ShakeActionEnumMap = {
|
||||
ShakeAction.none: 'none',
|
||||
ShakeAction.playPause: 'playPause',
|
||||
ShakeAction.resetSleepTimer: 'resetSleepTimer',
|
||||
ShakeAction.fastForward: 'fastForward',
|
||||
ShakeAction.rewind: 'rewind',
|
||||
};
|
||||
|
||||
const _$ShakeDetectedFeedbackEnumMap = {
|
||||
ShakeDetectedFeedback.vibrate: 'vibrate',
|
||||
ShakeDetectedFeedback.beep: 'beep',
|
||||
};
|
||||
|
||||
_$HomePageSettingsImpl _$$HomePageSettingsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$HomePageSettingsImpl(
|
||||
showPlayButtonOnContinueListeningShelf:
|
||||
json['showPlayButtonOnContinueListeningShelf'] as bool? ?? true,
|
||||
showPlayButtonOnContinueSeriesShelf:
|
||||
json['showPlayButtonOnContinueSeriesShelf'] as bool? ?? false,
|
||||
showPlayButtonOnAllRemainingShelves:
|
||||
json['showPlayButtonOnAllRemainingShelves'] as bool? ?? false,
|
||||
showPlayButtonOnListenAgainShelf:
|
||||
json['showPlayButtonOnListenAgainShelf'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$HomePageSettingsImplToJson(
|
||||
_$HomePageSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'showPlayButtonOnContinueListeningShelf':
|
||||
instance.showPlayButtonOnContinueListeningShelf,
|
||||
'showPlayButtonOnContinueSeriesShelf':
|
||||
instance.showPlayButtonOnContinueSeriesShelf,
|
||||
'showPlayButtonOnAllRemainingShelves':
|
||||
instance.showPlayButtonOnAllRemainingShelves,
|
||||
'showPlayButtonOnListenAgainShelf':
|
||||
instance.showPlayButtonOnListenAgainShelf,
|
||||
};
|
||||
18
lib/features/settings/models/audiobookshelf_server.dart
Normal file
18
lib/features/settings/models/audiobookshelf_server.dart
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'audiobookshelf_server.freezed.dart';
|
||||
part 'audiobookshelf_server.g.dart';
|
||||
|
||||
typedef AudiobookShelfUri = Uri;
|
||||
|
||||
/// Represents a audiobookshelf server
|
||||
@freezed
|
||||
class AudiobookShelfServer with _$AudiobookShelfServer {
|
||||
const factory AudiobookShelfServer({
|
||||
required AudiobookShelfUri serverUrl,
|
||||
// String? serverName,
|
||||
}) = _AudiobookShelfServer;
|
||||
|
||||
factory AudiobookShelfServer.fromJson(Map<String, dynamic> json) =>
|
||||
_$AudiobookShelfServerFromJson(json);
|
||||
}
|
||||
169
lib/features/settings/models/audiobookshelf_server.freezed.dart
Normal file
169
lib/features/settings/models/audiobookshelf_server.freezed.dart
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
// 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 'audiobookshelf_server.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');
|
||||
|
||||
AudiobookShelfServer _$AudiobookShelfServerFromJson(Map<String, dynamic> json) {
|
||||
return _AudiobookShelfServer.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AudiobookShelfServer {
|
||||
Uri get serverUrl => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AudiobookShelfServer to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AudiobookShelfServer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AudiobookShelfServerCopyWith<AudiobookShelfServer> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AudiobookShelfServerCopyWith<$Res> {
|
||||
factory $AudiobookShelfServerCopyWith(AudiobookShelfServer value,
|
||||
$Res Function(AudiobookShelfServer) then) =
|
||||
_$AudiobookShelfServerCopyWithImpl<$Res, AudiobookShelfServer>;
|
||||
@useResult
|
||||
$Res call({Uri serverUrl});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AudiobookShelfServerCopyWithImpl<$Res,
|
||||
$Val extends AudiobookShelfServer>
|
||||
implements $AudiobookShelfServerCopyWith<$Res> {
|
||||
_$AudiobookShelfServerCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AudiobookShelfServer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? serverUrl = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
serverUrl: null == serverUrl
|
||||
? _value.serverUrl
|
||||
: serverUrl // ignore: cast_nullable_to_non_nullable
|
||||
as Uri,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AudiobookShelfServerImplCopyWith<$Res>
|
||||
implements $AudiobookShelfServerCopyWith<$Res> {
|
||||
factory _$$AudiobookShelfServerImplCopyWith(_$AudiobookShelfServerImpl value,
|
||||
$Res Function(_$AudiobookShelfServerImpl) then) =
|
||||
__$$AudiobookShelfServerImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({Uri serverUrl});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AudiobookShelfServerImplCopyWithImpl<$Res>
|
||||
extends _$AudiobookShelfServerCopyWithImpl<$Res, _$AudiobookShelfServerImpl>
|
||||
implements _$$AudiobookShelfServerImplCopyWith<$Res> {
|
||||
__$$AudiobookShelfServerImplCopyWithImpl(_$AudiobookShelfServerImpl _value,
|
||||
$Res Function(_$AudiobookShelfServerImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AudiobookShelfServer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? serverUrl = null,
|
||||
}) {
|
||||
return _then(_$AudiobookShelfServerImpl(
|
||||
serverUrl: null == serverUrl
|
||||
? _value.serverUrl
|
||||
: serverUrl // ignore: cast_nullable_to_non_nullable
|
||||
as Uri,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AudiobookShelfServerImpl implements _AudiobookShelfServer {
|
||||
const _$AudiobookShelfServerImpl({required this.serverUrl});
|
||||
|
||||
factory _$AudiobookShelfServerImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AudiobookShelfServerImplFromJson(json);
|
||||
|
||||
@override
|
||||
final Uri serverUrl;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AudiobookShelfServer(serverUrl: $serverUrl)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AudiobookShelfServerImpl &&
|
||||
(identical(other.serverUrl, serverUrl) ||
|
||||
other.serverUrl == serverUrl));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, serverUrl);
|
||||
|
||||
/// Create a copy of AudiobookShelfServer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AudiobookShelfServerImplCopyWith<_$AudiobookShelfServerImpl>
|
||||
get copyWith =>
|
||||
__$$AudiobookShelfServerImplCopyWithImpl<_$AudiobookShelfServerImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AudiobookShelfServerImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AudiobookShelfServer implements AudiobookShelfServer {
|
||||
const factory _AudiobookShelfServer({required final Uri serverUrl}) =
|
||||
_$AudiobookShelfServerImpl;
|
||||
|
||||
factory _AudiobookShelfServer.fromJson(Map<String, dynamic> json) =
|
||||
_$AudiobookShelfServerImpl.fromJson;
|
||||
|
||||
@override
|
||||
Uri get serverUrl;
|
||||
|
||||
/// Create a copy of AudiobookShelfServer
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AudiobookShelfServerImplCopyWith<_$AudiobookShelfServerImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
19
lib/features/settings/models/audiobookshelf_server.g.dart
Normal file
19
lib/features/settings/models/audiobookshelf_server.g.dart
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'audiobookshelf_server.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AudiobookShelfServerImpl _$$AudiobookShelfServerImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$AudiobookShelfServerImpl(
|
||||
serverUrl: Uri.parse(json['serverUrl'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AudiobookShelfServerImplToJson(
|
||||
_$AudiobookShelfServerImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'serverUrl': instance.serverUrl.toString(),
|
||||
};
|
||||
19
lib/features/settings/models/authenticated_user.dart
Normal file
19
lib/features/settings/models/authenticated_user.dart
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:vaani/features/settings/models/audiobookshelf_server.dart';
|
||||
|
||||
part 'authenticated_user.freezed.dart';
|
||||
part 'authenticated_user.g.dart';
|
||||
|
||||
/// authenticated user with server and credentials
|
||||
@freezed
|
||||
class AuthenticatedUser with _$AuthenticatedUser {
|
||||
const factory AuthenticatedUser({
|
||||
required AudiobookShelfServer server,
|
||||
required String authToken,
|
||||
required String id,
|
||||
String? username,
|
||||
}) = _AuthenticatedUser;
|
||||
|
||||
factory AuthenticatedUser.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthenticatedUserFromJson(json);
|
||||
}
|
||||
246
lib/features/settings/models/authenticated_user.freezed.dart
Normal file
246
lib/features/settings/models/authenticated_user.freezed.dart
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
// 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 'authenticated_user.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');
|
||||
|
||||
AuthenticatedUser _$AuthenticatedUserFromJson(Map<String, dynamic> json) {
|
||||
return _AuthenticatedUser.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthenticatedUser {
|
||||
AudiobookShelfServer get server => throw _privateConstructorUsedError;
|
||||
String get authToken => throw _privateConstructorUsedError;
|
||||
String get id => throw _privateConstructorUsedError;
|
||||
String? get username => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AuthenticatedUser to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AuthenticatedUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AuthenticatedUserCopyWith<AuthenticatedUser> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AuthenticatedUserCopyWith<$Res> {
|
||||
factory $AuthenticatedUserCopyWith(
|
||||
AuthenticatedUser value, $Res Function(AuthenticatedUser) then) =
|
||||
_$AuthenticatedUserCopyWithImpl<$Res, AuthenticatedUser>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{AudiobookShelfServer server,
|
||||
String authToken,
|
||||
String id,
|
||||
String? username});
|
||||
|
||||
$AudiobookShelfServerCopyWith<$Res> get server;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AuthenticatedUserCopyWithImpl<$Res, $Val extends AuthenticatedUser>
|
||||
implements $AuthenticatedUserCopyWith<$Res> {
|
||||
_$AuthenticatedUserCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AuthenticatedUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? server = null,
|
||||
Object? authToken = null,
|
||||
Object? id = null,
|
||||
Object? username = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
server: null == server
|
||||
? _value.server
|
||||
: server // ignore: cast_nullable_to_non_nullable
|
||||
as AudiobookShelfServer,
|
||||
authToken: null == authToken
|
||||
? _value.authToken
|
||||
: authToken // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
username: freezed == username
|
||||
? _value.username
|
||||
: username // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
/// Create a copy of AuthenticatedUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AudiobookShelfServerCopyWith<$Res> get server {
|
||||
return $AudiobookShelfServerCopyWith<$Res>(_value.server, (value) {
|
||||
return _then(_value.copyWith(server: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthenticatedUserImplCopyWith<$Res>
|
||||
implements $AuthenticatedUserCopyWith<$Res> {
|
||||
factory _$$AuthenticatedUserImplCopyWith(_$AuthenticatedUserImpl value,
|
||||
$Res Function(_$AuthenticatedUserImpl) then) =
|
||||
__$$AuthenticatedUserImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{AudiobookShelfServer server,
|
||||
String authToken,
|
||||
String id,
|
||||
String? username});
|
||||
|
||||
@override
|
||||
$AudiobookShelfServerCopyWith<$Res> get server;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthenticatedUserImplCopyWithImpl<$Res>
|
||||
extends _$AuthenticatedUserCopyWithImpl<$Res, _$AuthenticatedUserImpl>
|
||||
implements _$$AuthenticatedUserImplCopyWith<$Res> {
|
||||
__$$AuthenticatedUserImplCopyWithImpl(_$AuthenticatedUserImpl _value,
|
||||
$Res Function(_$AuthenticatedUserImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AuthenticatedUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? server = null,
|
||||
Object? authToken = null,
|
||||
Object? id = null,
|
||||
Object? username = freezed,
|
||||
}) {
|
||||
return _then(_$AuthenticatedUserImpl(
|
||||
server: null == server
|
||||
? _value.server
|
||||
: server // ignore: cast_nullable_to_non_nullable
|
||||
as AudiobookShelfServer,
|
||||
authToken: null == authToken
|
||||
? _value.authToken
|
||||
: authToken // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
username: freezed == username
|
||||
? _value.username
|
||||
: username // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$AuthenticatedUserImpl implements _AuthenticatedUser {
|
||||
const _$AuthenticatedUserImpl(
|
||||
{required this.server,
|
||||
required this.authToken,
|
||||
required this.id,
|
||||
this.username});
|
||||
|
||||
factory _$AuthenticatedUserImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AuthenticatedUserImplFromJson(json);
|
||||
|
||||
@override
|
||||
final AudiobookShelfServer server;
|
||||
@override
|
||||
final String authToken;
|
||||
@override
|
||||
final String id;
|
||||
@override
|
||||
final String? username;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthenticatedUser(server: $server, authToken: $authToken, id: $id, username: $username)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthenticatedUserImpl &&
|
||||
(identical(other.server, server) || other.server == server) &&
|
||||
(identical(other.authToken, authToken) ||
|
||||
other.authToken == authToken) &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.username, username) ||
|
||||
other.username == username));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, server, authToken, id, username);
|
||||
|
||||
/// Create a copy of AuthenticatedUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthenticatedUserImplCopyWith<_$AuthenticatedUserImpl> get copyWith =>
|
||||
__$$AuthenticatedUserImplCopyWithImpl<_$AuthenticatedUserImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$AuthenticatedUserImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _AuthenticatedUser implements AuthenticatedUser {
|
||||
const factory _AuthenticatedUser(
|
||||
{required final AudiobookShelfServer server,
|
||||
required final String authToken,
|
||||
required final String id,
|
||||
final String? username}) = _$AuthenticatedUserImpl;
|
||||
|
||||
factory _AuthenticatedUser.fromJson(Map<String, dynamic> json) =
|
||||
_$AuthenticatedUserImpl.fromJson;
|
||||
|
||||
@override
|
||||
AudiobookShelfServer get server;
|
||||
@override
|
||||
String get authToken;
|
||||
@override
|
||||
String get id;
|
||||
@override
|
||||
String? get username;
|
||||
|
||||
/// Create a copy of AuthenticatedUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AuthenticatedUserImplCopyWith<_$AuthenticatedUserImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
26
lib/features/settings/models/authenticated_user.g.dart
Normal file
26
lib/features/settings/models/authenticated_user.g.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'authenticated_user.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AuthenticatedUserImpl _$$AuthenticatedUserImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$AuthenticatedUserImpl(
|
||||
server:
|
||||
AudiobookShelfServer.fromJson(json['server'] as Map<String, dynamic>),
|
||||
authToken: json['authToken'] as String,
|
||||
id: json['id'] as String,
|
||||
username: json['username'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AuthenticatedUserImplToJson(
|
||||
_$AuthenticatedUserImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'server': instance.server,
|
||||
'authToken': instance.authToken,
|
||||
'id': instance.id,
|
||||
'username': instance.username,
|
||||
};
|
||||
4
lib/features/settings/models/models.dart
Normal file
4
lib/features/settings/models/models.dart
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export 'api_settings.dart';
|
||||
export 'app_settings.dart';
|
||||
export 'audiobookshelf_server.dart';
|
||||
export 'authenticated_user.dart';
|
||||
Loading…
Add table
Add a link
Reference in a new issue