From 06694f5f0b9181eeed862ceaaaa2b30a22400e78 Mon Sep 17 00:00:00 2001 From: "Dr.Blank" <64108942+Dr-Blank@users.noreply.github.com> Date: Sat, 10 Jan 2026 14:43:59 +0530 Subject: [PATCH 1/3] chore: target android api 36 --- .fvmrc | 2 +- .vscode/settings.json | 2 +- android/app/build.gradle | 4 +- lib/db/cache/schemas/image.dart | 66 ++++++++++++++--------------- lib/db/player_prefs/book_prefs.dart | 50 +++++++++++----------- pubspec.lock | 2 +- pubspec.yaml | 4 +- 7 files changed, 64 insertions(+), 66 deletions(-) diff --git a/.fvmrc b/.fvmrc index c0ef54d..3ca65ff 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,3 +1,3 @@ { - "flutter": "3.32.0" + "flutter": "3.32.8" } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 9185c43..8ba2d8f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,7 +22,7 @@ "utsname", "Vaani" ], - "dart.flutterSdkPath": ".fvm/versions/3.32.0", + "dart.flutterSdkPath": ".fvm/versions/3.32.8", "files.exclude": { "**/*.freezed.dart": true, "**/*.g.dart": true diff --git a/android/app/build.gradle b/android/app/build.gradle index 0161f0d..8200a20 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -30,7 +30,7 @@ if (keystorePropertiesFile.exists()) { android { namespace "dr.blank.vaani" - compileSdk flutter.compileSdkVersion + compileSdk 36 // ndkVersion flutter.ndkVersion // The NDK version is set to a specific version since it was not building // TODO remove when https://github.com/flutter/flutter/issues/139427 is closed @@ -65,7 +65,7 @@ android { // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion 23 - targetSdkVersion flutter.targetSdkVersion + targetSdkVersion 36 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/lib/db/cache/schemas/image.dart b/lib/db/cache/schemas/image.dart index 9e93073..fef8025 100644 --- a/lib/db/cache/schemas/image.dart +++ b/lib/db/cache/schemas/image.dart @@ -1,39 +1,39 @@ -import 'package:isar/isar.dart'; +// import 'package:isar/isar.dart'; -part 'image.g.dart'; +// part 'image.g.dart'; -/// Represents a cover image for a library item -/// -/// stores 2 paths, one is thumbnail and the other is the full size image -/// both are optional -/// also stores last fetched date for the image -/// Id is passed as a parameter to the collection annotation (the lib_item_id) -/// also index the id -/// This is because the image is a part of the library item and the library item -/// is the parent of the image -@Collection(ignore: {'path'}) -@Name('CacheImage') -class Image { - @Id() - int id; +// /// Represents a cover image for a library item +// /// +// /// stores 2 paths, one is thumbnail and the other is the full size image +// /// both are optional +// /// also stores last fetched date for the image +// /// Id is passed as a parameter to the collection annotation (the lib_item_id) +// /// also index the id +// /// This is because the image is a part of the library item and the library item +// /// is the parent of the image +// @Collection(ignore: {'path'}) +// @Name('CacheImage') +// class Image { +// @Id() +// int id; - String? thumbnailPath; - String? imagePath; - DateTime lastSaved; +// String? thumbnailPath; +// String? imagePath; +// DateTime lastSaved; - Image({ - required this.id, - this.thumbnailPath, - this.imagePath, - }) : lastSaved = DateTime.now(); +// Image({ +// required this.id, +// this.thumbnailPath, +// this.imagePath, +// }) : lastSaved = DateTime.now(); - /// returns the path to the image - String? get path => thumbnailPath ?? imagePath; +// /// returns the path to the image +// String? get path => thumbnailPath ?? imagePath; - /// automatically updates the last fetched date when saving a new path - void updatePath(String? thumbnailPath, String? imagePath) async { - this.thumbnailPath = thumbnailPath; - this.imagePath = imagePath; - lastSaved = DateTime.now(); - } -} +// /// automatically updates the last fetched date when saving a new path +// void updatePath(String? thumbnailPath, String? imagePath) async { +// this.thumbnailPath = thumbnailPath; +// this.imagePath = imagePath; +// lastSaved = DateTime.now(); +// } +// } diff --git a/lib/db/player_prefs/book_prefs.dart b/lib/db/player_prefs/book_prefs.dart index b4e3807..ca610c8 100644 --- a/lib/db/player_prefs/book_prefs.dart +++ b/lib/db/player_prefs/book_prefs.dart @@ -1,29 +1,29 @@ -// a table to track preferences of player for each book -import 'package:isar/isar.dart'; +// // a table to track preferences of player for each book +// import 'package:isar/isar.dart'; -part 'book_prefs.g.dart'; +// part 'book_prefs.g.dart'; -/// stores the preferences of the player for a book -@Collection() -@Name('BookPrefs') -class BookPrefs { - @Id() - int libItemId; +// /// stores the preferences of the player for a book +// @Collection() +// @Name('BookPrefs') +// class BookPrefs { +// @Id() +// int libItemId; - double? speed; - // double? volume; - // Duration? sleepTimer; - // bool? showTotalProgress; - // bool? showChapterProgress; - // bool? useChapterInfo; +// double? speed; +// // double? volume; +// // Duration? sleepTimer; +// // bool? showTotalProgress; +// // bool? showChapterProgress; +// // bool? useChapterInfo; - BookPrefs({ - required this.libItemId, - this.speed, - // this.volume, - // this.sleepTimer, - // this.showTotalProgress, - // this.showChapterProgress, - // this.useChapterInfo, - }); -} +// BookPrefs({ +// required this.libItemId, +// this.speed, +// // this.volume, +// // this.sleepTimer, +// // this.showTotalProgress, +// // this.showChapterProgress, +// // this.useChapterInfo, +// }); +// } diff --git a/pubspec.lock b/pubspec.lock index 216ce34..f4c775c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1597,4 +1597,4 @@ packages: version: "3.1.3" sdks: dart: ">=3.7.0 <4.0.0" - flutter: ">=3.32.0" + flutter: ">=3.32.8" diff --git a/pubspec.yaml b/pubspec.yaml index daa3a2e..7ccbe61 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,9 +20,7 @@ version: 0.0.18+9 environment: sdk: ">=3.3.4 <4.0.0" - flutter: 3.32.0 - -isar_version: &isar_version ^4.0.0-dev.13 # define the version to be used + flutter: 3.32.8 # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions From a520136e01688e781b0fb0e33c37094eb3d8dab0 Mon Sep 17 00:00:00 2001 From: "Dr.Blank" <64108942+Dr-Blank@users.noreply.github.com> Date: Sat, 10 Jan 2026 16:46:06 +0530 Subject: [PATCH 2/3] chore: update flutter and dependencies --- .fvmrc | 2 +- .vscode/settings.json | 2 +- android/app/build.gradle | 12 +- android/settings.gradle | 2 +- lib/api/api_provider.g.dart | 1025 ++-- lib/api/authenticated_users_provider.dart | 2 +- lib/api/authenticated_users_provider.g.dart | 83 +- lib/api/image_provider.g.dart | 215 +- lib/api/library_item_provider.g.dart | 244 +- lib/api/library_provider.dart | 3 +- lib/api/library_provider.g.dart | 274 +- lib/api/server_provider.dart | 2 +- lib/api/server_provider.g.dart | 91 +- lib/db/available_boxes.dart | 2 +- lib/db/cache/schemas/image.g.dart | 1009 --- lib/db/init.dart | 2 +- lib/db/player_prefs/book_prefs.g.dart | 496 -- lib/db/register_models.dart | 2 +- .../downloads/providers/download_manager.dart | 2 +- .../providers/download_manager.g.dart | 967 ++- .../providers/search_controller.g.dart | 72 +- .../providers/search_result_provider.g.dart | 220 +- lib/features/explore/view/explore_page.dart | 2 +- .../view/library_item_actions.dart | 6 +- .../view/library_item_hero_section.dart | 6 +- .../view/library_item_metadata.dart | 2 +- .../item_viewer/view/library_item_page.dart | 2 +- .../view/library_item_sliver_app_bar.dart | 2 +- .../view/library_browser_page.dart | 2 +- .../logging/providers/logs_provider.g.dart | 58 +- lib/features/onboarding/models/flow.dart | 2 +- .../onboarding/models/flow.freezed.dart | 447 +- .../providers/oauth_provider.g.dart | 342 +- .../models/book_settings.dart | 2 +- .../models/book_settings.freezed.dart | 411 +- .../models/book_settings.g.dart | 9 +- .../models/nullable_player_settings.dart | 2 +- .../nullable_player_settings.freezed.dart | 650 +- .../models/nullable_player_settings.g.dart | 76 +- .../providers/book_settings_provider.g.dart | 217 +- .../playback_reporter_provider.g.dart | 66 +- lib/features/player/playlist_provider.g.dart | 67 +- .../player/providers/audiobook_player.g.dart | 138 +- .../currently_playing_provider.g.dart | 185 +- .../player/providers/player_form.dart | 2 +- .../player/providers/player_form.g.dart | 170 +- .../player/view/audiobook_player.dart | 14 +- .../providers/shake_detector.g.dart | 68 +- .../providers/sleep_timer_provider.g.dart | 67 +- lib/main.dart | 12 +- lib/router/models/library_item_extras.dart | 2 +- .../models/library_item_extras.freezed.dart | 350 +- lib/router/scaffold_with_nav_bar.dart | 29 +- lib/settings/api_settings_provider.dart | 2 +- lib/settings/api_settings_provider.g.dart | 65 +- lib/settings/app_settings_provider.dart | 2 +- lib/settings/app_settings_provider.g.dart | 131 +- .../metadata/metadata_provider.g.dart | 182 +- lib/settings/models/api_settings.dart | 2 +- lib/settings/models/api_settings.freezed.dart | 479 +- lib/settings/models/api_settings.g.dart | 25 +- lib/settings/models/app_settings.dart | 63 +- lib/settings/models/app_settings.freezed.dart | 5407 ++++++++--------- lib/settings/models/app_settings.g.dart | 463 +- .../models/audiobookshelf_server.dart | 2 +- .../models/audiobookshelf_server.freezed.dart | 358 +- .../models/audiobookshelf_server.g.dart | 16 +- lib/settings/models/authenticated_user.dart | 2 +- .../models/authenticated_user.freezed.dart | 460 +- lib/settings/models/authenticated_user.g.dart | 13 +- lib/shared/widgets/shelves/book_shelf.dart | 4 +- .../providers/system_theme_provider.g.dart | 207 +- .../theme_from_cover_provider.g.dart | 466 +- linux/flutter/generated_plugin_registrant.cc | 8 +- linux/flutter/generated_plugins.cmake | 2 +- pubspec.lock | 313 +- pubspec.yaml | 23 +- shelfsdk | 2 +- .../flutter/generated_plugin_registrant.cc | 6 +- windows/flutter/generated_plugins.cmake | 2 +- 80 files changed, 7701 insertions(+), 9141 deletions(-) delete mode 100644 lib/db/cache/schemas/image.g.dart delete mode 100644 lib/db/player_prefs/book_prefs.g.dart diff --git a/.fvmrc b/.fvmrc index 3ca65ff..45c2124 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,3 +1,3 @@ { - "flutter": "3.32.8" + "flutter": "3.38.6" } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 8ba2d8f..fd30314 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,7 +22,7 @@ "utsname", "Vaani" ], - "dart.flutterSdkPath": ".fvm/versions/3.32.8", + "dart.flutterSdkPath": ".fvm/versions/3.38.6", "files.exclude": { "**/*.freezed.dart": true, "**/*.g.dart": true diff --git a/android/app/build.gradle b/android/app/build.gradle index 8200a20..49b2a91 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -30,11 +30,11 @@ if (keystorePropertiesFile.exists()) { android { namespace "dr.blank.vaani" - compileSdk 36 - // ndkVersion flutter.ndkVersion + compileSdk flutter.compileSdkVersion + ndkVersion flutter.ndkVersion // The NDK version is set to a specific version since it was not building // TODO remove when https://github.com/flutter/flutter/issues/139427 is closed - ndkVersion = "29.0.13113456" + // ndkVersion = "29.0.13113456" compileOptions { @@ -64,8 +64,8 @@ android { applicationId "dr.blank.vaani" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdkVersion 23 - targetSdkVersion 36 + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } @@ -100,4 +100,4 @@ configurations.all { force "androidx.core:core:1.13.1" force "androidx.core:core-ktx:1.13.1" } -} \ No newline at end of file +} diff --git a/android/settings.gradle b/android/settings.gradle index 7435dcb..4529834 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -20,7 +20,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version '8.10.0' apply false - id "org.jetbrains.kotlin.android" version "2.0.20" apply false + id "org.jetbrains.kotlin.android" version "2.1.10" apply false } include ":app" diff --git a/lib/api/api_provider.g.dart b/lib/api/api_provider.g.dart index 619a729..dabe437 100644 --- a/lib/api/api_provider.g.dart +++ b/lib/api/api_provider.g.dart @@ -6,679 +6,536 @@ part of 'api_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$audiobookshelfApiHash() => r'f23a06c404e11867a7f796877eaca99b8ff25458'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// get the api instance for the given base url -/// -/// Copied from [audiobookshelfApi]. + @ProviderFor(audiobookshelfApi) -const audiobookshelfApiProvider = AudiobookshelfApiFamily(); +final audiobookshelfApiProvider = AudiobookshelfApiFamily._(); /// get the api instance for the given base url -/// -/// Copied from [audiobookshelfApi]. -class AudiobookshelfApiFamily extends Family { - /// get the api instance for the given base url - /// - /// Copied from [audiobookshelfApi]. - const AudiobookshelfApiFamily(); +final class AudiobookshelfApiProvider + extends + $FunctionalProvider< + AudiobookshelfApi, + AudiobookshelfApi, + AudiobookshelfApi + > + with $Provider { /// get the api instance for the given base url - /// - /// Copied from [audiobookshelfApi]. - AudiobookshelfApiProvider call( - Uri? baseUrl, - ) { - return AudiobookshelfApiProvider( - baseUrl, - ); + AudiobookshelfApiProvider._({ + required AudiobookshelfApiFamily super.from, + required Uri? super.argument, + }) : super( + retry: null, + name: r'audiobookshelfApiProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$audiobookshelfApiHash(); + + @override + String toString() { + return r'audiobookshelfApiProvider' + '' + '($argument)'; } + @$internal @override - AudiobookshelfApiProvider getProviderOverride( - covariant AudiobookshelfApiProvider provider, - ) { - return call( - provider.baseUrl, - ); + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + AudiobookshelfApi create(Ref ref) { + final argument = this.argument as Uri?; + return audiobookshelfApi(ref, argument); } - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'audiobookshelfApiProvider'; -} - -/// get the api instance for the given base url -/// -/// Copied from [audiobookshelfApi]. -class AudiobookshelfApiProvider extends AutoDisposeProvider { - /// get the api instance for the given base url - /// - /// Copied from [audiobookshelfApi]. - AudiobookshelfApiProvider( - Uri? baseUrl, - ) : this._internal( - (ref) => audiobookshelfApi( - ref as AudiobookshelfApiRef, - baseUrl, - ), - from: audiobookshelfApiProvider, - name: r'audiobookshelfApiProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$audiobookshelfApiHash, - dependencies: AudiobookshelfApiFamily._dependencies, - allTransitiveDependencies: - AudiobookshelfApiFamily._allTransitiveDependencies, - baseUrl: baseUrl, - ); - - AudiobookshelfApiProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.baseUrl, - }) : super.internal(); - - final Uri? baseUrl; - - @override - Override overrideWith( - AudiobookshelfApi Function(AudiobookshelfApiRef provider) create, - ) { - return ProviderOverride( + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AudiobookshelfApi value) { + return $ProviderOverride( origin: this, - override: AudiobookshelfApiProvider._internal( - (ref) => create(ref as AudiobookshelfApiRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - baseUrl: baseUrl, - ), + providerOverride: $SyncValueProvider(value), ); } - @override - AutoDisposeProviderElement createElement() { - return _AudiobookshelfApiProviderElement(this); - } - @override bool operator ==(Object other) { - return other is AudiobookshelfApiProvider && other.baseUrl == baseUrl; + return other is AudiobookshelfApiProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, baseUrl.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin AudiobookshelfApiRef on AutoDisposeProviderRef { - /// The parameter `baseUrl` of this provider. - Uri? get baseUrl; -} +String _$audiobookshelfApiHash() => r'f23a06c404e11867a7f796877eaca99b8ff25458'; -class _AudiobookshelfApiProviderElement - extends AutoDisposeProviderElement - with AudiobookshelfApiRef { - _AudiobookshelfApiProviderElement(super.provider); +/// get the api instance for the given base url + +final class AudiobookshelfApiFamily extends $Family + with $FunctionalFamilyOverride { + AudiobookshelfApiFamily._() + : super( + retry: null, + name: r'audiobookshelfApiProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + /// get the api instance for the given base url + + AudiobookshelfApiProvider call(Uri? baseUrl) => + AudiobookshelfApiProvider._(argument: baseUrl, from: this); @override - Uri? get baseUrl => (origin as AudiobookshelfApiProvider).baseUrl; + String toString() => r'audiobookshelfApiProvider'; } -String _$authenticatedApiHash() => r'284be2c39823c20fb70035a136c430862c28fa27'; - /// get the api instance for the authenticated user /// /// if the user is not authenticated throw an error -/// -/// Copied from [authenticatedApi]. + @ProviderFor(authenticatedApi) -final authenticatedApiProvider = Provider.internal( - authenticatedApi, - name: r'authenticatedApiProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$authenticatedApiHash, - dependencies: null, - allTransitiveDependencies: null, -); +final authenticatedApiProvider = AuthenticatedApiProvider._(); -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef AuthenticatedApiRef = ProviderRef; -String _$isServerAliveHash() => r'bb3a53cae1eb64b8760a56864feed47b7a3f1c29'; - -/// ping the server to check if it is reachable +/// get the api instance for the authenticated user /// -/// Copied from [isServerAlive]. -@ProviderFor(isServerAlive) -const isServerAliveProvider = IsServerAliveFamily(); +/// if the user is not authenticated throw an error -/// ping the server to check if it is reachable -/// -/// Copied from [isServerAlive]. -class IsServerAliveFamily extends Family> { - /// ping the server to check if it is reachable +final class AuthenticatedApiProvider + extends + $FunctionalProvider< + AudiobookshelfApi, + AudiobookshelfApi, + AudiobookshelfApi + > + with $Provider { + /// get the api instance for the authenticated user /// - /// Copied from [isServerAlive]. - const IsServerAliveFamily(); + /// if the user is not authenticated throw an error + AuthenticatedApiProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'authenticatedApiProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// ping the server to check if it is reachable - /// - /// Copied from [isServerAlive]. - IsServerAliveProvider call( - String address, - ) { - return IsServerAliveProvider( - address, - ); + @override + String debugGetCreateSourceHash() => _$authenticatedApiHash(); + + @$internal + @override + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + AudiobookshelfApi create(Ref ref) { + return authenticatedApi(ref); } - @override - IsServerAliveProvider getProviderOverride( - covariant IsServerAliveProvider provider, - ) { - return call( - provider.address, + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AudiobookshelfApi value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'isServerAliveProvider'; } +String _$authenticatedApiHash() => r'284be2c39823c20fb70035a136c430862c28fa27'; + /// ping the server to check if it is reachable -/// -/// Copied from [isServerAlive]. -class IsServerAliveProvider extends AutoDisposeFutureProvider { + +@ProviderFor(isServerAlive) +final isServerAliveProvider = IsServerAliveFamily._(); + +/// ping the server to check if it is reachable + +final class IsServerAliveProvider + extends $FunctionalProvider, bool, FutureOr> + with $FutureModifier, $FutureProvider { /// ping the server to check if it is reachable - /// - /// Copied from [isServerAlive]. - IsServerAliveProvider( - String address, - ) : this._internal( - (ref) => isServerAlive( - ref as IsServerAliveRef, - address, - ), - from: isServerAliveProvider, - name: r'isServerAliveProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$isServerAliveHash, - dependencies: IsServerAliveFamily._dependencies, - allTransitiveDependencies: - IsServerAliveFamily._allTransitiveDependencies, - address: address, - ); - - IsServerAliveProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.address, - }) : super.internal(); - - final String address; + IsServerAliveProvider._({ + required IsServerAliveFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'isServerAliveProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - Override overrideWith( - FutureOr Function(IsServerAliveRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: IsServerAliveProvider._internal( - (ref) => create(ref as IsServerAliveRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - address: address, - ), - ); + String debugGetCreateSourceHash() => _$isServerAliveHash(); + + @override + String toString() { + return r'isServerAliveProvider' + '' + '($argument)'; } + @$internal @override - AutoDisposeFutureProviderElement createElement() { - return _IsServerAliveProviderElement(this); + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + final argument = this.argument as String; + return isServerAlive(ref, argument); } @override bool operator ==(Object other) { - return other is IsServerAliveProvider && other.address == address; + return other is IsServerAliveProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, address.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin IsServerAliveRef on AutoDisposeFutureProviderRef { - /// The parameter `address` of this provider. - String get address; -} +String _$isServerAliveHash() => r'bb3a53cae1eb64b8760a56864feed47b7a3f1c29'; -class _IsServerAliveProviderElement - extends AutoDisposeFutureProviderElement with IsServerAliveRef { - _IsServerAliveProviderElement(super.provider); +/// ping the server to check if it is reachable + +final class IsServerAliveFamily extends $Family + with $FunctionalFamilyOverride, String> { + IsServerAliveFamily._() + : super( + retry: null, + name: r'isServerAliveProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + /// ping the server to check if it is reachable + + IsServerAliveProvider call(String address) => + IsServerAliveProvider._(argument: address, from: this); @override - String get address => (origin as IsServerAliveProvider).address; + String toString() => r'isServerAliveProvider'; +} + +/// fetch status of server + +@ProviderFor(serverStatus) +final serverStatusProvider = ServerStatusFamily._(); + +/// fetch status of server + +final class ServerStatusProvider + extends + $FunctionalProvider< + AsyncValue, + ServerStatusResponse?, + FutureOr + > + with + $FutureModifier, + $FutureProvider { + /// fetch status of server + ServerStatusProvider._({ + required ServerStatusFamily super.from, + required (Uri, ResponseErrorHandler?) super.argument, + }) : super( + retry: null, + name: r'serverStatusProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$serverStatusHash(); + + @override + String toString() { + return r'serverStatusProvider' + '' + '$argument'; + } + + @$internal + @override + $FutureProviderElement $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + final argument = this.argument as (Uri, ResponseErrorHandler?); + return serverStatus(ref, argument.$1, argument.$2); + } + + @override + bool operator ==(Object other) { + return other is ServerStatusProvider && other.argument == argument; + } + + @override + int get hashCode { + return argument.hashCode; + } } String _$serverStatusHash() => r'2d9c5d6f970caec555e5322d43a388ea8572619f'; /// fetch status of server -/// -/// Copied from [serverStatus]. -@ProviderFor(serverStatus) -const serverStatusProvider = ServerStatusFamily(); -/// fetch status of server -/// -/// Copied from [serverStatus]. -class ServerStatusFamily extends Family> { - /// fetch status of server - /// - /// Copied from [serverStatus]. - const ServerStatusFamily(); +final class ServerStatusFamily extends $Family + with + $FunctionalFamilyOverride< + FutureOr, + (Uri, ResponseErrorHandler?) + > { + ServerStatusFamily._() + : super( + retry: null, + name: r'serverStatusProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); /// fetch status of server - /// - /// Copied from [serverStatus]. + ServerStatusProvider call( Uri baseUrl, [ - void Function(Response, [Object?])? responseErrorHandler, - ]) { - return ServerStatusProvider( - baseUrl, - responseErrorHandler, - ); - } + ResponseErrorHandler? responseErrorHandler, + ]) => ServerStatusProvider._( + argument: (baseUrl, responseErrorHandler), + from: this, + ); @override - ServerStatusProvider getProviderOverride( - covariant ServerStatusProvider provider, - ) { - return call( - provider.baseUrl, - provider.responseErrorHandler, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'serverStatusProvider'; + String toString() => r'serverStatusProvider'; } -/// fetch status of server -/// -/// Copied from [serverStatus]. -class ServerStatusProvider - extends AutoDisposeFutureProvider { - /// fetch status of server - /// - /// Copied from [serverStatus]. - ServerStatusProvider( - Uri baseUrl, [ - void Function(Response, [Object?])? responseErrorHandler, - ]) : this._internal( - (ref) => serverStatus( - ref as ServerStatusRef, - baseUrl, - responseErrorHandler, - ), - from: serverStatusProvider, - name: r'serverStatusProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$serverStatusHash, - dependencies: ServerStatusFamily._dependencies, - allTransitiveDependencies: - ServerStatusFamily._allTransitiveDependencies, - baseUrl: baseUrl, - responseErrorHandler: responseErrorHandler, - ); +/// fetch the personalized view - ServerStatusProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.baseUrl, - required this.responseErrorHandler, - }) : super.internal(); +@ProviderFor(PersonalizedView) +final personalizedViewProvider = PersonalizedViewProvider._(); - final Uri baseUrl; - final void Function(Response, [Object?])? responseErrorHandler; - - @override - Override overrideWith( - FutureOr Function(ServerStatusRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: ServerStatusProvider._internal( - (ref) => create(ref as ServerStatusRef), - from: from, - name: null, +/// fetch the personalized view +final class PersonalizedViewProvider + extends $StreamNotifierProvider> { + /// fetch the personalized view + PersonalizedViewProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'personalizedViewProvider', + isAutoDispose: true, dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - baseUrl: baseUrl, - responseErrorHandler: responseErrorHandler, - ), - ); - } + $allTransitiveDependencies: null, + ); @override - AutoDisposeFutureProviderElement createElement() { - return _ServerStatusProviderElement(this); - } + String debugGetCreateSourceHash() => _$personalizedViewHash(); + @$internal @override - bool operator ==(Object other) { - return other is ServerStatusProvider && - other.baseUrl == baseUrl && - other.responseErrorHandler == responseErrorHandler; - } - - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, baseUrl.hashCode); - hash = _SystemHash.combine(hash, responseErrorHandler.hashCode); - - return _SystemHash.finish(hash); - } -} - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin ServerStatusRef on AutoDisposeFutureProviderRef { - /// The parameter `baseUrl` of this provider. - Uri get baseUrl; - - /// The parameter `responseErrorHandler` of this provider. - void Function(Response, [Object?])? get responseErrorHandler; -} - -class _ServerStatusProviderElement - extends AutoDisposeFutureProviderElement - with ServerStatusRef { - _ServerStatusProviderElement(super.provider); - - @override - Uri get baseUrl => (origin as ServerStatusProvider).baseUrl; - @override - void Function(Response, [Object?])? get responseErrorHandler => - (origin as ServerStatusProvider).responseErrorHandler; -} - -String _$fetchContinueListeningHash() => - r'50aeb77369eda38d496b2f56f3df2aea135dab45'; - -/// fetch continue listening audiobooks -/// -/// Copied from [fetchContinueListening]. -@ProviderFor(fetchContinueListening) -final fetchContinueListeningProvider = - AutoDisposeFutureProvider.internal( - fetchContinueListening, - name: r'fetchContinueListeningProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$fetchContinueListeningHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef FetchContinueListeningRef - = AutoDisposeFutureProviderRef; -String _$meHash() => r'b3b6d6d940b465c60d0c29cd6e81ba2fcccab186'; - -/// See also [me]. -@ProviderFor(me) -final meProvider = AutoDisposeFutureProvider.internal( - me, - name: r'meProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$meHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef MeRef = AutoDisposeFutureProviderRef; -String _$loginHash() => r'99410c2bed9c8f412c7b47c4e655db64e0054be2'; - -/// See also [login]. -@ProviderFor(login) -const loginProvider = LoginFamily(); - -/// See also [login]. -class LoginFamily extends Family> { - /// See also [login]. - const LoginFamily(); - - /// See also [login]. - LoginProvider call({ - AuthenticatedUser? user, - }) { - return LoginProvider( - user: user, - ); - } - - @override - LoginProvider getProviderOverride( - covariant LoginProvider provider, - ) { - return call( - user: provider.user, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'loginProvider'; -} - -/// See also [login]. -class LoginProvider extends AutoDisposeFutureProvider { - /// See also [login]. - LoginProvider({ - AuthenticatedUser? user, - }) : this._internal( - (ref) => login( - ref as LoginRef, - user: user, - ), - from: loginProvider, - name: r'loginProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$loginHash, - dependencies: LoginFamily._dependencies, - allTransitiveDependencies: LoginFamily._allTransitiveDependencies, - user: user, - ); - - LoginProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.user, - }) : super.internal(); - - final AuthenticatedUser? user; - - @override - Override overrideWith( - FutureOr Function(LoginRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: LoginProvider._internal( - (ref) => create(ref as LoginRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - user: user, - ), - ); - } - - @override - AutoDisposeFutureProviderElement createElement() { - return _LoginProviderElement(this); - } - - @override - bool operator ==(Object other) { - return other is LoginProvider && other.user == user; - } - - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, user.hashCode); - - return _SystemHash.finish(hash); - } -} - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin LoginRef on AutoDisposeFutureProviderRef { - /// The parameter `user` of this provider. - AuthenticatedUser? get user; -} - -class _LoginProviderElement - extends AutoDisposeFutureProviderElement with LoginRef { - _LoginProviderElement(super.provider); - - @override - AuthenticatedUser? get user => (origin as LoginProvider).user; + PersonalizedView create() => PersonalizedView(); } String _$personalizedViewHash() => r'425e89d99d7e4712b4d6a688f3a12442bd66584f'; /// fetch the personalized view -/// -/// Copied from [PersonalizedView]. -@ProviderFor(PersonalizedView) -final personalizedViewProvider = - AutoDisposeStreamNotifierProvider>.internal( - PersonalizedView.new, - name: r'personalizedViewProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$personalizedViewHash, - dependencies: null, - allTransitiveDependencies: null, -); -typedef _$PersonalizedView = AutoDisposeStreamNotifier>; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$PersonalizedView extends $StreamNotifier> { + Stream> build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref>, List>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier>, List>, + AsyncValue>, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} + +/// fetch continue listening audiobooks + +@ProviderFor(fetchContinueListening) +final fetchContinueListeningProvider = FetchContinueListeningProvider._(); + +/// fetch continue listening audiobooks + +final class FetchContinueListeningProvider + extends + $FunctionalProvider< + AsyncValue, + GetUserSessionsResponse, + FutureOr + > + with + $FutureModifier, + $FutureProvider { + /// fetch continue listening audiobooks + FetchContinueListeningProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'fetchContinueListeningProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$fetchContinueListeningHash(); + + @$internal + @override + $FutureProviderElement $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return fetchContinueListening(ref); + } +} + +String _$fetchContinueListeningHash() => + r'50aeb77369eda38d496b2f56f3df2aea135dab45'; + +@ProviderFor(me) +final meProvider = MeProvider._(); + +final class MeProvider + extends $FunctionalProvider, User, FutureOr> + with $FutureModifier, $FutureProvider { + MeProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'meProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$meHash(); + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return me(ref); + } +} + +String _$meHash() => r'b3b6d6d940b465c60d0c29cd6e81ba2fcccab186'; + +@ProviderFor(login) +final loginProvider = LoginFamily._(); + +final class LoginProvider + extends + $FunctionalProvider< + AsyncValue, + LoginResponse?, + FutureOr + > + with $FutureModifier, $FutureProvider { + LoginProvider._({ + required LoginFamily super.from, + required AuthenticatedUser? super.argument, + }) : super( + retry: null, + name: r'loginProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$loginHash(); + + @override + String toString() { + return r'loginProvider' + '' + '($argument)'; + } + + @$internal + @override + $FutureProviderElement $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + final argument = this.argument as AuthenticatedUser?; + return login(ref, user: argument); + } + + @override + bool operator ==(Object other) { + return other is LoginProvider && other.argument == argument; + } + + @override + int get hashCode { + return argument.hashCode; + } +} + +String _$loginHash() => r'99410c2bed9c8f412c7b47c4e655db64e0054be2'; + +final class LoginFamily extends $Family + with + $FunctionalFamilyOverride< + FutureOr, + AuthenticatedUser? + > { + LoginFamily._() + : super( + retry: null, + name: r'loginProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + LoginProvider call({AuthenticatedUser? user}) => + LoginProvider._(argument: user, from: this); + + @override + String toString() => r'loginProvider'; +} diff --git a/lib/api/authenticated_users_provider.dart b/lib/api/authenticated_users_provider.dart index 5e78fab..7f74ae4 100644 --- a/lib/api/authenticated_users_provider.dart +++ b/lib/api/authenticated_users_provider.dart @@ -19,7 +19,7 @@ final _logger = Logger('authenticated_users_provider'); class AuthenticatedUsers extends _$AuthenticatedUsers { @override Set build() { - ref.listenSelf((_, __) { + listenSelf((_, __) { writeStateToBox(); }); // get the app settings diff --git a/lib/api/authenticated_users_provider.g.dart b/lib/api/authenticated_users_provider.g.dart index 44a2610..8e3021f 100644 --- a/lib/api/authenticated_users_provider.g.dart +++ b/lib/api/authenticated_users_provider.g.dart @@ -6,25 +6,70 @@ part of 'authenticated_users_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$authenticatedUsersHash() => - r'5fdd472f62fc3b73ff8417cdce9f02e86c33d00f'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning +/// provides with a set of authenticated users + +@ProviderFor(AuthenticatedUsers) +final authenticatedUsersProvider = AuthenticatedUsersProvider._(); /// provides with a set of authenticated users -/// -/// Copied from [AuthenticatedUsers]. -@ProviderFor(AuthenticatedUsers) -final authenticatedUsersProvider = AutoDisposeNotifierProvider< - AuthenticatedUsers, Set>.internal( - AuthenticatedUsers.new, - name: r'authenticatedUsersProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$authenticatedUsersHash, - dependencies: null, - allTransitiveDependencies: null, -); +final class AuthenticatedUsersProvider + extends + $NotifierProvider> { + /// provides with a set of authenticated users + AuthenticatedUsersProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'authenticatedUsersProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); -typedef _$AuthenticatedUsers - = AutoDisposeNotifier>; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package + @override + String debugGetCreateSourceHash() => _$authenticatedUsersHash(); + + @$internal + @override + AuthenticatedUsers create() => AuthenticatedUsers(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(Set value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider>(value), + ); + } +} + +String _$authenticatedUsersHash() => + r'c5e82cc70ffc31a0d315e3db9e07a141c583471e'; + +/// provides with a set of authenticated users + +abstract class _$AuthenticatedUsers + extends $Notifier> { + Set build(); + @$mustCallSuper + @override + void runBuild() { + final ref = + this.ref + as $Ref, Set>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier< + Set, + Set + >, + Set, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/api/image_provider.g.dart b/lib/api/image_provider.g.dart index 25f94d6..02ccad8 100644 --- a/lib/api/image_provider.g.dart +++ b/lib/api/image_provider.g.dart @@ -6,169 +6,94 @@ part of 'image_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$coverImageHash() => r'89cc4783cbc76bb41beae34384d92fb277135c75'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - -abstract class _$CoverImage extends BuildlessStreamNotifier { - late final String itemId; - - Stream build( - String itemId, - ); -} - -/// See also [CoverImage]. @ProviderFor(CoverImage) -const coverImageProvider = CoverImageFamily(); +final coverImageProvider = CoverImageFamily._(); -/// See also [CoverImage]. -class CoverImageFamily extends Family> { - /// See also [CoverImage]. - const CoverImageFamily(); +final class CoverImageProvider + extends $StreamNotifierProvider { + CoverImageProvider._({ + required CoverImageFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'coverImageProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// See also [CoverImage]. - CoverImageProvider call( - String itemId, - ) { - return CoverImageProvider( - itemId, - ); + @override + String debugGetCreateSourceHash() => _$coverImageHash(); + + @override + String toString() { + return r'coverImageProvider' + '' + '($argument)'; } + @$internal @override - CoverImageProvider getProviderOverride( - covariant CoverImageProvider provider, - ) { - return call( - provider.itemId, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'coverImageProvider'; -} - -/// See also [CoverImage]. -class CoverImageProvider - extends StreamNotifierProviderImpl { - /// See also [CoverImage]. - CoverImageProvider( - String itemId, - ) : this._internal( - () => CoverImage()..itemId = itemId, - from: coverImageProvider, - name: r'coverImageProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$coverImageHash, - dependencies: CoverImageFamily._dependencies, - allTransitiveDependencies: - CoverImageFamily._allTransitiveDependencies, - itemId: itemId, - ); - - CoverImageProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.itemId, - }) : super.internal(); - - final String itemId; - - @override - Stream runNotifierBuild( - covariant CoverImage notifier, - ) { - return notifier.build( - itemId, - ); - } - - @override - Override overrideWith(CoverImage Function() create) { - return ProviderOverride( - origin: this, - override: CoverImageProvider._internal( - () => create()..itemId = itemId, - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - itemId: itemId, - ), - ); - } - - @override - StreamNotifierProviderElement createElement() { - return _CoverImageProviderElement(this); - } + CoverImage create() => CoverImage(); @override bool operator ==(Object other) { - return other is CoverImageProvider && other.itemId == itemId; + return other is CoverImageProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, itemId.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin CoverImageRef on StreamNotifierProviderRef { - /// The parameter `itemId` of this provider. - String get itemId; -} +String _$coverImageHash() => r'89cc4783cbc76bb41beae34384d92fb277135c75'; -class _CoverImageProviderElement - extends StreamNotifierProviderElement - with CoverImageRef { - _CoverImageProviderElement(super.provider); +final class CoverImageFamily extends $Family + with + $ClassFamilyOverride< + CoverImage, + AsyncValue, + Uint8List, + Stream, + String + > { + CoverImageFamily._() + : super( + retry: null, + name: r'coverImageProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: false, + ); + + CoverImageProvider call(String itemId) => + CoverImageProvider._(argument: itemId, from: this); @override - String get itemId => (origin as CoverImageProvider).itemId; + String toString() => r'coverImageProvider'; +} + +abstract class _$CoverImage extends $StreamNotifier { + late final _$args = ref.$arg as String; + String get itemId => _$args; + + Stream build(String itemId); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref, Uint8List>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, Uint8List>, + AsyncValue, + Object?, + Object? + >; + element.handleCreate(ref, () => build(_$args)); + } } -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/api/library_item_provider.g.dart b/lib/api/library_item_provider.g.dart index 5261d9c..df8fe0e 100644 --- a/lib/api/library_item_provider.g.dart +++ b/lib/api/library_item_provider.g.dart @@ -6,184 +6,112 @@ part of 'library_item_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$libraryItemHash() => r'a3cfa7f912e9498a70b5782899018b6964d6445c'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - -abstract class _$LibraryItem - extends BuildlessStreamNotifier { - late final String id; - - Stream build( - String id, - ); -} - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// provides the library item for the given id -/// -/// Copied from [LibraryItem]. + @ProviderFor(LibraryItem) -const libraryItemProvider = LibraryItemFamily(); +final libraryItemProvider = LibraryItemFamily._(); /// provides the library item for the given id -/// -/// Copied from [LibraryItem]. -class LibraryItemFamily - extends Family> { +final class LibraryItemProvider + extends $StreamNotifierProvider { /// provides the library item for the given id - /// - /// Copied from [LibraryItem]. - const LibraryItemFamily(); + LibraryItemProvider._({ + required LibraryItemFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'libraryItemProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// provides the library item for the given id - /// - /// Copied from [LibraryItem]. - LibraryItemProvider call( - String id, - ) { - return LibraryItemProvider( - id, - ); + @override + String debugGetCreateSourceHash() => _$libraryItemHash(); + + @override + String toString() { + return r'libraryItemProvider' + '' + '($argument)'; } + @$internal @override - LibraryItemProvider getProviderOverride( - covariant LibraryItemProvider provider, - ) { - return call( - provider.id, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'libraryItemProvider'; -} - -/// provides the library item for the given id -/// -/// Copied from [LibraryItem]. -class LibraryItemProvider extends StreamNotifierProviderImpl { - /// provides the library item for the given id - /// - /// Copied from [LibraryItem]. - LibraryItemProvider( - String id, - ) : this._internal( - () => LibraryItem()..id = id, - from: libraryItemProvider, - name: r'libraryItemProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$libraryItemHash, - dependencies: LibraryItemFamily._dependencies, - allTransitiveDependencies: - LibraryItemFamily._allTransitiveDependencies, - id: id, - ); - - LibraryItemProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.id, - }) : super.internal(); - - final String id; - - @override - Stream runNotifierBuild( - covariant LibraryItem notifier, - ) { - return notifier.build( - id, - ); - } - - @override - Override overrideWith(LibraryItem Function() create) { - return ProviderOverride( - origin: this, - override: LibraryItemProvider._internal( - () => create()..id = id, - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - id: id, - ), - ); - } - - @override - StreamNotifierProviderElement - createElement() { - return _LibraryItemProviderElement(this); - } + LibraryItem create() => LibraryItem(); @override bool operator ==(Object other) { - return other is LibraryItemProvider && other.id == id; + return other is LibraryItemProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, id.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin LibraryItemRef - on StreamNotifierProviderRef { - /// The parameter `id` of this provider. - String get id; -} +String _$libraryItemHash() => r'a3cfa7f912e9498a70b5782899018b6964d6445c'; -class _LibraryItemProviderElement extends StreamNotifierProviderElement< - LibraryItem, shelfsdk.LibraryItemExpanded> with LibraryItemRef { - _LibraryItemProviderElement(super.provider); +/// provides the library item for the given id + +final class LibraryItemFamily extends $Family + with + $ClassFamilyOverride< + LibraryItem, + AsyncValue, + shelfsdk.LibraryItemExpanded, + Stream, + String + > { + LibraryItemFamily._() + : super( + retry: null, + name: r'libraryItemProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: false, + ); + + /// provides the library item for the given id + + LibraryItemProvider call(String id) => + LibraryItemProvider._(argument: id, from: this); @override - String get id => (origin as LibraryItemProvider).id; + String toString() => r'libraryItemProvider'; +} + +/// provides the library item for the given id + +abstract class _$LibraryItem + extends $StreamNotifier { + late final _$args = ref.$arg as String; + String get id => _$args; + + Stream build(String id); + @$mustCallSuper + @override + void runBuild() { + final ref = + this.ref + as $Ref< + AsyncValue, + shelfsdk.LibraryItemExpanded + >; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier< + AsyncValue, + shelfsdk.LibraryItemExpanded + >, + AsyncValue, + Object?, + Object? + >; + element.handleCreate(ref, () => build(_$args)); + } } -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/api/library_provider.dart b/lib/api/library_provider.dart index 62c79d8..b565d26 100644 --- a/lib/api/library_provider.dart +++ b/lib/api/library_provider.dart @@ -1,4 +1,5 @@ -import 'package:hooks_riverpod/hooks_riverpod.dart' show Ref; +import 'package:hooks_riverpod/hooks_riverpod.dart' + show Ref, ProviderListenableSelect; import 'package:logging/logging.dart' show Logger; import 'package:riverpod_annotation/riverpod_annotation.dart'; diff --git a/lib/api/library_provider.g.dart b/lib/api/library_provider.g.dart index a8bc88a..df8fbfd 100644 --- a/lib/api/library_provider.g.dart +++ b/lib/api/library_provider.g.dart @@ -6,187 +6,153 @@ part of 'library_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$libraryHash() => r'f8a34100acb58f02fa958c71a629577bf815710e'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - -/// See also [library]. @ProviderFor(library) -const libraryProvider = LibraryFamily(); +final libraryProvider = LibraryFamily._(); -/// See also [library]. -class LibraryFamily extends Family> { - /// See also [library]. - const LibraryFamily(); +final class LibraryProvider + extends + $FunctionalProvider, Library?, FutureOr> + with $FutureModifier, $FutureProvider { + LibraryProvider._({ + required LibraryFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'libraryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// See also [library]. - LibraryProvider call( - String id, - ) { - return LibraryProvider( - id, - ); + @override + String debugGetCreateSourceHash() => _$libraryHash(); + + @override + String toString() { + return r'libraryProvider' + '' + '($argument)'; } + @$internal @override - LibraryProvider getProviderOverride( - covariant LibraryProvider provider, - ) { - return call( - provider.id, - ); - } - - static const Iterable? _dependencies = null; + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'libraryProvider'; -} - -/// See also [library]. -class LibraryProvider extends AutoDisposeFutureProvider { - /// See also [library]. - LibraryProvider( - String id, - ) : this._internal( - (ref) => library( - ref as LibraryRef, - id, - ), - from: libraryProvider, - name: r'libraryProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$libraryHash, - dependencies: LibraryFamily._dependencies, - allTransitiveDependencies: LibraryFamily._allTransitiveDependencies, - id: id, - ); - - LibraryProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.id, - }) : super.internal(); - - final String id; - - @override - Override overrideWith( - FutureOr Function(LibraryRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: LibraryProvider._internal( - (ref) => create(ref as LibraryRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - id: id, - ), - ); - } - - @override - AutoDisposeFutureProviderElement createElement() { - return _LibraryProviderElement(this); + FutureOr create(Ref ref) { + final argument = this.argument as String; + return library(ref, argument); } @override bool operator ==(Object other) { - return other is LibraryProvider && other.id == id; + return other is LibraryProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, id.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin LibraryRef on AutoDisposeFutureProviderRef { - /// The parameter `id` of this provider. - String get id; -} +String _$libraryHash() => r'f8a34100acb58f02fa958c71a629577bf815710e'; -class _LibraryProviderElement extends AutoDisposeFutureProviderElement - with LibraryRef { - _LibraryProviderElement(super.provider); +final class LibraryFamily extends $Family + with $FunctionalFamilyOverride, String> { + LibraryFamily._() + : super( + retry: null, + name: r'libraryProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + LibraryProvider call(String id) => + LibraryProvider._(argument: id, from: this); @override - String get id => (origin as LibraryProvider).id; + String toString() => r'libraryProvider'; +} + +@ProviderFor(currentLibrary) +final currentLibraryProvider = CurrentLibraryProvider._(); + +final class CurrentLibraryProvider + extends + $FunctionalProvider, Library?, FutureOr> + with $FutureModifier, $FutureProvider { + CurrentLibraryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'currentLibraryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$currentLibraryHash(); + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return currentLibrary(ref); + } } String _$currentLibraryHash() => r'658498a531e04a01e2b3915a3319101285601118'; -/// See also [currentLibrary]. -@ProviderFor(currentLibrary) -final currentLibraryProvider = AutoDisposeFutureProvider.internal( - currentLibrary, - name: r'currentLibraryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$currentLibraryHash, - dependencies: null, - allTransitiveDependencies: null, -); +@ProviderFor(Libraries) +final librariesProvider = LibrariesProvider._(); + +final class LibrariesProvider + extends $AsyncNotifierProvider> { + LibrariesProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'librariesProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$librariesHash(); + + @$internal + @override + Libraries create() => Libraries(); +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CurrentLibraryRef = AutoDisposeFutureProviderRef; String _$librariesHash() => r'95ebd4d1ac0cc2acf7617dc22895eff0ca30600f'; -/// See also [Libraries]. -@ProviderFor(Libraries) -final librariesProvider = - AutoDisposeAsyncNotifierProvider>.internal( - Libraries.new, - name: r'librariesProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$librariesHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$Libraries = AutoDisposeAsyncNotifier>; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$Libraries extends $AsyncNotifier> { + FutureOr> build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref>, List>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier>, List>, + AsyncValue>, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/api/server_provider.dart b/lib/api/server_provider.dart index ef1c864..690dcc4 100644 --- a/lib/api/server_provider.dart +++ b/lib/api/server_provider.dart @@ -28,7 +28,7 @@ class ServerAlreadyExistsException implements Exception { class AudiobookShelfServer extends _$AudiobookShelfServer { @override Set build() { - ref.listenSelf((_, __) { + listenSelf((_, __) { writeStateToBox(); }); // get the app settings diff --git a/lib/api/server_provider.g.dart b/lib/api/server_provider.g.dart index ff2406a..16eddd0 100644 --- a/lib/api/server_provider.g.dart +++ b/lib/api/server_provider.g.dart @@ -6,25 +6,78 @@ part of 'server_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$audiobookShelfServerHash() => - r'31a96b431221965cd586aad670a32ca901539e41'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning +/// provides with a set of servers added by the user + +@ProviderFor(AudiobookShelfServer) +final audiobookShelfServerProvider = AudiobookShelfServerProvider._(); /// provides with a set of servers added by the user -/// -/// Copied from [AudiobookShelfServer]. -@ProviderFor(AudiobookShelfServer) -final audiobookShelfServerProvider = AutoDisposeNotifierProvider< - AudiobookShelfServer, Set>.internal( - AudiobookShelfServer.new, - name: r'audiobookShelfServerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$audiobookShelfServerHash, - dependencies: null, - allTransitiveDependencies: null, -); +final class AudiobookShelfServerProvider + extends + $NotifierProvider< + AudiobookShelfServer, + Set + > { + /// provides with a set of servers added by the user + AudiobookShelfServerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'audiobookShelfServerProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); -typedef _$AudiobookShelfServer - = AutoDisposeNotifier>; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package + @override + String debugGetCreateSourceHash() => _$audiobookShelfServerHash(); + + @$internal + @override + AudiobookShelfServer create() => AudiobookShelfServer(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(Set value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider>( + value, + ), + ); + } +} + +String _$audiobookShelfServerHash() => + r'144817dcb3704b80c5b60763167fcf932f00c29c'; + +/// provides with a set of servers added by the user + +abstract class _$AudiobookShelfServer + extends $Notifier> { + Set build(); + @$mustCallSuper + @override + void runBuild() { + final ref = + this.ref + as $Ref< + Set, + Set + >; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier< + Set, + Set + >, + Set, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/db/available_boxes.dart b/lib/db/available_boxes.dart index ff01acc..dc2d5a1 100644 --- a/lib/db/available_boxes.dart +++ b/lib/db/available_boxes.dart @@ -1,5 +1,5 @@ import 'package:flutter/foundation.dart' show immutable; -import 'package:hive/hive.dart'; +import 'package:hive_plus_secure/hive_plus_secure.dart'; import 'package:vaani/features/per_book_settings/models/book_settings.dart'; import 'package:vaani/settings/models/models.dart'; diff --git a/lib/db/cache/schemas/image.g.dart b/lib/db/cache/schemas/image.g.dart deleted file mode 100644 index 555ce5e..0000000 --- a/lib/db/cache/schemas/image.g.dart +++ /dev/null @@ -1,1009 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'image.dart'; - -// ************************************************************************** -// _IsarCollectionGenerator -// ************************************************************************** - -// coverage:ignore-file -// ignore_for_file: duplicate_ignore, invalid_use_of_protected_member, lines_longer_than_80_chars, constant_identifier_names, avoid_js_rounded_ints, no_leading_underscores_for_local_identifiers, require_trailing_commas, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_in_if_null_operators, library_private_types_in_public_api, prefer_const_constructors -// ignore_for_file: type=lint - -extension GetImageCollection on Isar { - IsarCollection get images => this.collection(); -} - -const ImageSchema = IsarGeneratedSchema( - schema: IsarSchema( - name: 'CacheImage', - idName: 'id', - embedded: false, - properties: [ - IsarPropertySchema( - name: 'thumbnailPath', - type: IsarType.string, - ), - IsarPropertySchema( - name: 'imagePath', - type: IsarType.string, - ), - IsarPropertySchema( - name: 'lastSaved', - type: IsarType.dateTime, - ), - ], - indexes: [], - ), - converter: IsarObjectConverter( - serialize: serializeImage, - deserialize: deserializeImage, - deserializeProperty: deserializeImageProp, - ), - embeddedSchemas: [], -); - -@isarProtected -int serializeImage(IsarWriter writer, Image object) { - { - final value = object.thumbnailPath; - if (value == null) { - IsarCore.writeNull(writer, 1); - } else { - IsarCore.writeString(writer, 1, value); - } - } - { - final value = object.imagePath; - if (value == null) { - IsarCore.writeNull(writer, 2); - } else { - IsarCore.writeString(writer, 2, value); - } - } - IsarCore.writeLong( - writer, 3, object.lastSaved.toUtc().microsecondsSinceEpoch); - return object.id; -} - -@isarProtected -Image deserializeImage(IsarReader reader) { - final int _id; - _id = IsarCore.readId(reader); - final String? _thumbnailPath; - _thumbnailPath = IsarCore.readString(reader, 1); - final String? _imagePath; - _imagePath = IsarCore.readString(reader, 2); - final object = Image( - id: _id, - thumbnailPath: _thumbnailPath, - imagePath: _imagePath, - ); - { - final value = IsarCore.readLong(reader, 3); - if (value == -9223372036854775808) { - object.lastSaved = - DateTime.fromMillisecondsSinceEpoch(0, isUtc: true).toLocal(); - } else { - object.lastSaved = - DateTime.fromMicrosecondsSinceEpoch(value, isUtc: true).toLocal(); - } - } - return object; -} - -@isarProtected -dynamic deserializeImageProp(IsarReader reader, int property) { - switch (property) { - case 0: - return IsarCore.readId(reader); - case 1: - return IsarCore.readString(reader, 1); - case 2: - return IsarCore.readString(reader, 2); - case 3: - { - final value = IsarCore.readLong(reader, 3); - if (value == -9223372036854775808) { - return DateTime.fromMillisecondsSinceEpoch(0, isUtc: true).toLocal(); - } else { - return DateTime.fromMicrosecondsSinceEpoch(value, isUtc: true) - .toLocal(); - } - } - default: - throw ArgumentError('Unknown property: $property'); - } -} - -sealed class _ImageUpdate { - bool call({ - required int id, - String? thumbnailPath, - String? imagePath, - DateTime? lastSaved, - }); -} - -class _ImageUpdateImpl implements _ImageUpdate { - const _ImageUpdateImpl(this.collection); - - final IsarCollection collection; - - @override - bool call({ - required int id, - Object? thumbnailPath = ignore, - Object? imagePath = ignore, - Object? lastSaved = ignore, - }) { - return collection.updateProperties([ - id - ], { - if (thumbnailPath != ignore) 1: thumbnailPath as String?, - if (imagePath != ignore) 2: imagePath as String?, - if (lastSaved != ignore) 3: lastSaved as DateTime?, - }) > - 0; - } -} - -sealed class _ImageUpdateAll { - int call({ - required List id, - String? thumbnailPath, - String? imagePath, - DateTime? lastSaved, - }); -} - -class _ImageUpdateAllImpl implements _ImageUpdateAll { - const _ImageUpdateAllImpl(this.collection); - - final IsarCollection collection; - - @override - int call({ - required List id, - Object? thumbnailPath = ignore, - Object? imagePath = ignore, - Object? lastSaved = ignore, - }) { - return collection.updateProperties(id, { - if (thumbnailPath != ignore) 1: thumbnailPath as String?, - if (imagePath != ignore) 2: imagePath as String?, - if (lastSaved != ignore) 3: lastSaved as DateTime?, - }); - } -} - -extension ImageUpdate on IsarCollection { - _ImageUpdate get update => _ImageUpdateImpl(this); - - _ImageUpdateAll get updateAll => _ImageUpdateAllImpl(this); -} - -sealed class _ImageQueryUpdate { - int call({ - String? thumbnailPath, - String? imagePath, - DateTime? lastSaved, - }); -} - -class _ImageQueryUpdateImpl implements _ImageQueryUpdate { - const _ImageQueryUpdateImpl(this.query, {this.limit}); - - final IsarQuery query; - final int? limit; - - @override - int call({ - Object? thumbnailPath = ignore, - Object? imagePath = ignore, - Object? lastSaved = ignore, - }) { - return query.updateProperties(limit: limit, { - if (thumbnailPath != ignore) 1: thumbnailPath as String?, - if (imagePath != ignore) 2: imagePath as String?, - if (lastSaved != ignore) 3: lastSaved as DateTime?, - }); - } -} - -extension ImageQueryUpdate on IsarQuery { - _ImageQueryUpdate get updateFirst => _ImageQueryUpdateImpl(this, limit: 1); - - _ImageQueryUpdate get updateAll => _ImageQueryUpdateImpl(this); -} - -class _ImageQueryBuilderUpdateImpl implements _ImageQueryUpdate { - const _ImageQueryBuilderUpdateImpl(this.query, {this.limit}); - - final QueryBuilder query; - final int? limit; - - @override - int call({ - Object? thumbnailPath = ignore, - Object? imagePath = ignore, - Object? lastSaved = ignore, - }) { - final q = query.build(); - try { - return q.updateProperties(limit: limit, { - if (thumbnailPath != ignore) 1: thumbnailPath as String?, - if (imagePath != ignore) 2: imagePath as String?, - if (lastSaved != ignore) 3: lastSaved as DateTime?, - }); - } finally { - q.close(); - } - } -} - -extension ImageQueryBuilderUpdate on QueryBuilder { - _ImageQueryUpdate get updateFirst => - _ImageQueryBuilderUpdateImpl(this, limit: 1); - - _ImageQueryUpdate get updateAll => _ImageQueryBuilderUpdateImpl(this); -} - -extension ImageQueryFilter on QueryBuilder { - QueryBuilder idEqualTo( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - EqualCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder idGreaterThan( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder idGreaterThanOrEqualTo( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterOrEqualCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder idLessThan( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder idLessThanOrEqualTo( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessOrEqualCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder idBetween( - int lower, - int upper, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - BetweenCondition( - property: 0, - lower: lower, - upper: upper, - ), - ); - }); - } - - QueryBuilder thumbnailPathIsNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const IsNullCondition(property: 1)); - }); - } - - QueryBuilder thumbnailPathIsNotNull() { - return QueryBuilder.apply(not(), (query) { - return query.addFilterCondition(const IsNullCondition(property: 1)); - }); - } - - QueryBuilder thumbnailPathEqualTo( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - EqualCondition( - property: 1, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder thumbnailPathGreaterThan( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterCondition( - property: 1, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder - thumbnailPathGreaterThanOrEqualTo( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterOrEqualCondition( - property: 1, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder thumbnailPathLessThan( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessCondition( - property: 1, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder - thumbnailPathLessThanOrEqualTo( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessOrEqualCondition( - property: 1, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder thumbnailPathBetween( - String? lower, - String? upper, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - BetweenCondition( - property: 1, - lower: lower, - upper: upper, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder thumbnailPathStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - StartsWithCondition( - property: 1, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder thumbnailPathEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - EndsWithCondition( - property: 1, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder thumbnailPathContains( - String value, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - ContainsCondition( - property: 1, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder thumbnailPathMatches( - String pattern, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - MatchesCondition( - property: 1, - wildcard: pattern, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder thumbnailPathIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - const EqualCondition( - property: 1, - value: '', - ), - ); - }); - } - - QueryBuilder thumbnailPathIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - const GreaterCondition( - property: 1, - value: '', - ), - ); - }); - } - - QueryBuilder imagePathIsNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const IsNullCondition(property: 2)); - }); - } - - QueryBuilder imagePathIsNotNull() { - return QueryBuilder.apply(not(), (query) { - return query.addFilterCondition(const IsNullCondition(property: 2)); - }); - } - - QueryBuilder imagePathEqualTo( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - EqualCondition( - property: 2, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathGreaterThan( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterCondition( - property: 2, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder - imagePathGreaterThanOrEqualTo( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterOrEqualCondition( - property: 2, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathLessThan( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessCondition( - property: 2, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathLessThanOrEqualTo( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessOrEqualCondition( - property: 2, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathBetween( - String? lower, - String? upper, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - BetweenCondition( - property: 2, - lower: lower, - upper: upper, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - StartsWithCondition( - property: 2, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - EndsWithCondition( - property: 2, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathContains( - String value, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - ContainsCondition( - property: 2, - value: value, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathMatches( - String pattern, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - MatchesCondition( - property: 2, - wildcard: pattern, - caseSensitive: caseSensitive, - ), - ); - }); - } - - QueryBuilder imagePathIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - const EqualCondition( - property: 2, - value: '', - ), - ); - }); - } - - QueryBuilder imagePathIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - const GreaterCondition( - property: 2, - value: '', - ), - ); - }); - } - - QueryBuilder lastSavedEqualTo( - DateTime value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - EqualCondition( - property: 3, - value: value, - ), - ); - }); - } - - QueryBuilder lastSavedGreaterThan( - DateTime value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterCondition( - property: 3, - value: value, - ), - ); - }); - } - - QueryBuilder - lastSavedGreaterThanOrEqualTo( - DateTime value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterOrEqualCondition( - property: 3, - value: value, - ), - ); - }); - } - - QueryBuilder lastSavedLessThan( - DateTime value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessCondition( - property: 3, - value: value, - ), - ); - }); - } - - QueryBuilder lastSavedLessThanOrEqualTo( - DateTime value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessOrEqualCondition( - property: 3, - value: value, - ), - ); - }); - } - - QueryBuilder lastSavedBetween( - DateTime lower, - DateTime upper, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - BetweenCondition( - property: 3, - lower: lower, - upper: upper, - ), - ); - }); - } -} - -extension ImageQueryObject on QueryBuilder {} - -extension ImageQuerySortBy on QueryBuilder { - QueryBuilder sortById() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(0); - }); - } - - QueryBuilder sortByIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(0, sort: Sort.desc); - }); - } - - QueryBuilder sortByThumbnailPath( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addSortBy( - 1, - caseSensitive: caseSensitive, - ); - }); - } - - QueryBuilder sortByThumbnailPathDesc( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addSortBy( - 1, - sort: Sort.desc, - caseSensitive: caseSensitive, - ); - }); - } - - QueryBuilder sortByImagePath( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addSortBy( - 2, - caseSensitive: caseSensitive, - ); - }); - } - - QueryBuilder sortByImagePathDesc( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addSortBy( - 2, - sort: Sort.desc, - caseSensitive: caseSensitive, - ); - }); - } - - QueryBuilder sortByLastSaved() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(3); - }); - } - - QueryBuilder sortByLastSavedDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(3, sort: Sort.desc); - }); - } -} - -extension ImageQuerySortThenBy on QueryBuilder { - QueryBuilder thenById() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(0); - }); - } - - QueryBuilder thenByIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(0, sort: Sort.desc); - }); - } - - QueryBuilder thenByThumbnailPath( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(1, caseSensitive: caseSensitive); - }); - } - - QueryBuilder thenByThumbnailPathDesc( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(1, sort: Sort.desc, caseSensitive: caseSensitive); - }); - } - - QueryBuilder thenByImagePath( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(2, caseSensitive: caseSensitive); - }); - } - - QueryBuilder thenByImagePathDesc( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(2, sort: Sort.desc, caseSensitive: caseSensitive); - }); - } - - QueryBuilder thenByLastSaved() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(3); - }); - } - - QueryBuilder thenByLastSavedDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(3, sort: Sort.desc); - }); - } -} - -extension ImageQueryWhereDistinct on QueryBuilder { - QueryBuilder distinctByThumbnailPath( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(1, caseSensitive: caseSensitive); - }); - } - - QueryBuilder distinctByImagePath( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(2, caseSensitive: caseSensitive); - }); - } - - QueryBuilder distinctByLastSaved() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(3); - }); - } -} - -extension ImageQueryProperty1 on QueryBuilder { - QueryBuilder idProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(0); - }); - } - - QueryBuilder thumbnailPathProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(1); - }); - } - - QueryBuilder imagePathProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(2); - }); - } - - QueryBuilder lastSavedProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(3); - }); - } -} - -extension ImageQueryProperty2 on QueryBuilder { - QueryBuilder idProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(0); - }); - } - - QueryBuilder thumbnailPathProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(1); - }); - } - - QueryBuilder imagePathProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(2); - }); - } - - QueryBuilder lastSavedProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(3); - }); - } -} - -extension ImageQueryProperty3 - on QueryBuilder { - QueryBuilder idProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(0); - }); - } - - QueryBuilder thumbnailPathProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(1); - }); - } - - QueryBuilder imagePathProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(2); - }); - } - - QueryBuilder lastSavedProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(3); - }); - } -} diff --git a/lib/db/init.dart b/lib/db/init.dart index 8b5e7d0..452648e 100644 --- a/lib/db/init.dart +++ b/lib/db/init.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:hive/hive.dart'; +import 'package:hive_plus_secure/hive_plus_secure.dart'; import 'package:path/path.dart' as p; import 'package:path_provider/path_provider.dart'; import 'package:vaani/main.dart'; diff --git a/lib/db/player_prefs/book_prefs.g.dart b/lib/db/player_prefs/book_prefs.g.dart deleted file mode 100644 index ee012a5..0000000 --- a/lib/db/player_prefs/book_prefs.g.dart +++ /dev/null @@ -1,496 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'book_prefs.dart'; - -// ************************************************************************** -// _IsarCollectionGenerator -// ************************************************************************** - -// coverage:ignore-file -// ignore_for_file: duplicate_ignore, invalid_use_of_protected_member, lines_longer_than_80_chars, constant_identifier_names, avoid_js_rounded_ints, no_leading_underscores_for_local_identifiers, require_trailing_commas, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_in_if_null_operators, library_private_types_in_public_api, prefer_const_constructors -// ignore_for_file: type=lint - -extension GetBookPrefsCollection on Isar { - IsarCollection get bookPrefs => this.collection(); -} - -const BookPrefsSchema = IsarGeneratedSchema( - schema: IsarSchema( - name: 'BookPrefs', - idName: 'libItemId', - embedded: false, - properties: [ - IsarPropertySchema( - name: 'speed', - type: IsarType.double, - ), - ], - indexes: [], - ), - converter: IsarObjectConverter( - serialize: serializeBookPrefs, - deserialize: deserializeBookPrefs, - deserializeProperty: deserializeBookPrefsProp, - ), - embeddedSchemas: [], -); - -@isarProtected -int serializeBookPrefs(IsarWriter writer, BookPrefs object) { - IsarCore.writeDouble(writer, 1, object.speed ?? double.nan); - return object.libItemId; -} - -@isarProtected -BookPrefs deserializeBookPrefs(IsarReader reader) { - final int _libItemId; - _libItemId = IsarCore.readId(reader); - final double? _speed; - { - final value = IsarCore.readDouble(reader, 1); - if (value.isNaN) { - _speed = null; - } else { - _speed = value; - } - } - final object = BookPrefs( - libItemId: _libItemId, - speed: _speed, - ); - return object; -} - -@isarProtected -dynamic deserializeBookPrefsProp(IsarReader reader, int property) { - switch (property) { - case 0: - return IsarCore.readId(reader); - case 1: - { - final value = IsarCore.readDouble(reader, 1); - if (value.isNaN) { - return null; - } else { - return value; - } - } - default: - throw ArgumentError('Unknown property: $property'); - } -} - -sealed class _BookPrefsUpdate { - bool call({ - required int libItemId, - double? speed, - }); -} - -class _BookPrefsUpdateImpl implements _BookPrefsUpdate { - const _BookPrefsUpdateImpl(this.collection); - - final IsarCollection collection; - - @override - bool call({ - required int libItemId, - Object? speed = ignore, - }) { - return collection.updateProperties([ - libItemId - ], { - if (speed != ignore) 1: speed as double?, - }) > - 0; - } -} - -sealed class _BookPrefsUpdateAll { - int call({ - required List libItemId, - double? speed, - }); -} - -class _BookPrefsUpdateAllImpl implements _BookPrefsUpdateAll { - const _BookPrefsUpdateAllImpl(this.collection); - - final IsarCollection collection; - - @override - int call({ - required List libItemId, - Object? speed = ignore, - }) { - return collection.updateProperties(libItemId, { - if (speed != ignore) 1: speed as double?, - }); - } -} - -extension BookPrefsUpdate on IsarCollection { - _BookPrefsUpdate get update => _BookPrefsUpdateImpl(this); - - _BookPrefsUpdateAll get updateAll => _BookPrefsUpdateAllImpl(this); -} - -sealed class _BookPrefsQueryUpdate { - int call({ - double? speed, - }); -} - -class _BookPrefsQueryUpdateImpl implements _BookPrefsQueryUpdate { - const _BookPrefsQueryUpdateImpl(this.query, {this.limit}); - - final IsarQuery query; - final int? limit; - - @override - int call({ - Object? speed = ignore, - }) { - return query.updateProperties(limit: limit, { - if (speed != ignore) 1: speed as double?, - }); - } -} - -extension BookPrefsQueryUpdate on IsarQuery { - _BookPrefsQueryUpdate get updateFirst => - _BookPrefsQueryUpdateImpl(this, limit: 1); - - _BookPrefsQueryUpdate get updateAll => _BookPrefsQueryUpdateImpl(this); -} - -class _BookPrefsQueryBuilderUpdateImpl implements _BookPrefsQueryUpdate { - const _BookPrefsQueryBuilderUpdateImpl(this.query, {this.limit}); - - final QueryBuilder query; - final int? limit; - - @override - int call({ - Object? speed = ignore, - }) { - final q = query.build(); - try { - return q.updateProperties(limit: limit, { - if (speed != ignore) 1: speed as double?, - }); - } finally { - q.close(); - } - } -} - -extension BookPrefsQueryBuilderUpdate - on QueryBuilder { - _BookPrefsQueryUpdate get updateFirst => - _BookPrefsQueryBuilderUpdateImpl(this, limit: 1); - - _BookPrefsQueryUpdate get updateAll => _BookPrefsQueryBuilderUpdateImpl(this); -} - -extension BookPrefsQueryFilter - on QueryBuilder { - QueryBuilder libItemIdEqualTo( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - EqualCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder - libItemIdGreaterThan( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder - libItemIdGreaterThanOrEqualTo( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterOrEqualCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder libItemIdLessThan( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder - libItemIdLessThanOrEqualTo( - int value, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessOrEqualCondition( - property: 0, - value: value, - ), - ); - }); - } - - QueryBuilder libItemIdBetween( - int lower, - int upper, - ) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - BetweenCondition( - property: 0, - lower: lower, - upper: upper, - ), - ); - }); - } - - QueryBuilder speedIsNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const IsNullCondition(property: 1)); - }); - } - - QueryBuilder speedIsNotNull() { - return QueryBuilder.apply(not(), (query) { - return query.addFilterCondition(const IsNullCondition(property: 1)); - }); - } - - QueryBuilder speedEqualTo( - double? value, { - double epsilon = Filter.epsilon, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - EqualCondition( - property: 1, - value: value, - epsilon: epsilon, - ), - ); - }); - } - - QueryBuilder speedGreaterThan( - double? value, { - double epsilon = Filter.epsilon, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterCondition( - property: 1, - value: value, - epsilon: epsilon, - ), - ); - }); - } - - QueryBuilder - speedGreaterThanOrEqualTo( - double? value, { - double epsilon = Filter.epsilon, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - GreaterOrEqualCondition( - property: 1, - value: value, - epsilon: epsilon, - ), - ); - }); - } - - QueryBuilder speedLessThan( - double? value, { - double epsilon = Filter.epsilon, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessCondition( - property: 1, - value: value, - epsilon: epsilon, - ), - ); - }); - } - - QueryBuilder - speedLessThanOrEqualTo( - double? value, { - double epsilon = Filter.epsilon, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - LessOrEqualCondition( - property: 1, - value: value, - epsilon: epsilon, - ), - ); - }); - } - - QueryBuilder speedBetween( - double? lower, - double? upper, { - double epsilon = Filter.epsilon, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition( - BetweenCondition( - property: 1, - lower: lower, - upper: upper, - epsilon: epsilon, - ), - ); - }); - } -} - -extension BookPrefsQueryObject - on QueryBuilder {} - -extension BookPrefsQuerySortBy on QueryBuilder { - QueryBuilder sortByLibItemId() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(0); - }); - } - - QueryBuilder sortByLibItemIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(0, sort: Sort.desc); - }); - } - - QueryBuilder sortBySpeed() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(1); - }); - } - - QueryBuilder sortBySpeedDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(1, sort: Sort.desc); - }); - } -} - -extension BookPrefsQuerySortThenBy - on QueryBuilder { - QueryBuilder thenByLibItemId() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(0); - }); - } - - QueryBuilder thenByLibItemIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(0, sort: Sort.desc); - }); - } - - QueryBuilder thenBySpeed() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(1); - }); - } - - QueryBuilder thenBySpeedDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(1, sort: Sort.desc); - }); - } -} - -extension BookPrefsQueryWhereDistinct - on QueryBuilder { - QueryBuilder distinctBySpeed() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(1); - }); - } -} - -extension BookPrefsQueryProperty1 - on QueryBuilder { - QueryBuilder libItemIdProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(0); - }); - } - - QueryBuilder speedProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(1); - }); - } -} - -extension BookPrefsQueryProperty2 - on QueryBuilder { - QueryBuilder libItemIdProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(0); - }); - } - - QueryBuilder speedProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(1); - }); - } -} - -extension BookPrefsQueryProperty3 - on QueryBuilder { - QueryBuilder libItemIdProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(0); - }); - } - - QueryBuilder speedProperty() { - return QueryBuilder.apply(this, (query) { - return query.addProperty(1); - }); - } -} diff --git a/lib/db/register_models.dart b/lib/db/register_models.dart index e185e33..8695ab1 100644 --- a/lib/db/register_models.dart +++ b/lib/db/register_models.dart @@ -1,4 +1,4 @@ -import 'package:hive/hive.dart'; +import 'package:hive_plus_secure/hive_plus_secure.dart'; import 'package:vaani/features/per_book_settings/models/book_settings.dart'; import 'package:vaani/settings/models/models.dart'; diff --git a/lib/features/downloads/providers/download_manager.dart b/lib/features/downloads/providers/download_manager.dart index 6ffdded..7f75a17 100644 --- a/lib/features/downloads/providers/download_manager.dart +++ b/lib/features/downloads/providers/download_manager.dart @@ -110,7 +110,7 @@ class ItemDownloadProgress extends _$ItemDownloadProgress { final totalDownloadedSize = downloadedSize + inProgressFileSize; final progress = totalDownloadedSize / totalSize; // if current progress is more than calculated progress, do not update - if (progress < (state.valueOrNull ?? 0.0)) { + if (progress < (state.value ?? 0.0)) { return; } diff --git a/lib/features/downloads/providers/download_manager.g.dart b/lib/features/downloads/providers/download_manager.g.dart index 6b08886..0d0879e 100644 --- a/lib/features/downloads/providers/download_manager.g.dart +++ b/lib/features/downloads/providers/download_manager.g.dart @@ -6,627 +6,480 @@ part of 'download_manager.dart'; // RiverpodGenerator // ************************************************************************** -String _$downloadHistoryHash() => r'4d8b84e30f7ff5ae69d23c8e03ff24af1234a1ad'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); +@ProviderFor(SimpleDownloadManager) +final simpleDownloadManagerProvider = SimpleDownloadManagerProvider._(); - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - -/// See also [downloadHistory]. -@ProviderFor(downloadHistory) -const downloadHistoryProvider = DownloadHistoryFamily(); - -/// See also [downloadHistory]. -class DownloadHistoryFamily extends Family>> { - /// See also [downloadHistory]. - const DownloadHistoryFamily(); - - /// See also [downloadHistory]. - DownloadHistoryProvider call({ - String? group, - }) { - return DownloadHistoryProvider( - group: group, - ); - } - - @override - DownloadHistoryProvider getProviderOverride( - covariant DownloadHistoryProvider provider, - ) { - return call( - group: provider.group, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'downloadHistoryProvider'; -} - -/// See also [downloadHistory]. -class DownloadHistoryProvider - extends AutoDisposeFutureProvider> { - /// See also [downloadHistory]. - DownloadHistoryProvider({ - String? group, - }) : this._internal( - (ref) => downloadHistory( - ref as DownloadHistoryRef, - group: group, - ), - from: downloadHistoryProvider, - name: r'downloadHistoryProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$downloadHistoryHash, - dependencies: DownloadHistoryFamily._dependencies, - allTransitiveDependencies: - DownloadHistoryFamily._allTransitiveDependencies, - group: group, - ); - - DownloadHistoryProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.group, - }) : super.internal(); - - final String? group; - - @override - Override overrideWith( - FutureOr> Function(DownloadHistoryRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: DownloadHistoryProvider._internal( - (ref) => create(ref as DownloadHistoryRef), - from: from, - name: null, +final class SimpleDownloadManagerProvider + extends + $NotifierProvider< + SimpleDownloadManager, + core.AudiobookDownloadManager + > { + SimpleDownloadManagerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'simpleDownloadManagerProvider', + isAutoDispose: false, dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - group: group, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$simpleDownloadManagerHash(); + + @$internal + @override + SimpleDownloadManager create() => SimpleDownloadManager(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(core.AudiobookDownloadManager value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider( + value, ), ); } - - @override - AutoDisposeFutureProviderElement> createElement() { - return _DownloadHistoryProviderElement(this); - } - - @override - bool operator ==(Object other) { - return other is DownloadHistoryProvider && other.group == group; - } - - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, group.hashCode); - - return _SystemHash.finish(hash); - } -} - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin DownloadHistoryRef on AutoDisposeFutureProviderRef> { - /// The parameter `group` of this provider. - String? get group; -} - -class _DownloadHistoryProviderElement - extends AutoDisposeFutureProviderElement> - with DownloadHistoryRef { - _DownloadHistoryProviderElement(super.provider); - - @override - String? get group => (origin as DownloadHistoryProvider).group; } String _$simpleDownloadManagerHash() => r'8ab13f06ec5f2f73b73064bd285813dc890b7f36'; -/// See also [SimpleDownloadManager]. -@ProviderFor(SimpleDownloadManager) -final simpleDownloadManagerProvider = NotifierProvider.internal( - SimpleDownloadManager.new, - name: r'simpleDownloadManagerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$simpleDownloadManagerHash, - dependencies: null, - allTransitiveDependencies: null, -); +abstract class _$SimpleDownloadManager + extends $Notifier { + core.AudiobookDownloadManager build(); + @$mustCallSuper + @override + void runBuild() { + final ref = + this.ref + as $Ref< + core.AudiobookDownloadManager, + core.AudiobookDownloadManager + >; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier< + core.AudiobookDownloadManager, + core.AudiobookDownloadManager + >, + core.AudiobookDownloadManager, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} -typedef _$SimpleDownloadManager = Notifier; -String _$downloadManagerHash() => r'852012e32e613f86445afc7f7e4e85bec808e982'; - -/// See also [DownloadManager]. @ProviderFor(DownloadManager) -final downloadManagerProvider = - NotifierProvider.internal( - DownloadManager.new, - name: r'downloadManagerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$downloadManagerHash, - dependencies: null, - allTransitiveDependencies: null, -); +final downloadManagerProvider = DownloadManagerProvider._(); -typedef _$DownloadManager = Notifier; -String _$isItemDownloadingHash() => r'ea43c06393beec828134e08d5f896ddbcfbac8f0'; - -abstract class _$IsItemDownloading extends BuildlessAutoDisposeNotifier { - late final String id; - - bool build( - String id, - ); -} - -/// See also [IsItemDownloading]. -@ProviderFor(IsItemDownloading) -const isItemDownloadingProvider = IsItemDownloadingFamily(); - -/// See also [IsItemDownloading]. -class IsItemDownloadingFamily extends Family { - /// See also [IsItemDownloading]. - const IsItemDownloadingFamily(); - - /// See also [IsItemDownloading]. - IsItemDownloadingProvider call( - String id, - ) { - return IsItemDownloadingProvider( - id, - ); - } - - @override - IsItemDownloadingProvider getProviderOverride( - covariant IsItemDownloadingProvider provider, - ) { - return call( - provider.id, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'isItemDownloadingProvider'; -} - -/// See also [IsItemDownloading]. -class IsItemDownloadingProvider - extends AutoDisposeNotifierProviderImpl { - /// See also [IsItemDownloading]. - IsItemDownloadingProvider( - String id, - ) : this._internal( - () => IsItemDownloading()..id = id, - from: isItemDownloadingProvider, - name: r'isItemDownloadingProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$isItemDownloadingHash, - dependencies: IsItemDownloadingFamily._dependencies, - allTransitiveDependencies: - IsItemDownloadingFamily._allTransitiveDependencies, - id: id, - ); - - IsItemDownloadingProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.id, - }) : super.internal(); - - final String id; - - @override - bool runNotifierBuild( - covariant IsItemDownloading notifier, - ) { - return notifier.build( - id, - ); - } - - @override - Override overrideWith(IsItemDownloading Function() create) { - return ProviderOverride( - origin: this, - override: IsItemDownloadingProvider._internal( - () => create()..id = id, - from: from, - name: null, +final class DownloadManagerProvider + extends $NotifierProvider { + DownloadManagerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'downloadManagerProvider', + isAutoDispose: false, dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - id: id, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$downloadManagerHash(); + + @$internal + @override + DownloadManager create() => DownloadManager(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(core.AudiobookDownloadManager value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider( + value, ), ); } +} + +String _$downloadManagerHash() => r'852012e32e613f86445afc7f7e4e85bec808e982'; + +abstract class _$DownloadManager + extends $Notifier { + core.AudiobookDownloadManager build(); + @$mustCallSuper + @override + void runBuild() { + final ref = + this.ref + as $Ref< + core.AudiobookDownloadManager, + core.AudiobookDownloadManager + >; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier< + core.AudiobookDownloadManager, + core.AudiobookDownloadManager + >, + core.AudiobookDownloadManager, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} + +@ProviderFor(IsItemDownloading) +final isItemDownloadingProvider = IsItemDownloadingFamily._(); + +final class IsItemDownloadingProvider + extends $NotifierProvider { + IsItemDownloadingProvider._({ + required IsItemDownloadingFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'isItemDownloadingProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - AutoDisposeNotifierProviderElement createElement() { - return _IsItemDownloadingProviderElement(this); + String debugGetCreateSourceHash() => _$isItemDownloadingHash(); + + @override + String toString() { + return r'isItemDownloadingProvider' + '' + '($argument)'; + } + + @$internal + @override + IsItemDownloading create() => IsItemDownloading(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(bool value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); } @override bool operator ==(Object other) { - return other is IsItemDownloadingProvider && other.id == id; + return other is IsItemDownloadingProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, id.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin IsItemDownloadingRef on AutoDisposeNotifierProviderRef { - /// The parameter `id` of this provider. - String get id; -} +String _$isItemDownloadingHash() => r'ea43c06393beec828134e08d5f896ddbcfbac8f0'; -class _IsItemDownloadingProviderElement - extends AutoDisposeNotifierProviderElement - with IsItemDownloadingRef { - _IsItemDownloadingProviderElement(super.provider); +final class IsItemDownloadingFamily extends $Family + with $ClassFamilyOverride { + IsItemDownloadingFamily._() + : super( + retry: null, + name: r'isItemDownloadingProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + IsItemDownloadingProvider call(String id) => + IsItemDownloadingProvider._(argument: id, from: this); @override - String get id => (origin as IsItemDownloadingProvider).id; + String toString() => r'isItemDownloadingProvider'; +} + +abstract class _$IsItemDownloading extends $Notifier { + late final _$args = ref.$arg as String; + String get id => _$args; + + bool build(String id); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + bool, + Object?, + Object? + >; + element.handleCreate(ref, () => build(_$args)); + } +} + +@ProviderFor(ItemDownloadProgress) +final itemDownloadProgressProvider = ItemDownloadProgressFamily._(); + +final class ItemDownloadProgressProvider + extends $AsyncNotifierProvider { + ItemDownloadProgressProvider._({ + required ItemDownloadProgressFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'itemDownloadProgressProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$itemDownloadProgressHash(); + + @override + String toString() { + return r'itemDownloadProgressProvider' + '' + '($argument)'; + } + + @$internal + @override + ItemDownloadProgress create() => ItemDownloadProgress(); + + @override + bool operator ==(Object other) { + return other is ItemDownloadProgressProvider && other.argument == argument; + } + + @override + int get hashCode { + return argument.hashCode; + } } String _$itemDownloadProgressHash() => - r'd007c55c6e2e4b992069d0306df8a600225d8598'; + r'95f6ec0945f73d9156bf89bdb1865f3b2c9ffcaa'; -abstract class _$ItemDownloadProgress - extends BuildlessAutoDisposeAsyncNotifier { - late final String id; - - FutureOr build( - String id, - ); -} - -/// See also [ItemDownloadProgress]. -@ProviderFor(ItemDownloadProgress) -const itemDownloadProgressProvider = ItemDownloadProgressFamily(); - -/// See also [ItemDownloadProgress]. -class ItemDownloadProgressFamily extends Family> { - /// See also [ItemDownloadProgress]. - const ItemDownloadProgressFamily(); - - /// See also [ItemDownloadProgress]. - ItemDownloadProgressProvider call( - String id, - ) { - return ItemDownloadProgressProvider( - id, - ); - } - - @override - ItemDownloadProgressProvider getProviderOverride( - covariant ItemDownloadProgressProvider provider, - ) { - return call( - provider.id, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'itemDownloadProgressProvider'; -} - -/// See also [ItemDownloadProgress]. -class ItemDownloadProgressProvider extends AutoDisposeAsyncNotifierProviderImpl< - ItemDownloadProgress, double?> { - /// See also [ItemDownloadProgress]. - ItemDownloadProgressProvider( - String id, - ) : this._internal( - () => ItemDownloadProgress()..id = id, - from: itemDownloadProgressProvider, - name: r'itemDownloadProgressProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$itemDownloadProgressHash, - dependencies: ItemDownloadProgressFamily._dependencies, - allTransitiveDependencies: - ItemDownloadProgressFamily._allTransitiveDependencies, - id: id, - ); - - ItemDownloadProgressProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.id, - }) : super.internal(); - - final String id; - - @override - FutureOr runNotifierBuild( - covariant ItemDownloadProgress notifier, - ) { - return notifier.build( - id, - ); - } - - @override - Override overrideWith(ItemDownloadProgress Function() create) { - return ProviderOverride( - origin: this, - override: ItemDownloadProgressProvider._internal( - () => create()..id = id, - from: from, - name: null, +final class ItemDownloadProgressFamily extends $Family + with + $ClassFamilyOverride< + ItemDownloadProgress, + AsyncValue, + double?, + FutureOr, + String + > { + ItemDownloadProgressFamily._() + : super( + retry: null, + name: r'itemDownloadProgressProvider', dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - id: id, - ), - ); - } + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + ItemDownloadProgressProvider call(String id) => + ItemDownloadProgressProvider._(argument: id, from: this); @override - AutoDisposeAsyncNotifierProviderElement - createElement() { - return _ItemDownloadProgressProviderElement(this); + String toString() => r'itemDownloadProgressProvider'; +} + +abstract class _$ItemDownloadProgress extends $AsyncNotifier { + late final _$args = ref.$arg as String; + String get id => _$args; + + FutureOr build(String id); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref, double?>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, double?>, + AsyncValue, + Object?, + Object? + >; + element.handleCreate(ref, () => build(_$args)); + } +} + +@ProviderFor(downloadHistory) +final downloadHistoryProvider = DownloadHistoryFamily._(); + +final class DownloadHistoryProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with $FutureModifier>, $FutureProvider> { + DownloadHistoryProvider._({ + required DownloadHistoryFamily super.from, + required String? super.argument, + }) : super( + retry: null, + name: r'downloadHistoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$downloadHistoryHash(); + + @override + String toString() { + return r'downloadHistoryProvider' + '' + '($argument)'; + } + + @$internal + @override + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr> create(Ref ref) { + final argument = this.argument as String?; + return downloadHistory(ref, group: argument); } @override bool operator ==(Object other) { - return other is ItemDownloadProgressProvider && other.id == id; + return other is DownloadHistoryProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, id.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin ItemDownloadProgressRef on AutoDisposeAsyncNotifierProviderRef { - /// The parameter `id` of this provider. - String get id; -} +String _$downloadHistoryHash() => r'4d8b84e30f7ff5ae69d23c8e03ff24af1234a1ad'; -class _ItemDownloadProgressProviderElement - extends AutoDisposeAsyncNotifierProviderElement with ItemDownloadProgressRef { - _ItemDownloadProgressProviderElement(super.provider); +final class DownloadHistoryFamily extends $Family + with $FunctionalFamilyOverride>, String?> { + DownloadHistoryFamily._() + : super( + retry: null, + name: r'downloadHistoryProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + DownloadHistoryProvider call({String? group}) => + DownloadHistoryProvider._(argument: group, from: this); @override - String get id => (origin as ItemDownloadProgressProvider).id; + String toString() => r'downloadHistoryProvider'; +} + +@ProviderFor(IsItemDownloaded) +final isItemDownloadedProvider = IsItemDownloadedFamily._(); + +final class IsItemDownloadedProvider + extends $AsyncNotifierProvider { + IsItemDownloadedProvider._({ + required IsItemDownloadedFamily super.from, + required LibraryItemExpanded super.argument, + }) : super( + retry: null, + name: r'isItemDownloadedProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$isItemDownloadedHash(); + + @override + String toString() { + return r'isItemDownloadedProvider' + '' + '($argument)'; + } + + @$internal + @override + IsItemDownloaded create() => IsItemDownloaded(); + + @override + bool operator ==(Object other) { + return other is IsItemDownloadedProvider && other.argument == argument; + } + + @override + int get hashCode { + return argument.hashCode; + } } String _$isItemDownloadedHash() => r'9bb7ba28bdb73e1ba706e849fedc9c7bd67f4b67'; -abstract class _$IsItemDownloaded - extends BuildlessAutoDisposeAsyncNotifier { - late final LibraryItemExpanded item; - - FutureOr build( - LibraryItemExpanded item, - ); -} - -/// See also [IsItemDownloaded]. -@ProviderFor(IsItemDownloaded) -const isItemDownloadedProvider = IsItemDownloadedFamily(); - -/// See also [IsItemDownloaded]. -class IsItemDownloadedFamily extends Family> { - /// See also [IsItemDownloaded]. - const IsItemDownloadedFamily(); - - /// See also [IsItemDownloaded]. - IsItemDownloadedProvider call( - LibraryItemExpanded item, - ) { - return IsItemDownloadedProvider( - item, - ); - } - - @override - IsItemDownloadedProvider getProviderOverride( - covariant IsItemDownloadedProvider provider, - ) { - return call( - provider.item, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'isItemDownloadedProvider'; -} - -/// See also [IsItemDownloaded]. -class IsItemDownloadedProvider - extends AutoDisposeAsyncNotifierProviderImpl { - /// See also [IsItemDownloaded]. - IsItemDownloadedProvider( - LibraryItemExpanded item, - ) : this._internal( - () => IsItemDownloaded()..item = item, - from: isItemDownloadedProvider, - name: r'isItemDownloadedProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$isItemDownloadedHash, - dependencies: IsItemDownloadedFamily._dependencies, - allTransitiveDependencies: - IsItemDownloadedFamily._allTransitiveDependencies, - item: item, - ); - - IsItemDownloadedProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.item, - }) : super.internal(); - - final LibraryItemExpanded item; - - @override - FutureOr runNotifierBuild( - covariant IsItemDownloaded notifier, - ) { - return notifier.build( - item, - ); - } - - @override - Override overrideWith(IsItemDownloaded Function() create) { - return ProviderOverride( - origin: this, - override: IsItemDownloadedProvider._internal( - () => create()..item = item, - from: from, - name: null, +final class IsItemDownloadedFamily extends $Family + with + $ClassFamilyOverride< + IsItemDownloaded, + AsyncValue, + bool, + FutureOr, + LibraryItemExpanded + > { + IsItemDownloadedFamily._() + : super( + retry: null, + name: r'isItemDownloadedProvider', dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - item: item, - ), - ); - } + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + IsItemDownloadedProvider call(LibraryItemExpanded item) => + IsItemDownloadedProvider._(argument: item, from: this); @override - AutoDisposeAsyncNotifierProviderElement - createElement() { - return _IsItemDownloadedProviderElement(this); - } - - @override - bool operator ==(Object other) { - return other is IsItemDownloadedProvider && other.item == item; - } - - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, item.hashCode); - - return _SystemHash.finish(hash); - } + String toString() => r'isItemDownloadedProvider'; } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin IsItemDownloadedRef on AutoDisposeAsyncNotifierProviderRef { - /// The parameter `item` of this provider. - LibraryItemExpanded get item; -} - -class _IsItemDownloadedProviderElement - extends AutoDisposeAsyncNotifierProviderElement - with IsItemDownloadedRef { - _IsItemDownloadedProviderElement(super.provider); +abstract class _$IsItemDownloaded extends $AsyncNotifier { + late final _$args = ref.$arg as LibraryItemExpanded; + LibraryItemExpanded get item => _$args; + FutureOr build(LibraryItemExpanded item); + @$mustCallSuper @override - LibraryItemExpanded get item => (origin as IsItemDownloadedProvider).item; + void runBuild() { + final ref = this.ref as $Ref, bool>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, bool>, + AsyncValue, + Object?, + Object? + >; + element.handleCreate(ref, () => build(_$args)); + } } -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/features/explore/providers/search_controller.g.dart b/lib/features/explore/providers/search_controller.g.dart index fab5671..a44d078 100644 --- a/lib/features/explore/providers/search_controller.g.dart +++ b/lib/features/explore/providers/search_controller.g.dart @@ -6,24 +6,64 @@ part of 'search_controller.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning +/// The controller for the search bar. + +@ProviderFor(GlobalSearchController) +final globalSearchControllerProvider = GlobalSearchControllerProvider._(); + +/// The controller for the search bar. +final class GlobalSearchControllerProvider + extends $NotifierProvider> { + /// The controller for the search bar. + GlobalSearchControllerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'globalSearchControllerProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$globalSearchControllerHash(); + + @$internal + @override + GlobalSearchController create() => GlobalSearchController(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(Raw value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider>(value), + ); + } +} + String _$globalSearchControllerHash() => r'd854ace6f2e00a10fc33aba63051375f82ad1b10'; /// The controller for the search bar. -/// -/// Copied from [GlobalSearchController]. -@ProviderFor(GlobalSearchController) -final globalSearchControllerProvider = - NotifierProvider>.internal( - GlobalSearchController.new, - name: r'globalSearchControllerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$globalSearchControllerHash, - dependencies: null, - allTransitiveDependencies: null, -); -typedef _$GlobalSearchController = Notifier>; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$GlobalSearchController + extends $Notifier> { + Raw build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref, Raw>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, Raw>, + Raw, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/features/explore/providers/search_result_provider.g.dart b/lib/features/explore/providers/search_result_provider.g.dart index 764b781..51b077b 100644 --- a/lib/features/explore/providers/search_result_provider.g.dart +++ b/lib/features/explore/providers/search_result_provider.g.dart @@ -6,186 +6,94 @@ part of 'search_result_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$searchResultHash() => r'33785de298ad0d53c9d21e8fec88ba2f22f1363f'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// The provider for the search result. -/// -/// Copied from [searchResult]. + @ProviderFor(searchResult) -const searchResultProvider = SearchResultFamily(); +final searchResultProvider = SearchResultFamily._(); /// The provider for the search result. -/// -/// Copied from [searchResult]. -class SearchResultFamily extends Family> { - /// The provider for the search result. - /// - /// Copied from [searchResult]. - const SearchResultFamily(); +final class SearchResultProvider + extends + $FunctionalProvider< + AsyncValue, + LibrarySearchResponse?, + FutureOr + > + with + $FutureModifier, + $FutureProvider { /// The provider for the search result. - /// - /// Copied from [searchResult]. - SearchResultProvider call( - String query, { - int limit = 25, - }) { - return SearchResultProvider( - query, - limit: limit, - ); + SearchResultProvider._({ + required SearchResultFamily super.from, + required (String, {int limit}) super.argument, + }) : super( + retry: null, + name: r'searchResultProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$searchResultHash(); + + @override + String toString() { + return r'searchResultProvider' + '' + '$argument'; } + @$internal @override - SearchResultProvider getProviderOverride( - covariant SearchResultProvider provider, - ) { - return call( - provider.query, - limit: provider.limit, - ); - } - - static const Iterable? _dependencies = null; + $FutureProviderElement $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'searchResultProvider'; -} - -/// The provider for the search result. -/// -/// Copied from [searchResult]. -class SearchResultProvider - extends AutoDisposeFutureProvider { - /// The provider for the search result. - /// - /// Copied from [searchResult]. - SearchResultProvider( - String query, { - int limit = 25, - }) : this._internal( - (ref) => searchResult( - ref as SearchResultRef, - query, - limit: limit, - ), - from: searchResultProvider, - name: r'searchResultProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$searchResultHash, - dependencies: SearchResultFamily._dependencies, - allTransitiveDependencies: - SearchResultFamily._allTransitiveDependencies, - query: query, - limit: limit, - ); - - SearchResultProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.query, - required this.limit, - }) : super.internal(); - - final String query; - final int limit; - - @override - Override overrideWith( - FutureOr Function(SearchResultRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: SearchResultProvider._internal( - (ref) => create(ref as SearchResultRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - query: query, - limit: limit, - ), - ); - } - - @override - AutoDisposeFutureProviderElement createElement() { - return _SearchResultProviderElement(this); + FutureOr create(Ref ref) { + final argument = this.argument as (String, {int limit}); + return searchResult(ref, argument.$1, limit: argument.limit); } @override bool operator ==(Object other) { - return other is SearchResultProvider && - other.query == query && - other.limit == limit; + return other is SearchResultProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, query.hashCode); - hash = _SystemHash.combine(hash, limit.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin SearchResultRef on AutoDisposeFutureProviderRef { - /// The parameter `query` of this provider. - String get query; +String _$searchResultHash() => r'33785de298ad0d53c9d21e8fec88ba2f22f1363f'; - /// The parameter `limit` of this provider. - int get limit; -} +/// The provider for the search result. -class _SearchResultProviderElement - extends AutoDisposeFutureProviderElement - with SearchResultRef { - _SearchResultProviderElement(super.provider); +final class SearchResultFamily extends $Family + with + $FunctionalFamilyOverride< + FutureOr, + (String, {int limit}) + > { + SearchResultFamily._() + : super( + retry: null, + name: r'searchResultProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + /// The provider for the search result. + + SearchResultProvider call(String query, {int limit = 25}) => + SearchResultProvider._(argument: (query, limit: limit), from: this); @override - String get query => (origin as SearchResultProvider).query; - @override - int get limit => (origin as SearchResultProvider).limit; + String toString() => r'searchResultProvider'; } -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/features/explore/view/explore_page.dart b/lib/features/explore/view/explore_page.dart index 1682254..2ed7b52 100644 --- a/lib/features/explore/view/explore_page.dart +++ b/lib/features/explore/view/explore_page.dart @@ -232,7 +232,7 @@ class BookSearchResultMini extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final item = ref.watch(libraryItemProvider(book.libraryItemId)).valueOrNull; + final item = ref.watch(libraryItemProvider(book.libraryItemId)).value; final image = item == null ? const AsyncValue.loading() : ref.watch(coverImageProvider(item.id)); diff --git a/lib/features/item_viewer/view/library_item_actions.dart b/lib/features/item_viewer/view/library_item_actions.dart index fe5525f..7299e5c 100644 --- a/lib/features/item_viewer/view/library_item_actions.dart +++ b/lib/features/item_viewer/view/library_item_actions.dart @@ -35,7 +35,7 @@ class LibraryItemActions extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final item = ref.watch(libraryItemProvider(id)).valueOrNull; + final item = ref.watch(libraryItemProvider(id)).value; if (item == null) { return const SizedBox.shrink(); } @@ -216,7 +216,7 @@ class LibItemDownloadButton extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final isItemDownloaded = ref.watch(isItemDownloadedProvider(item)); - if (isItemDownloaded.valueOrNull ?? false) { + if (isItemDownloaded.value ?? false) { return AlreadyItemDownloadedButton(item: item); } final isItemDownloading = ref.watch(isItemDownloadingProvider(item.id)); @@ -252,7 +252,7 @@ class ItemCurrentlyInDownloadQueue extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final progress = ref .watch(itemDownloadProgressProvider(item.id)) - .valueOrNull + .value ?.clamp(0.05, 1.0); if (progress == 1) { diff --git a/lib/features/item_viewer/view/library_item_hero_section.dart b/lib/features/item_viewer/view/library_item_hero_section.dart index da4adea..ae83420 100644 --- a/lib/features/item_viewer/view/library_item_hero_section.dart +++ b/lib/features/item_viewer/view/library_item_hero_section.dart @@ -90,7 +90,7 @@ class _BookDetails extends HookConsumerWidget { final itemFromApi = ref.watch(libraryItemProvider(id)); final itemBookMetadata = - itemFromApi.valueOrNull?.media.metadata.asBookMetadataExpanded; + itemFromApi.value?.media.metadata.asBookMetadataExpanded; return Expanded( child: Padding( @@ -143,7 +143,7 @@ class _LibraryItemProgressIndicator extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final player = ref.watch(audiobookPlayerProvider); - final libraryItem = ref.watch(libraryItemProvider(id)).valueOrNull; + final libraryItem = ref.watch(libraryItemProvider(id)).value; if (libraryItem == null) { return const SizedBox.shrink(); } @@ -362,7 +362,7 @@ class _BookCover extends HookConsumerWidget { MediaQuery.of(context).highContrast, ), ) - .valueOrNull; + .value; } return ThemeSwitcher( diff --git a/lib/features/item_viewer/view/library_item_metadata.dart b/lib/features/item_viewer/view/library_item_metadata.dart index 664daac..753a38e 100644 --- a/lib/features/item_viewer/view/library_item_metadata.dart +++ b/lib/features/item_viewer/view/library_item_metadata.dart @@ -13,7 +13,7 @@ class LibraryItemMetadata extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final item = ref.watch(libraryItemProvider(id)).valueOrNull; + final item = ref.watch(libraryItemProvider(id)).value; /// formats the duration of the book as `10h 30m` /// diff --git a/lib/features/item_viewer/view/library_item_page.dart b/lib/features/item_viewer/view/library_item_page.dart index e7b9310..b685a6a 100644 --- a/lib/features/item_viewer/view/library_item_page.dart +++ b/lib/features/item_viewer/view/library_item_page.dart @@ -145,7 +145,7 @@ class LibraryItemDescription extends HookConsumerWidget { final String id; @override Widget build(BuildContext context, WidgetRef ref) { - final item = ref.watch(libraryItemProvider(id)).valueOrNull; + final item = ref.watch(libraryItemProvider(id)).value; if (item == null) { return const SizedBox(); } diff --git a/lib/features/item_viewer/view/library_item_sliver_app_bar.dart b/lib/features/item_viewer/view/library_item_sliver_app_bar.dart index fd6b621..5616a96 100644 --- a/lib/features/item_viewer/view/library_item_sliver_app_bar.dart +++ b/lib/features/item_viewer/view/library_item_sliver_app_bar.dart @@ -17,7 +17,7 @@ class LibraryItemSliverAppBar extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final item = ref.watch(libraryItemProvider(id)).valueOrNull; + final item = ref.watch(libraryItemProvider(id)).value; final showTitle = useState(false); diff --git a/lib/features/library_browser/view/library_browser_page.dart b/lib/features/library_browser/view/library_browser_page.dart index 4327b17..26cb2df 100644 --- a/lib/features/library_browser/view/library_browser_page.dart +++ b/lib/features/library_browser/view/library_browser_page.dart @@ -13,7 +13,7 @@ class LibraryBrowserPage extends HookConsumerWidget { const LibraryBrowserPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { - final currentLibrary = ref.watch(currentLibraryProvider).valueOrNull; + final currentLibrary = ref.watch(currentLibraryProvider).value; // Determine the icon to use, with a fallback final IconData libraryIconData = diff --git a/lib/features/logging/providers/logs_provider.g.dart b/lib/features/logging/providers/logs_provider.g.dart index 53babc0..c7bb6f8 100644 --- a/lib/features/logging/providers/logs_provider.g.dart +++ b/lib/features/logging/providers/logs_provider.g.dart @@ -6,20 +6,48 @@ part of 'logs_provider.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(Logs) +final logsProvider = LogsProvider._(); + +final class LogsProvider extends $AsyncNotifierProvider> { + LogsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'logsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$logsHash(); + + @$internal + @override + Logs create() => Logs(); +} + String _$logsHash() => r'aa9d3d56586cba6ddf69615320ea605d071ea5e2'; -/// See also [Logs]. -@ProviderFor(Logs) -final logsProvider = - AutoDisposeAsyncNotifierProvider>.internal( - Logs.new, - name: r'logsProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$logsHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$Logs = AutoDisposeAsyncNotifier>; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$Logs extends $AsyncNotifier> { + FutureOr> build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref>, List>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier>, List>, + AsyncValue>, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/features/onboarding/models/flow.dart b/lib/features/onboarding/models/flow.dart index 80e8514..46539f6 100644 --- a/lib/features/onboarding/models/flow.dart +++ b/lib/features/onboarding/models/flow.dart @@ -5,7 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'flow.freezed.dart'; @freezed -class Flow with _$Flow { +sealed class Flow with _$Flow { const factory Flow({ required Uri serverUri, required String state, diff --git a/lib/features/onboarding/models/flow.freezed.dart b/lib/features/onboarding/models/flow.freezed.dart index 1437f2e..f79c8bb 100644 --- a/lib/features/onboarding/models/flow.freezed.dart +++ b/lib/features/onboarding/models/flow.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // 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 @@ -9,241 +9,272 @@ part of 'flow.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(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 _$Flow { - Uri get serverUri => throw _privateConstructorUsedError; - String get state => throw _privateConstructorUsedError; - String get verifier => throw _privateConstructorUsedError; - Cookie get cookie => throw _privateConstructorUsedError; - bool get isFlowComplete => throw _privateConstructorUsedError; - String? get authToken => throw _privateConstructorUsedError; - /// Create a copy of Flow - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $FlowCopyWith get copyWith => throw _privateConstructorUsedError; + Uri get serverUri; String get state; String get verifier; Cookie get cookie; bool get isFlowComplete; String? get authToken; +/// Create a copy of Flow +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$FlowCopyWith get copyWith => _$FlowCopyWithImpl(this as Flow, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Flow&&(identical(other.serverUri, serverUri) || other.serverUri == serverUri)&&(identical(other.state, state) || other.state == state)&&(identical(other.verifier, verifier) || other.verifier == verifier)&&(identical(other.cookie, cookie) || other.cookie == cookie)&&(identical(other.isFlowComplete, isFlowComplete) || other.isFlowComplete == isFlowComplete)&&(identical(other.authToken, authToken) || other.authToken == authToken)); +} + + +@override +int get hashCode => Object.hash(runtimeType,serverUri,state,verifier,cookie,isFlowComplete,authToken); + +@override +String toString() { + return 'Flow(serverUri: $serverUri, state: $state, verifier: $verifier, cookie: $cookie, isFlowComplete: $isFlowComplete, authToken: $authToken)'; +} + + } /// @nodoc -abstract class $FlowCopyWith<$Res> { - factory $FlowCopyWith(Flow value, $Res Function(Flow) then) = - _$FlowCopyWithImpl<$Res, Flow>; - @useResult - $Res call( - {Uri serverUri, - String state, - String verifier, - Cookie cookie, - bool isFlowComplete, - String? authToken}); -} +abstract mixin class $FlowCopyWith<$Res> { + factory $FlowCopyWith(Flow value, $Res Function(Flow) _then) = _$FlowCopyWithImpl; +@useResult +$Res call({ + Uri serverUri, String state, String verifier, Cookie cookie, bool isFlowComplete, String? authToken +}); + + + +} /// @nodoc -class _$FlowCopyWithImpl<$Res, $Val extends Flow> +class _$FlowCopyWithImpl<$Res> implements $FlowCopyWith<$Res> { - _$FlowCopyWithImpl(this._value, this._then); + _$FlowCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final Flow _self; + final $Res Function(Flow) _then; - /// Create a copy of Flow - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? serverUri = null, - Object? state = null, - Object? verifier = null, - Object? cookie = null, - Object? isFlowComplete = null, - Object? authToken = freezed, - }) { - return _then(_value.copyWith( - serverUri: null == serverUri - ? _value.serverUri - : serverUri // ignore: cast_nullable_to_non_nullable - as Uri, - state: null == state - ? _value.state - : state // ignore: cast_nullable_to_non_nullable - as String, - verifier: null == verifier - ? _value.verifier - : verifier // ignore: cast_nullable_to_non_nullable - as String, - cookie: null == cookie - ? _value.cookie - : cookie // ignore: cast_nullable_to_non_nullable - as Cookie, - isFlowComplete: null == isFlowComplete - ? _value.isFlowComplete - : isFlowComplete // ignore: cast_nullable_to_non_nullable - as bool, - authToken: freezed == authToken - ? _value.authToken - : authToken // ignore: cast_nullable_to_non_nullable - as String?, - ) as $Val); - } +/// Create a copy of Flow +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? serverUri = null,Object? state = null,Object? verifier = null,Object? cookie = null,Object? isFlowComplete = null,Object? authToken = freezed,}) { + return _then(_self.copyWith( +serverUri: null == serverUri ? _self.serverUri : serverUri // ignore: cast_nullable_to_non_nullable +as Uri,state: null == state ? _self.state : state // ignore: cast_nullable_to_non_nullable +as String,verifier: null == verifier ? _self.verifier : verifier // ignore: cast_nullable_to_non_nullable +as String,cookie: null == cookie ? _self.cookie : cookie // ignore: cast_nullable_to_non_nullable +as Cookie,isFlowComplete: null == isFlowComplete ? _self.isFlowComplete : isFlowComplete // ignore: cast_nullable_to_non_nullable +as bool,authToken: freezed == authToken ? _self.authToken : authToken // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$FlowImplCopyWith<$Res> implements $FlowCopyWith<$Res> { - factory _$$FlowImplCopyWith( - _$FlowImpl value, $Res Function(_$FlowImpl) then) = - __$$FlowImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {Uri serverUri, - String state, - String verifier, - Cookie cookie, - bool isFlowComplete, - String? authToken}); } -/// @nodoc -class __$$FlowImplCopyWithImpl<$Res> - extends _$FlowCopyWithImpl<$Res, _$FlowImpl> - implements _$$FlowImplCopyWith<$Res> { - __$$FlowImplCopyWithImpl(_$FlowImpl _value, $Res Function(_$FlowImpl) _then) - : super(_value, _then); - /// Create a copy of Flow - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? serverUri = null, - Object? state = null, - Object? verifier = null, - Object? cookie = null, - Object? isFlowComplete = null, - Object? authToken = freezed, - }) { - return _then(_$FlowImpl( - serverUri: null == serverUri - ? _value.serverUri - : serverUri // ignore: cast_nullable_to_non_nullable - as Uri, - state: null == state - ? _value.state - : state // ignore: cast_nullable_to_non_nullable - as String, - verifier: null == verifier - ? _value.verifier - : verifier // ignore: cast_nullable_to_non_nullable - as String, - cookie: null == cookie - ? _value.cookie - : cookie // ignore: cast_nullable_to_non_nullable - as Cookie, - isFlowComplete: null == isFlowComplete - ? _value.isFlowComplete - : isFlowComplete // ignore: cast_nullable_to_non_nullable - as bool, - authToken: freezed == authToken - ? _value.authToken - : authToken // ignore: cast_nullable_to_non_nullable - as String?, - )); - } +/// Adds pattern-matching-related methods to [Flow]. +extension FlowPatterns on Flow { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Flow value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Flow() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Flow value) $default,){ +final _that = this; +switch (_that) { +case _Flow(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Flow value)? $default,){ +final _that = this; +switch (_that) { +case _Flow() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( Uri serverUri, String state, String verifier, Cookie cookie, bool isFlowComplete, String? authToken)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Flow() when $default != null: +return $default(_that.serverUri,_that.state,_that.verifier,_that.cookie,_that.isFlowComplete,_that.authToken);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( Uri serverUri, String state, String verifier, Cookie cookie, bool isFlowComplete, String? authToken) $default,) {final _that = this; +switch (_that) { +case _Flow(): +return $default(_that.serverUri,_that.state,_that.verifier,_that.cookie,_that.isFlowComplete,_that.authToken);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( Uri serverUri, String state, String verifier, Cookie cookie, bool isFlowComplete, String? authToken)? $default,) {final _that = this; +switch (_that) { +case _Flow() when $default != null: +return $default(_that.serverUri,_that.state,_that.verifier,_that.cookie,_that.isFlowComplete,_that.authToken);case _: + return null; + +} +} + } /// @nodoc -class _$FlowImpl implements _Flow { - const _$FlowImpl( - {required this.serverUri, - required this.state, - required this.verifier, - required this.cookie, - this.isFlowComplete = false, - this.authToken}); - @override - final Uri serverUri; - @override - final String state; - @override - final String verifier; - @override - final Cookie cookie; - @override - @JsonKey() - final bool isFlowComplete; - @override - final String? authToken; +class _Flow implements Flow { + const _Flow({required this.serverUri, required this.state, required this.verifier, required this.cookie, this.isFlowComplete = false, this.authToken}); + - @override - String toString() { - return 'Flow(serverUri: $serverUri, state: $state, verifier: $verifier, cookie: $cookie, isFlowComplete: $isFlowComplete, authToken: $authToken)'; - } +@override final Uri serverUri; +@override final String state; +@override final String verifier; +@override final Cookie cookie; +@override@JsonKey() final bool isFlowComplete; +@override final String? authToken; - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$FlowImpl && - (identical(other.serverUri, serverUri) || - other.serverUri == serverUri) && - (identical(other.state, state) || other.state == state) && - (identical(other.verifier, verifier) || - other.verifier == verifier) && - (identical(other.cookie, cookie) || other.cookie == cookie) && - (identical(other.isFlowComplete, isFlowComplete) || - other.isFlowComplete == isFlowComplete) && - (identical(other.authToken, authToken) || - other.authToken == authToken)); - } +/// Create a copy of Flow +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$FlowCopyWith<_Flow> get copyWith => __$FlowCopyWithImpl<_Flow>(this, _$identity); - @override - int get hashCode => Object.hash(runtimeType, serverUri, state, verifier, - cookie, isFlowComplete, authToken); - /// Create a copy of Flow - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$FlowImplCopyWith<_$FlowImpl> get copyWith => - __$$FlowImplCopyWithImpl<_$FlowImpl>(this, _$identity); + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Flow&&(identical(other.serverUri, serverUri) || other.serverUri == serverUri)&&(identical(other.state, state) || other.state == state)&&(identical(other.verifier, verifier) || other.verifier == verifier)&&(identical(other.cookie, cookie) || other.cookie == cookie)&&(identical(other.isFlowComplete, isFlowComplete) || other.isFlowComplete == isFlowComplete)&&(identical(other.authToken, authToken) || other.authToken == authToken)); } -abstract class _Flow implements Flow { - const factory _Flow( - {required final Uri serverUri, - required final String state, - required final String verifier, - required final Cookie cookie, - final bool isFlowComplete, - final String? authToken}) = _$FlowImpl; - @override - Uri get serverUri; - @override - String get state; - @override - String get verifier; - @override - Cookie get cookie; - @override - bool get isFlowComplete; - @override - String? get authToken; +@override +int get hashCode => Object.hash(runtimeType,serverUri,state,verifier,cookie,isFlowComplete,authToken); - /// Create a copy of Flow - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$FlowImplCopyWith<_$FlowImpl> get copyWith => - throw _privateConstructorUsedError; +@override +String toString() { + return 'Flow(serverUri: $serverUri, state: $state, verifier: $verifier, cookie: $cookie, isFlowComplete: $isFlowComplete, authToken: $authToken)'; } + + +} + +/// @nodoc +abstract mixin class _$FlowCopyWith<$Res> implements $FlowCopyWith<$Res> { + factory _$FlowCopyWith(_Flow value, $Res Function(_Flow) _then) = __$FlowCopyWithImpl; +@override @useResult +$Res call({ + Uri serverUri, String state, String verifier, Cookie cookie, bool isFlowComplete, String? authToken +}); + + + + +} +/// @nodoc +class __$FlowCopyWithImpl<$Res> + implements _$FlowCopyWith<$Res> { + __$FlowCopyWithImpl(this._self, this._then); + + final _Flow _self; + final $Res Function(_Flow) _then; + +/// Create a copy of Flow +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? serverUri = null,Object? state = null,Object? verifier = null,Object? cookie = null,Object? isFlowComplete = null,Object? authToken = freezed,}) { + return _then(_Flow( +serverUri: null == serverUri ? _self.serverUri : serverUri // ignore: cast_nullable_to_non_nullable +as Uri,state: null == state ? _self.state : state // ignore: cast_nullable_to_non_nullable +as String,verifier: null == verifier ? _self.verifier : verifier // ignore: cast_nullable_to_non_nullable +as String,cookie: null == cookie ? _self.cookie : cookie // ignore: cast_nullable_to_non_nullable +as Cookie,isFlowComplete: null == isFlowComplete ? _self.isFlowComplete : isFlowComplete // ignore: cast_nullable_to_non_nullable +as bool,authToken: freezed == authToken ? _self.authToken : authToken // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +// dart format on diff --git a/lib/features/onboarding/providers/oauth_provider.g.dart b/lib/features/onboarding/providers/oauth_provider.g.dart index 8f44538..d9c7575 100644 --- a/lib/features/onboarding/providers/oauth_provider.g.dart +++ b/lib/features/onboarding/providers/oauth_provider.g.dart @@ -6,221 +6,167 @@ part of 'oauth_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$loginInExchangeForCodeHash() => - r'bfc3945529048a0f536052fd5579b76457560fcd'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); +@ProviderFor(OauthFlows) +final oauthFlowsProvider = OauthFlowsProvider._(); - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - -/// the code returned by the server in exchange for the verifier -/// -/// Copied from [loginInExchangeForCode]. -@ProviderFor(loginInExchangeForCode) -const loginInExchangeForCodeProvider = LoginInExchangeForCodeFamily(); - -/// the code returned by the server in exchange for the verifier -/// -/// Copied from [loginInExchangeForCode]. -class LoginInExchangeForCodeFamily extends Family> { - /// the code returned by the server in exchange for the verifier - /// - /// Copied from [loginInExchangeForCode]. - const LoginInExchangeForCodeFamily(); - - /// the code returned by the server in exchange for the verifier - /// - /// Copied from [loginInExchangeForCode]. - LoginInExchangeForCodeProvider call({ - required String oauthState, - required String code, - ErrorResponseHandler? responseHandler, - }) { - return LoginInExchangeForCodeProvider( - oauthState: oauthState, - code: code, - responseHandler: responseHandler, - ); - } - - @override - LoginInExchangeForCodeProvider getProviderOverride( - covariant LoginInExchangeForCodeProvider provider, - ) { - return call( - oauthState: provider.oauthState, - code: provider.code, - responseHandler: provider.responseHandler, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'loginInExchangeForCodeProvider'; -} - -/// the code returned by the server in exchange for the verifier -/// -/// Copied from [loginInExchangeForCode]. -class LoginInExchangeForCodeProvider - extends AutoDisposeFutureProvider { - /// the code returned by the server in exchange for the verifier - /// - /// Copied from [loginInExchangeForCode]. - LoginInExchangeForCodeProvider({ - required String oauthState, - required String code, - ErrorResponseHandler? responseHandler, - }) : this._internal( - (ref) => loginInExchangeForCode( - ref as LoginInExchangeForCodeRef, - oauthState: oauthState, - code: code, - responseHandler: responseHandler, - ), - from: loginInExchangeForCodeProvider, - name: r'loginInExchangeForCodeProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$loginInExchangeForCodeHash, - dependencies: LoginInExchangeForCodeFamily._dependencies, - allTransitiveDependencies: - LoginInExchangeForCodeFamily._allTransitiveDependencies, - oauthState: oauthState, - code: code, - responseHandler: responseHandler, - ); - - LoginInExchangeForCodeProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.oauthState, - required this.code, - required this.responseHandler, - }) : super.internal(); - - final String oauthState; - final String code; - final ErrorResponseHandler? responseHandler; - - @override - Override overrideWith( - FutureOr Function(LoginInExchangeForCodeRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: LoginInExchangeForCodeProvider._internal( - (ref) => create(ref as LoginInExchangeForCodeRef), - from: from, - name: null, +final class OauthFlowsProvider + extends $NotifierProvider> { + OauthFlowsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'oauthFlowsProvider', + isAutoDispose: false, dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - oauthState: oauthState, - code: code, - responseHandler: responseHandler, - ), - ); - } + $allTransitiveDependencies: null, + ); @override - AutoDisposeFutureProviderElement createElement() { - return _LoginInExchangeForCodeProviderElement(this); + String debugGetCreateSourceHash() => _$oauthFlowsHash(); + + @$internal + @override + OauthFlows create() => OauthFlows(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(Map value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider>(value), + ); + } +} + +String _$oauthFlowsHash() => r'4e278baa0bf26f2a10694ca2caadb68dd5b6156f'; + +abstract class _$OauthFlows extends $Notifier> { + Map build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref, Map>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, Map>, + Map, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} + +/// the code returned by the server in exchange for the verifier + +@ProviderFor(loginInExchangeForCode) +final loginInExchangeForCodeProvider = LoginInExchangeForCodeFamily._(); + +/// the code returned by the server in exchange for the verifier + +final class LoginInExchangeForCodeProvider + extends $FunctionalProvider, String?, FutureOr> + with $FutureModifier, $FutureProvider { + /// the code returned by the server in exchange for the verifier + LoginInExchangeForCodeProvider._({ + required LoginInExchangeForCodeFamily super.from, + required ({ + State oauthState, + Code code, + ErrorResponseHandler? responseHandler, + }) + super.argument, + }) : super( + retry: null, + name: r'loginInExchangeForCodeProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$loginInExchangeForCodeHash(); + + @override + String toString() { + return r'loginInExchangeForCodeProvider' + '' + '$argument'; + } + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + final argument = + this.argument + as ({ + State oauthState, + Code code, + ErrorResponseHandler? responseHandler, + }); + return loginInExchangeForCode( + ref, + oauthState: argument.oauthState, + code: argument.code, + responseHandler: argument.responseHandler, + ); } @override bool operator ==(Object other) { return other is LoginInExchangeForCodeProvider && - other.oauthState == oauthState && - other.code == code && - other.responseHandler == responseHandler; + other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, oauthState.hashCode); - hash = _SystemHash.combine(hash, code.hashCode); - hash = _SystemHash.combine(hash, responseHandler.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin LoginInExchangeForCodeRef on AutoDisposeFutureProviderRef { - /// The parameter `oauthState` of this provider. - String get oauthState; +String _$loginInExchangeForCodeHash() => + r'bfc3945529048a0f536052fd5579b76457560fcd'; - /// The parameter `code` of this provider. - String get code; +/// the code returned by the server in exchange for the verifier - /// The parameter `responseHandler` of this provider. - ErrorResponseHandler? get responseHandler; +final class LoginInExchangeForCodeFamily extends $Family + with + $FunctionalFamilyOverride< + FutureOr, + ({State oauthState, Code code, ErrorResponseHandler? responseHandler}) + > { + LoginInExchangeForCodeFamily._() + : super( + retry: null, + name: r'loginInExchangeForCodeProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + /// the code returned by the server in exchange for the verifier + + LoginInExchangeForCodeProvider call({ + required State oauthState, + required Code code, + ErrorResponseHandler? responseHandler, + }) => LoginInExchangeForCodeProvider._( + argument: ( + oauthState: oauthState, + code: code, + responseHandler: responseHandler, + ), + from: this, + ); + + @override + String toString() => r'loginInExchangeForCodeProvider'; } - -class _LoginInExchangeForCodeProviderElement - extends AutoDisposeFutureProviderElement - with LoginInExchangeForCodeRef { - _LoginInExchangeForCodeProviderElement(super.provider); - - @override - String get oauthState => - (origin as LoginInExchangeForCodeProvider).oauthState; - @override - String get code => (origin as LoginInExchangeForCodeProvider).code; - @override - ErrorResponseHandler? get responseHandler => - (origin as LoginInExchangeForCodeProvider).responseHandler; -} - -String _$oauthFlowsHash() => r'4e278baa0bf26f2a10694ca2caadb68dd5b6156f'; - -/// See also [OauthFlows]. -@ProviderFor(OauthFlows) -final oauthFlowsProvider = - NotifierProvider>.internal( - OauthFlows.new, - name: r'oauthFlowsProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$oauthFlowsHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$OauthFlows = Notifier>; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/features/per_book_settings/models/book_settings.dart b/lib/features/per_book_settings/models/book_settings.dart index b4f0cda..853fe53 100644 --- a/lib/features/per_book_settings/models/book_settings.dart +++ b/lib/features/per_book_settings/models/book_settings.dart @@ -6,7 +6,7 @@ part 'book_settings.g.dart'; /// per book settings @freezed -class BookSettings with _$BookSettings { +sealed class BookSettings with _$BookSettings { const factory BookSettings({ required String bookId, @Default(NullablePlayerSettings()) NullablePlayerSettings playerSettings, diff --git a/lib/features/per_book_settings/models/book_settings.freezed.dart b/lib/features/per_book_settings/models/book_settings.freezed.dart index 63b55da..8ba7009 100644 --- a/lib/features/per_book_settings/models/book_settings.freezed.dart +++ b/lib/features/per_book_settings/models/book_settings.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // 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 @@ -9,195 +9,284 @@ part of 'book_settings.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(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'); - -BookSettings _$BookSettingsFromJson(Map json) { - return _BookSettings.fromJson(json); -} - /// @nodoc mixin _$BookSettings { - String get bookId => throw _privateConstructorUsedError; - NullablePlayerSettings get playerSettings => - throw _privateConstructorUsedError; + + String get bookId; NullablePlayerSettings get playerSettings; +/// Create a copy of BookSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$BookSettingsCopyWith get copyWith => _$BookSettingsCopyWithImpl(this as BookSettings, _$identity); /// Serializes this BookSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is BookSettings&&(identical(other.bookId, bookId) || other.bookId == bookId)&&(identical(other.playerSettings, playerSettings) || other.playerSettings == playerSettings)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,bookId,playerSettings); + +@override +String toString() { + return 'BookSettings(bookId: $bookId, playerSettings: $playerSettings)'; +} + - /// Create a copy of BookSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $BookSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $BookSettingsCopyWith<$Res> { - factory $BookSettingsCopyWith( - BookSettings value, $Res Function(BookSettings) then) = - _$BookSettingsCopyWithImpl<$Res, BookSettings>; - @useResult - $Res call({String bookId, NullablePlayerSettings playerSettings}); +abstract mixin class $BookSettingsCopyWith<$Res> { + factory $BookSettingsCopyWith(BookSettings value, $Res Function(BookSettings) _then) = _$BookSettingsCopyWithImpl; +@useResult +$Res call({ + String bookId, NullablePlayerSettings playerSettings +}); + + +$NullablePlayerSettingsCopyWith<$Res> get playerSettings; - $NullablePlayerSettingsCopyWith<$Res> get playerSettings; } - /// @nodoc -class _$BookSettingsCopyWithImpl<$Res, $Val extends BookSettings> +class _$BookSettingsCopyWithImpl<$Res> implements $BookSettingsCopyWith<$Res> { - _$BookSettingsCopyWithImpl(this._value, this._then); + _$BookSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final BookSettings _self; + final $Res Function(BookSettings) _then; - /// Create a copy of BookSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? bookId = null, - Object? playerSettings = null, - }) { - return _then(_value.copyWith( - bookId: null == bookId - ? _value.bookId - : bookId // ignore: cast_nullable_to_non_nullable - as String, - playerSettings: null == playerSettings - ? _value.playerSettings - : playerSettings // ignore: cast_nullable_to_non_nullable - as NullablePlayerSettings, - ) as $Val); - } - - /// Create a copy of BookSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $NullablePlayerSettingsCopyWith<$Res> get playerSettings { - return $NullablePlayerSettingsCopyWith<$Res>(_value.playerSettings, - (value) { - return _then(_value.copyWith(playerSettings: value) as $Val); - }); - } +/// Create a copy of BookSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? bookId = null,Object? playerSettings = null,}) { + return _then(_self.copyWith( +bookId: null == bookId ? _self.bookId : bookId // ignore: cast_nullable_to_non_nullable +as String,playerSettings: null == playerSettings ? _self.playerSettings : playerSettings // ignore: cast_nullable_to_non_nullable +as NullablePlayerSettings, + )); +} +/// Create a copy of BookSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$NullablePlayerSettingsCopyWith<$Res> get playerSettings { + + return $NullablePlayerSettingsCopyWith<$Res>(_self.playerSettings, (value) { + return _then(_self.copyWith(playerSettings: value)); + }); +} } -/// @nodoc -abstract class _$$BookSettingsImplCopyWith<$Res> - implements $BookSettingsCopyWith<$Res> { - factory _$$BookSettingsImplCopyWith( - _$BookSettingsImpl value, $Res Function(_$BookSettingsImpl) then) = - __$$BookSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String bookId, NullablePlayerSettings playerSettings}); - @override - $NullablePlayerSettingsCopyWith<$Res> get playerSettings; +/// Adds pattern-matching-related methods to [BookSettings]. +extension BookSettingsPatterns on BookSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _BookSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _BookSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _BookSettings value) $default,){ +final _that = this; +switch (_that) { +case _BookSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _BookSettings value)? $default,){ +final _that = this; +switch (_that) { +case _BookSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String bookId, NullablePlayerSettings playerSettings)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _BookSettings() when $default != null: +return $default(_that.bookId,_that.playerSettings);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String bookId, NullablePlayerSettings playerSettings) $default,) {final _that = this; +switch (_that) { +case _BookSettings(): +return $default(_that.bookId,_that.playerSettings);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String bookId, NullablePlayerSettings playerSettings)? $default,) {final _that = this; +switch (_that) { +case _BookSettings() when $default != null: +return $default(_that.bookId,_that.playerSettings);case _: + return null; + +} } -/// @nodoc -class __$$BookSettingsImplCopyWithImpl<$Res> - extends _$BookSettingsCopyWithImpl<$Res, _$BookSettingsImpl> - implements _$$BookSettingsImplCopyWith<$Res> { - __$$BookSettingsImplCopyWithImpl( - _$BookSettingsImpl _value, $Res Function(_$BookSettingsImpl) _then) - : super(_value, _then); - - /// Create a copy of BookSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? bookId = null, - Object? playerSettings = null, - }) { - return _then(_$BookSettingsImpl( - bookId: null == bookId - ? _value.bookId - : bookId // ignore: cast_nullable_to_non_nullable - as String, - playerSettings: null == playerSettings - ? _value.playerSettings - : playerSettings // ignore: cast_nullable_to_non_nullable - as NullablePlayerSettings, - )); - } } /// @nodoc @JsonSerializable() -class _$BookSettingsImpl implements _BookSettings { - const _$BookSettingsImpl( - {required this.bookId, - this.playerSettings = const NullablePlayerSettings()}); - factory _$BookSettingsImpl.fromJson(Map json) => - _$$BookSettingsImplFromJson(json); +class _BookSettings implements BookSettings { + const _BookSettings({required this.bookId, this.playerSettings = const NullablePlayerSettings()}); + factory _BookSettings.fromJson(Map json) => _$BookSettingsFromJson(json); - @override - final String bookId; - @override - @JsonKey() - final NullablePlayerSettings playerSettings; +@override final String bookId; +@override@JsonKey() final NullablePlayerSettings playerSettings; - @override - String toString() { - return 'BookSettings(bookId: $bookId, playerSettings: $playerSettings)'; - } +/// Create a copy of BookSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$BookSettingsCopyWith<_BookSettings> get copyWith => __$BookSettingsCopyWithImpl<_BookSettings>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$BookSettingsImpl && - (identical(other.bookId, bookId) || other.bookId == bookId) && - (identical(other.playerSettings, playerSettings) || - other.playerSettings == playerSettings)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, bookId, playerSettings); - - /// Create a copy of BookSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$BookSettingsImplCopyWith<_$BookSettingsImpl> get copyWith => - __$$BookSettingsImplCopyWithImpl<_$BookSettingsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$BookSettingsImplToJson( - this, - ); - } +@override +Map toJson() { + return _$BookSettingsToJson(this, ); } -abstract class _BookSettings implements BookSettings { - const factory _BookSettings( - {required final String bookId, - final NullablePlayerSettings playerSettings}) = _$BookSettingsImpl; - - factory _BookSettings.fromJson(Map json) = - _$BookSettingsImpl.fromJson; - - @override - String get bookId; - @override - NullablePlayerSettings get playerSettings; - - /// Create a copy of BookSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$BookSettingsImplCopyWith<_$BookSettingsImpl> get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _BookSettings&&(identical(other.bookId, bookId) || other.bookId == bookId)&&(identical(other.playerSettings, playerSettings) || other.playerSettings == playerSettings)); } + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,bookId,playerSettings); + +@override +String toString() { + return 'BookSettings(bookId: $bookId, playerSettings: $playerSettings)'; +} + + +} + +/// @nodoc +abstract mixin class _$BookSettingsCopyWith<$Res> implements $BookSettingsCopyWith<$Res> { + factory _$BookSettingsCopyWith(_BookSettings value, $Res Function(_BookSettings) _then) = __$BookSettingsCopyWithImpl; +@override @useResult +$Res call({ + String bookId, NullablePlayerSettings playerSettings +}); + + +@override $NullablePlayerSettingsCopyWith<$Res> get playerSettings; + +} +/// @nodoc +class __$BookSettingsCopyWithImpl<$Res> + implements _$BookSettingsCopyWith<$Res> { + __$BookSettingsCopyWithImpl(this._self, this._then); + + final _BookSettings _self; + final $Res Function(_BookSettings) _then; + +/// Create a copy of BookSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? bookId = null,Object? playerSettings = null,}) { + return _then(_BookSettings( +bookId: null == bookId ? _self.bookId : bookId // ignore: cast_nullable_to_non_nullable +as String,playerSettings: null == playerSettings ? _self.playerSettings : playerSettings // ignore: cast_nullable_to_non_nullable +as NullablePlayerSettings, + )); +} + +/// Create a copy of BookSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$NullablePlayerSettingsCopyWith<$Res> get playerSettings { + + return $NullablePlayerSettingsCopyWith<$Res>(_self.playerSettings, (value) { + return _then(_self.copyWith(playerSettings: value)); + }); +} +} + +// dart format on diff --git a/lib/features/per_book_settings/models/book_settings.g.dart b/lib/features/per_book_settings/models/book_settings.g.dart index a66fba1..b5888f7 100644 --- a/lib/features/per_book_settings/models/book_settings.g.dart +++ b/lib/features/per_book_settings/models/book_settings.g.dart @@ -6,16 +6,17 @@ part of 'book_settings.dart'; // JsonSerializableGenerator // ************************************************************************** -_$BookSettingsImpl _$$BookSettingsImplFromJson(Map json) => - _$BookSettingsImpl( +_BookSettings _$BookSettingsFromJson(Map json) => + _BookSettings( bookId: json['bookId'] as String, playerSettings: json['playerSettings'] == null ? const NullablePlayerSettings() : NullablePlayerSettings.fromJson( - json['playerSettings'] as Map), + json['playerSettings'] as Map, + ), ); -Map _$$BookSettingsImplToJson(_$BookSettingsImpl instance) => +Map _$BookSettingsToJson(_BookSettings instance) => { 'bookId': instance.bookId, 'playerSettings': instance.playerSettings, diff --git a/lib/features/per_book_settings/models/nullable_player_settings.dart b/lib/features/per_book_settings/models/nullable_player_settings.dart index 39135d7..d54e2eb 100644 --- a/lib/features/per_book_settings/models/nullable_player_settings.dart +++ b/lib/features/per_book_settings/models/nullable_player_settings.dart @@ -5,7 +5,7 @@ part 'nullable_player_settings.freezed.dart'; part 'nullable_player_settings.g.dart'; @freezed -class NullablePlayerSettings with _$NullablePlayerSettings { +sealed class NullablePlayerSettings with _$NullablePlayerSettings { const factory NullablePlayerSettings({ MinimizedPlayerSettings? miniPlayerSettings, ExpandedPlayerSettings? expandedPlayerSettings, diff --git a/lib/features/per_book_settings/models/nullable_player_settings.freezed.dart b/lib/features/per_book_settings/models/nullable_player_settings.freezed.dart index 9450ed4..8039d60 100644 --- a/lib/features/per_book_settings/models/nullable_player_settings.freezed.dart +++ b/lib/features/per_book_settings/models/nullable_player_settings.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // 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 @@ -9,369 +9,361 @@ part of 'nullable_player_settings.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(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'); - -NullablePlayerSettings _$NullablePlayerSettingsFromJson( - Map json) { - return _NullablePlayerSettings.fromJson(json); -} - /// @nodoc mixin _$NullablePlayerSettings { - MinimizedPlayerSettings? get miniPlayerSettings => - throw _privateConstructorUsedError; - ExpandedPlayerSettings? get expandedPlayerSettings => - throw _privateConstructorUsedError; - double? get preferredDefaultVolume => throw _privateConstructorUsedError; - double? get preferredDefaultSpeed => throw _privateConstructorUsedError; - List? get speedOptions => throw _privateConstructorUsedError; - SleepTimerSettings? get sleepTimerSettings => - throw _privateConstructorUsedError; - Duration? get playbackReportInterval => throw _privateConstructorUsedError; + + MinimizedPlayerSettings? get miniPlayerSettings; ExpandedPlayerSettings? get expandedPlayerSettings; double? get preferredDefaultVolume; double? get preferredDefaultSpeed; List? get speedOptions; SleepTimerSettings? get sleepTimerSettings; Duration? get playbackReportInterval; +/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$NullablePlayerSettingsCopyWith get copyWith => _$NullablePlayerSettingsCopyWithImpl(this as NullablePlayerSettings, _$identity); /// Serializes this NullablePlayerSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is NullablePlayerSettings&&(identical(other.miniPlayerSettings, miniPlayerSettings) || other.miniPlayerSettings == miniPlayerSettings)&&(identical(other.expandedPlayerSettings, expandedPlayerSettings) || other.expandedPlayerSettings == expandedPlayerSettings)&&(identical(other.preferredDefaultVolume, preferredDefaultVolume) || other.preferredDefaultVolume == preferredDefaultVolume)&&(identical(other.preferredDefaultSpeed, preferredDefaultSpeed) || other.preferredDefaultSpeed == preferredDefaultSpeed)&&const DeepCollectionEquality().equals(other.speedOptions, speedOptions)&&(identical(other.sleepTimerSettings, sleepTimerSettings) || other.sleepTimerSettings == sleepTimerSettings)&&(identical(other.playbackReportInterval, playbackReportInterval) || other.playbackReportInterval == playbackReportInterval)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,miniPlayerSettings,expandedPlayerSettings,preferredDefaultVolume,preferredDefaultSpeed,const DeepCollectionEquality().hash(speedOptions),sleepTimerSettings,playbackReportInterval); + +@override +String toString() { + return 'NullablePlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, sleepTimerSettings: $sleepTimerSettings, playbackReportInterval: $playbackReportInterval)'; +} + - /// Create a copy of NullablePlayerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $NullablePlayerSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $NullablePlayerSettingsCopyWith<$Res> { - factory $NullablePlayerSettingsCopyWith(NullablePlayerSettings value, - $Res Function(NullablePlayerSettings) then) = - _$NullablePlayerSettingsCopyWithImpl<$Res, NullablePlayerSettings>; - @useResult - $Res call( - {MinimizedPlayerSettings? miniPlayerSettings, - ExpandedPlayerSettings? expandedPlayerSettings, - double? preferredDefaultVolume, - double? preferredDefaultSpeed, - List? speedOptions, - SleepTimerSettings? sleepTimerSettings, - Duration? playbackReportInterval}); +abstract mixin class $NullablePlayerSettingsCopyWith<$Res> { + factory $NullablePlayerSettingsCopyWith(NullablePlayerSettings value, $Res Function(NullablePlayerSettings) _then) = _$NullablePlayerSettingsCopyWithImpl; +@useResult +$Res call({ + MinimizedPlayerSettings? miniPlayerSettings, ExpandedPlayerSettings? expandedPlayerSettings, double? preferredDefaultVolume, double? preferredDefaultSpeed, List? speedOptions, SleepTimerSettings? sleepTimerSettings, Duration? playbackReportInterval +}); + + +$MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings;$ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings;$SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings; - $MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings; - $ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings; - $SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings; } - /// @nodoc -class _$NullablePlayerSettingsCopyWithImpl<$Res, - $Val extends NullablePlayerSettings> +class _$NullablePlayerSettingsCopyWithImpl<$Res> implements $NullablePlayerSettingsCopyWith<$Res> { - _$NullablePlayerSettingsCopyWithImpl(this._value, this._then); + _$NullablePlayerSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final NullablePlayerSettings _self; + final $Res Function(NullablePlayerSettings) _then; - /// Create a copy of NullablePlayerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? miniPlayerSettings = freezed, - Object? expandedPlayerSettings = freezed, - Object? preferredDefaultVolume = freezed, - Object? preferredDefaultSpeed = freezed, - Object? speedOptions = freezed, - Object? sleepTimerSettings = freezed, - Object? playbackReportInterval = freezed, - }) { - return _then(_value.copyWith( - miniPlayerSettings: freezed == miniPlayerSettings - ? _value.miniPlayerSettings - : miniPlayerSettings // ignore: cast_nullable_to_non_nullable - as MinimizedPlayerSettings?, - expandedPlayerSettings: freezed == expandedPlayerSettings - ? _value.expandedPlayerSettings - : expandedPlayerSettings // ignore: cast_nullable_to_non_nullable - as ExpandedPlayerSettings?, - preferredDefaultVolume: freezed == preferredDefaultVolume - ? _value.preferredDefaultVolume - : preferredDefaultVolume // ignore: cast_nullable_to_non_nullable - as double?, - preferredDefaultSpeed: freezed == preferredDefaultSpeed - ? _value.preferredDefaultSpeed - : preferredDefaultSpeed // ignore: cast_nullable_to_non_nullable - as double?, - speedOptions: freezed == speedOptions - ? _value.speedOptions - : speedOptions // ignore: cast_nullable_to_non_nullable - as List?, - sleepTimerSettings: freezed == sleepTimerSettings - ? _value.sleepTimerSettings - : sleepTimerSettings // ignore: cast_nullable_to_non_nullable - as SleepTimerSettings?, - playbackReportInterval: freezed == playbackReportInterval - ? _value.playbackReportInterval - : playbackReportInterval // ignore: cast_nullable_to_non_nullable - as Duration?, - ) as $Val); +/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? miniPlayerSettings = freezed,Object? expandedPlayerSettings = freezed,Object? preferredDefaultVolume = freezed,Object? preferredDefaultSpeed = freezed,Object? speedOptions = freezed,Object? sleepTimerSettings = freezed,Object? playbackReportInterval = freezed,}) { + return _then(_self.copyWith( +miniPlayerSettings: freezed == miniPlayerSettings ? _self.miniPlayerSettings : miniPlayerSettings // ignore: cast_nullable_to_non_nullable +as MinimizedPlayerSettings?,expandedPlayerSettings: freezed == expandedPlayerSettings ? _self.expandedPlayerSettings : expandedPlayerSettings // ignore: cast_nullable_to_non_nullable +as ExpandedPlayerSettings?,preferredDefaultVolume: freezed == preferredDefaultVolume ? _self.preferredDefaultVolume : preferredDefaultVolume // ignore: cast_nullable_to_non_nullable +as double?,preferredDefaultSpeed: freezed == preferredDefaultSpeed ? _self.preferredDefaultSpeed : preferredDefaultSpeed // ignore: cast_nullable_to_non_nullable +as double?,speedOptions: freezed == speedOptions ? _self.speedOptions : speedOptions // ignore: cast_nullable_to_non_nullable +as List?,sleepTimerSettings: freezed == sleepTimerSettings ? _self.sleepTimerSettings : sleepTimerSettings // ignore: cast_nullable_to_non_nullable +as SleepTimerSettings?,playbackReportInterval: freezed == playbackReportInterval ? _self.playbackReportInterval : playbackReportInterval // ignore: cast_nullable_to_non_nullable +as Duration?, + )); +} +/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings { + if (_self.miniPlayerSettings == null) { + return null; } - /// Create a copy of NullablePlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings { - if (_value.miniPlayerSettings == null) { - return null; - } - - return $MinimizedPlayerSettingsCopyWith<$Res>(_value.miniPlayerSettings!, - (value) { - return _then(_value.copyWith(miniPlayerSettings: value) as $Val); - }); + return $MinimizedPlayerSettingsCopyWith<$Res>(_self.miniPlayerSettings!, (value) { + return _then(_self.copyWith(miniPlayerSettings: value)); + }); +}/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings { + if (_self.expandedPlayerSettings == null) { + return null; } - /// Create a copy of NullablePlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings { - if (_value.expandedPlayerSettings == null) { - return null; - } - - return $ExpandedPlayerSettingsCopyWith<$Res>(_value.expandedPlayerSettings!, - (value) { - return _then(_value.copyWith(expandedPlayerSettings: value) as $Val); - }); + return $ExpandedPlayerSettingsCopyWith<$Res>(_self.expandedPlayerSettings!, (value) { + return _then(_self.copyWith(expandedPlayerSettings: value)); + }); +}/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings { + if (_self.sleepTimerSettings == null) { + return null; } - /// Create a copy of NullablePlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings { - if (_value.sleepTimerSettings == null) { - return null; - } - - return $SleepTimerSettingsCopyWith<$Res>(_value.sleepTimerSettings!, - (value) { - return _then(_value.copyWith(sleepTimerSettings: value) as $Val); - }); - } + return $SleepTimerSettingsCopyWith<$Res>(_self.sleepTimerSettings!, (value) { + return _then(_self.copyWith(sleepTimerSettings: value)); + }); +} } -/// @nodoc -abstract class _$$NullablePlayerSettingsImplCopyWith<$Res> - implements $NullablePlayerSettingsCopyWith<$Res> { - factory _$$NullablePlayerSettingsImplCopyWith( - _$NullablePlayerSettingsImpl value, - $Res Function(_$NullablePlayerSettingsImpl) then) = - __$$NullablePlayerSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {MinimizedPlayerSettings? miniPlayerSettings, - ExpandedPlayerSettings? expandedPlayerSettings, - double? preferredDefaultVolume, - double? preferredDefaultSpeed, - List? speedOptions, - SleepTimerSettings? sleepTimerSettings, - Duration? playbackReportInterval}); - @override - $MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings; - @override - $ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings; - @override - $SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings; +/// Adds pattern-matching-related methods to [NullablePlayerSettings]. +extension NullablePlayerSettingsPatterns on NullablePlayerSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _NullablePlayerSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _NullablePlayerSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _NullablePlayerSettings value) $default,){ +final _that = this; +switch (_that) { +case _NullablePlayerSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _NullablePlayerSettings value)? $default,){ +final _that = this; +switch (_that) { +case _NullablePlayerSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( MinimizedPlayerSettings? miniPlayerSettings, ExpandedPlayerSettings? expandedPlayerSettings, double? preferredDefaultVolume, double? preferredDefaultSpeed, List? speedOptions, SleepTimerSettings? sleepTimerSettings, Duration? playbackReportInterval)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _NullablePlayerSettings() when $default != null: +return $default(_that.miniPlayerSettings,_that.expandedPlayerSettings,_that.preferredDefaultVolume,_that.preferredDefaultSpeed,_that.speedOptions,_that.sleepTimerSettings,_that.playbackReportInterval);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( MinimizedPlayerSettings? miniPlayerSettings, ExpandedPlayerSettings? expandedPlayerSettings, double? preferredDefaultVolume, double? preferredDefaultSpeed, List? speedOptions, SleepTimerSettings? sleepTimerSettings, Duration? playbackReportInterval) $default,) {final _that = this; +switch (_that) { +case _NullablePlayerSettings(): +return $default(_that.miniPlayerSettings,_that.expandedPlayerSettings,_that.preferredDefaultVolume,_that.preferredDefaultSpeed,_that.speedOptions,_that.sleepTimerSettings,_that.playbackReportInterval);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( MinimizedPlayerSettings? miniPlayerSettings, ExpandedPlayerSettings? expandedPlayerSettings, double? preferredDefaultVolume, double? preferredDefaultSpeed, List? speedOptions, SleepTimerSettings? sleepTimerSettings, Duration? playbackReportInterval)? $default,) {final _that = this; +switch (_that) { +case _NullablePlayerSettings() when $default != null: +return $default(_that.miniPlayerSettings,_that.expandedPlayerSettings,_that.preferredDefaultVolume,_that.preferredDefaultSpeed,_that.speedOptions,_that.sleepTimerSettings,_that.playbackReportInterval);case _: + return null; + +} } -/// @nodoc -class __$$NullablePlayerSettingsImplCopyWithImpl<$Res> - extends _$NullablePlayerSettingsCopyWithImpl<$Res, - _$NullablePlayerSettingsImpl> - implements _$$NullablePlayerSettingsImplCopyWith<$Res> { - __$$NullablePlayerSettingsImplCopyWithImpl( - _$NullablePlayerSettingsImpl _value, - $Res Function(_$NullablePlayerSettingsImpl) _then) - : super(_value, _then); - - /// Create a copy of NullablePlayerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? miniPlayerSettings = freezed, - Object? expandedPlayerSettings = freezed, - Object? preferredDefaultVolume = freezed, - Object? preferredDefaultSpeed = freezed, - Object? speedOptions = freezed, - Object? sleepTimerSettings = freezed, - Object? playbackReportInterval = freezed, - }) { - return _then(_$NullablePlayerSettingsImpl( - miniPlayerSettings: freezed == miniPlayerSettings - ? _value.miniPlayerSettings - : miniPlayerSettings // ignore: cast_nullable_to_non_nullable - as MinimizedPlayerSettings?, - expandedPlayerSettings: freezed == expandedPlayerSettings - ? _value.expandedPlayerSettings - : expandedPlayerSettings // ignore: cast_nullable_to_non_nullable - as ExpandedPlayerSettings?, - preferredDefaultVolume: freezed == preferredDefaultVolume - ? _value.preferredDefaultVolume - : preferredDefaultVolume // ignore: cast_nullable_to_non_nullable - as double?, - preferredDefaultSpeed: freezed == preferredDefaultSpeed - ? _value.preferredDefaultSpeed - : preferredDefaultSpeed // ignore: cast_nullable_to_non_nullable - as double?, - speedOptions: freezed == speedOptions - ? _value._speedOptions - : speedOptions // ignore: cast_nullable_to_non_nullable - as List?, - sleepTimerSettings: freezed == sleepTimerSettings - ? _value.sleepTimerSettings - : sleepTimerSettings // ignore: cast_nullable_to_non_nullable - as SleepTimerSettings?, - playbackReportInterval: freezed == playbackReportInterval - ? _value.playbackReportInterval - : playbackReportInterval // ignore: cast_nullable_to_non_nullable - as Duration?, - )); - } } /// @nodoc @JsonSerializable() -class _$NullablePlayerSettingsImpl implements _NullablePlayerSettings { - const _$NullablePlayerSettingsImpl( - {this.miniPlayerSettings, - this.expandedPlayerSettings, - this.preferredDefaultVolume, - this.preferredDefaultSpeed, - final List? speedOptions, - this.sleepTimerSettings, - this.playbackReportInterval}) - : _speedOptions = speedOptions; - factory _$NullablePlayerSettingsImpl.fromJson(Map json) => - _$$NullablePlayerSettingsImplFromJson(json); +class _NullablePlayerSettings implements NullablePlayerSettings { + const _NullablePlayerSettings({this.miniPlayerSettings, this.expandedPlayerSettings, this.preferredDefaultVolume, this.preferredDefaultSpeed, final List? speedOptions, this.sleepTimerSettings, this.playbackReportInterval}): _speedOptions = speedOptions; + factory _NullablePlayerSettings.fromJson(Map json) => _$NullablePlayerSettingsFromJson(json); - @override - final MinimizedPlayerSettings? miniPlayerSettings; - @override - final ExpandedPlayerSettings? expandedPlayerSettings; - @override - final double? preferredDefaultVolume; - @override - final double? preferredDefaultSpeed; - final List? _speedOptions; - @override - List? get speedOptions { - final value = _speedOptions; - if (value == null) return null; - if (_speedOptions is EqualUnmodifiableListView) return _speedOptions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); - } - - @override - final SleepTimerSettings? sleepTimerSettings; - @override - final Duration? playbackReportInterval; - - @override - String toString() { - return 'NullablePlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, sleepTimerSettings: $sleepTimerSettings, playbackReportInterval: $playbackReportInterval)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$NullablePlayerSettingsImpl && - (identical(other.miniPlayerSettings, miniPlayerSettings) || - other.miniPlayerSettings == miniPlayerSettings) && - (identical(other.expandedPlayerSettings, expandedPlayerSettings) || - other.expandedPlayerSettings == expandedPlayerSettings) && - (identical(other.preferredDefaultVolume, preferredDefaultVolume) || - other.preferredDefaultVolume == preferredDefaultVolume) && - (identical(other.preferredDefaultSpeed, preferredDefaultSpeed) || - other.preferredDefaultSpeed == preferredDefaultSpeed) && - const DeepCollectionEquality() - .equals(other._speedOptions, _speedOptions) && - (identical(other.sleepTimerSettings, sleepTimerSettings) || - other.sleepTimerSettings == sleepTimerSettings) && - (identical(other.playbackReportInterval, playbackReportInterval) || - other.playbackReportInterval == playbackReportInterval)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - miniPlayerSettings, - expandedPlayerSettings, - preferredDefaultVolume, - preferredDefaultSpeed, - const DeepCollectionEquality().hash(_speedOptions), - sleepTimerSettings, - playbackReportInterval); - - /// Create a copy of NullablePlayerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$NullablePlayerSettingsImplCopyWith<_$NullablePlayerSettingsImpl> - get copyWith => __$$NullablePlayerSettingsImplCopyWithImpl< - _$NullablePlayerSettingsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$NullablePlayerSettingsImplToJson( - this, - ); - } +@override final MinimizedPlayerSettings? miniPlayerSettings; +@override final ExpandedPlayerSettings? expandedPlayerSettings; +@override final double? preferredDefaultVolume; +@override final double? preferredDefaultSpeed; + final List? _speedOptions; +@override List? get speedOptions { + final value = _speedOptions; + if (value == null) return null; + if (_speedOptions is EqualUnmodifiableListView) return _speedOptions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); } -abstract class _NullablePlayerSettings implements NullablePlayerSettings { - const factory _NullablePlayerSettings( - {final MinimizedPlayerSettings? miniPlayerSettings, - final ExpandedPlayerSettings? expandedPlayerSettings, - final double? preferredDefaultVolume, - final double? preferredDefaultSpeed, - final List? speedOptions, - final SleepTimerSettings? sleepTimerSettings, - final Duration? playbackReportInterval}) = _$NullablePlayerSettingsImpl; +@override final SleepTimerSettings? sleepTimerSettings; +@override final Duration? playbackReportInterval; - factory _NullablePlayerSettings.fromJson(Map json) = - _$NullablePlayerSettingsImpl.fromJson; +/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NullablePlayerSettingsCopyWith<_NullablePlayerSettings> get copyWith => __$NullablePlayerSettingsCopyWithImpl<_NullablePlayerSettings>(this, _$identity); - @override - MinimizedPlayerSettings? get miniPlayerSettings; - @override - ExpandedPlayerSettings? get expandedPlayerSettings; - @override - double? get preferredDefaultVolume; - @override - double? get preferredDefaultSpeed; - @override - List? get speedOptions; - @override - SleepTimerSettings? get sleepTimerSettings; - @override - Duration? get playbackReportInterval; - - /// Create a copy of NullablePlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$NullablePlayerSettingsImplCopyWith<_$NullablePlayerSettingsImpl> - get copyWith => throw _privateConstructorUsedError; +@override +Map toJson() { + return _$NullablePlayerSettingsToJson(this, ); } + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NullablePlayerSettings&&(identical(other.miniPlayerSettings, miniPlayerSettings) || other.miniPlayerSettings == miniPlayerSettings)&&(identical(other.expandedPlayerSettings, expandedPlayerSettings) || other.expandedPlayerSettings == expandedPlayerSettings)&&(identical(other.preferredDefaultVolume, preferredDefaultVolume) || other.preferredDefaultVolume == preferredDefaultVolume)&&(identical(other.preferredDefaultSpeed, preferredDefaultSpeed) || other.preferredDefaultSpeed == preferredDefaultSpeed)&&const DeepCollectionEquality().equals(other._speedOptions, _speedOptions)&&(identical(other.sleepTimerSettings, sleepTimerSettings) || other.sleepTimerSettings == sleepTimerSettings)&&(identical(other.playbackReportInterval, playbackReportInterval) || other.playbackReportInterval == playbackReportInterval)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,miniPlayerSettings,expandedPlayerSettings,preferredDefaultVolume,preferredDefaultSpeed,const DeepCollectionEquality().hash(_speedOptions),sleepTimerSettings,playbackReportInterval); + +@override +String toString() { + return 'NullablePlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, sleepTimerSettings: $sleepTimerSettings, playbackReportInterval: $playbackReportInterval)'; +} + + +} + +/// @nodoc +abstract mixin class _$NullablePlayerSettingsCopyWith<$Res> implements $NullablePlayerSettingsCopyWith<$Res> { + factory _$NullablePlayerSettingsCopyWith(_NullablePlayerSettings value, $Res Function(_NullablePlayerSettings) _then) = __$NullablePlayerSettingsCopyWithImpl; +@override @useResult +$Res call({ + MinimizedPlayerSettings? miniPlayerSettings, ExpandedPlayerSettings? expandedPlayerSettings, double? preferredDefaultVolume, double? preferredDefaultSpeed, List? speedOptions, SleepTimerSettings? sleepTimerSettings, Duration? playbackReportInterval +}); + + +@override $MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings;@override $ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings;@override $SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings; + +} +/// @nodoc +class __$NullablePlayerSettingsCopyWithImpl<$Res> + implements _$NullablePlayerSettingsCopyWith<$Res> { + __$NullablePlayerSettingsCopyWithImpl(this._self, this._then); + + final _NullablePlayerSettings _self; + final $Res Function(_NullablePlayerSettings) _then; + +/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? miniPlayerSettings = freezed,Object? expandedPlayerSettings = freezed,Object? preferredDefaultVolume = freezed,Object? preferredDefaultSpeed = freezed,Object? speedOptions = freezed,Object? sleepTimerSettings = freezed,Object? playbackReportInterval = freezed,}) { + return _then(_NullablePlayerSettings( +miniPlayerSettings: freezed == miniPlayerSettings ? _self.miniPlayerSettings : miniPlayerSettings // ignore: cast_nullable_to_non_nullable +as MinimizedPlayerSettings?,expandedPlayerSettings: freezed == expandedPlayerSettings ? _self.expandedPlayerSettings : expandedPlayerSettings // ignore: cast_nullable_to_non_nullable +as ExpandedPlayerSettings?,preferredDefaultVolume: freezed == preferredDefaultVolume ? _self.preferredDefaultVolume : preferredDefaultVolume // ignore: cast_nullable_to_non_nullable +as double?,preferredDefaultSpeed: freezed == preferredDefaultSpeed ? _self.preferredDefaultSpeed : preferredDefaultSpeed // ignore: cast_nullable_to_non_nullable +as double?,speedOptions: freezed == speedOptions ? _self._speedOptions : speedOptions // ignore: cast_nullable_to_non_nullable +as List?,sleepTimerSettings: freezed == sleepTimerSettings ? _self.sleepTimerSettings : sleepTimerSettings // ignore: cast_nullable_to_non_nullable +as SleepTimerSettings?,playbackReportInterval: freezed == playbackReportInterval ? _self.playbackReportInterval : playbackReportInterval // ignore: cast_nullable_to_non_nullable +as Duration?, + )); +} + +/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings { + if (_self.miniPlayerSettings == null) { + return null; + } + + return $MinimizedPlayerSettingsCopyWith<$Res>(_self.miniPlayerSettings!, (value) { + return _then(_self.copyWith(miniPlayerSettings: value)); + }); +}/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings { + if (_self.expandedPlayerSettings == null) { + return null; + } + + return $ExpandedPlayerSettingsCopyWith<$Res>(_self.expandedPlayerSettings!, (value) { + return _then(_self.copyWith(expandedPlayerSettings: value)); + }); +}/// Create a copy of NullablePlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings { + if (_self.sleepTimerSettings == null) { + return null; + } + + return $SleepTimerSettingsCopyWith<$Res>(_self.sleepTimerSettings!, (value) { + return _then(_self.copyWith(sleepTimerSettings: value)); + }); +} +} + +// dart format on diff --git a/lib/features/per_book_settings/models/nullable_player_settings.g.dart b/lib/features/per_book_settings/models/nullable_player_settings.g.dart index 28eb3bc..3c45864 100644 --- a/lib/features/per_book_settings/models/nullable_player_settings.g.dart +++ b/lib/features/per_book_settings/models/nullable_player_settings.g.dart @@ -6,42 +6,42 @@ part of 'nullable_player_settings.dart'; // JsonSerializableGenerator // ************************************************************************** -_$NullablePlayerSettingsImpl _$$NullablePlayerSettingsImplFromJson( - Map json) => - _$NullablePlayerSettingsImpl( - miniPlayerSettings: json['miniPlayerSettings'] == null - ? null - : MinimizedPlayerSettings.fromJson( - json['miniPlayerSettings'] as Map), - expandedPlayerSettings: json['expandedPlayerSettings'] == null - ? null - : ExpandedPlayerSettings.fromJson( - json['expandedPlayerSettings'] as Map), - preferredDefaultVolume: - (json['preferredDefaultVolume'] as num?)?.toDouble(), - preferredDefaultSpeed: - (json['preferredDefaultSpeed'] as num?)?.toDouble(), - speedOptions: (json['speedOptions'] as List?) - ?.map((e) => (e as num).toDouble()) - .toList(), - sleepTimerSettings: json['sleepTimerSettings'] == null - ? null - : SleepTimerSettings.fromJson( - json['sleepTimerSettings'] as Map), - playbackReportInterval: json['playbackReportInterval'] == null - ? null - : Duration( - microseconds: (json['playbackReportInterval'] as num).toInt()), - ); +_NullablePlayerSettings _$NullablePlayerSettingsFromJson( + Map json, +) => _NullablePlayerSettings( + miniPlayerSettings: json['miniPlayerSettings'] == null + ? null + : MinimizedPlayerSettings.fromJson( + json['miniPlayerSettings'] as Map, + ), + expandedPlayerSettings: json['expandedPlayerSettings'] == null + ? null + : ExpandedPlayerSettings.fromJson( + json['expandedPlayerSettings'] as Map, + ), + preferredDefaultVolume: (json['preferredDefaultVolume'] as num?)?.toDouble(), + preferredDefaultSpeed: (json['preferredDefaultSpeed'] as num?)?.toDouble(), + speedOptions: (json['speedOptions'] as List?) + ?.map((e) => (e as num).toDouble()) + .toList(), + sleepTimerSettings: json['sleepTimerSettings'] == null + ? null + : SleepTimerSettings.fromJson( + json['sleepTimerSettings'] as Map, + ), + playbackReportInterval: json['playbackReportInterval'] == null + ? null + : Duration(microseconds: (json['playbackReportInterval'] as num).toInt()), +); -Map _$$NullablePlayerSettingsImplToJson( - _$NullablePlayerSettingsImpl instance) => - { - 'miniPlayerSettings': instance.miniPlayerSettings, - 'expandedPlayerSettings': instance.expandedPlayerSettings, - 'preferredDefaultVolume': instance.preferredDefaultVolume, - 'preferredDefaultSpeed': instance.preferredDefaultSpeed, - 'speedOptions': instance.speedOptions, - 'sleepTimerSettings': instance.sleepTimerSettings, - 'playbackReportInterval': instance.playbackReportInterval?.inMicroseconds, - }; +Map _$NullablePlayerSettingsToJson( + _NullablePlayerSettings instance, +) => { + 'miniPlayerSettings': instance.miniPlayerSettings, + 'expandedPlayerSettings': instance.expandedPlayerSettings, + 'preferredDefaultVolume': instance.preferredDefaultVolume, + 'preferredDefaultSpeed': instance.preferredDefaultSpeed, + 'speedOptions': instance.speedOptions, + 'sleepTimerSettings': instance.sleepTimerSettings, + 'playbackReportInterval': instance.playbackReportInterval?.inMicroseconds, +}; diff --git a/lib/features/per_book_settings/providers/book_settings_provider.g.dart b/lib/features/per_book_settings/providers/book_settings_provider.g.dart index 221433f..b8ed222 100644 --- a/lib/features/per_book_settings/providers/book_settings_provider.g.dart +++ b/lib/features/per_book_settings/providers/book_settings_provider.g.dart @@ -6,171 +6,102 @@ part of 'book_settings_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$bookSettingsHash() => r'b976df954edf98ec6ccb3eb41e9d07dd4a9193eb'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - -abstract class _$BookSettings - extends BuildlessAutoDisposeNotifier { - late final String bookId; - - model.BookSettings build( - String bookId, - ); -} - -/// See also [BookSettings]. @ProviderFor(BookSettings) -const bookSettingsProvider = BookSettingsFamily(); +final bookSettingsProvider = BookSettingsFamily._(); -/// See also [BookSettings]. -class BookSettingsFamily extends Family { - /// See also [BookSettings]. - const BookSettingsFamily(); +final class BookSettingsProvider + extends $NotifierProvider { + BookSettingsProvider._({ + required BookSettingsFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'bookSettingsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// See also [BookSettings]. - BookSettingsProvider call( - String bookId, - ) { - return BookSettingsProvider( - bookId, - ); + @override + String debugGetCreateSourceHash() => _$bookSettingsHash(); + + @override + String toString() { + return r'bookSettingsProvider' + '' + '($argument)'; } + @$internal @override - BookSettingsProvider getProviderOverride( - covariant BookSettingsProvider provider, - ) { - return call( - provider.bookId, - ); - } + BookSettings create() => BookSettings(); - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'bookSettingsProvider'; -} - -/// See also [BookSettings]. -class BookSettingsProvider - extends AutoDisposeNotifierProviderImpl { - /// See also [BookSettings]. - BookSettingsProvider( - String bookId, - ) : this._internal( - () => BookSettings()..bookId = bookId, - from: bookSettingsProvider, - name: r'bookSettingsProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$bookSettingsHash, - dependencies: BookSettingsFamily._dependencies, - allTransitiveDependencies: - BookSettingsFamily._allTransitiveDependencies, - bookId: bookId, - ); - - BookSettingsProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.bookId, - }) : super.internal(); - - final String bookId; - - @override - model.BookSettings runNotifierBuild( - covariant BookSettings notifier, - ) { - return notifier.build( - bookId, - ); - } - - @override - Override overrideWith(BookSettings Function() create) { - return ProviderOverride( + /// {@macro riverpod.override_with_value} + Override overrideWithValue(model.BookSettings value) { + return $ProviderOverride( origin: this, - override: BookSettingsProvider._internal( - () => create()..bookId = bookId, - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - bookId: bookId, - ), + providerOverride: $SyncValueProvider(value), ); } - @override - AutoDisposeNotifierProviderElement - createElement() { - return _BookSettingsProviderElement(this); - } - @override bool operator ==(Object other) { - return other is BookSettingsProvider && other.bookId == bookId; + return other is BookSettingsProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, bookId.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin BookSettingsRef on AutoDisposeNotifierProviderRef { - /// The parameter `bookId` of this provider. - String get bookId; -} +String _$bookSettingsHash() => r'b976df954edf98ec6ccb3eb41e9d07dd4a9193eb'; -class _BookSettingsProviderElement - extends AutoDisposeNotifierProviderElement - with BookSettingsRef { - _BookSettingsProviderElement(super.provider); +final class BookSettingsFamily extends $Family + with + $ClassFamilyOverride< + BookSettings, + model.BookSettings, + model.BookSettings, + model.BookSettings, + String + > { + BookSettingsFamily._() + : super( + retry: null, + name: r'bookSettingsProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + BookSettingsProvider call(String bookId) => + BookSettingsProvider._(argument: bookId, from: this); @override - String get bookId => (origin as BookSettingsProvider).bookId; + String toString() => r'bookSettingsProvider'; +} + +abstract class _$BookSettings extends $Notifier { + late final _$args = ref.$arg as String; + String get bookId => _$args; + + model.BookSettings build(String bookId); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + model.BookSettings, + Object?, + Object? + >; + element.handleCreate(ref, () => build(_$args)); + } } -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/features/playback_reporting/providers/playback_reporter_provider.g.dart b/lib/features/playback_reporting/providers/playback_reporter_provider.g.dart index 3c21f16..e017dbb 100644 --- a/lib/features/playback_reporting/providers/playback_reporter_provider.g.dart +++ b/lib/features/playback_reporting/providers/playback_reporter_provider.g.dart @@ -6,21 +6,55 @@ part of 'playback_reporter_provider.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(PlaybackReporter) +final playbackReporterProvider = PlaybackReporterProvider._(); + +final class PlaybackReporterProvider + extends $AsyncNotifierProvider { + PlaybackReporterProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'playbackReporterProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$playbackReporterHash(); + + @$internal + @override + PlaybackReporter create() => PlaybackReporter(); +} + String _$playbackReporterHash() => r'f5436d652e51c37bcc684acdaec94e17a97e68e5'; -/// See also [PlaybackReporter]. -@ProviderFor(PlaybackReporter) -final playbackReporterProvider = - AsyncNotifierProvider.internal( - PlaybackReporter.new, - name: r'playbackReporterProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$playbackReporterHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$PlaybackReporter = AsyncNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$PlaybackReporter + extends $AsyncNotifier { + FutureOr build(); + @$mustCallSuper + @override + void runBuild() { + final ref = + this.ref + as $Ref, core.PlaybackReporter>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier< + AsyncValue, + core.PlaybackReporter + >, + AsyncValue, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/features/player/playlist_provider.g.dart b/lib/features/player/playlist_provider.g.dart index abf7c33..2baca58 100644 --- a/lib/features/player/playlist_provider.g.dart +++ b/lib/features/player/playlist_provider.g.dart @@ -6,20 +6,57 @@ part of 'playlist_provider.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(Playlist) +final playlistProvider = PlaylistProvider._(); + +final class PlaylistProvider + extends $NotifierProvider { + PlaylistProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'playlistProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$playlistHash(); + + @$internal + @override + Playlist create() => Playlist(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AudiobookPlaylist value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + String _$playlistHash() => r'bed4642e4c2de829e4d0630cb5bf92bffeeb1f60'; -/// See also [Playlist]. -@ProviderFor(Playlist) -final playlistProvider = - AutoDisposeNotifierProvider.internal( - Playlist.new, - name: r'playlistProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$playlistHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$Playlist = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$Playlist extends $Notifier { + AudiobookPlaylist build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + AudiobookPlaylist, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/features/player/providers/audiobook_player.g.dart b/lib/features/player/providers/audiobook_player.g.dart index d38dd30..900fd73 100644 --- a/lib/features/player/providers/audiobook_player.g.dart +++ b/lib/features/player/providers/audiobook_player.g.dart @@ -6,41 +6,119 @@ part of 'audiobook_player.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning +/// Simple because it doesn't rebuild when the player state changes +/// it only rebuilds when the token changes + +@ProviderFor(SimpleAudiobookPlayer) +final simpleAudiobookPlayerProvider = SimpleAudiobookPlayerProvider._(); + +/// Simple because it doesn't rebuild when the player state changes +/// it only rebuilds when the token changes +final class SimpleAudiobookPlayerProvider + extends $NotifierProvider { + /// Simple because it doesn't rebuild when the player state changes + /// it only rebuilds when the token changes + SimpleAudiobookPlayerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'simpleAudiobookPlayerProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$simpleAudiobookPlayerHash(); + + @$internal + @override + SimpleAudiobookPlayer create() => SimpleAudiobookPlayer(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(core.AudiobookPlayer value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + String _$simpleAudiobookPlayerHash() => r'5e94bbff4314adceb5affa704fc4d079d4016afa'; /// Simple because it doesn't rebuild when the player state changes /// it only rebuilds when the token changes -/// -/// Copied from [SimpleAudiobookPlayer]. -@ProviderFor(SimpleAudiobookPlayer) -final simpleAudiobookPlayerProvider = - NotifierProvider.internal( - SimpleAudiobookPlayer.new, - name: r'simpleAudiobookPlayerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$simpleAudiobookPlayerHash, - dependencies: null, - allTransitiveDependencies: null, -); -typedef _$SimpleAudiobookPlayer = Notifier; +abstract class _$SimpleAudiobookPlayer extends $Notifier { + core.AudiobookPlayer build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + core.AudiobookPlayer, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} + +@ProviderFor(AudiobookPlayer) +final audiobookPlayerProvider = AudiobookPlayerProvider._(); + +final class AudiobookPlayerProvider + extends $NotifierProvider { + AudiobookPlayerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'audiobookPlayerProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$audiobookPlayerHash(); + + @$internal + @override + AudiobookPlayer create() => AudiobookPlayer(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(core.AudiobookPlayer value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + String _$audiobookPlayerHash() => r'0f180308067486896fec6a65a6afb0e6686ac4a0'; -/// See also [AudiobookPlayer]. -@ProviderFor(AudiobookPlayer) -final audiobookPlayerProvider = - NotifierProvider.internal( - AudiobookPlayer.new, - name: r'audiobookPlayerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$audiobookPlayerHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$AudiobookPlayer = Notifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$AudiobookPlayer extends $Notifier { + core.AudiobookPlayer build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + core.AudiobookPlayer, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/features/player/providers/currently_playing_provider.g.dart b/lib/features/player/providers/currently_playing_provider.g.dart index 428aa0b..f886f8e 100644 --- a/lib/features/player/providers/currently_playing_provider.g.dart +++ b/lib/features/player/providers/currently_playing_provider.g.dart @@ -6,66 +6,147 @@ part of 'currently_playing_provider.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(currentlyPlayingBook) +final currentlyPlayingBookProvider = CurrentlyPlayingBookProvider._(); + +final class CurrentlyPlayingBookProvider + extends $FunctionalProvider + with $Provider { + CurrentlyPlayingBookProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'currentlyPlayingBookProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$currentlyPlayingBookHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + BookExpanded? create(Ref ref) { + return currentlyPlayingBook(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(BookExpanded? value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + String _$currentlyPlayingBookHash() => r'e4258694c8f0d1e89651b330fae0f672ca13a484'; -/// See also [currentlyPlayingBook]. -@ProviderFor(currentlyPlayingBook) -final currentlyPlayingBookProvider = - AutoDisposeProvider.internal( - currentlyPlayingBook, - name: r'currentlyPlayingBookProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$currentlyPlayingBookHash, - dependencies: null, - allTransitiveDependencies: null, -); +/// provided the current chapter of the book being played + +@ProviderFor(currentPlayingChapter) +final currentPlayingChapterProvider = CurrentPlayingChapterProvider._(); + +/// provided the current chapter of the book being played + +final class CurrentPlayingChapterProvider + extends $FunctionalProvider + with $Provider { + /// provided the current chapter of the book being played + CurrentPlayingChapterProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'currentPlayingChapterProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$currentPlayingChapterHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + BookChapter? create(Ref ref) { + return currentPlayingChapter(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(BookChapter? value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CurrentlyPlayingBookRef = AutoDisposeProviderRef; String _$currentPlayingChapterHash() => r'73db8b8a9058573bb0c68ec5d5f8aba9306f3d24'; -/// provided the current chapter of the book being played -/// -/// Copied from [currentPlayingChapter]. -@ProviderFor(currentPlayingChapter) -final currentPlayingChapterProvider = - AutoDisposeProvider.internal( - currentPlayingChapter, - name: r'currentPlayingChapterProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$currentPlayingChapterHash, - dependencies: null, - allTransitiveDependencies: null, -); +/// provides the book metadata of the currently playing book -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CurrentPlayingChapterRef = AutoDisposeProviderRef; -String _$currentBookMetadataHash() => - r'f537ef4ef19280bc952de658ecf6520c535ae344'; +@ProviderFor(currentBookMetadata) +final currentBookMetadataProvider = CurrentBookMetadataProvider._(); /// provides the book metadata of the currently playing book -/// -/// Copied from [currentBookMetadata]. -@ProviderFor(currentBookMetadata) -final currentBookMetadataProvider = - AutoDisposeProvider.internal( - currentBookMetadata, - name: r'currentBookMetadataProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$currentBookMetadataHash, - dependencies: null, - allTransitiveDependencies: null, -); -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CurrentBookMetadataRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +final class CurrentBookMetadataProvider + extends + $FunctionalProvider< + BookMetadataExpanded?, + BookMetadataExpanded?, + BookMetadataExpanded? + > + with $Provider { + /// provides the book metadata of the currently playing book + CurrentBookMetadataProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'currentBookMetadataProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$currentBookMetadataHash(); + + @$internal + @override + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + BookMetadataExpanded? create(Ref ref) { + return currentBookMetadata(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(BookMetadataExpanded? value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$currentBookMetadataHash() => + r'f537ef4ef19280bc952de658ecf6520c535ae344'; diff --git a/lib/features/player/providers/player_form.dart b/lib/features/player/providers/player_form.dart index 10376ee..73d6bdc 100644 --- a/lib/features/player/providers/player_form.dart +++ b/lib/features/player/providers/player_form.dart @@ -49,7 +49,7 @@ Raw> playerExpandProgressNotifier( double playerHeight( Ref ref, ) { - final playerExpandProgress = ref.watch(playerExpandProgressNotifierProvider); + final playerExpandProgress = ref.watch(playerExpandProgressProvider); // on change of the playerExpandProgress invalidate playerExpandProgress.addListener(() { diff --git a/lib/features/player/providers/player_form.g.dart b/lib/features/player/providers/player_form.g.dart index 6dcfcf9..b2d17ce 100644 --- a/lib/features/player/providers/player_form.g.dart +++ b/lib/features/player/providers/player_form.g.dart @@ -6,58 +6,134 @@ part of 'player_form.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(playerExpandProgressNotifier) +final playerExpandProgressProvider = PlayerExpandProgressNotifierProvider._(); + +final class PlayerExpandProgressNotifierProvider + extends + $FunctionalProvider< + Raw>, + Raw>, + Raw> + > + with $Provider>> { + PlayerExpandProgressNotifierProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'playerExpandProgressProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$playerExpandProgressNotifierHash(); + + @$internal + @override + $ProviderElement>> $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + Raw> create(Ref ref) { + return playerExpandProgressNotifier(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(Raw> value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider>>(value), + ); + } +} + String _$playerExpandProgressNotifierHash() => r'1ac7172d90a070f96222286edd1a176be197f378'; -/// See also [playerExpandProgressNotifier]. -@ProviderFor(playerExpandProgressNotifier) -final playerExpandProgressNotifierProvider = - Provider>>.internal( - playerExpandProgressNotifier, - name: r'playerExpandProgressNotifierProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$playerExpandProgressNotifierHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef PlayerExpandProgressNotifierRef - = ProviderRef>>; -String _$playerHeightHash() => r'3f031eaffdffbb2c6ddf7eb1aba31bf1619260fc'; - -/// See also [playerHeight]. @ProviderFor(playerHeight) -final playerHeightProvider = Provider.internal( - playerHeight, - name: r'playerHeightProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$playerHeightHash, - dependencies: null, - allTransitiveDependencies: null, -); +final playerHeightProvider = PlayerHeightProvider._(); -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef PlayerHeightRef = ProviderRef; -String _$isPlayerActiveHash() => r'2c7ca125423126fb5f0ef218d37bc8fe0ca9ec98'; +final class PlayerHeightProvider + extends $FunctionalProvider + with $Provider { + PlayerHeightProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'playerHeightProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$playerHeightHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + double create(Ref ref) { + return playerHeight(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(double value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$playerHeightHash() => r'41144a733b5ffd1c872a237ed7c9ea5f450dd0d4'; -/// See also [isPlayerActive]. @ProviderFor(isPlayerActive) -final isPlayerActiveProvider = Provider.internal( - isPlayerActive, - name: r'isPlayerActiveProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$isPlayerActiveHash, - dependencies: null, - allTransitiveDependencies: null, -); +final isPlayerActiveProvider = IsPlayerActiveProvider._(); -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef IsPlayerActiveRef = ProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +final class IsPlayerActiveProvider extends $FunctionalProvider + with $Provider { + IsPlayerActiveProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'isPlayerActiveProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$isPlayerActiveHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + bool create(Ref ref) { + return isPlayerActive(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(bool value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$isPlayerActiveHash() => r'2c7ca125423126fb5f0ef218d37bc8fe0ca9ec98'; diff --git a/lib/features/player/view/audiobook_player.dart b/lib/features/player/view/audiobook_player.dart index 1940ba7..2909a9b 100644 --- a/lib/features/player/view/audiobook_player.dart +++ b/lib/features/player/view/audiobook_player.dart @@ -34,14 +34,14 @@ class AudiobookPlayer extends HookConsumerWidget { final itemBeingPlayed = ref.watch(libraryItemProvider(currentBook.libraryItemId)); final player = ref.watch(audiobookPlayerProvider); - final imageOfItemBeingPlayed = itemBeingPlayed.valueOrNull != null + final imageOfItemBeingPlayed = itemBeingPlayed.value != null ? ref.watch( - coverImageProvider(itemBeingPlayed.valueOrNull!.id), + coverImageProvider(itemBeingPlayed.value!.id), ) : null; - final imgWidget = imageOfItemBeingPlayed?.valueOrNull != null + final imgWidget = imageOfItemBeingPlayed?.value != null ? Image.memory( - imageOfItemBeingPlayed!.valueOrNull!, + imageOfItemBeingPlayed!.value!, fit: BoxFit.cover, ) : const BookCoverSkeleton(); @@ -63,7 +63,7 @@ class AudiobookPlayer extends HookConsumerWidget { // theme from image final imageTheme = ref.watch( themeOfLibraryItemProvider( - itemBeingPlayed.valueOrNull?.id, + itemBeingPlayed.value?.id, brightness: Theme.of(context).brightness, highContrast: appSettings.themeSettings.highContrast || MediaQuery.of(context).highContrast, @@ -81,10 +81,10 @@ class AudiobookPlayer extends HookConsumerWidget { final preferredVolume = appSettings.playerSettings.preferredDefaultVolume; return Theme( data: ThemeData( - colorScheme: imageTheme.valueOrNull ?? Theme.of(context).colorScheme, + colorScheme: imageTheme.value ?? Theme.of(context).colorScheme, ), child: Miniplayer( - valueNotifier: ref.watch(playerExpandProgressNotifierProvider), + valueNotifier: ref.watch(playerExpandProgressProvider), onDragDown: (percentage) async { // preferred volume // set volume to 0 when dragging down diff --git a/lib/features/shake_detection/providers/shake_detector.g.dart b/lib/features/shake_detection/providers/shake_detector.g.dart index ed81aaf..669d6d5 100644 --- a/lib/features/shake_detection/providers/shake_detector.g.dart +++ b/lib/features/shake_detection/providers/shake_detector.g.dart @@ -6,21 +6,57 @@ part of 'shake_detector.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(ShakeDetector) +final shakeDetectorProvider = ShakeDetectorProvider._(); + +final class ShakeDetectorProvider + extends $NotifierProvider { + ShakeDetectorProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'shakeDetectorProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$shakeDetectorHash(); + + @$internal + @override + ShakeDetector create() => ShakeDetector(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(core.ShakeDetector? value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + String _$shakeDetectorHash() => r'2a380bab1d4021d05d2ae40fec964a5f33d3730c'; -/// See also [ShakeDetector]. -@ProviderFor(ShakeDetector) -final shakeDetectorProvider = - AutoDisposeNotifierProvider.internal( - ShakeDetector.new, - name: r'shakeDetectorProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$shakeDetectorHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$ShakeDetector = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$ShakeDetector extends $Notifier { + core.ShakeDetector? build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + core.ShakeDetector?, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/features/sleep_timer/providers/sleep_timer_provider.g.dart b/lib/features/sleep_timer/providers/sleep_timer_provider.g.dart index 0b1db3f..a3b0e3e 100644 --- a/lib/features/sleep_timer/providers/sleep_timer_provider.g.dart +++ b/lib/features/sleep_timer/providers/sleep_timer_provider.g.dart @@ -6,20 +6,57 @@ part of 'sleep_timer_provider.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(SleepTimer) +final sleepTimerProvider = SleepTimerProvider._(); + +final class SleepTimerProvider + extends $NotifierProvider { + SleepTimerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'sleepTimerProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$sleepTimerHash(); + + @$internal + @override + SleepTimer create() => SleepTimer(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(core.SleepTimer? value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + String _$sleepTimerHash() => r'2679454a217d0630a833d730557ab4e4feac2e56'; -/// See also [SleepTimer]. -@ProviderFor(SleepTimer) -final sleepTimerProvider = - NotifierProvider.internal( - SleepTimer.new, - name: r'sleepTimerProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$sleepTimerHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$SleepTimer = Notifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$SleepTimer extends $Notifier { + core.SleepTimer? build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + core.SleepTimer?, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/main.dart b/lib/main.dart index 6020a6a..b67d8a9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -76,9 +76,9 @@ class MyApp extends ConsumerWidget { if (themeSettings.useMaterialThemeFromSystem) { var themes = ref.watch(systemThemeProvider(highContrast: shouldUseHighContrast)); - if (themes.valueOrNull != null) { - lightColorScheme = themes.valueOrNull!.$1; - darkColorScheme = themes.valueOrNull!.$2; + if (themes.value != null) { + lightColorScheme = themes.value!.$1; + darkColorScheme = themes.value!.$2; } } @@ -100,9 +100,9 @@ class MyApp extends ConsumerWidget { brightness: Brightness.dark, ), ); - if (themeLight.valueOrNull != null && themeDark.valueOrNull != null) { - lightColorScheme = themeLight.valueOrNull!; - darkColorScheme = themeDark.valueOrNull!; + if (themeLight.value != null && themeDark.value != null) { + lightColorScheme = themeLight.value!; + darkColorScheme = themeDark.value!; } } } catch (e) { diff --git a/lib/router/models/library_item_extras.dart b/lib/router/models/library_item_extras.dart index 55b734e..e67a508 100644 --- a/lib/router/models/library_item_extras.dart +++ b/lib/router/models/library_item_extras.dart @@ -11,7 +11,7 @@ part 'library_item_extras.freezed.dart'; /// [book] is the book that the item represents /// [heroTagSuffix] is the suffix to use for the hero tag to avoid conflicts @freezed -class LibraryItemExtras with _$LibraryItemExtras { +sealed class LibraryItemExtras with _$LibraryItemExtras { const factory LibraryItemExtras({ BookMinified? book, @Default('') String heroTagSuffix, diff --git a/lib/router/models/library_item_extras.freezed.dart b/lib/router/models/library_item_extras.freezed.dart index 900fdec..fe6ae17 100644 --- a/lib/router/models/library_item_extras.freezed.dart +++ b/lib/router/models/library_item_extras.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // 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 @@ -9,156 +9,260 @@ part of 'library_item_extras.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(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 _$LibraryItemExtras { - BookMinified? get book => throw _privateConstructorUsedError; - String get heroTagSuffix => throw _privateConstructorUsedError; - /// Create a copy of LibraryItemExtras - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $LibraryItemExtrasCopyWith get copyWith => - throw _privateConstructorUsedError; + BookMinified? get book; String get heroTagSuffix; +/// Create a copy of LibraryItemExtras +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LibraryItemExtrasCopyWith get copyWith => _$LibraryItemExtrasCopyWithImpl(this as LibraryItemExtras, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LibraryItemExtras&&(identical(other.book, book) || other.book == book)&&(identical(other.heroTagSuffix, heroTagSuffix) || other.heroTagSuffix == heroTagSuffix)); +} + + +@override +int get hashCode => Object.hash(runtimeType,book,heroTagSuffix); + +@override +String toString() { + return 'LibraryItemExtras(book: $book, heroTagSuffix: $heroTagSuffix)'; +} + + } /// @nodoc -abstract class $LibraryItemExtrasCopyWith<$Res> { - factory $LibraryItemExtrasCopyWith( - LibraryItemExtras value, $Res Function(LibraryItemExtras) then) = - _$LibraryItemExtrasCopyWithImpl<$Res, LibraryItemExtras>; - @useResult - $Res call({BookMinified? book, String heroTagSuffix}); -} +abstract mixin class $LibraryItemExtrasCopyWith<$Res> { + factory $LibraryItemExtrasCopyWith(LibraryItemExtras value, $Res Function(LibraryItemExtras) _then) = _$LibraryItemExtrasCopyWithImpl; +@useResult +$Res call({ + BookMinified? book, String heroTagSuffix +}); + + + +} /// @nodoc -class _$LibraryItemExtrasCopyWithImpl<$Res, $Val extends LibraryItemExtras> +class _$LibraryItemExtrasCopyWithImpl<$Res> implements $LibraryItemExtrasCopyWith<$Res> { - _$LibraryItemExtrasCopyWithImpl(this._value, this._then); + _$LibraryItemExtrasCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final LibraryItemExtras _self; + final $Res Function(LibraryItemExtras) _then; - /// Create a copy of LibraryItemExtras - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? book = freezed, - Object? heroTagSuffix = null, - }) { - return _then(_value.copyWith( - book: freezed == book - ? _value.book - : book // ignore: cast_nullable_to_non_nullable - as BookMinified?, - heroTagSuffix: null == heroTagSuffix - ? _value.heroTagSuffix - : heroTagSuffix // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } +/// Create a copy of LibraryItemExtras +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? book = freezed,Object? heroTagSuffix = null,}) { + return _then(_self.copyWith( +book: freezed == book ? _self.book : book // ignore: cast_nullable_to_non_nullable +as BookMinified?,heroTagSuffix: null == heroTagSuffix ? _self.heroTagSuffix : heroTagSuffix // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -abstract class _$$LibraryItemExtrasImplCopyWith<$Res> - implements $LibraryItemExtrasCopyWith<$Res> { - factory _$$LibraryItemExtrasImplCopyWith(_$LibraryItemExtrasImpl value, - $Res Function(_$LibraryItemExtrasImpl) then) = - __$$LibraryItemExtrasImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({BookMinified? book, String heroTagSuffix}); } -/// @nodoc -class __$$LibraryItemExtrasImplCopyWithImpl<$Res> - extends _$LibraryItemExtrasCopyWithImpl<$Res, _$LibraryItemExtrasImpl> - implements _$$LibraryItemExtrasImplCopyWith<$Res> { - __$$LibraryItemExtrasImplCopyWithImpl(_$LibraryItemExtrasImpl _value, - $Res Function(_$LibraryItemExtrasImpl) _then) - : super(_value, _then); - /// Create a copy of LibraryItemExtras - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? book = freezed, - Object? heroTagSuffix = null, - }) { - return _then(_$LibraryItemExtrasImpl( - book: freezed == book - ? _value.book - : book // ignore: cast_nullable_to_non_nullable - as BookMinified?, - heroTagSuffix: null == heroTagSuffix - ? _value.heroTagSuffix - : heroTagSuffix // ignore: cast_nullable_to_non_nullable - as String, - )); - } +/// Adds pattern-matching-related methods to [LibraryItemExtras]. +extension LibraryItemExtrasPatterns on LibraryItemExtras { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _LibraryItemExtras value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LibraryItemExtras() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _LibraryItemExtras value) $default,){ +final _that = this; +switch (_that) { +case _LibraryItemExtras(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LibraryItemExtras value)? $default,){ +final _that = this; +switch (_that) { +case _LibraryItemExtras() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( BookMinified? book, String heroTagSuffix)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LibraryItemExtras() when $default != null: +return $default(_that.book,_that.heroTagSuffix);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( BookMinified? book, String heroTagSuffix) $default,) {final _that = this; +switch (_that) { +case _LibraryItemExtras(): +return $default(_that.book,_that.heroTagSuffix);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( BookMinified? book, String heroTagSuffix)? $default,) {final _that = this; +switch (_that) { +case _LibraryItemExtras() when $default != null: +return $default(_that.book,_that.heroTagSuffix);case _: + return null; + +} +} + } /// @nodoc -class _$LibraryItemExtrasImpl implements _LibraryItemExtras { - const _$LibraryItemExtrasImpl({this.book, this.heroTagSuffix = ''}); - @override - final BookMinified? book; - @override - @JsonKey() - final String heroTagSuffix; +class _LibraryItemExtras implements LibraryItemExtras { + const _LibraryItemExtras({this.book, this.heroTagSuffix = ''}); + - @override - String toString() { - return 'LibraryItemExtras(book: $book, heroTagSuffix: $heroTagSuffix)'; - } +@override final BookMinified? book; +@override@JsonKey() final String heroTagSuffix; - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LibraryItemExtrasImpl && - (identical(other.book, book) || other.book == book) && - (identical(other.heroTagSuffix, heroTagSuffix) || - other.heroTagSuffix == heroTagSuffix)); - } +/// Create a copy of LibraryItemExtras +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LibraryItemExtrasCopyWith<_LibraryItemExtras> get copyWith => __$LibraryItemExtrasCopyWithImpl<_LibraryItemExtras>(this, _$identity); - @override - int get hashCode => Object.hash(runtimeType, book, heroTagSuffix); - /// Create a copy of LibraryItemExtras - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$LibraryItemExtrasImplCopyWith<_$LibraryItemExtrasImpl> get copyWith => - __$$LibraryItemExtrasImplCopyWithImpl<_$LibraryItemExtrasImpl>( - this, _$identity); + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LibraryItemExtras&&(identical(other.book, book) || other.book == book)&&(identical(other.heroTagSuffix, heroTagSuffix) || other.heroTagSuffix == heroTagSuffix)); } -abstract class _LibraryItemExtras implements LibraryItemExtras { - const factory _LibraryItemExtras( - {final BookMinified? book, - final String heroTagSuffix}) = _$LibraryItemExtrasImpl; - @override - BookMinified? get book; - @override - String get heroTagSuffix; +@override +int get hashCode => Object.hash(runtimeType,book,heroTagSuffix); - /// Create a copy of LibraryItemExtras - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$LibraryItemExtrasImplCopyWith<_$LibraryItemExtrasImpl> get copyWith => - throw _privateConstructorUsedError; +@override +String toString() { + return 'LibraryItemExtras(book: $book, heroTagSuffix: $heroTagSuffix)'; } + + +} + +/// @nodoc +abstract mixin class _$LibraryItemExtrasCopyWith<$Res> implements $LibraryItemExtrasCopyWith<$Res> { + factory _$LibraryItemExtrasCopyWith(_LibraryItemExtras value, $Res Function(_LibraryItemExtras) _then) = __$LibraryItemExtrasCopyWithImpl; +@override @useResult +$Res call({ + BookMinified? book, String heroTagSuffix +}); + + + + +} +/// @nodoc +class __$LibraryItemExtrasCopyWithImpl<$Res> + implements _$LibraryItemExtrasCopyWith<$Res> { + __$LibraryItemExtrasCopyWithImpl(this._self, this._then); + + final _LibraryItemExtras _self; + final $Res Function(_LibraryItemExtras) _then; + +/// Create a copy of LibraryItemExtras +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? book = freezed,Object? heroTagSuffix = null,}) { + return _then(_LibraryItemExtras( +book: freezed == book ? _self.book : book // ignore: cast_nullable_to_non_nullable +as BookMinified?,heroTagSuffix: null == heroTagSuffix ? _self.heroTagSuffix : heroTagSuffix // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +// dart format on diff --git a/lib/router/scaffold_with_nav_bar.dart b/lib/router/scaffold_with_nav_bar.dart index 27c3355..5f0b026 100644 --- a/lib/router/scaffold_with_nav_bar.dart +++ b/lib/router/scaffold_with_nav_bar.dart @@ -23,10 +23,8 @@ const bottomBarHeight = 64; /// BottomNavigationBar, where [child] is placed in the body of the Scaffold. class ScaffoldWithNavBar extends HookConsumerWidget { /// Constructs an [ScaffoldWithNavBar]. - const ScaffoldWithNavBar({ - required this.navigationShell, - Key? key, - }) : super(key: key ?? const ValueKey('ScaffoldWithNavBar')); + const ScaffoldWithNavBar({required this.navigationShell, Key? key}) + : super(key: key ?? const ValueKey('ScaffoldWithNavBar')); /// The navigation shell and container for the branch Navigators. final StatefulNavigationShell navigationShell; @@ -35,10 +33,11 @@ class ScaffoldWithNavBar extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { // playerExpandProgress is used to animate bottom navigation bar to opacity 0 and slide down when player is expanded // final playerProgress = - // useValueListenable(ref.watch(playerExpandProgressNotifierProvider)); + // useValueListenable(ref.watch(playerExpandProgressProvider)); final playerProgress = ref.watch(playerHeightProvider); final playerMaxHeight = MediaQuery.of(context).size.height; - var percentExpandedMiniPlayer = (playerProgress - playerMinHeight) / + var percentExpandedMiniPlayer = + (playerProgress - playerMinHeight) / (playerMaxHeight - playerMinHeight); // Clamp the value between 0 and 1 percentExpandedMiniPlayer = percentExpandedMiniPlayer.clamp(0.0, 1.0); @@ -52,9 +51,7 @@ class ScaffoldWithNavBar extends HookConsumerWidget { // close miniplayer if it is open if (isPlayerExpanded && pendingPlayerModals == 0) { - appLogger.fine( - 'BackButtonListener: closing the player', - ); + appLogger.fine('BackButtonListener: closing the player'); audioBookMiniplayerController.animateToHeight(state: PanelState.MIN); return true; } @@ -96,12 +93,7 @@ class ScaffoldWithNavBar extends HookConsumerWidget { return BackButtonListener( onBackButtonPressed: onBackButtonPressed, child: Scaffold( - body: Stack( - children: [ - navigationShell, - const AudiobookPlayer(), - ], - ), + body: Stack(children: [navigationShell, const AudiobookPlayer()]), bottomNavigationBar: Opacity( // Opacity is interpolated from 1 to 0 when player is expanded opacity: 1 - percentExpandedMiniPlayer, @@ -116,11 +108,8 @@ class ScaffoldWithNavBar extends HookConsumerWidget { // `navigationShell.route.branches`. destinations: _navigationItems.map((item) { final isDestinationLibrary = item.name == 'Library'; - var currentLibrary = - ref.watch(currentLibraryProvider).valueOrNull; - final libraryIcon = AbsIcons.getIconByName( - currentLibrary?.icon, - ); + var currentLibrary = ref.watch(currentLibraryProvider).value; + final libraryIcon = AbsIcons.getIconByName(currentLibrary?.icon); final destinationWidget = NavigationDestination( icon: Icon( isDestinationLibrary ? libraryIcon ?? item.icon : item.icon, diff --git a/lib/settings/api_settings_provider.dart b/lib/settings/api_settings_provider.dart index 91334f0..132ac7b 100644 --- a/lib/settings/api_settings_provider.dart +++ b/lib/settings/api_settings_provider.dart @@ -17,7 +17,7 @@ class ApiSettings extends _$ApiSettings { @override model.ApiSettings build() { state = readFromBoxOrCreate(); - ref.listenSelf((_, __) { + listenSelf((_, __) { writeToBox(); }); diff --git a/lib/settings/api_settings_provider.g.dart b/lib/settings/api_settings_provider.g.dart index eff1d41..752dfcc 100644 --- a/lib/settings/api_settings_provider.g.dart +++ b/lib/settings/api_settings_provider.g.dart @@ -6,20 +6,57 @@ part of 'api_settings_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$apiSettingsHash() => r'5bc1e16e9d72b77fb10637aabadf08e8947da580'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [ApiSettings]. @ProviderFor(ApiSettings) -final apiSettingsProvider = - NotifierProvider.internal( - ApiSettings.new, - name: r'apiSettingsProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$apiSettingsHash, - dependencies: null, - allTransitiveDependencies: null, -); +final apiSettingsProvider = ApiSettingsProvider._(); -typedef _$ApiSettings = Notifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +final class ApiSettingsProvider + extends $NotifierProvider { + ApiSettingsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'apiSettingsProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$apiSettingsHash(); + + @$internal + @override + ApiSettings create() => ApiSettings(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(model.ApiSettings value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$apiSettingsHash() => r'02af850985338eade33d76fc9965808bed548290'; + +abstract class _$ApiSettings extends $Notifier { + model.ApiSettings build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + model.ApiSettings, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/settings/app_settings_provider.dart b/lib/settings/app_settings_provider.dart index b86e736..fc10f9a 100644 --- a/lib/settings/app_settings_provider.dart +++ b/lib/settings/app_settings_provider.dart @@ -34,7 +34,7 @@ class AppSettings extends _$AppSettings { @override model.AppSettings build() { state = loadOrCreateAppSettings(); - ref.listenSelf((_, __) { + listenSelf((_, __) { writeToBox(); }); return state; diff --git a/lib/settings/app_settings_provider.g.dart b/lib/settings/app_settings_provider.g.dart index 8f3d8f5..8cb4a0f 100644 --- a/lib/settings/app_settings_provider.g.dart +++ b/lib/settings/app_settings_provider.g.dart @@ -6,37 +6,112 @@ part of 'app_settings_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$appSettingsHash() => r'314d7936f54550f57d308056a99230402342a6d0'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [AppSettings]. @ProviderFor(AppSettings) -final appSettingsProvider = - NotifierProvider.internal( - AppSettings.new, - name: r'appSettingsProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$appSettingsHash, - dependencies: null, - allTransitiveDependencies: null, -); +final appSettingsProvider = AppSettingsProvider._(); + +final class AppSettingsProvider + extends $NotifierProvider { + AppSettingsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'appSettingsProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$appSettingsHash(); + + @$internal + @override + AppSettings create() => AppSettings(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(model.AppSettings value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$appSettingsHash() => r'744d7e0157eb3b089c4187b35b845fc78547a44e'; + +abstract class _$AppSettings extends $Notifier { + model.AppSettings build(); + @$mustCallSuper + @override + void runBuild() { + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + model.AppSettings, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} + +@ProviderFor(SleepTimerSettings) +final sleepTimerSettingsProvider = SleepTimerSettingsProvider._(); + +final class SleepTimerSettingsProvider + extends $NotifierProvider { + SleepTimerSettingsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'sleepTimerSettingsProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$sleepTimerSettingsHash(); + + @$internal + @override + SleepTimerSettings create() => SleepTimerSettings(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(model.SleepTimerSettings value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} -typedef _$AppSettings = Notifier; String _$sleepTimerSettingsHash() => r'85bb3d3fb292b9a3a5b771d86e5fc57718519c69'; -/// See also [SleepTimerSettings]. -@ProviderFor(SleepTimerSettings) -final sleepTimerSettingsProvider = - NotifierProvider.internal( - SleepTimerSettings.new, - name: r'sleepTimerSettingsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$sleepTimerSettingsHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$SleepTimerSettings = Notifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$SleepTimerSettings + extends $Notifier { + model.SleepTimerSettings build(); + @$mustCallSuper + @override + void runBuild() { + final ref = + this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + model.SleepTimerSettings, + Object?, + Object? + >; + element.handleCreate(ref, build); + } +} diff --git a/lib/settings/metadata/metadata_provider.g.dart b/lib/settings/metadata/metadata_provider.g.dart index b83c0f0..50c6f1f 100644 --- a/lib/settings/metadata/metadata_provider.g.dart +++ b/lib/settings/metadata/metadata_provider.g.dart @@ -6,72 +6,138 @@ part of 'metadata_provider.dart'; // RiverpodGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(deviceName) +final deviceNameProvider = DeviceNameProvider._(); + +final class DeviceNameProvider + extends $FunctionalProvider, String, FutureOr> + with $FutureModifier, $FutureProvider { + DeviceNameProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'deviceNameProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$deviceNameHash(); + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return deviceName(ref); + } +} + String _$deviceNameHash() => r'9e38adda74e70a91851a682f05228bd759356dcc'; -/// See also [deviceName]. -@ProviderFor(deviceName) -final deviceNameProvider = FutureProvider.internal( - deviceName, - name: r'deviceNameProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$deviceNameHash, - dependencies: null, - allTransitiveDependencies: null, -); +@ProviderFor(deviceModel) +final deviceModelProvider = DeviceModelProvider._(); + +final class DeviceModelProvider + extends $FunctionalProvider, String, FutureOr> + with $FutureModifier, $FutureProvider { + DeviceModelProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'deviceModelProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$deviceModelHash(); + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return deviceModel(ref); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef DeviceNameRef = FutureProviderRef; String _$deviceModelHash() => r'922b13d9e35b5b5c5b8e96f2f2c2ae594f4f41f2'; -/// See also [deviceModel]. -@ProviderFor(deviceModel) -final deviceModelProvider = FutureProvider.internal( - deviceModel, - name: r'deviceModelProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') ? null : _$deviceModelHash, - dependencies: null, - allTransitiveDependencies: null, -); +@ProviderFor(deviceSdkVersion) +final deviceSdkVersionProvider = DeviceSdkVersionProvider._(); + +final class DeviceSdkVersionProvider + extends $FunctionalProvider, String, FutureOr> + with $FutureModifier, $FutureProvider { + DeviceSdkVersionProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'deviceSdkVersionProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$deviceSdkVersionHash(); + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return deviceSdkVersion(ref); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef DeviceModelRef = FutureProviderRef; String _$deviceSdkVersionHash() => r'33178d80590808d1f4cca2be8a3b52c6f6724cac'; -/// See also [deviceSdkVersion]. -@ProviderFor(deviceSdkVersion) -final deviceSdkVersionProvider = FutureProvider.internal( - deviceSdkVersion, - name: r'deviceSdkVersionProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$deviceSdkVersionHash, - dependencies: null, - allTransitiveDependencies: null, -); +@ProviderFor(deviceManufacturer) +final deviceManufacturerProvider = DeviceManufacturerProvider._(); + +final class DeviceManufacturerProvider + extends $FunctionalProvider, String, FutureOr> + with $FutureModifier, $FutureProvider { + DeviceManufacturerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'deviceManufacturerProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$deviceManufacturerHash(); + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return deviceManufacturer(ref); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef DeviceSdkVersionRef = FutureProviderRef; String _$deviceManufacturerHash() => r'39250767deb8635fa7c7e18bae23576b9b863e04'; - -/// See also [deviceManufacturer]. -@ProviderFor(deviceManufacturer) -final deviceManufacturerProvider = FutureProvider.internal( - deviceManufacturer, - name: r'deviceManufacturerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$deviceManufacturerHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef DeviceManufacturerRef = FutureProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/settings/models/api_settings.dart b/lib/settings/models/api_settings.dart index 6410938..dd7aada 100644 --- a/lib/settings/models/api_settings.dart +++ b/lib/settings/models/api_settings.dart @@ -11,7 +11,7 @@ part 'api_settings.g.dart'; /// /// all settings that are needed to interact with the server are stored here @freezed -class ApiSettings with _$ApiSettings { +sealed class ApiSettings with _$ApiSettings { const factory ApiSettings({ AudiobookShelfServer? activeServer, AuthenticatedUser? activeUser, diff --git a/lib/settings/models/api_settings.freezed.dart b/lib/settings/models/api_settings.freezed.dart index 2f3c6e5..6669a2b 100644 --- a/lib/settings/models/api_settings.freezed.dart +++ b/lib/settings/models/api_settings.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // 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 @@ -9,238 +9,317 @@ part of 'api_settings.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(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 json) { - return _ApiSettings.fromJson(json); -} - /// @nodoc mixin _$ApiSettings { - AudiobookShelfServer? get activeServer => throw _privateConstructorUsedError; - AuthenticatedUser? get activeUser => throw _privateConstructorUsedError; - String? get activeLibraryId => throw _privateConstructorUsedError; + + AudiobookShelfServer? get activeServer; AuthenticatedUser? get activeUser; String? get activeLibraryId; +/// Create a copy of ApiSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ApiSettingsCopyWith get copyWith => _$ApiSettingsCopyWithImpl(this as ApiSettings, _$identity); /// Serializes this ApiSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ApiSettings&&(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); + +@override +String toString() { + return 'ApiSettings(activeServer: $activeServer, activeUser: $activeUser, activeLibraryId: $activeLibraryId)'; +} + - /// Create a copy of ApiSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ApiSettingsCopyWith 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}); +abstract mixin class $ApiSettingsCopyWith<$Res> { + factory $ApiSettingsCopyWith(ApiSettings value, $Res Function(ApiSettings) _then) = _$ApiSettingsCopyWithImpl; +@useResult +$Res call({ + AudiobookShelfServer? activeServer, AuthenticatedUser? activeUser, String? activeLibraryId +}); + + +$AudiobookShelfServerCopyWith<$Res>? get activeServer;$AuthenticatedUserCopyWith<$Res>? get activeUser; - $AudiobookShelfServerCopyWith<$Res>? get activeServer; - $AuthenticatedUserCopyWith<$Res>? get activeUser; } - /// @nodoc -class _$ApiSettingsCopyWithImpl<$Res, $Val extends ApiSettings> +class _$ApiSettingsCopyWithImpl<$Res> implements $ApiSettingsCopyWith<$Res> { - _$ApiSettingsCopyWithImpl(this._value, this._then); + _$ApiSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final ApiSettings _self; + final $Res Function(ApiSettings) _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. +@pragma('vm:prefer-inline') @override $Res call({Object? activeServer = freezed,Object? activeUser = freezed,Object? activeLibraryId = freezed,}) { + return _then(_self.copyWith( +activeServer: freezed == activeServer ? _self.activeServer : activeServer // ignore: cast_nullable_to_non_nullable +as AudiobookShelfServer?,activeUser: freezed == activeUser ? _self.activeUser : activeUser // ignore: cast_nullable_to_non_nullable +as AuthenticatedUser?,activeLibraryId: freezed == activeLibraryId ? _self.activeLibraryId : activeLibraryId // ignore: cast_nullable_to_non_nullable +as String?, + )); +} +/// 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 (_self.activeServer == null) { + return null; } - /// 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); - }); + return $AudiobookShelfServerCopyWith<$Res>(_self.activeServer!, (value) { + return _then(_self.copyWith(activeServer: value)); + }); +}/// 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 (_self.activeUser == null) { + return null; } - /// 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); - }); - } + return $AuthenticatedUserCopyWith<$Res>(_self.activeUser!, (value) { + return _then(_self.copyWith(activeUser: value)); + }); +} } -/// @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; +/// Adds pattern-matching-related methods to [ApiSettings]. +extension ApiSettingsPatterns on ApiSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _ApiSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ApiSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _ApiSettings value) $default,){ +final _that = this; +switch (_that) { +case _ApiSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _ApiSettings value)? $default,){ +final _that = this; +switch (_that) { +case _ApiSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( AudiobookShelfServer? activeServer, AuthenticatedUser? activeUser, String? activeLibraryId)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ApiSettings() when $default != null: +return $default(_that.activeServer,_that.activeUser,_that.activeLibraryId);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( AudiobookShelfServer? activeServer, AuthenticatedUser? activeUser, String? activeLibraryId) $default,) {final _that = this; +switch (_that) { +case _ApiSettings(): +return $default(_that.activeServer,_that.activeUser,_that.activeLibraryId);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( AudiobookShelfServer? activeServer, AuthenticatedUser? activeUser, String? activeLibraryId)? $default,) {final _that = this; +switch (_that) { +case _ApiSettings() when $default != null: +return $default(_that.activeServer,_that.activeUser,_that.activeLibraryId);case _: + return null; + +} } -/// @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 json) => - _$$ApiSettingsImplFromJson(json); +class _ApiSettings implements ApiSettings { + const _ApiSettings({this.activeServer, this.activeUser, this.activeLibraryId}); + factory _ApiSettings.fromJson(Map json) => _$ApiSettingsFromJson(json); - @override - final AudiobookShelfServer? activeServer; - @override - final AuthenticatedUser? activeUser; - @override - final String? activeLibraryId; +@override final AudiobookShelfServer? activeServer; +@override final AuthenticatedUser? activeUser; +@override final String? activeLibraryId; - @override - String toString() { - return 'ApiSettings(activeServer: $activeServer, activeUser: $activeUser, activeLibraryId: $activeLibraryId)'; - } +/// Create a copy of ApiSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ApiSettingsCopyWith<_ApiSettings> get copyWith => __$ApiSettingsCopyWithImpl<_ApiSettings>(this, _$identity); - @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 toJson() { - return _$$ApiSettingsImplToJson( - this, - ); - } +@override +Map toJson() { + return _$ApiSettingsToJson(this, ); } -abstract class _ApiSettings implements ApiSettings { - const factory _ApiSettings( - {final AudiobookShelfServer? activeServer, - final AuthenticatedUser? activeUser, - final String? activeLibraryId}) = _$ApiSettingsImpl; - - factory _ApiSettings.fromJson(Map 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; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ApiSettings&&(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); + +@override +String toString() { + return 'ApiSettings(activeServer: $activeServer, activeUser: $activeUser, activeLibraryId: $activeLibraryId)'; +} + + +} + +/// @nodoc +abstract mixin class _$ApiSettingsCopyWith<$Res> implements $ApiSettingsCopyWith<$Res> { + factory _$ApiSettingsCopyWith(_ApiSettings value, $Res Function(_ApiSettings) _then) = __$ApiSettingsCopyWithImpl; +@override @useResult +$Res call({ + AudiobookShelfServer? activeServer, AuthenticatedUser? activeUser, String? activeLibraryId +}); + + +@override $AudiobookShelfServerCopyWith<$Res>? get activeServer;@override $AuthenticatedUserCopyWith<$Res>? get activeUser; + +} +/// @nodoc +class __$ApiSettingsCopyWithImpl<$Res> + implements _$ApiSettingsCopyWith<$Res> { + __$ApiSettingsCopyWithImpl(this._self, this._then); + + final _ApiSettings _self; + final $Res Function(_ApiSettings) _then; + +/// Create a copy of ApiSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? activeServer = freezed,Object? activeUser = freezed,Object? activeLibraryId = freezed,}) { + return _then(_ApiSettings( +activeServer: freezed == activeServer ? _self.activeServer : activeServer // ignore: cast_nullable_to_non_nullable +as AudiobookShelfServer?,activeUser: freezed == activeUser ? _self.activeUser : activeUser // ignore: cast_nullable_to_non_nullable +as AuthenticatedUser?,activeLibraryId: freezed == activeLibraryId ? _self.activeLibraryId : activeLibraryId // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +/// 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 (_self.activeServer == null) { + return null; + } + + return $AudiobookShelfServerCopyWith<$Res>(_self.activeServer!, (value) { + return _then(_self.copyWith(activeServer: value)); + }); +}/// 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 (_self.activeUser == null) { + return null; + } + + return $AuthenticatedUserCopyWith<$Res>(_self.activeUser!, (value) { + return _then(_self.copyWith(activeUser: value)); + }); +} +} + +// dart format on diff --git a/lib/settings/models/api_settings.g.dart b/lib/settings/models/api_settings.g.dart index 568754a..13b6359 100644 --- a/lib/settings/models/api_settings.g.dart +++ b/lib/settings/models/api_settings.g.dart @@ -6,20 +6,19 @@ part of 'api_settings.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ApiSettingsImpl _$$ApiSettingsImplFromJson(Map json) => - _$ApiSettingsImpl( - activeServer: json['activeServer'] == null - ? null - : AudiobookShelfServer.fromJson( - json['activeServer'] as Map), - activeUser: json['activeUser'] == null - ? null - : AuthenticatedUser.fromJson( - json['activeUser'] as Map), - activeLibraryId: json['activeLibraryId'] as String?, - ); +_ApiSettings _$ApiSettingsFromJson(Map json) => _ApiSettings( + activeServer: json['activeServer'] == null + ? null + : AudiobookShelfServer.fromJson( + json['activeServer'] as Map, + ), + activeUser: json['activeUser'] == null + ? null + : AuthenticatedUser.fromJson(json['activeUser'] as Map), + activeLibraryId: json['activeLibraryId'] as String?, +); -Map _$$ApiSettingsImplToJson(_$ApiSettingsImpl instance) => +Map _$ApiSettingsToJson(_ApiSettings instance) => { 'activeServer': instance.activeServer, 'activeUser': instance.activeUser, diff --git a/lib/settings/models/app_settings.dart b/lib/settings/models/app_settings.dart index fe1f7be..41fddd0 100644 --- a/lib/settings/models/app_settings.dart +++ b/lib/settings/models/app_settings.dart @@ -10,7 +10,7 @@ part 'app_settings.g.dart'; /// /// only the visual settings are stored here @freezed -class AppSettings with _$AppSettings { +sealed class AppSettings with _$AppSettings { const factory AppSettings({ @Default(ThemeSettings()) ThemeSettings themeSettings, @Default(PlayerSettings()) PlayerSettings playerSettings, @@ -27,7 +27,7 @@ class AppSettings with _$AppSettings { } @freezed -class ThemeSettings with _$ThemeSettings { +sealed class ThemeSettings with _$ThemeSettings { const factory ThemeSettings({ @Default(ThemeMode.system) ThemeMode themeMode, @Default(false) bool highContrast, @@ -42,7 +42,7 @@ class ThemeSettings with _$ThemeSettings { } @freezed -class PlayerSettings with _$PlayerSettings { +sealed class PlayerSettings with _$PlayerSettings { const factory PlayerSettings({ @Default(MinimizedPlayerSettings()) MinimizedPlayerSettings miniPlayerSettings, @@ -65,7 +65,7 @@ class PlayerSettings with _$PlayerSettings { } @freezed -class ExpandedPlayerSettings with _$ExpandedPlayerSettings { +sealed class ExpandedPlayerSettings with _$ExpandedPlayerSettings { const factory ExpandedPlayerSettings({ @Default(false) bool showTotalProgress, @Default(true) bool showChapterProgress, @@ -76,28 +76,25 @@ class ExpandedPlayerSettings with _$ExpandedPlayerSettings { } @freezed -class MinimizedPlayerSettings with _$MinimizedPlayerSettings { - const factory MinimizedPlayerSettings({ - @Default(false) bool useChapterInfo, - }) = _MinimizedPlayerSettings; +sealed class MinimizedPlayerSettings with _$MinimizedPlayerSettings { + const factory MinimizedPlayerSettings({@Default(false) bool useChapterInfo}) = + _MinimizedPlayerSettings; factory MinimizedPlayerSettings.fromJson(Map json) => _$MinimizedPlayerSettingsFromJson(json); } @freezed -class SleepTimerSettings with _$SleepTimerSettings { +sealed 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), - ], - ) + @Default([ + Duration(minutes: 5), + Duration(minutes: 10), + Duration(minutes: 15), + Duration(minutes: 20), + Duration(minutes: 30), + ]) List presetDurations, @Default(Duration(minutes: 100)) Duration maxDuration, @Default(false) bool fadeOutAudio, @@ -134,7 +131,7 @@ class SleepTimerSettings with _$SleepTimerSettings { } @freezed -class DownloadSettings with _$DownloadSettings { +sealed class DownloadSettings with _$DownloadSettings { const factory DownloadSettings({ @Default(true) bool requiresWiFi, @Default(3) int retries, @@ -149,21 +146,19 @@ class DownloadSettings with _$DownloadSettings { } @freezed -class NotificationSettings with _$NotificationSettings { +sealed 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, - ], - ) + @Default([ + NotificationMediaControl.rewind, + NotificationMediaControl.fastForward, + NotificationMediaControl.skipToPreviousChapter, + NotificationMediaControl.skipToNextChapter, + ]) List mediaControls, }) = _NotificationSettings; @@ -196,7 +191,7 @@ enum NotificationMediaControl { /// Shake Detection Settings @freezed -class ShakeDetectionSettings with _$ShakeDetectionSettings { +sealed class ShakeDetectionSettings with _$ShakeDetectionSettings { const factory ShakeDetectionSettings({ @Default(true) bool isEnabled, @Default(ShakeDirection.horizontal) ShakeDirection direction, @@ -222,18 +217,12 @@ class ShakeDetectionSettings with _$ShakeDetectionSettings { enum ShakeDirection { horizontal, vertical } -enum ShakeAction { - none, - playPause, - resetSleepTimer, - fastForward, - rewind, -} +enum ShakeAction { none, playPause, resetSleepTimer, fastForward, rewind } enum ShakeDetectedFeedback { vibrate, beep } @freezed -class HomePageSettings with _$HomePageSettings { +sealed class HomePageSettings with _$HomePageSettings { const factory HomePageSettings({ @Default(true) bool showPlayButtonOnContinueListeningShelf, @Default(false) bool showPlayButtonOnContinueSeriesShelf, diff --git a/lib/settings/models/app_settings.freezed.dart b/lib/settings/models/app_settings.freezed.dart index 17dea47..3d17503 100644 --- a/lib/settings/models/app_settings.freezed.dart +++ b/lib/settings/models/app_settings.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // 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 @@ -9,3102 +9,2951 @@ part of 'app_settings.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(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'); - -AppSettings _$AppSettingsFromJson(Map json) { - return _AppSettings.fromJson(json); -} - /// @nodoc mixin _$AppSettings { - ThemeSettings get themeSettings => throw _privateConstructorUsedError; - PlayerSettings get playerSettings => throw _privateConstructorUsedError; - SleepTimerSettings get sleepTimerSettings => - throw _privateConstructorUsedError; - DownloadSettings get downloadSettings => throw _privateConstructorUsedError; - NotificationSettings get notificationSettings => - throw _privateConstructorUsedError; - ShakeDetectionSettings get shakeDetectionSettings => - throw _privateConstructorUsedError; - HomePageSettings get homePageSettings => throw _privateConstructorUsedError; + + ThemeSettings get themeSettings; PlayerSettings get playerSettings; SleepTimerSettings get sleepTimerSettings; DownloadSettings get downloadSettings; NotificationSettings get notificationSettings; ShakeDetectionSettings get shakeDetectionSettings; HomePageSettings get homePageSettings; +/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$AppSettingsCopyWith get copyWith => _$AppSettingsCopyWithImpl(this as AppSettings, _$identity); /// Serializes this AppSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is AppSettings&&(identical(other.themeSettings, themeSettings) || other.themeSettings == themeSettings)&&(identical(other.playerSettings, playerSettings) || other.playerSettings == playerSettings)&&(identical(other.sleepTimerSettings, sleepTimerSettings) || other.sleepTimerSettings == sleepTimerSettings)&&(identical(other.downloadSettings, downloadSettings) || other.downloadSettings == downloadSettings)&&(identical(other.notificationSettings, notificationSettings) || other.notificationSettings == notificationSettings)&&(identical(other.shakeDetectionSettings, shakeDetectionSettings) || other.shakeDetectionSettings == shakeDetectionSettings)&&(identical(other.homePageSettings, homePageSettings) || other.homePageSettings == homePageSettings)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,themeSettings,playerSettings,sleepTimerSettings,downloadSettings,notificationSettings,shakeDetectionSettings,homePageSettings); + +@override +String toString() { + return 'AppSettings(themeSettings: $themeSettings, playerSettings: $playerSettings, sleepTimerSettings: $sleepTimerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings, homePageSettings: $homePageSettings)'; +} + - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $AppSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $AppSettingsCopyWith<$Res> { - factory $AppSettingsCopyWith( - AppSettings value, $Res Function(AppSettings) then) = - _$AppSettingsCopyWithImpl<$Res, AppSettings>; - @useResult - $Res call( - {ThemeSettings themeSettings, - PlayerSettings playerSettings, - SleepTimerSettings sleepTimerSettings, - DownloadSettings downloadSettings, - NotificationSettings notificationSettings, - ShakeDetectionSettings shakeDetectionSettings, - HomePageSettings homePageSettings}); +abstract mixin class $AppSettingsCopyWith<$Res> { + factory $AppSettingsCopyWith(AppSettings value, $Res Function(AppSettings) _then) = _$AppSettingsCopyWithImpl; +@useResult +$Res call({ + ThemeSettings themeSettings, PlayerSettings playerSettings, SleepTimerSettings sleepTimerSettings, DownloadSettings downloadSettings, NotificationSettings notificationSettings, ShakeDetectionSettings shakeDetectionSettings, HomePageSettings homePageSettings +}); + + +$ThemeSettingsCopyWith<$Res> get themeSettings;$PlayerSettingsCopyWith<$Res> get playerSettings;$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings;$DownloadSettingsCopyWith<$Res> get downloadSettings;$NotificationSettingsCopyWith<$Res> get notificationSettings;$ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings;$HomePageSettingsCopyWith<$Res> get homePageSettings; - $ThemeSettingsCopyWith<$Res> get themeSettings; - $PlayerSettingsCopyWith<$Res> get playerSettings; - $SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings; - $DownloadSettingsCopyWith<$Res> get downloadSettings; - $NotificationSettingsCopyWith<$Res> get notificationSettings; - $ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings; - $HomePageSettingsCopyWith<$Res> get homePageSettings; } - /// @nodoc -class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings> +class _$AppSettingsCopyWithImpl<$Res> implements $AppSettingsCopyWith<$Res> { - _$AppSettingsCopyWithImpl(this._value, this._then); + _$AppSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final AppSettings _self; + final $Res Function(AppSettings) _then; - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? themeSettings = null, - Object? playerSettings = null, - Object? sleepTimerSettings = null, - Object? downloadSettings = null, - Object? notificationSettings = null, - Object? shakeDetectionSettings = null, - Object? homePageSettings = null, - }) { - return _then(_value.copyWith( - themeSettings: null == themeSettings - ? _value.themeSettings - : themeSettings // ignore: cast_nullable_to_non_nullable - as ThemeSettings, - playerSettings: null == playerSettings - ? _value.playerSettings - : playerSettings // ignore: cast_nullable_to_non_nullable - as PlayerSettings, - sleepTimerSettings: null == sleepTimerSettings - ? _value.sleepTimerSettings - : sleepTimerSettings // ignore: cast_nullable_to_non_nullable - as SleepTimerSettings, - downloadSettings: null == downloadSettings - ? _value.downloadSettings - : downloadSettings // ignore: cast_nullable_to_non_nullable - as DownloadSettings, - notificationSettings: null == notificationSettings - ? _value.notificationSettings - : notificationSettings // ignore: cast_nullable_to_non_nullable - as NotificationSettings, - shakeDetectionSettings: null == shakeDetectionSettings - ? _value.shakeDetectionSettings - : shakeDetectionSettings // ignore: cast_nullable_to_non_nullable - as ShakeDetectionSettings, - homePageSettings: null == homePageSettings - ? _value.homePageSettings - : homePageSettings // ignore: cast_nullable_to_non_nullable - as HomePageSettings, - ) as $Val); - } - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ThemeSettingsCopyWith<$Res> get themeSettings { - return $ThemeSettingsCopyWith<$Res>(_value.themeSettings, (value) { - return _then(_value.copyWith(themeSettings: value) as $Val); - }); - } - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $PlayerSettingsCopyWith<$Res> get playerSettings { - return $PlayerSettingsCopyWith<$Res>(_value.playerSettings, (value) { - return _then(_value.copyWith(playerSettings: value) as $Val); - }); - } - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings { - return $SleepTimerSettingsCopyWith<$Res>(_value.sleepTimerSettings, - (value) { - return _then(_value.copyWith(sleepTimerSettings: value) as $Val); - }); - } - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $DownloadSettingsCopyWith<$Res> get downloadSettings { - return $DownloadSettingsCopyWith<$Res>(_value.downloadSettings, (value) { - return _then(_value.copyWith(downloadSettings: value) as $Val); - }); - } - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $NotificationSettingsCopyWith<$Res> get notificationSettings { - return $NotificationSettingsCopyWith<$Res>(_value.notificationSettings, - (value) { - return _then(_value.copyWith(notificationSettings: value) as $Val); - }); - } - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings { - return $ShakeDetectionSettingsCopyWith<$Res>(_value.shakeDetectionSettings, - (value) { - return _then(_value.copyWith(shakeDetectionSettings: value) as $Val); - }); - } - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $HomePageSettingsCopyWith<$Res> get homePageSettings { - return $HomePageSettingsCopyWith<$Res>(_value.homePageSettings, (value) { - return _then(_value.copyWith(homePageSettings: value) as $Val); - }); - } +/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? themeSettings = null,Object? playerSettings = null,Object? sleepTimerSettings = null,Object? downloadSettings = null,Object? notificationSettings = null,Object? shakeDetectionSettings = null,Object? homePageSettings = null,}) { + return _then(_self.copyWith( +themeSettings: null == themeSettings ? _self.themeSettings : themeSettings // ignore: cast_nullable_to_non_nullable +as ThemeSettings,playerSettings: null == playerSettings ? _self.playerSettings : playerSettings // ignore: cast_nullable_to_non_nullable +as PlayerSettings,sleepTimerSettings: null == sleepTimerSettings ? _self.sleepTimerSettings : sleepTimerSettings // ignore: cast_nullable_to_non_nullable +as SleepTimerSettings,downloadSettings: null == downloadSettings ? _self.downloadSettings : downloadSettings // ignore: cast_nullable_to_non_nullable +as DownloadSettings,notificationSettings: null == notificationSettings ? _self.notificationSettings : notificationSettings // ignore: cast_nullable_to_non_nullable +as NotificationSettings,shakeDetectionSettings: null == shakeDetectionSettings ? _self.shakeDetectionSettings : shakeDetectionSettings // ignore: cast_nullable_to_non_nullable +as ShakeDetectionSettings,homePageSettings: null == homePageSettings ? _self.homePageSettings : homePageSettings // ignore: cast_nullable_to_non_nullable +as HomePageSettings, + )); +} +/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ThemeSettingsCopyWith<$Res> get themeSettings { + + return $ThemeSettingsCopyWith<$Res>(_self.themeSettings, (value) { + return _then(_self.copyWith(themeSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PlayerSettingsCopyWith<$Res> get playerSettings { + + return $PlayerSettingsCopyWith<$Res>(_self.playerSettings, (value) { + return _then(_self.copyWith(playerSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings { + + return $SleepTimerSettingsCopyWith<$Res>(_self.sleepTimerSettings, (value) { + return _then(_self.copyWith(sleepTimerSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$DownloadSettingsCopyWith<$Res> get downloadSettings { + + return $DownloadSettingsCopyWith<$Res>(_self.downloadSettings, (value) { + return _then(_self.copyWith(downloadSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$NotificationSettingsCopyWith<$Res> get notificationSettings { + + return $NotificationSettingsCopyWith<$Res>(_self.notificationSettings, (value) { + return _then(_self.copyWith(notificationSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings { + + return $ShakeDetectionSettingsCopyWith<$Res>(_self.shakeDetectionSettings, (value) { + return _then(_self.copyWith(shakeDetectionSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$HomePageSettingsCopyWith<$Res> get homePageSettings { + + return $HomePageSettingsCopyWith<$Res>(_self.homePageSettings, (value) { + return _then(_self.copyWith(homePageSettings: value)); + }); +} } -/// @nodoc -abstract class _$$AppSettingsImplCopyWith<$Res> - implements $AppSettingsCopyWith<$Res> { - factory _$$AppSettingsImplCopyWith( - _$AppSettingsImpl value, $Res Function(_$AppSettingsImpl) then) = - __$$AppSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {ThemeSettings themeSettings, - PlayerSettings playerSettings, - SleepTimerSettings sleepTimerSettings, - DownloadSettings downloadSettings, - NotificationSettings notificationSettings, - ShakeDetectionSettings shakeDetectionSettings, - HomePageSettings homePageSettings}); - @override - $ThemeSettingsCopyWith<$Res> get themeSettings; - @override - $PlayerSettingsCopyWith<$Res> get playerSettings; - @override - $SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings; - @override - $DownloadSettingsCopyWith<$Res> get downloadSettings; - @override - $NotificationSettingsCopyWith<$Res> get notificationSettings; - @override - $ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings; - @override - $HomePageSettingsCopyWith<$Res> get homePageSettings; +/// Adds pattern-matching-related methods to [AppSettings]. +extension AppSettingsPatterns on AppSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _AppSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _AppSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _AppSettings value) $default,){ +final _that = this; +switch (_that) { +case _AppSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _AppSettings value)? $default,){ +final _that = this; +switch (_that) { +case _AppSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( ThemeSettings themeSettings, PlayerSettings playerSettings, SleepTimerSettings sleepTimerSettings, DownloadSettings downloadSettings, NotificationSettings notificationSettings, ShakeDetectionSettings shakeDetectionSettings, HomePageSettings homePageSettings)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _AppSettings() when $default != null: +return $default(_that.themeSettings,_that.playerSettings,_that.sleepTimerSettings,_that.downloadSettings,_that.notificationSettings,_that.shakeDetectionSettings,_that.homePageSettings);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( ThemeSettings themeSettings, PlayerSettings playerSettings, SleepTimerSettings sleepTimerSettings, DownloadSettings downloadSettings, NotificationSettings notificationSettings, ShakeDetectionSettings shakeDetectionSettings, HomePageSettings homePageSettings) $default,) {final _that = this; +switch (_that) { +case _AppSettings(): +return $default(_that.themeSettings,_that.playerSettings,_that.sleepTimerSettings,_that.downloadSettings,_that.notificationSettings,_that.shakeDetectionSettings,_that.homePageSettings);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( ThemeSettings themeSettings, PlayerSettings playerSettings, SleepTimerSettings sleepTimerSettings, DownloadSettings downloadSettings, NotificationSettings notificationSettings, ShakeDetectionSettings shakeDetectionSettings, HomePageSettings homePageSettings)? $default,) {final _that = this; +switch (_that) { +case _AppSettings() when $default != null: +return $default(_that.themeSettings,_that.playerSettings,_that.sleepTimerSettings,_that.downloadSettings,_that.notificationSettings,_that.shakeDetectionSettings,_that.homePageSettings);case _: + return null; + +} } -/// @nodoc -class __$$AppSettingsImplCopyWithImpl<$Res> - extends _$AppSettingsCopyWithImpl<$Res, _$AppSettingsImpl> - implements _$$AppSettingsImplCopyWith<$Res> { - __$$AppSettingsImplCopyWithImpl( - _$AppSettingsImpl _value, $Res Function(_$AppSettingsImpl) _then) - : super(_value, _then); - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? themeSettings = null, - Object? playerSettings = null, - Object? sleepTimerSettings = null, - Object? downloadSettings = null, - Object? notificationSettings = null, - Object? shakeDetectionSettings = null, - Object? homePageSettings = null, - }) { - return _then(_$AppSettingsImpl( - themeSettings: null == themeSettings - ? _value.themeSettings - : themeSettings // ignore: cast_nullable_to_non_nullable - as ThemeSettings, - playerSettings: null == playerSettings - ? _value.playerSettings - : playerSettings // ignore: cast_nullable_to_non_nullable - as PlayerSettings, - sleepTimerSettings: null == sleepTimerSettings - ? _value.sleepTimerSettings - : sleepTimerSettings // ignore: cast_nullable_to_non_nullable - as SleepTimerSettings, - downloadSettings: null == downloadSettings - ? _value.downloadSettings - : downloadSettings // ignore: cast_nullable_to_non_nullable - as DownloadSettings, - notificationSettings: null == notificationSettings - ? _value.notificationSettings - : notificationSettings // ignore: cast_nullable_to_non_nullable - as NotificationSettings, - shakeDetectionSettings: null == shakeDetectionSettings - ? _value.shakeDetectionSettings - : shakeDetectionSettings // ignore: cast_nullable_to_non_nullable - as ShakeDetectionSettings, - homePageSettings: null == homePageSettings - ? _value.homePageSettings - : homePageSettings // ignore: cast_nullable_to_non_nullable - as HomePageSettings, - )); - } } /// @nodoc @JsonSerializable() -class _$AppSettingsImpl implements _AppSettings { - const _$AppSettingsImpl( - {this.themeSettings = const ThemeSettings(), - this.playerSettings = const PlayerSettings(), - this.sleepTimerSettings = const SleepTimerSettings(), - this.downloadSettings = const DownloadSettings(), - this.notificationSettings = const NotificationSettings(), - this.shakeDetectionSettings = const ShakeDetectionSettings(), - this.homePageSettings = const HomePageSettings()}); - factory _$AppSettingsImpl.fromJson(Map json) => - _$$AppSettingsImplFromJson(json); +class _AppSettings implements AppSettings { + const _AppSettings({this.themeSettings = const ThemeSettings(), this.playerSettings = const PlayerSettings(), this.sleepTimerSettings = const SleepTimerSettings(), this.downloadSettings = const DownloadSettings(), this.notificationSettings = const NotificationSettings(), this.shakeDetectionSettings = const ShakeDetectionSettings(), this.homePageSettings = const HomePageSettings()}); + factory _AppSettings.fromJson(Map json) => _$AppSettingsFromJson(json); - @override - @JsonKey() - final ThemeSettings themeSettings; - @override - @JsonKey() - final PlayerSettings playerSettings; - @override - @JsonKey() - final SleepTimerSettings sleepTimerSettings; - @override - @JsonKey() - final DownloadSettings downloadSettings; - @override - @JsonKey() - final NotificationSettings notificationSettings; - @override - @JsonKey() - final ShakeDetectionSettings shakeDetectionSettings; - @override - @JsonKey() - final HomePageSettings homePageSettings; +@override@JsonKey() final ThemeSettings themeSettings; +@override@JsonKey() final PlayerSettings playerSettings; +@override@JsonKey() final SleepTimerSettings sleepTimerSettings; +@override@JsonKey() final DownloadSettings downloadSettings; +@override@JsonKey() final NotificationSettings notificationSettings; +@override@JsonKey() final ShakeDetectionSettings shakeDetectionSettings; +@override@JsonKey() final HomePageSettings homePageSettings; - @override - String toString() { - return 'AppSettings(themeSettings: $themeSettings, playerSettings: $playerSettings, sleepTimerSettings: $sleepTimerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings, homePageSettings: $homePageSettings)'; - } +/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AppSettingsCopyWith<_AppSettings> get copyWith => __$AppSettingsCopyWithImpl<_AppSettings>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$AppSettingsImpl && - (identical(other.themeSettings, themeSettings) || - other.themeSettings == themeSettings) && - (identical(other.playerSettings, playerSettings) || - other.playerSettings == playerSettings) && - (identical(other.sleepTimerSettings, sleepTimerSettings) || - other.sleepTimerSettings == sleepTimerSettings) && - (identical(other.downloadSettings, downloadSettings) || - other.downloadSettings == downloadSettings) && - (identical(other.notificationSettings, notificationSettings) || - other.notificationSettings == notificationSettings) && - (identical(other.shakeDetectionSettings, shakeDetectionSettings) || - other.shakeDetectionSettings == shakeDetectionSettings) && - (identical(other.homePageSettings, homePageSettings) || - other.homePageSettings == homePageSettings)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - themeSettings, - playerSettings, - sleepTimerSettings, - downloadSettings, - notificationSettings, - shakeDetectionSettings, - homePageSettings); - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$AppSettingsImplCopyWith<_$AppSettingsImpl> get copyWith => - __$$AppSettingsImplCopyWithImpl<_$AppSettingsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$AppSettingsImplToJson( - this, - ); - } +@override +Map toJson() { + return _$AppSettingsToJson(this, ); } -abstract class _AppSettings implements AppSettings { - const factory _AppSettings( - {final ThemeSettings themeSettings, - final PlayerSettings playerSettings, - final SleepTimerSettings sleepTimerSettings, - final DownloadSettings downloadSettings, - final NotificationSettings notificationSettings, - final ShakeDetectionSettings shakeDetectionSettings, - final HomePageSettings homePageSettings}) = _$AppSettingsImpl; - - factory _AppSettings.fromJson(Map json) = - _$AppSettingsImpl.fromJson; - - @override - ThemeSettings get themeSettings; - @override - PlayerSettings get playerSettings; - @override - SleepTimerSettings get sleepTimerSettings; - @override - DownloadSettings get downloadSettings; - @override - NotificationSettings get notificationSettings; - @override - ShakeDetectionSettings get shakeDetectionSettings; - @override - HomePageSettings get homePageSettings; - - /// Create a copy of AppSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$AppSettingsImplCopyWith<_$AppSettingsImpl> get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AppSettings&&(identical(other.themeSettings, themeSettings) || other.themeSettings == themeSettings)&&(identical(other.playerSettings, playerSettings) || other.playerSettings == playerSettings)&&(identical(other.sleepTimerSettings, sleepTimerSettings) || other.sleepTimerSettings == sleepTimerSettings)&&(identical(other.downloadSettings, downloadSettings) || other.downloadSettings == downloadSettings)&&(identical(other.notificationSettings, notificationSettings) || other.notificationSettings == notificationSettings)&&(identical(other.shakeDetectionSettings, shakeDetectionSettings) || other.shakeDetectionSettings == shakeDetectionSettings)&&(identical(other.homePageSettings, homePageSettings) || other.homePageSettings == homePageSettings)); } -ThemeSettings _$ThemeSettingsFromJson(Map json) { - return _ThemeSettings.fromJson(json); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,themeSettings,playerSettings,sleepTimerSettings,downloadSettings,notificationSettings,shakeDetectionSettings,homePageSettings); + +@override +String toString() { + return 'AppSettings(themeSettings: $themeSettings, playerSettings: $playerSettings, sleepTimerSettings: $sleepTimerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings, homePageSettings: $homePageSettings)'; } + +} + +/// @nodoc +abstract mixin class _$AppSettingsCopyWith<$Res> implements $AppSettingsCopyWith<$Res> { + factory _$AppSettingsCopyWith(_AppSettings value, $Res Function(_AppSettings) _then) = __$AppSettingsCopyWithImpl; +@override @useResult +$Res call({ + ThemeSettings themeSettings, PlayerSettings playerSettings, SleepTimerSettings sleepTimerSettings, DownloadSettings downloadSettings, NotificationSettings notificationSettings, ShakeDetectionSettings shakeDetectionSettings, HomePageSettings homePageSettings +}); + + +@override $ThemeSettingsCopyWith<$Res> get themeSettings;@override $PlayerSettingsCopyWith<$Res> get playerSettings;@override $SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings;@override $DownloadSettingsCopyWith<$Res> get downloadSettings;@override $NotificationSettingsCopyWith<$Res> get notificationSettings;@override $ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings;@override $HomePageSettingsCopyWith<$Res> get homePageSettings; + +} +/// @nodoc +class __$AppSettingsCopyWithImpl<$Res> + implements _$AppSettingsCopyWith<$Res> { + __$AppSettingsCopyWithImpl(this._self, this._then); + + final _AppSettings _self; + final $Res Function(_AppSettings) _then; + +/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? themeSettings = null,Object? playerSettings = null,Object? sleepTimerSettings = null,Object? downloadSettings = null,Object? notificationSettings = null,Object? shakeDetectionSettings = null,Object? homePageSettings = null,}) { + return _then(_AppSettings( +themeSettings: null == themeSettings ? _self.themeSettings : themeSettings // ignore: cast_nullable_to_non_nullable +as ThemeSettings,playerSettings: null == playerSettings ? _self.playerSettings : playerSettings // ignore: cast_nullable_to_non_nullable +as PlayerSettings,sleepTimerSettings: null == sleepTimerSettings ? _self.sleepTimerSettings : sleepTimerSettings // ignore: cast_nullable_to_non_nullable +as SleepTimerSettings,downloadSettings: null == downloadSettings ? _self.downloadSettings : downloadSettings // ignore: cast_nullable_to_non_nullable +as DownloadSettings,notificationSettings: null == notificationSettings ? _self.notificationSettings : notificationSettings // ignore: cast_nullable_to_non_nullable +as NotificationSettings,shakeDetectionSettings: null == shakeDetectionSettings ? _self.shakeDetectionSettings : shakeDetectionSettings // ignore: cast_nullable_to_non_nullable +as ShakeDetectionSettings,homePageSettings: null == homePageSettings ? _self.homePageSettings : homePageSettings // ignore: cast_nullable_to_non_nullable +as HomePageSettings, + )); +} + +/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ThemeSettingsCopyWith<$Res> get themeSettings { + + return $ThemeSettingsCopyWith<$Res>(_self.themeSettings, (value) { + return _then(_self.copyWith(themeSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PlayerSettingsCopyWith<$Res> get playerSettings { + + return $PlayerSettingsCopyWith<$Res>(_self.playerSettings, (value) { + return _then(_self.copyWith(playerSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings { + + return $SleepTimerSettingsCopyWith<$Res>(_self.sleepTimerSettings, (value) { + return _then(_self.copyWith(sleepTimerSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$DownloadSettingsCopyWith<$Res> get downloadSettings { + + return $DownloadSettingsCopyWith<$Res>(_self.downloadSettings, (value) { + return _then(_self.copyWith(downloadSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$NotificationSettingsCopyWith<$Res> get notificationSettings { + + return $NotificationSettingsCopyWith<$Res>(_self.notificationSettings, (value) { + return _then(_self.copyWith(notificationSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings { + + return $ShakeDetectionSettingsCopyWith<$Res>(_self.shakeDetectionSettings, (value) { + return _then(_self.copyWith(shakeDetectionSettings: value)); + }); +}/// Create a copy of AppSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$HomePageSettingsCopyWith<$Res> get homePageSettings { + + return $HomePageSettingsCopyWith<$Res>(_self.homePageSettings, (value) { + return _then(_self.copyWith(homePageSettings: value)); + }); +} +} + + /// @nodoc mixin _$ThemeSettings { - ThemeMode get themeMode => throw _privateConstructorUsedError; - bool get highContrast => throw _privateConstructorUsedError; - bool get useMaterialThemeFromSystem => throw _privateConstructorUsedError; - String get customThemeColor => throw _privateConstructorUsedError; - bool get useMaterialThemeOnItemPage => throw _privateConstructorUsedError; - bool get useCurrentPlayerThemeThroughoutApp => - throw _privateConstructorUsedError; + + ThemeMode get themeMode; bool get highContrast; bool get useMaterialThemeFromSystem; String get customThemeColor; bool get useMaterialThemeOnItemPage; bool get useCurrentPlayerThemeThroughoutApp; +/// Create a copy of ThemeSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ThemeSettingsCopyWith get copyWith => _$ThemeSettingsCopyWithImpl(this as ThemeSettings, _$identity); /// Serializes this ThemeSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ThemeSettings&&(identical(other.themeMode, themeMode) || other.themeMode == themeMode)&&(identical(other.highContrast, highContrast) || other.highContrast == highContrast)&&(identical(other.useMaterialThemeFromSystem, useMaterialThemeFromSystem) || other.useMaterialThemeFromSystem == useMaterialThemeFromSystem)&&(identical(other.customThemeColor, customThemeColor) || other.customThemeColor == customThemeColor)&&(identical(other.useMaterialThemeOnItemPage, useMaterialThemeOnItemPage) || other.useMaterialThemeOnItemPage == useMaterialThemeOnItemPage)&&(identical(other.useCurrentPlayerThemeThroughoutApp, useCurrentPlayerThemeThroughoutApp) || other.useCurrentPlayerThemeThroughoutApp == useCurrentPlayerThemeThroughoutApp)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,themeMode,highContrast,useMaterialThemeFromSystem,customThemeColor,useMaterialThemeOnItemPage,useCurrentPlayerThemeThroughoutApp); + +@override +String toString() { + return 'ThemeSettings(themeMode: $themeMode, highContrast: $highContrast, useMaterialThemeFromSystem: $useMaterialThemeFromSystem, customThemeColor: $customThemeColor, useMaterialThemeOnItemPage: $useMaterialThemeOnItemPage, useCurrentPlayerThemeThroughoutApp: $useCurrentPlayerThemeThroughoutApp)'; +} + - /// Create a copy of ThemeSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ThemeSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $ThemeSettingsCopyWith<$Res> { - factory $ThemeSettingsCopyWith( - ThemeSettings value, $Res Function(ThemeSettings) then) = - _$ThemeSettingsCopyWithImpl<$Res, ThemeSettings>; - @useResult - $Res call( - {ThemeMode themeMode, - bool highContrast, - bool useMaterialThemeFromSystem, - String customThemeColor, - bool useMaterialThemeOnItemPage, - bool useCurrentPlayerThemeThroughoutApp}); -} +abstract mixin class $ThemeSettingsCopyWith<$Res> { + factory $ThemeSettingsCopyWith(ThemeSettings value, $Res Function(ThemeSettings) _then) = _$ThemeSettingsCopyWithImpl; +@useResult +$Res call({ + ThemeMode themeMode, bool highContrast, bool useMaterialThemeFromSystem, String customThemeColor, bool useMaterialThemeOnItemPage, bool useCurrentPlayerThemeThroughoutApp +}); + + + +} /// @nodoc -class _$ThemeSettingsCopyWithImpl<$Res, $Val extends ThemeSettings> +class _$ThemeSettingsCopyWithImpl<$Res> implements $ThemeSettingsCopyWith<$Res> { - _$ThemeSettingsCopyWithImpl(this._value, this._then); + _$ThemeSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final ThemeSettings _self; + final $Res Function(ThemeSettings) _then; - /// Create a copy of ThemeSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? themeMode = null, - Object? highContrast = null, - Object? useMaterialThemeFromSystem = null, - Object? customThemeColor = null, - Object? useMaterialThemeOnItemPage = null, - Object? useCurrentPlayerThemeThroughoutApp = null, - }) { - return _then(_value.copyWith( - themeMode: null == themeMode - ? _value.themeMode - : themeMode // ignore: cast_nullable_to_non_nullable - as ThemeMode, - highContrast: null == highContrast - ? _value.highContrast - : highContrast // ignore: cast_nullable_to_non_nullable - as bool, - useMaterialThemeFromSystem: null == useMaterialThemeFromSystem - ? _value.useMaterialThemeFromSystem - : useMaterialThemeFromSystem // ignore: cast_nullable_to_non_nullable - as bool, - customThemeColor: null == customThemeColor - ? _value.customThemeColor - : customThemeColor // ignore: cast_nullable_to_non_nullable - as String, - useMaterialThemeOnItemPage: null == useMaterialThemeOnItemPage - ? _value.useMaterialThemeOnItemPage - : useMaterialThemeOnItemPage // ignore: cast_nullable_to_non_nullable - as bool, - useCurrentPlayerThemeThroughoutApp: null == - useCurrentPlayerThemeThroughoutApp - ? _value.useCurrentPlayerThemeThroughoutApp - : useCurrentPlayerThemeThroughoutApp // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } +/// Create a copy of ThemeSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? themeMode = null,Object? highContrast = null,Object? useMaterialThemeFromSystem = null,Object? customThemeColor = null,Object? useMaterialThemeOnItemPage = null,Object? useCurrentPlayerThemeThroughoutApp = null,}) { + return _then(_self.copyWith( +themeMode: null == themeMode ? _self.themeMode : themeMode // ignore: cast_nullable_to_non_nullable +as ThemeMode,highContrast: null == highContrast ? _self.highContrast : highContrast // ignore: cast_nullable_to_non_nullable +as bool,useMaterialThemeFromSystem: null == useMaterialThemeFromSystem ? _self.useMaterialThemeFromSystem : useMaterialThemeFromSystem // ignore: cast_nullable_to_non_nullable +as bool,customThemeColor: null == customThemeColor ? _self.customThemeColor : customThemeColor // ignore: cast_nullable_to_non_nullable +as String,useMaterialThemeOnItemPage: null == useMaterialThemeOnItemPage ? _self.useMaterialThemeOnItemPage : useMaterialThemeOnItemPage // ignore: cast_nullable_to_non_nullable +as bool,useCurrentPlayerThemeThroughoutApp: null == useCurrentPlayerThemeThroughoutApp ? _self.useCurrentPlayerThemeThroughoutApp : useCurrentPlayerThemeThroughoutApp // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$ThemeSettingsImplCopyWith<$Res> - implements $ThemeSettingsCopyWith<$Res> { - factory _$$ThemeSettingsImplCopyWith( - _$ThemeSettingsImpl value, $Res Function(_$ThemeSettingsImpl) then) = - __$$ThemeSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {ThemeMode themeMode, - bool highContrast, - bool useMaterialThemeFromSystem, - String customThemeColor, - bool useMaterialThemeOnItemPage, - bool useCurrentPlayerThemeThroughoutApp}); } -/// @nodoc -class __$$ThemeSettingsImplCopyWithImpl<$Res> - extends _$ThemeSettingsCopyWithImpl<$Res, _$ThemeSettingsImpl> - implements _$$ThemeSettingsImplCopyWith<$Res> { - __$$ThemeSettingsImplCopyWithImpl( - _$ThemeSettingsImpl _value, $Res Function(_$ThemeSettingsImpl) _then) - : super(_value, _then); - /// Create a copy of ThemeSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? themeMode = null, - Object? highContrast = null, - Object? useMaterialThemeFromSystem = null, - Object? customThemeColor = null, - Object? useMaterialThemeOnItemPage = null, - Object? useCurrentPlayerThemeThroughoutApp = null, - }) { - return _then(_$ThemeSettingsImpl( - themeMode: null == themeMode - ? _value.themeMode - : themeMode // ignore: cast_nullable_to_non_nullable - as ThemeMode, - highContrast: null == highContrast - ? _value.highContrast - : highContrast // ignore: cast_nullable_to_non_nullable - as bool, - useMaterialThemeFromSystem: null == useMaterialThemeFromSystem - ? _value.useMaterialThemeFromSystem - : useMaterialThemeFromSystem // ignore: cast_nullable_to_non_nullable - as bool, - customThemeColor: null == customThemeColor - ? _value.customThemeColor - : customThemeColor // ignore: cast_nullable_to_non_nullable - as String, - useMaterialThemeOnItemPage: null == useMaterialThemeOnItemPage - ? _value.useMaterialThemeOnItemPage - : useMaterialThemeOnItemPage // ignore: cast_nullable_to_non_nullable - as bool, - useCurrentPlayerThemeThroughoutApp: null == - useCurrentPlayerThemeThroughoutApp - ? _value.useCurrentPlayerThemeThroughoutApp - : useCurrentPlayerThemeThroughoutApp // ignore: cast_nullable_to_non_nullable - as bool, - )); - } +/// Adds pattern-matching-related methods to [ThemeSettings]. +extension ThemeSettingsPatterns on ThemeSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _ThemeSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ThemeSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _ThemeSettings value) $default,){ +final _that = this; +switch (_that) { +case _ThemeSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _ThemeSettings value)? $default,){ +final _that = this; +switch (_that) { +case _ThemeSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( ThemeMode themeMode, bool highContrast, bool useMaterialThemeFromSystem, String customThemeColor, bool useMaterialThemeOnItemPage, bool useCurrentPlayerThemeThroughoutApp)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ThemeSettings() when $default != null: +return $default(_that.themeMode,_that.highContrast,_that.useMaterialThemeFromSystem,_that.customThemeColor,_that.useMaterialThemeOnItemPage,_that.useCurrentPlayerThemeThroughoutApp);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( ThemeMode themeMode, bool highContrast, bool useMaterialThemeFromSystem, String customThemeColor, bool useMaterialThemeOnItemPage, bool useCurrentPlayerThemeThroughoutApp) $default,) {final _that = this; +switch (_that) { +case _ThemeSettings(): +return $default(_that.themeMode,_that.highContrast,_that.useMaterialThemeFromSystem,_that.customThemeColor,_that.useMaterialThemeOnItemPage,_that.useCurrentPlayerThemeThroughoutApp);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( ThemeMode themeMode, bool highContrast, bool useMaterialThemeFromSystem, String customThemeColor, bool useMaterialThemeOnItemPage, bool useCurrentPlayerThemeThroughoutApp)? $default,) {final _that = this; +switch (_that) { +case _ThemeSettings() when $default != null: +return $default(_that.themeMode,_that.highContrast,_that.useMaterialThemeFromSystem,_that.customThemeColor,_that.useMaterialThemeOnItemPage,_that.useCurrentPlayerThemeThroughoutApp);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$ThemeSettingsImpl implements _ThemeSettings { - const _$ThemeSettingsImpl( - {this.themeMode = ThemeMode.system, - this.highContrast = false, - this.useMaterialThemeFromSystem = false, - this.customThemeColor = '#FF311B92', - this.useMaterialThemeOnItemPage = true, - this.useCurrentPlayerThemeThroughoutApp = true}); - factory _$ThemeSettingsImpl.fromJson(Map json) => - _$$ThemeSettingsImplFromJson(json); +class _ThemeSettings implements ThemeSettings { + const _ThemeSettings({this.themeMode = ThemeMode.system, this.highContrast = false, this.useMaterialThemeFromSystem = false, this.customThemeColor = '#FF311B92', this.useMaterialThemeOnItemPage = true, this.useCurrentPlayerThemeThroughoutApp = true}); + factory _ThemeSettings.fromJson(Map json) => _$ThemeSettingsFromJson(json); - @override - @JsonKey() - final ThemeMode themeMode; - @override - @JsonKey() - final bool highContrast; - @override - @JsonKey() - final bool useMaterialThemeFromSystem; - @override - @JsonKey() - final String customThemeColor; - @override - @JsonKey() - final bool useMaterialThemeOnItemPage; - @override - @JsonKey() - final bool useCurrentPlayerThemeThroughoutApp; +@override@JsonKey() final ThemeMode themeMode; +@override@JsonKey() final bool highContrast; +@override@JsonKey() final bool useMaterialThemeFromSystem; +@override@JsonKey() final String customThemeColor; +@override@JsonKey() final bool useMaterialThemeOnItemPage; +@override@JsonKey() final bool useCurrentPlayerThemeThroughoutApp; - @override - String toString() { - return 'ThemeSettings(themeMode: $themeMode, highContrast: $highContrast, useMaterialThemeFromSystem: $useMaterialThemeFromSystem, customThemeColor: $customThemeColor, useMaterialThemeOnItemPage: $useMaterialThemeOnItemPage, useCurrentPlayerThemeThroughoutApp: $useCurrentPlayerThemeThroughoutApp)'; - } +/// Create a copy of ThemeSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ThemeSettingsCopyWith<_ThemeSettings> get copyWith => __$ThemeSettingsCopyWithImpl<_ThemeSettings>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ThemeSettingsImpl && - (identical(other.themeMode, themeMode) || - other.themeMode == themeMode) && - (identical(other.highContrast, highContrast) || - other.highContrast == highContrast) && - (identical(other.useMaterialThemeFromSystem, - useMaterialThemeFromSystem) || - other.useMaterialThemeFromSystem == - useMaterialThemeFromSystem) && - (identical(other.customThemeColor, customThemeColor) || - other.customThemeColor == customThemeColor) && - (identical(other.useMaterialThemeOnItemPage, - useMaterialThemeOnItemPage) || - other.useMaterialThemeOnItemPage == - useMaterialThemeOnItemPage) && - (identical(other.useCurrentPlayerThemeThroughoutApp, - useCurrentPlayerThemeThroughoutApp) || - other.useCurrentPlayerThemeThroughoutApp == - useCurrentPlayerThemeThroughoutApp)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - themeMode, - highContrast, - useMaterialThemeFromSystem, - customThemeColor, - useMaterialThemeOnItemPage, - useCurrentPlayerThemeThroughoutApp); - - /// Create a copy of ThemeSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ThemeSettingsImplCopyWith<_$ThemeSettingsImpl> get copyWith => - __$$ThemeSettingsImplCopyWithImpl<_$ThemeSettingsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$ThemeSettingsImplToJson( - this, - ); - } +@override +Map toJson() { + return _$ThemeSettingsToJson(this, ); } -abstract class _ThemeSettings implements ThemeSettings { - const factory _ThemeSettings( - {final ThemeMode themeMode, - final bool highContrast, - final bool useMaterialThemeFromSystem, - final String customThemeColor, - final bool useMaterialThemeOnItemPage, - final bool useCurrentPlayerThemeThroughoutApp}) = _$ThemeSettingsImpl; - - factory _ThemeSettings.fromJson(Map json) = - _$ThemeSettingsImpl.fromJson; - - @override - ThemeMode get themeMode; - @override - bool get highContrast; - @override - bool get useMaterialThemeFromSystem; - @override - String get customThemeColor; - @override - bool get useMaterialThemeOnItemPage; - @override - bool get useCurrentPlayerThemeThroughoutApp; - - /// Create a copy of ThemeSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ThemeSettingsImplCopyWith<_$ThemeSettingsImpl> get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ThemeSettings&&(identical(other.themeMode, themeMode) || other.themeMode == themeMode)&&(identical(other.highContrast, highContrast) || other.highContrast == highContrast)&&(identical(other.useMaterialThemeFromSystem, useMaterialThemeFromSystem) || other.useMaterialThemeFromSystem == useMaterialThemeFromSystem)&&(identical(other.customThemeColor, customThemeColor) || other.customThemeColor == customThemeColor)&&(identical(other.useMaterialThemeOnItemPage, useMaterialThemeOnItemPage) || other.useMaterialThemeOnItemPage == useMaterialThemeOnItemPage)&&(identical(other.useCurrentPlayerThemeThroughoutApp, useCurrentPlayerThemeThroughoutApp) || other.useCurrentPlayerThemeThroughoutApp == useCurrentPlayerThemeThroughoutApp)); } -PlayerSettings _$PlayerSettingsFromJson(Map json) { - return _PlayerSettings.fromJson(json); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,themeMode,highContrast,useMaterialThemeFromSystem,customThemeColor,useMaterialThemeOnItemPage,useCurrentPlayerThemeThroughoutApp); + +@override +String toString() { + return 'ThemeSettings(themeMode: $themeMode, highContrast: $highContrast, useMaterialThemeFromSystem: $useMaterialThemeFromSystem, customThemeColor: $customThemeColor, useMaterialThemeOnItemPage: $useMaterialThemeOnItemPage, useCurrentPlayerThemeThroughoutApp: $useCurrentPlayerThemeThroughoutApp)'; } + +} + +/// @nodoc +abstract mixin class _$ThemeSettingsCopyWith<$Res> implements $ThemeSettingsCopyWith<$Res> { + factory _$ThemeSettingsCopyWith(_ThemeSettings value, $Res Function(_ThemeSettings) _then) = __$ThemeSettingsCopyWithImpl; +@override @useResult +$Res call({ + ThemeMode themeMode, bool highContrast, bool useMaterialThemeFromSystem, String customThemeColor, bool useMaterialThemeOnItemPage, bool useCurrentPlayerThemeThroughoutApp +}); + + + + +} +/// @nodoc +class __$ThemeSettingsCopyWithImpl<$Res> + implements _$ThemeSettingsCopyWith<$Res> { + __$ThemeSettingsCopyWithImpl(this._self, this._then); + + final _ThemeSettings _self; + final $Res Function(_ThemeSettings) _then; + +/// Create a copy of ThemeSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? themeMode = null,Object? highContrast = null,Object? useMaterialThemeFromSystem = null,Object? customThemeColor = null,Object? useMaterialThemeOnItemPage = null,Object? useCurrentPlayerThemeThroughoutApp = null,}) { + return _then(_ThemeSettings( +themeMode: null == themeMode ? _self.themeMode : themeMode // ignore: cast_nullable_to_non_nullable +as ThemeMode,highContrast: null == highContrast ? _self.highContrast : highContrast // ignore: cast_nullable_to_non_nullable +as bool,useMaterialThemeFromSystem: null == useMaterialThemeFromSystem ? _self.useMaterialThemeFromSystem : useMaterialThemeFromSystem // ignore: cast_nullable_to_non_nullable +as bool,customThemeColor: null == customThemeColor ? _self.customThemeColor : customThemeColor // ignore: cast_nullable_to_non_nullable +as String,useMaterialThemeOnItemPage: null == useMaterialThemeOnItemPage ? _self.useMaterialThemeOnItemPage : useMaterialThemeOnItemPage // ignore: cast_nullable_to_non_nullable +as bool,useCurrentPlayerThemeThroughoutApp: null == useCurrentPlayerThemeThroughoutApp ? _self.useCurrentPlayerThemeThroughoutApp : useCurrentPlayerThemeThroughoutApp // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + + /// @nodoc mixin _$PlayerSettings { - MinimizedPlayerSettings get miniPlayerSettings => - throw _privateConstructorUsedError; - ExpandedPlayerSettings get expandedPlayerSettings => - throw _privateConstructorUsedError; - double get preferredDefaultVolume => throw _privateConstructorUsedError; - double get preferredDefaultSpeed => throw _privateConstructorUsedError; - List get speedOptions => throw _privateConstructorUsedError; - double get speedIncrement => throw _privateConstructorUsedError; - double get minSpeed => throw _privateConstructorUsedError; - double get maxSpeed => throw _privateConstructorUsedError; - Duration get minimumPositionForReporting => - throw _privateConstructorUsedError; - Duration get playbackReportInterval => throw _privateConstructorUsedError; - Duration get markCompleteWhenTimeLeft => throw _privateConstructorUsedError; - bool get configurePlayerForEveryBook => throw _privateConstructorUsedError; + + MinimizedPlayerSettings get miniPlayerSettings; ExpandedPlayerSettings get expandedPlayerSettings; double get preferredDefaultVolume; double get preferredDefaultSpeed; List get speedOptions; double get speedIncrement; double get minSpeed; double get maxSpeed; Duration get minimumPositionForReporting; Duration get playbackReportInterval; Duration get markCompleteWhenTimeLeft; bool get configurePlayerForEveryBook; +/// Create a copy of PlayerSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PlayerSettingsCopyWith get copyWith => _$PlayerSettingsCopyWithImpl(this as PlayerSettings, _$identity); /// Serializes this PlayerSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PlayerSettings&&(identical(other.miniPlayerSettings, miniPlayerSettings) || other.miniPlayerSettings == miniPlayerSettings)&&(identical(other.expandedPlayerSettings, expandedPlayerSettings) || other.expandedPlayerSettings == expandedPlayerSettings)&&(identical(other.preferredDefaultVolume, preferredDefaultVolume) || other.preferredDefaultVolume == preferredDefaultVolume)&&(identical(other.preferredDefaultSpeed, preferredDefaultSpeed) || other.preferredDefaultSpeed == preferredDefaultSpeed)&&const DeepCollectionEquality().equals(other.speedOptions, speedOptions)&&(identical(other.speedIncrement, speedIncrement) || other.speedIncrement == speedIncrement)&&(identical(other.minSpeed, minSpeed) || other.minSpeed == minSpeed)&&(identical(other.maxSpeed, maxSpeed) || other.maxSpeed == maxSpeed)&&(identical(other.minimumPositionForReporting, minimumPositionForReporting) || other.minimumPositionForReporting == minimumPositionForReporting)&&(identical(other.playbackReportInterval, playbackReportInterval) || other.playbackReportInterval == playbackReportInterval)&&(identical(other.markCompleteWhenTimeLeft, markCompleteWhenTimeLeft) || other.markCompleteWhenTimeLeft == markCompleteWhenTimeLeft)&&(identical(other.configurePlayerForEveryBook, configurePlayerForEveryBook) || other.configurePlayerForEveryBook == configurePlayerForEveryBook)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,miniPlayerSettings,expandedPlayerSettings,preferredDefaultVolume,preferredDefaultSpeed,const DeepCollectionEquality().hash(speedOptions),speedIncrement,minSpeed,maxSpeed,minimumPositionForReporting,playbackReportInterval,markCompleteWhenTimeLeft,configurePlayerForEveryBook); + +@override +String toString() { + return 'PlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, speedIncrement: $speedIncrement, minSpeed: $minSpeed, maxSpeed: $maxSpeed, minimumPositionForReporting: $minimumPositionForReporting, playbackReportInterval: $playbackReportInterval, markCompleteWhenTimeLeft: $markCompleteWhenTimeLeft, configurePlayerForEveryBook: $configurePlayerForEveryBook)'; +} + - /// Create a copy of PlayerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PlayerSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $PlayerSettingsCopyWith<$Res> { - factory $PlayerSettingsCopyWith( - PlayerSettings value, $Res Function(PlayerSettings) then) = - _$PlayerSettingsCopyWithImpl<$Res, PlayerSettings>; - @useResult - $Res call( - {MinimizedPlayerSettings miniPlayerSettings, - ExpandedPlayerSettings expandedPlayerSettings, - double preferredDefaultVolume, - double preferredDefaultSpeed, - List speedOptions, - double speedIncrement, - double minSpeed, - double maxSpeed, - Duration minimumPositionForReporting, - Duration playbackReportInterval, - Duration markCompleteWhenTimeLeft, - bool configurePlayerForEveryBook}); +abstract mixin class $PlayerSettingsCopyWith<$Res> { + factory $PlayerSettingsCopyWith(PlayerSettings value, $Res Function(PlayerSettings) _then) = _$PlayerSettingsCopyWithImpl; +@useResult +$Res call({ + MinimizedPlayerSettings miniPlayerSettings, ExpandedPlayerSettings expandedPlayerSettings, double preferredDefaultVolume, double preferredDefaultSpeed, List speedOptions, double speedIncrement, double minSpeed, double maxSpeed, Duration minimumPositionForReporting, Duration playbackReportInterval, Duration markCompleteWhenTimeLeft, bool configurePlayerForEveryBook +}); + + +$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings; - $MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings; - $ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings; } - /// @nodoc -class _$PlayerSettingsCopyWithImpl<$Res, $Val extends PlayerSettings> +class _$PlayerSettingsCopyWithImpl<$Res> implements $PlayerSettingsCopyWith<$Res> { - _$PlayerSettingsCopyWithImpl(this._value, this._then); + _$PlayerSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final PlayerSettings _self; + final $Res Function(PlayerSettings) _then; - /// Create a copy of PlayerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? miniPlayerSettings = null, - Object? expandedPlayerSettings = null, - Object? preferredDefaultVolume = null, - Object? preferredDefaultSpeed = null, - Object? speedOptions = null, - Object? speedIncrement = null, - Object? minSpeed = null, - Object? maxSpeed = null, - Object? minimumPositionForReporting = null, - Object? playbackReportInterval = null, - Object? markCompleteWhenTimeLeft = null, - Object? configurePlayerForEveryBook = null, - }) { - return _then(_value.copyWith( - miniPlayerSettings: null == miniPlayerSettings - ? _value.miniPlayerSettings - : miniPlayerSettings // ignore: cast_nullable_to_non_nullable - as MinimizedPlayerSettings, - expandedPlayerSettings: null == expandedPlayerSettings - ? _value.expandedPlayerSettings - : expandedPlayerSettings // ignore: cast_nullable_to_non_nullable - as ExpandedPlayerSettings, - preferredDefaultVolume: null == preferredDefaultVolume - ? _value.preferredDefaultVolume - : preferredDefaultVolume // ignore: cast_nullable_to_non_nullable - as double, - preferredDefaultSpeed: null == preferredDefaultSpeed - ? _value.preferredDefaultSpeed - : preferredDefaultSpeed // ignore: cast_nullable_to_non_nullable - as double, - speedOptions: null == speedOptions - ? _value.speedOptions - : speedOptions // ignore: cast_nullable_to_non_nullable - as List, - speedIncrement: null == speedIncrement - ? _value.speedIncrement - : speedIncrement // ignore: cast_nullable_to_non_nullable - as double, - minSpeed: null == minSpeed - ? _value.minSpeed - : minSpeed // ignore: cast_nullable_to_non_nullable - as double, - maxSpeed: null == maxSpeed - ? _value.maxSpeed - : maxSpeed // ignore: cast_nullable_to_non_nullable - as double, - minimumPositionForReporting: null == minimumPositionForReporting - ? _value.minimumPositionForReporting - : minimumPositionForReporting // ignore: cast_nullable_to_non_nullable - as Duration, - playbackReportInterval: null == playbackReportInterval - ? _value.playbackReportInterval - : playbackReportInterval // ignore: cast_nullable_to_non_nullable - as Duration, - markCompleteWhenTimeLeft: null == markCompleteWhenTimeLeft - ? _value.markCompleteWhenTimeLeft - : markCompleteWhenTimeLeft // ignore: cast_nullable_to_non_nullable - as Duration, - configurePlayerForEveryBook: null == configurePlayerForEveryBook - ? _value.configurePlayerForEveryBook - : configurePlayerForEveryBook // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } - - /// Create a copy of PlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings { - return $MinimizedPlayerSettingsCopyWith<$Res>(_value.miniPlayerSettings, - (value) { - return _then(_value.copyWith(miniPlayerSettings: value) as $Val); - }); - } - - /// Create a copy of PlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings { - return $ExpandedPlayerSettingsCopyWith<$Res>(_value.expandedPlayerSettings, - (value) { - return _then(_value.copyWith(expandedPlayerSettings: value) as $Val); - }); - } +/// Create a copy of PlayerSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? miniPlayerSettings = null,Object? expandedPlayerSettings = null,Object? preferredDefaultVolume = null,Object? preferredDefaultSpeed = null,Object? speedOptions = null,Object? speedIncrement = null,Object? minSpeed = null,Object? maxSpeed = null,Object? minimumPositionForReporting = null,Object? playbackReportInterval = null,Object? markCompleteWhenTimeLeft = null,Object? configurePlayerForEveryBook = null,}) { + return _then(_self.copyWith( +miniPlayerSettings: null == miniPlayerSettings ? _self.miniPlayerSettings : miniPlayerSettings // ignore: cast_nullable_to_non_nullable +as MinimizedPlayerSettings,expandedPlayerSettings: null == expandedPlayerSettings ? _self.expandedPlayerSettings : expandedPlayerSettings // ignore: cast_nullable_to_non_nullable +as ExpandedPlayerSettings,preferredDefaultVolume: null == preferredDefaultVolume ? _self.preferredDefaultVolume : preferredDefaultVolume // ignore: cast_nullable_to_non_nullable +as double,preferredDefaultSpeed: null == preferredDefaultSpeed ? _self.preferredDefaultSpeed : preferredDefaultSpeed // ignore: cast_nullable_to_non_nullable +as double,speedOptions: null == speedOptions ? _self.speedOptions : speedOptions // ignore: cast_nullable_to_non_nullable +as List,speedIncrement: null == speedIncrement ? _self.speedIncrement : speedIncrement // ignore: cast_nullable_to_non_nullable +as double,minSpeed: null == minSpeed ? _self.minSpeed : minSpeed // ignore: cast_nullable_to_non_nullable +as double,maxSpeed: null == maxSpeed ? _self.maxSpeed : maxSpeed // ignore: cast_nullable_to_non_nullable +as double,minimumPositionForReporting: null == minimumPositionForReporting ? _self.minimumPositionForReporting : minimumPositionForReporting // ignore: cast_nullable_to_non_nullable +as Duration,playbackReportInterval: null == playbackReportInterval ? _self.playbackReportInterval : playbackReportInterval // ignore: cast_nullable_to_non_nullable +as Duration,markCompleteWhenTimeLeft: null == markCompleteWhenTimeLeft ? _self.markCompleteWhenTimeLeft : markCompleteWhenTimeLeft // ignore: cast_nullable_to_non_nullable +as Duration,configurePlayerForEveryBook: null == configurePlayerForEveryBook ? _self.configurePlayerForEveryBook : configurePlayerForEveryBook // ignore: cast_nullable_to_non_nullable +as bool, + )); +} +/// Create a copy of PlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings { + + return $MinimizedPlayerSettingsCopyWith<$Res>(_self.miniPlayerSettings, (value) { + return _then(_self.copyWith(miniPlayerSettings: value)); + }); +}/// Create a copy of PlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings { + + return $ExpandedPlayerSettingsCopyWith<$Res>(_self.expandedPlayerSettings, (value) { + return _then(_self.copyWith(expandedPlayerSettings: value)); + }); +} } -/// @nodoc -abstract class _$$PlayerSettingsImplCopyWith<$Res> - implements $PlayerSettingsCopyWith<$Res> { - factory _$$PlayerSettingsImplCopyWith(_$PlayerSettingsImpl value, - $Res Function(_$PlayerSettingsImpl) then) = - __$$PlayerSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {MinimizedPlayerSettings miniPlayerSettings, - ExpandedPlayerSettings expandedPlayerSettings, - double preferredDefaultVolume, - double preferredDefaultSpeed, - List speedOptions, - double speedIncrement, - double minSpeed, - double maxSpeed, - Duration minimumPositionForReporting, - Duration playbackReportInterval, - Duration markCompleteWhenTimeLeft, - bool configurePlayerForEveryBook}); - @override - $MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings; - @override - $ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings; +/// Adds pattern-matching-related methods to [PlayerSettings]. +extension PlayerSettingsPatterns on PlayerSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _PlayerSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PlayerSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _PlayerSettings value) $default,){ +final _that = this; +switch (_that) { +case _PlayerSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _PlayerSettings value)? $default,){ +final _that = this; +switch (_that) { +case _PlayerSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( MinimizedPlayerSettings miniPlayerSettings, ExpandedPlayerSettings expandedPlayerSettings, double preferredDefaultVolume, double preferredDefaultSpeed, List speedOptions, double speedIncrement, double minSpeed, double maxSpeed, Duration minimumPositionForReporting, Duration playbackReportInterval, Duration markCompleteWhenTimeLeft, bool configurePlayerForEveryBook)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PlayerSettings() when $default != null: +return $default(_that.miniPlayerSettings,_that.expandedPlayerSettings,_that.preferredDefaultVolume,_that.preferredDefaultSpeed,_that.speedOptions,_that.speedIncrement,_that.minSpeed,_that.maxSpeed,_that.minimumPositionForReporting,_that.playbackReportInterval,_that.markCompleteWhenTimeLeft,_that.configurePlayerForEveryBook);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( MinimizedPlayerSettings miniPlayerSettings, ExpandedPlayerSettings expandedPlayerSettings, double preferredDefaultVolume, double preferredDefaultSpeed, List speedOptions, double speedIncrement, double minSpeed, double maxSpeed, Duration minimumPositionForReporting, Duration playbackReportInterval, Duration markCompleteWhenTimeLeft, bool configurePlayerForEveryBook) $default,) {final _that = this; +switch (_that) { +case _PlayerSettings(): +return $default(_that.miniPlayerSettings,_that.expandedPlayerSettings,_that.preferredDefaultVolume,_that.preferredDefaultSpeed,_that.speedOptions,_that.speedIncrement,_that.minSpeed,_that.maxSpeed,_that.minimumPositionForReporting,_that.playbackReportInterval,_that.markCompleteWhenTimeLeft,_that.configurePlayerForEveryBook);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( MinimizedPlayerSettings miniPlayerSettings, ExpandedPlayerSettings expandedPlayerSettings, double preferredDefaultVolume, double preferredDefaultSpeed, List speedOptions, double speedIncrement, double minSpeed, double maxSpeed, Duration minimumPositionForReporting, Duration playbackReportInterval, Duration markCompleteWhenTimeLeft, bool configurePlayerForEveryBook)? $default,) {final _that = this; +switch (_that) { +case _PlayerSettings() when $default != null: +return $default(_that.miniPlayerSettings,_that.expandedPlayerSettings,_that.preferredDefaultVolume,_that.preferredDefaultSpeed,_that.speedOptions,_that.speedIncrement,_that.minSpeed,_that.maxSpeed,_that.minimumPositionForReporting,_that.playbackReportInterval,_that.markCompleteWhenTimeLeft,_that.configurePlayerForEveryBook);case _: + return null; + +} } -/// @nodoc -class __$$PlayerSettingsImplCopyWithImpl<$Res> - extends _$PlayerSettingsCopyWithImpl<$Res, _$PlayerSettingsImpl> - implements _$$PlayerSettingsImplCopyWith<$Res> { - __$$PlayerSettingsImplCopyWithImpl( - _$PlayerSettingsImpl _value, $Res Function(_$PlayerSettingsImpl) _then) - : super(_value, _then); - - /// Create a copy of PlayerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? miniPlayerSettings = null, - Object? expandedPlayerSettings = null, - Object? preferredDefaultVolume = null, - Object? preferredDefaultSpeed = null, - Object? speedOptions = null, - Object? speedIncrement = null, - Object? minSpeed = null, - Object? maxSpeed = null, - Object? minimumPositionForReporting = null, - Object? playbackReportInterval = null, - Object? markCompleteWhenTimeLeft = null, - Object? configurePlayerForEveryBook = null, - }) { - return _then(_$PlayerSettingsImpl( - miniPlayerSettings: null == miniPlayerSettings - ? _value.miniPlayerSettings - : miniPlayerSettings // ignore: cast_nullable_to_non_nullable - as MinimizedPlayerSettings, - expandedPlayerSettings: null == expandedPlayerSettings - ? _value.expandedPlayerSettings - : expandedPlayerSettings // ignore: cast_nullable_to_non_nullable - as ExpandedPlayerSettings, - preferredDefaultVolume: null == preferredDefaultVolume - ? _value.preferredDefaultVolume - : preferredDefaultVolume // ignore: cast_nullable_to_non_nullable - as double, - preferredDefaultSpeed: null == preferredDefaultSpeed - ? _value.preferredDefaultSpeed - : preferredDefaultSpeed // ignore: cast_nullable_to_non_nullable - as double, - speedOptions: null == speedOptions - ? _value._speedOptions - : speedOptions // ignore: cast_nullable_to_non_nullable - as List, - speedIncrement: null == speedIncrement - ? _value.speedIncrement - : speedIncrement // ignore: cast_nullable_to_non_nullable - as double, - minSpeed: null == minSpeed - ? _value.minSpeed - : minSpeed // ignore: cast_nullable_to_non_nullable - as double, - maxSpeed: null == maxSpeed - ? _value.maxSpeed - : maxSpeed // ignore: cast_nullable_to_non_nullable - as double, - minimumPositionForReporting: null == minimumPositionForReporting - ? _value.minimumPositionForReporting - : minimumPositionForReporting // ignore: cast_nullable_to_non_nullable - as Duration, - playbackReportInterval: null == playbackReportInterval - ? _value.playbackReportInterval - : playbackReportInterval // ignore: cast_nullable_to_non_nullable - as Duration, - markCompleteWhenTimeLeft: null == markCompleteWhenTimeLeft - ? _value.markCompleteWhenTimeLeft - : markCompleteWhenTimeLeft // ignore: cast_nullable_to_non_nullable - as Duration, - configurePlayerForEveryBook: null == configurePlayerForEveryBook - ? _value.configurePlayerForEveryBook - : configurePlayerForEveryBook // ignore: cast_nullable_to_non_nullable - as bool, - )); - } } /// @nodoc @JsonSerializable() -class _$PlayerSettingsImpl implements _PlayerSettings { - const _$PlayerSettingsImpl( - {this.miniPlayerSettings = const MinimizedPlayerSettings(), - this.expandedPlayerSettings = const ExpandedPlayerSettings(), - this.preferredDefaultVolume = 1, - this.preferredDefaultSpeed = 1, - final List speedOptions = const [1, 1.25, 1.5, 1.75, 2], - this.speedIncrement = 0.05, - this.minSpeed = 0.1, - this.maxSpeed = 4, - this.minimumPositionForReporting = const Duration(seconds: 10), - this.playbackReportInterval = const Duration(seconds: 10), - this.markCompleteWhenTimeLeft = const Duration(seconds: 15), - this.configurePlayerForEveryBook = true}) - : _speedOptions = speedOptions; - factory _$PlayerSettingsImpl.fromJson(Map json) => - _$$PlayerSettingsImplFromJson(json); +class _PlayerSettings implements PlayerSettings { + const _PlayerSettings({this.miniPlayerSettings = const MinimizedPlayerSettings(), this.expandedPlayerSettings = const ExpandedPlayerSettings(), this.preferredDefaultVolume = 1, this.preferredDefaultSpeed = 1, final List speedOptions = const [1, 1.25, 1.5, 1.75, 2], this.speedIncrement = 0.05, this.minSpeed = 0.1, this.maxSpeed = 4, this.minimumPositionForReporting = const Duration(seconds: 10), this.playbackReportInterval = const Duration(seconds: 10), this.markCompleteWhenTimeLeft = const Duration(seconds: 15), this.configurePlayerForEveryBook = true}): _speedOptions = speedOptions; + factory _PlayerSettings.fromJson(Map json) => _$PlayerSettingsFromJson(json); - @override - @JsonKey() - final MinimizedPlayerSettings miniPlayerSettings; - @override - @JsonKey() - final ExpandedPlayerSettings expandedPlayerSettings; - @override - @JsonKey() - final double preferredDefaultVolume; - @override - @JsonKey() - final double preferredDefaultSpeed; - final List _speedOptions; - @override - @JsonKey() - List get speedOptions { - if (_speedOptions is EqualUnmodifiableListView) return _speedOptions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_speedOptions); - } - - @override - @JsonKey() - final double speedIncrement; - @override - @JsonKey() - final double minSpeed; - @override - @JsonKey() - final double maxSpeed; - @override - @JsonKey() - final Duration minimumPositionForReporting; - @override - @JsonKey() - final Duration playbackReportInterval; - @override - @JsonKey() - final Duration markCompleteWhenTimeLeft; - @override - @JsonKey() - final bool configurePlayerForEveryBook; - - @override - String toString() { - return 'PlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, speedIncrement: $speedIncrement, minSpeed: $minSpeed, maxSpeed: $maxSpeed, minimumPositionForReporting: $minimumPositionForReporting, playbackReportInterval: $playbackReportInterval, markCompleteWhenTimeLeft: $markCompleteWhenTimeLeft, configurePlayerForEveryBook: $configurePlayerForEveryBook)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PlayerSettingsImpl && - (identical(other.miniPlayerSettings, miniPlayerSettings) || - other.miniPlayerSettings == miniPlayerSettings) && - (identical(other.expandedPlayerSettings, expandedPlayerSettings) || - other.expandedPlayerSettings == expandedPlayerSettings) && - (identical(other.preferredDefaultVolume, preferredDefaultVolume) || - other.preferredDefaultVolume == preferredDefaultVolume) && - (identical(other.preferredDefaultSpeed, preferredDefaultSpeed) || - other.preferredDefaultSpeed == preferredDefaultSpeed) && - const DeepCollectionEquality() - .equals(other._speedOptions, _speedOptions) && - (identical(other.speedIncrement, speedIncrement) || - other.speedIncrement == speedIncrement) && - (identical(other.minSpeed, minSpeed) || - other.minSpeed == minSpeed) && - (identical(other.maxSpeed, maxSpeed) || - other.maxSpeed == maxSpeed) && - (identical(other.minimumPositionForReporting, - minimumPositionForReporting) || - other.minimumPositionForReporting == - minimumPositionForReporting) && - (identical(other.playbackReportInterval, playbackReportInterval) || - other.playbackReportInterval == playbackReportInterval) && - (identical( - other.markCompleteWhenTimeLeft, markCompleteWhenTimeLeft) || - other.markCompleteWhenTimeLeft == markCompleteWhenTimeLeft) && - (identical(other.configurePlayerForEveryBook, - configurePlayerForEveryBook) || - other.configurePlayerForEveryBook == - configurePlayerForEveryBook)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - miniPlayerSettings, - expandedPlayerSettings, - preferredDefaultVolume, - preferredDefaultSpeed, - const DeepCollectionEquality().hash(_speedOptions), - speedIncrement, - minSpeed, - maxSpeed, - minimumPositionForReporting, - playbackReportInterval, - markCompleteWhenTimeLeft, - configurePlayerForEveryBook); - - /// Create a copy of PlayerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PlayerSettingsImplCopyWith<_$PlayerSettingsImpl> get copyWith => - __$$PlayerSettingsImplCopyWithImpl<_$PlayerSettingsImpl>( - this, _$identity); - - @override - Map toJson() { - return _$$PlayerSettingsImplToJson( - this, - ); - } +@override@JsonKey() final MinimizedPlayerSettings miniPlayerSettings; +@override@JsonKey() final ExpandedPlayerSettings expandedPlayerSettings; +@override@JsonKey() final double preferredDefaultVolume; +@override@JsonKey() final double preferredDefaultSpeed; + final List _speedOptions; +@override@JsonKey() List get speedOptions { + if (_speedOptions is EqualUnmodifiableListView) return _speedOptions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_speedOptions); } -abstract class _PlayerSettings implements PlayerSettings { - const factory _PlayerSettings( - {final MinimizedPlayerSettings miniPlayerSettings, - final ExpandedPlayerSettings expandedPlayerSettings, - final double preferredDefaultVolume, - final double preferredDefaultSpeed, - final List speedOptions, - final double speedIncrement, - final double minSpeed, - final double maxSpeed, - final Duration minimumPositionForReporting, - final Duration playbackReportInterval, - final Duration markCompleteWhenTimeLeft, - final bool configurePlayerForEveryBook}) = _$PlayerSettingsImpl; +@override@JsonKey() final double speedIncrement; +@override@JsonKey() final double minSpeed; +@override@JsonKey() final double maxSpeed; +@override@JsonKey() final Duration minimumPositionForReporting; +@override@JsonKey() final Duration playbackReportInterval; +@override@JsonKey() final Duration markCompleteWhenTimeLeft; +@override@JsonKey() final bool configurePlayerForEveryBook; - factory _PlayerSettings.fromJson(Map json) = - _$PlayerSettingsImpl.fromJson; +/// Create a copy of PlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PlayerSettingsCopyWith<_PlayerSettings> get copyWith => __$PlayerSettingsCopyWithImpl<_PlayerSettings>(this, _$identity); - @override - MinimizedPlayerSettings get miniPlayerSettings; - @override - ExpandedPlayerSettings get expandedPlayerSettings; - @override - double get preferredDefaultVolume; - @override - double get preferredDefaultSpeed; - @override - List get speedOptions; - @override - double get speedIncrement; - @override - double get minSpeed; - @override - double get maxSpeed; - @override - Duration get minimumPositionForReporting; - @override - Duration get playbackReportInterval; - @override - Duration get markCompleteWhenTimeLeft; - @override - bool get configurePlayerForEveryBook; - - /// Create a copy of PlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PlayerSettingsImplCopyWith<_$PlayerSettingsImpl> get copyWith => - throw _privateConstructorUsedError; +@override +Map toJson() { + return _$PlayerSettingsToJson(this, ); } -ExpandedPlayerSettings _$ExpandedPlayerSettingsFromJson( - Map json) { - return _ExpandedPlayerSettings.fromJson(json); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PlayerSettings&&(identical(other.miniPlayerSettings, miniPlayerSettings) || other.miniPlayerSettings == miniPlayerSettings)&&(identical(other.expandedPlayerSettings, expandedPlayerSettings) || other.expandedPlayerSettings == expandedPlayerSettings)&&(identical(other.preferredDefaultVolume, preferredDefaultVolume) || other.preferredDefaultVolume == preferredDefaultVolume)&&(identical(other.preferredDefaultSpeed, preferredDefaultSpeed) || other.preferredDefaultSpeed == preferredDefaultSpeed)&&const DeepCollectionEquality().equals(other._speedOptions, _speedOptions)&&(identical(other.speedIncrement, speedIncrement) || other.speedIncrement == speedIncrement)&&(identical(other.minSpeed, minSpeed) || other.minSpeed == minSpeed)&&(identical(other.maxSpeed, maxSpeed) || other.maxSpeed == maxSpeed)&&(identical(other.minimumPositionForReporting, minimumPositionForReporting) || other.minimumPositionForReporting == minimumPositionForReporting)&&(identical(other.playbackReportInterval, playbackReportInterval) || other.playbackReportInterval == playbackReportInterval)&&(identical(other.markCompleteWhenTimeLeft, markCompleteWhenTimeLeft) || other.markCompleteWhenTimeLeft == markCompleteWhenTimeLeft)&&(identical(other.configurePlayerForEveryBook, configurePlayerForEveryBook) || other.configurePlayerForEveryBook == configurePlayerForEveryBook)); } +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,miniPlayerSettings,expandedPlayerSettings,preferredDefaultVolume,preferredDefaultSpeed,const DeepCollectionEquality().hash(_speedOptions),speedIncrement,minSpeed,maxSpeed,minimumPositionForReporting,playbackReportInterval,markCompleteWhenTimeLeft,configurePlayerForEveryBook); + +@override +String toString() { + return 'PlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, speedIncrement: $speedIncrement, minSpeed: $minSpeed, maxSpeed: $maxSpeed, minimumPositionForReporting: $minimumPositionForReporting, playbackReportInterval: $playbackReportInterval, markCompleteWhenTimeLeft: $markCompleteWhenTimeLeft, configurePlayerForEveryBook: $configurePlayerForEveryBook)'; +} + + +} + +/// @nodoc +abstract mixin class _$PlayerSettingsCopyWith<$Res> implements $PlayerSettingsCopyWith<$Res> { + factory _$PlayerSettingsCopyWith(_PlayerSettings value, $Res Function(_PlayerSettings) _then) = __$PlayerSettingsCopyWithImpl; +@override @useResult +$Res call({ + MinimizedPlayerSettings miniPlayerSettings, ExpandedPlayerSettings expandedPlayerSettings, double preferredDefaultVolume, double preferredDefaultSpeed, List speedOptions, double speedIncrement, double minSpeed, double maxSpeed, Duration minimumPositionForReporting, Duration playbackReportInterval, Duration markCompleteWhenTimeLeft, bool configurePlayerForEveryBook +}); + + +@override $MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;@override $ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings; + +} +/// @nodoc +class __$PlayerSettingsCopyWithImpl<$Res> + implements _$PlayerSettingsCopyWith<$Res> { + __$PlayerSettingsCopyWithImpl(this._self, this._then); + + final _PlayerSettings _self; + final $Res Function(_PlayerSettings) _then; + +/// Create a copy of PlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? miniPlayerSettings = null,Object? expandedPlayerSettings = null,Object? preferredDefaultVolume = null,Object? preferredDefaultSpeed = null,Object? speedOptions = null,Object? speedIncrement = null,Object? minSpeed = null,Object? maxSpeed = null,Object? minimumPositionForReporting = null,Object? playbackReportInterval = null,Object? markCompleteWhenTimeLeft = null,Object? configurePlayerForEveryBook = null,}) { + return _then(_PlayerSettings( +miniPlayerSettings: null == miniPlayerSettings ? _self.miniPlayerSettings : miniPlayerSettings // ignore: cast_nullable_to_non_nullable +as MinimizedPlayerSettings,expandedPlayerSettings: null == expandedPlayerSettings ? _self.expandedPlayerSettings : expandedPlayerSettings // ignore: cast_nullable_to_non_nullable +as ExpandedPlayerSettings,preferredDefaultVolume: null == preferredDefaultVolume ? _self.preferredDefaultVolume : preferredDefaultVolume // ignore: cast_nullable_to_non_nullable +as double,preferredDefaultSpeed: null == preferredDefaultSpeed ? _self.preferredDefaultSpeed : preferredDefaultSpeed // ignore: cast_nullable_to_non_nullable +as double,speedOptions: null == speedOptions ? _self._speedOptions : speedOptions // ignore: cast_nullable_to_non_nullable +as List,speedIncrement: null == speedIncrement ? _self.speedIncrement : speedIncrement // ignore: cast_nullable_to_non_nullable +as double,minSpeed: null == minSpeed ? _self.minSpeed : minSpeed // ignore: cast_nullable_to_non_nullable +as double,maxSpeed: null == maxSpeed ? _self.maxSpeed : maxSpeed // ignore: cast_nullable_to_non_nullable +as double,minimumPositionForReporting: null == minimumPositionForReporting ? _self.minimumPositionForReporting : minimumPositionForReporting // ignore: cast_nullable_to_non_nullable +as Duration,playbackReportInterval: null == playbackReportInterval ? _self.playbackReportInterval : playbackReportInterval // ignore: cast_nullable_to_non_nullable +as Duration,markCompleteWhenTimeLeft: null == markCompleteWhenTimeLeft ? _self.markCompleteWhenTimeLeft : markCompleteWhenTimeLeft // ignore: cast_nullable_to_non_nullable +as Duration,configurePlayerForEveryBook: null == configurePlayerForEveryBook ? _self.configurePlayerForEveryBook : configurePlayerForEveryBook // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of PlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings { + + return $MinimizedPlayerSettingsCopyWith<$Res>(_self.miniPlayerSettings, (value) { + return _then(_self.copyWith(miniPlayerSettings: value)); + }); +}/// Create a copy of PlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings { + + return $ExpandedPlayerSettingsCopyWith<$Res>(_self.expandedPlayerSettings, (value) { + return _then(_self.copyWith(expandedPlayerSettings: value)); + }); +} +} + + /// @nodoc mixin _$ExpandedPlayerSettings { - bool get showTotalProgress => throw _privateConstructorUsedError; - bool get showChapterProgress => throw _privateConstructorUsedError; + + bool get showTotalProgress; bool get showChapterProgress; +/// Create a copy of ExpandedPlayerSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ExpandedPlayerSettingsCopyWith get copyWith => _$ExpandedPlayerSettingsCopyWithImpl(this as ExpandedPlayerSettings, _$identity); /// Serializes this ExpandedPlayerSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExpandedPlayerSettings&&(identical(other.showTotalProgress, showTotalProgress) || other.showTotalProgress == showTotalProgress)&&(identical(other.showChapterProgress, showChapterProgress) || other.showChapterProgress == showChapterProgress)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,showTotalProgress,showChapterProgress); + +@override +String toString() { + return 'ExpandedPlayerSettings(showTotalProgress: $showTotalProgress, showChapterProgress: $showChapterProgress)'; +} + - /// Create a copy of ExpandedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ExpandedPlayerSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $ExpandedPlayerSettingsCopyWith<$Res> { - factory $ExpandedPlayerSettingsCopyWith(ExpandedPlayerSettings value, - $Res Function(ExpandedPlayerSettings) then) = - _$ExpandedPlayerSettingsCopyWithImpl<$Res, ExpandedPlayerSettings>; - @useResult - $Res call({bool showTotalProgress, bool showChapterProgress}); -} +abstract mixin class $ExpandedPlayerSettingsCopyWith<$Res> { + factory $ExpandedPlayerSettingsCopyWith(ExpandedPlayerSettings value, $Res Function(ExpandedPlayerSettings) _then) = _$ExpandedPlayerSettingsCopyWithImpl; +@useResult +$Res call({ + bool showTotalProgress, bool showChapterProgress +}); + + + +} /// @nodoc -class _$ExpandedPlayerSettingsCopyWithImpl<$Res, - $Val extends ExpandedPlayerSettings> +class _$ExpandedPlayerSettingsCopyWithImpl<$Res> implements $ExpandedPlayerSettingsCopyWith<$Res> { - _$ExpandedPlayerSettingsCopyWithImpl(this._value, this._then); + _$ExpandedPlayerSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final ExpandedPlayerSettings _self; + final $Res Function(ExpandedPlayerSettings) _then; - /// Create a copy of ExpandedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? showTotalProgress = null, - Object? showChapterProgress = null, - }) { - return _then(_value.copyWith( - showTotalProgress: null == showTotalProgress - ? _value.showTotalProgress - : showTotalProgress // ignore: cast_nullable_to_non_nullable - as bool, - showChapterProgress: null == showChapterProgress - ? _value.showChapterProgress - : showChapterProgress // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } +/// Create a copy of ExpandedPlayerSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? showTotalProgress = null,Object? showChapterProgress = null,}) { + return _then(_self.copyWith( +showTotalProgress: null == showTotalProgress ? _self.showTotalProgress : showTotalProgress // ignore: cast_nullable_to_non_nullable +as bool,showChapterProgress: null == showChapterProgress ? _self.showChapterProgress : showChapterProgress // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$ExpandedPlayerSettingsImplCopyWith<$Res> - implements $ExpandedPlayerSettingsCopyWith<$Res> { - factory _$$ExpandedPlayerSettingsImplCopyWith( - _$ExpandedPlayerSettingsImpl value, - $Res Function(_$ExpandedPlayerSettingsImpl) then) = - __$$ExpandedPlayerSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({bool showTotalProgress, bool showChapterProgress}); } -/// @nodoc -class __$$ExpandedPlayerSettingsImplCopyWithImpl<$Res> - extends _$ExpandedPlayerSettingsCopyWithImpl<$Res, - _$ExpandedPlayerSettingsImpl> - implements _$$ExpandedPlayerSettingsImplCopyWith<$Res> { - __$$ExpandedPlayerSettingsImplCopyWithImpl( - _$ExpandedPlayerSettingsImpl _value, - $Res Function(_$ExpandedPlayerSettingsImpl) _then) - : super(_value, _then); - /// Create a copy of ExpandedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? showTotalProgress = null, - Object? showChapterProgress = null, - }) { - return _then(_$ExpandedPlayerSettingsImpl( - showTotalProgress: null == showTotalProgress - ? _value.showTotalProgress - : showTotalProgress // ignore: cast_nullable_to_non_nullable - as bool, - showChapterProgress: null == showChapterProgress - ? _value.showChapterProgress - : showChapterProgress // ignore: cast_nullable_to_non_nullable - as bool, - )); - } +/// Adds pattern-matching-related methods to [ExpandedPlayerSettings]. +extension ExpandedPlayerSettingsPatterns on ExpandedPlayerSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _ExpandedPlayerSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ExpandedPlayerSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _ExpandedPlayerSettings value) $default,){ +final _that = this; +switch (_that) { +case _ExpandedPlayerSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _ExpandedPlayerSettings value)? $default,){ +final _that = this; +switch (_that) { +case _ExpandedPlayerSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( bool showTotalProgress, bool showChapterProgress)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ExpandedPlayerSettings() when $default != null: +return $default(_that.showTotalProgress,_that.showChapterProgress);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( bool showTotalProgress, bool showChapterProgress) $default,) {final _that = this; +switch (_that) { +case _ExpandedPlayerSettings(): +return $default(_that.showTotalProgress,_that.showChapterProgress);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool showTotalProgress, bool showChapterProgress)? $default,) {final _that = this; +switch (_that) { +case _ExpandedPlayerSettings() when $default != null: +return $default(_that.showTotalProgress,_that.showChapterProgress);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$ExpandedPlayerSettingsImpl implements _ExpandedPlayerSettings { - const _$ExpandedPlayerSettingsImpl( - {this.showTotalProgress = false, this.showChapterProgress = true}); - factory _$ExpandedPlayerSettingsImpl.fromJson(Map json) => - _$$ExpandedPlayerSettingsImplFromJson(json); +class _ExpandedPlayerSettings implements ExpandedPlayerSettings { + const _ExpandedPlayerSettings({this.showTotalProgress = false, this.showChapterProgress = true}); + factory _ExpandedPlayerSettings.fromJson(Map json) => _$ExpandedPlayerSettingsFromJson(json); - @override - @JsonKey() - final bool showTotalProgress; - @override - @JsonKey() - final bool showChapterProgress; +@override@JsonKey() final bool showTotalProgress; +@override@JsonKey() final bool showChapterProgress; - @override - String toString() { - return 'ExpandedPlayerSettings(showTotalProgress: $showTotalProgress, showChapterProgress: $showChapterProgress)'; - } +/// Create a copy of ExpandedPlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExpandedPlayerSettingsCopyWith<_ExpandedPlayerSettings> get copyWith => __$ExpandedPlayerSettingsCopyWithImpl<_ExpandedPlayerSettings>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ExpandedPlayerSettingsImpl && - (identical(other.showTotalProgress, showTotalProgress) || - other.showTotalProgress == showTotalProgress) && - (identical(other.showChapterProgress, showChapterProgress) || - other.showChapterProgress == showChapterProgress)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, showTotalProgress, showChapterProgress); - - /// Create a copy of ExpandedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ExpandedPlayerSettingsImplCopyWith<_$ExpandedPlayerSettingsImpl> - get copyWith => __$$ExpandedPlayerSettingsImplCopyWithImpl< - _$ExpandedPlayerSettingsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$ExpandedPlayerSettingsImplToJson( - this, - ); - } +@override +Map toJson() { + return _$ExpandedPlayerSettingsToJson(this, ); } -abstract class _ExpandedPlayerSettings implements ExpandedPlayerSettings { - const factory _ExpandedPlayerSettings( - {final bool showTotalProgress, - final bool showChapterProgress}) = _$ExpandedPlayerSettingsImpl; - - factory _ExpandedPlayerSettings.fromJson(Map json) = - _$ExpandedPlayerSettingsImpl.fromJson; - - @override - bool get showTotalProgress; - @override - bool get showChapterProgress; - - /// Create a copy of ExpandedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ExpandedPlayerSettingsImplCopyWith<_$ExpandedPlayerSettingsImpl> - get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ExpandedPlayerSettings&&(identical(other.showTotalProgress, showTotalProgress) || other.showTotalProgress == showTotalProgress)&&(identical(other.showChapterProgress, showChapterProgress) || other.showChapterProgress == showChapterProgress)); } -MinimizedPlayerSettings _$MinimizedPlayerSettingsFromJson( - Map json) { - return _MinimizedPlayerSettings.fromJson(json); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,showTotalProgress,showChapterProgress); + +@override +String toString() { + return 'ExpandedPlayerSettings(showTotalProgress: $showTotalProgress, showChapterProgress: $showChapterProgress)'; } + +} + +/// @nodoc +abstract mixin class _$ExpandedPlayerSettingsCopyWith<$Res> implements $ExpandedPlayerSettingsCopyWith<$Res> { + factory _$ExpandedPlayerSettingsCopyWith(_ExpandedPlayerSettings value, $Res Function(_ExpandedPlayerSettings) _then) = __$ExpandedPlayerSettingsCopyWithImpl; +@override @useResult +$Res call({ + bool showTotalProgress, bool showChapterProgress +}); + + + + +} +/// @nodoc +class __$ExpandedPlayerSettingsCopyWithImpl<$Res> + implements _$ExpandedPlayerSettingsCopyWith<$Res> { + __$ExpandedPlayerSettingsCopyWithImpl(this._self, this._then); + + final _ExpandedPlayerSettings _self; + final $Res Function(_ExpandedPlayerSettings) _then; + +/// Create a copy of ExpandedPlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? showTotalProgress = null,Object? showChapterProgress = null,}) { + return _then(_ExpandedPlayerSettings( +showTotalProgress: null == showTotalProgress ? _self.showTotalProgress : showTotalProgress // ignore: cast_nullable_to_non_nullable +as bool,showChapterProgress: null == showChapterProgress ? _self.showChapterProgress : showChapterProgress // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + + /// @nodoc mixin _$MinimizedPlayerSettings { - bool get useChapterInfo => throw _privateConstructorUsedError; + + bool get useChapterInfo; +/// Create a copy of MinimizedPlayerSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$MinimizedPlayerSettingsCopyWith get copyWith => _$MinimizedPlayerSettingsCopyWithImpl(this as MinimizedPlayerSettings, _$identity); /// Serializes this MinimizedPlayerSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is MinimizedPlayerSettings&&(identical(other.useChapterInfo, useChapterInfo) || other.useChapterInfo == useChapterInfo)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,useChapterInfo); + +@override +String toString() { + return 'MinimizedPlayerSettings(useChapterInfo: $useChapterInfo)'; +} + - /// Create a copy of MinimizedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $MinimizedPlayerSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $MinimizedPlayerSettingsCopyWith<$Res> { - factory $MinimizedPlayerSettingsCopyWith(MinimizedPlayerSettings value, - $Res Function(MinimizedPlayerSettings) then) = - _$MinimizedPlayerSettingsCopyWithImpl<$Res, MinimizedPlayerSettings>; - @useResult - $Res call({bool useChapterInfo}); -} +abstract mixin class $MinimizedPlayerSettingsCopyWith<$Res> { + factory $MinimizedPlayerSettingsCopyWith(MinimizedPlayerSettings value, $Res Function(MinimizedPlayerSettings) _then) = _$MinimizedPlayerSettingsCopyWithImpl; +@useResult +$Res call({ + bool useChapterInfo +}); + + + +} /// @nodoc -class _$MinimizedPlayerSettingsCopyWithImpl<$Res, - $Val extends MinimizedPlayerSettings> +class _$MinimizedPlayerSettingsCopyWithImpl<$Res> implements $MinimizedPlayerSettingsCopyWith<$Res> { - _$MinimizedPlayerSettingsCopyWithImpl(this._value, this._then); + _$MinimizedPlayerSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final MinimizedPlayerSettings _self; + final $Res Function(MinimizedPlayerSettings) _then; - /// Create a copy of MinimizedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? useChapterInfo = null, - }) { - return _then(_value.copyWith( - useChapterInfo: null == useChapterInfo - ? _value.useChapterInfo - : useChapterInfo // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } +/// Create a copy of MinimizedPlayerSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? useChapterInfo = null,}) { + return _then(_self.copyWith( +useChapterInfo: null == useChapterInfo ? _self.useChapterInfo : useChapterInfo // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$MinimizedPlayerSettingsImplCopyWith<$Res> - implements $MinimizedPlayerSettingsCopyWith<$Res> { - factory _$$MinimizedPlayerSettingsImplCopyWith( - _$MinimizedPlayerSettingsImpl value, - $Res Function(_$MinimizedPlayerSettingsImpl) then) = - __$$MinimizedPlayerSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({bool useChapterInfo}); } -/// @nodoc -class __$$MinimizedPlayerSettingsImplCopyWithImpl<$Res> - extends _$MinimizedPlayerSettingsCopyWithImpl<$Res, - _$MinimizedPlayerSettingsImpl> - implements _$$MinimizedPlayerSettingsImplCopyWith<$Res> { - __$$MinimizedPlayerSettingsImplCopyWithImpl( - _$MinimizedPlayerSettingsImpl _value, - $Res Function(_$MinimizedPlayerSettingsImpl) _then) - : super(_value, _then); - /// Create a copy of MinimizedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? useChapterInfo = null, - }) { - return _then(_$MinimizedPlayerSettingsImpl( - useChapterInfo: null == useChapterInfo - ? _value.useChapterInfo - : useChapterInfo // ignore: cast_nullable_to_non_nullable - as bool, - )); - } +/// Adds pattern-matching-related methods to [MinimizedPlayerSettings]. +extension MinimizedPlayerSettingsPatterns on MinimizedPlayerSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _MinimizedPlayerSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _MinimizedPlayerSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _MinimizedPlayerSettings value) $default,){ +final _that = this; +switch (_that) { +case _MinimizedPlayerSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _MinimizedPlayerSettings value)? $default,){ +final _that = this; +switch (_that) { +case _MinimizedPlayerSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( bool useChapterInfo)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _MinimizedPlayerSettings() when $default != null: +return $default(_that.useChapterInfo);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( bool useChapterInfo) $default,) {final _that = this; +switch (_that) { +case _MinimizedPlayerSettings(): +return $default(_that.useChapterInfo);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool useChapterInfo)? $default,) {final _that = this; +switch (_that) { +case _MinimizedPlayerSettings() when $default != null: +return $default(_that.useChapterInfo);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$MinimizedPlayerSettingsImpl implements _MinimizedPlayerSettings { - const _$MinimizedPlayerSettingsImpl({this.useChapterInfo = false}); - factory _$MinimizedPlayerSettingsImpl.fromJson(Map json) => - _$$MinimizedPlayerSettingsImplFromJson(json); +class _MinimizedPlayerSettings implements MinimizedPlayerSettings { + const _MinimizedPlayerSettings({this.useChapterInfo = false}); + factory _MinimizedPlayerSettings.fromJson(Map json) => _$MinimizedPlayerSettingsFromJson(json); - @override - @JsonKey() - final bool useChapterInfo; +@override@JsonKey() final bool useChapterInfo; - @override - String toString() { - return 'MinimizedPlayerSettings(useChapterInfo: $useChapterInfo)'; - } +/// Create a copy of MinimizedPlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$MinimizedPlayerSettingsCopyWith<_MinimizedPlayerSettings> get copyWith => __$MinimizedPlayerSettingsCopyWithImpl<_MinimizedPlayerSettings>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MinimizedPlayerSettingsImpl && - (identical(other.useChapterInfo, useChapterInfo) || - other.useChapterInfo == useChapterInfo)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, useChapterInfo); - - /// Create a copy of MinimizedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$MinimizedPlayerSettingsImplCopyWith<_$MinimizedPlayerSettingsImpl> - get copyWith => __$$MinimizedPlayerSettingsImplCopyWithImpl< - _$MinimizedPlayerSettingsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$MinimizedPlayerSettingsImplToJson( - this, - ); - } +@override +Map toJson() { + return _$MinimizedPlayerSettingsToJson(this, ); } -abstract class _MinimizedPlayerSettings implements MinimizedPlayerSettings { - const factory _MinimizedPlayerSettings({final bool useChapterInfo}) = - _$MinimizedPlayerSettingsImpl; - - factory _MinimizedPlayerSettings.fromJson(Map json) = - _$MinimizedPlayerSettingsImpl.fromJson; - - @override - bool get useChapterInfo; - - /// Create a copy of MinimizedPlayerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$MinimizedPlayerSettingsImplCopyWith<_$MinimizedPlayerSettingsImpl> - get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _MinimizedPlayerSettings&&(identical(other.useChapterInfo, useChapterInfo) || other.useChapterInfo == useChapterInfo)); } -SleepTimerSettings _$SleepTimerSettingsFromJson(Map json) { - return _SleepTimerSettings.fromJson(json); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,useChapterInfo); + +@override +String toString() { + return 'MinimizedPlayerSettings(useChapterInfo: $useChapterInfo)'; } + +} + +/// @nodoc +abstract mixin class _$MinimizedPlayerSettingsCopyWith<$Res> implements $MinimizedPlayerSettingsCopyWith<$Res> { + factory _$MinimizedPlayerSettingsCopyWith(_MinimizedPlayerSettings value, $Res Function(_MinimizedPlayerSettings) _then) = __$MinimizedPlayerSettingsCopyWithImpl; +@override @useResult +$Res call({ + bool useChapterInfo +}); + + + + +} +/// @nodoc +class __$MinimizedPlayerSettingsCopyWithImpl<$Res> + implements _$MinimizedPlayerSettingsCopyWith<$Res> { + __$MinimizedPlayerSettingsCopyWithImpl(this._self, this._then); + + final _MinimizedPlayerSettings _self; + final $Res Function(_MinimizedPlayerSettings) _then; + +/// Create a copy of MinimizedPlayerSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? useChapterInfo = null,}) { + return _then(_MinimizedPlayerSettings( +useChapterInfo: null == useChapterInfo ? _self.useChapterInfo : useChapterInfo // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + + /// @nodoc mixin _$SleepTimerSettings { - Duration get defaultDuration => throw _privateConstructorUsedError; - List get presetDurations => throw _privateConstructorUsedError; - Duration get maxDuration => throw _privateConstructorUsedError; - bool get fadeOutAudio => throw _privateConstructorUsedError; - Duration get fadeOutDuration => throw _privateConstructorUsedError; - /// if true, the player will automatically rewind the audio when the sleep timer is stopped - bool get autoRewindWhenStopped => throw _privateConstructorUsedError; - - /// the key is the duration in minutes - Map get autoRewindDurations => - throw _privateConstructorUsedError; - - /// auto turn on timer settings - bool get autoTurnOnTimer => throw _privateConstructorUsedError; - - /// always auto turn on timer settings or during specific times - bool get alwaysAutoTurnOnTimer => throw _privateConstructorUsedError; - - /// auto timer settings, only used if [alwaysAutoTurnOnTimer] is false - /// - /// duration is the time from 00:00 - Duration get autoTurnOnTime => throw _privateConstructorUsedError; - Duration get autoTurnOffTime => throw _privateConstructorUsedError; + Duration get defaultDuration; List get presetDurations; Duration get maxDuration; bool get fadeOutAudio; Duration get fadeOutDuration;/// if true, the player will automatically rewind the audio when the sleep timer is stopped + bool get autoRewindWhenStopped;/// the key is the duration in minutes + Map get autoRewindDurations;/// auto turn on timer settings + bool get autoTurnOnTimer;/// always auto turn on timer settings or during specific times + bool get alwaysAutoTurnOnTimer;/// auto timer settings, only used if [alwaysAutoTurnOnTimer] is false +/// +/// duration is the time from 00:00 + Duration get autoTurnOnTime; Duration get autoTurnOffTime; +/// Create a copy of SleepTimerSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SleepTimerSettingsCopyWith get copyWith => _$SleepTimerSettingsCopyWithImpl(this as SleepTimerSettings, _$identity); /// Serializes this SleepTimerSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SleepTimerSettings&&(identical(other.defaultDuration, defaultDuration) || other.defaultDuration == defaultDuration)&&const DeepCollectionEquality().equals(other.presetDurations, presetDurations)&&(identical(other.maxDuration, maxDuration) || other.maxDuration == maxDuration)&&(identical(other.fadeOutAudio, fadeOutAudio) || other.fadeOutAudio == fadeOutAudio)&&(identical(other.fadeOutDuration, fadeOutDuration) || other.fadeOutDuration == fadeOutDuration)&&(identical(other.autoRewindWhenStopped, autoRewindWhenStopped) || other.autoRewindWhenStopped == autoRewindWhenStopped)&&const DeepCollectionEquality().equals(other.autoRewindDurations, autoRewindDurations)&&(identical(other.autoTurnOnTimer, autoTurnOnTimer) || other.autoTurnOnTimer == autoTurnOnTimer)&&(identical(other.alwaysAutoTurnOnTimer, alwaysAutoTurnOnTimer) || other.alwaysAutoTurnOnTimer == alwaysAutoTurnOnTimer)&&(identical(other.autoTurnOnTime, autoTurnOnTime) || other.autoTurnOnTime == autoTurnOnTime)&&(identical(other.autoTurnOffTime, autoTurnOffTime) || other.autoTurnOffTime == autoTurnOffTime)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,defaultDuration,const DeepCollectionEquality().hash(presetDurations),maxDuration,fadeOutAudio,fadeOutDuration,autoRewindWhenStopped,const DeepCollectionEquality().hash(autoRewindDurations),autoTurnOnTimer,alwaysAutoTurnOnTimer,autoTurnOnTime,autoTurnOffTime); + +@override +String toString() { + return 'SleepTimerSettings(defaultDuration: $defaultDuration, presetDurations: $presetDurations, maxDuration: $maxDuration, fadeOutAudio: $fadeOutAudio, fadeOutDuration: $fadeOutDuration, autoRewindWhenStopped: $autoRewindWhenStopped, autoRewindDurations: $autoRewindDurations, autoTurnOnTimer: $autoTurnOnTimer, alwaysAutoTurnOnTimer: $alwaysAutoTurnOnTimer, autoTurnOnTime: $autoTurnOnTime, autoTurnOffTime: $autoTurnOffTime)'; +} + - /// Create a copy of SleepTimerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $SleepTimerSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $SleepTimerSettingsCopyWith<$Res> { - factory $SleepTimerSettingsCopyWith( - SleepTimerSettings value, $Res Function(SleepTimerSettings) then) = - _$SleepTimerSettingsCopyWithImpl<$Res, SleepTimerSettings>; - @useResult - $Res call( - {Duration defaultDuration, - List presetDurations, - Duration maxDuration, - bool fadeOutAudio, - Duration fadeOutDuration, - bool autoRewindWhenStopped, - Map autoRewindDurations, - bool autoTurnOnTimer, - bool alwaysAutoTurnOnTimer, - Duration autoTurnOnTime, - Duration autoTurnOffTime}); -} +abstract mixin class $SleepTimerSettingsCopyWith<$Res> { + factory $SleepTimerSettingsCopyWith(SleepTimerSettings value, $Res Function(SleepTimerSettings) _then) = _$SleepTimerSettingsCopyWithImpl; +@useResult +$Res call({ + Duration defaultDuration, List presetDurations, Duration maxDuration, bool fadeOutAudio, Duration fadeOutDuration, bool autoRewindWhenStopped, Map autoRewindDurations, bool autoTurnOnTimer, bool alwaysAutoTurnOnTimer, Duration autoTurnOnTime, Duration autoTurnOffTime +}); + + + +} /// @nodoc -class _$SleepTimerSettingsCopyWithImpl<$Res, $Val extends SleepTimerSettings> +class _$SleepTimerSettingsCopyWithImpl<$Res> implements $SleepTimerSettingsCopyWith<$Res> { - _$SleepTimerSettingsCopyWithImpl(this._value, this._then); + _$SleepTimerSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final SleepTimerSettings _self; + final $Res Function(SleepTimerSettings) _then; - /// Create a copy of SleepTimerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? defaultDuration = null, - Object? presetDurations = null, - Object? maxDuration = null, - Object? fadeOutAudio = null, - Object? fadeOutDuration = null, - Object? autoRewindWhenStopped = null, - Object? autoRewindDurations = null, - Object? autoTurnOnTimer = null, - Object? alwaysAutoTurnOnTimer = null, - Object? autoTurnOnTime = null, - Object? autoTurnOffTime = null, - }) { - return _then(_value.copyWith( - defaultDuration: null == defaultDuration - ? _value.defaultDuration - : defaultDuration // ignore: cast_nullable_to_non_nullable - as Duration, - presetDurations: null == presetDurations - ? _value.presetDurations - : presetDurations // ignore: cast_nullable_to_non_nullable - as List, - maxDuration: null == maxDuration - ? _value.maxDuration - : maxDuration // ignore: cast_nullable_to_non_nullable - as Duration, - fadeOutAudio: null == fadeOutAudio - ? _value.fadeOutAudio - : fadeOutAudio // ignore: cast_nullable_to_non_nullable - as bool, - fadeOutDuration: null == fadeOutDuration - ? _value.fadeOutDuration - : fadeOutDuration // ignore: cast_nullable_to_non_nullable - as Duration, - autoRewindWhenStopped: null == autoRewindWhenStopped - ? _value.autoRewindWhenStopped - : autoRewindWhenStopped // ignore: cast_nullable_to_non_nullable - as bool, - autoRewindDurations: null == autoRewindDurations - ? _value.autoRewindDurations - : autoRewindDurations // ignore: cast_nullable_to_non_nullable - as Map, - autoTurnOnTimer: null == autoTurnOnTimer - ? _value.autoTurnOnTimer - : autoTurnOnTimer // ignore: cast_nullable_to_non_nullable - as bool, - alwaysAutoTurnOnTimer: null == alwaysAutoTurnOnTimer - ? _value.alwaysAutoTurnOnTimer - : alwaysAutoTurnOnTimer // ignore: cast_nullable_to_non_nullable - as bool, - autoTurnOnTime: null == autoTurnOnTime - ? _value.autoTurnOnTime - : autoTurnOnTime // ignore: cast_nullable_to_non_nullable - as Duration, - autoTurnOffTime: null == autoTurnOffTime - ? _value.autoTurnOffTime - : autoTurnOffTime // ignore: cast_nullable_to_non_nullable - as Duration, - ) as $Val); - } +/// Create a copy of SleepTimerSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? defaultDuration = null,Object? presetDurations = null,Object? maxDuration = null,Object? fadeOutAudio = null,Object? fadeOutDuration = null,Object? autoRewindWhenStopped = null,Object? autoRewindDurations = null,Object? autoTurnOnTimer = null,Object? alwaysAutoTurnOnTimer = null,Object? autoTurnOnTime = null,Object? autoTurnOffTime = null,}) { + return _then(_self.copyWith( +defaultDuration: null == defaultDuration ? _self.defaultDuration : defaultDuration // ignore: cast_nullable_to_non_nullable +as Duration,presetDurations: null == presetDurations ? _self.presetDurations : presetDurations // ignore: cast_nullable_to_non_nullable +as List,maxDuration: null == maxDuration ? _self.maxDuration : maxDuration // ignore: cast_nullable_to_non_nullable +as Duration,fadeOutAudio: null == fadeOutAudio ? _self.fadeOutAudio : fadeOutAudio // ignore: cast_nullable_to_non_nullable +as bool,fadeOutDuration: null == fadeOutDuration ? _self.fadeOutDuration : fadeOutDuration // ignore: cast_nullable_to_non_nullable +as Duration,autoRewindWhenStopped: null == autoRewindWhenStopped ? _self.autoRewindWhenStopped : autoRewindWhenStopped // ignore: cast_nullable_to_non_nullable +as bool,autoRewindDurations: null == autoRewindDurations ? _self.autoRewindDurations : autoRewindDurations // ignore: cast_nullable_to_non_nullable +as Map,autoTurnOnTimer: null == autoTurnOnTimer ? _self.autoTurnOnTimer : autoTurnOnTimer // ignore: cast_nullable_to_non_nullable +as bool,alwaysAutoTurnOnTimer: null == alwaysAutoTurnOnTimer ? _self.alwaysAutoTurnOnTimer : alwaysAutoTurnOnTimer // ignore: cast_nullable_to_non_nullable +as bool,autoTurnOnTime: null == autoTurnOnTime ? _self.autoTurnOnTime : autoTurnOnTime // ignore: cast_nullable_to_non_nullable +as Duration,autoTurnOffTime: null == autoTurnOffTime ? _self.autoTurnOffTime : autoTurnOffTime // ignore: cast_nullable_to_non_nullable +as Duration, + )); } -/// @nodoc -abstract class _$$SleepTimerSettingsImplCopyWith<$Res> - implements $SleepTimerSettingsCopyWith<$Res> { - factory _$$SleepTimerSettingsImplCopyWith(_$SleepTimerSettingsImpl value, - $Res Function(_$SleepTimerSettingsImpl) then) = - __$$SleepTimerSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {Duration defaultDuration, - List presetDurations, - Duration maxDuration, - bool fadeOutAudio, - Duration fadeOutDuration, - bool autoRewindWhenStopped, - Map autoRewindDurations, - bool autoTurnOnTimer, - bool alwaysAutoTurnOnTimer, - Duration autoTurnOnTime, - Duration autoTurnOffTime}); } -/// @nodoc -class __$$SleepTimerSettingsImplCopyWithImpl<$Res> - extends _$SleepTimerSettingsCopyWithImpl<$Res, _$SleepTimerSettingsImpl> - implements _$$SleepTimerSettingsImplCopyWith<$Res> { - __$$SleepTimerSettingsImplCopyWithImpl(_$SleepTimerSettingsImpl _value, - $Res Function(_$SleepTimerSettingsImpl) _then) - : super(_value, _then); - /// Create a copy of SleepTimerSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? defaultDuration = null, - Object? presetDurations = null, - Object? maxDuration = null, - Object? fadeOutAudio = null, - Object? fadeOutDuration = null, - Object? autoRewindWhenStopped = null, - Object? autoRewindDurations = null, - Object? autoTurnOnTimer = null, - Object? alwaysAutoTurnOnTimer = null, - Object? autoTurnOnTime = null, - Object? autoTurnOffTime = null, - }) { - return _then(_$SleepTimerSettingsImpl( - defaultDuration: null == defaultDuration - ? _value.defaultDuration - : defaultDuration // ignore: cast_nullable_to_non_nullable - as Duration, - presetDurations: null == presetDurations - ? _value._presetDurations - : presetDurations // ignore: cast_nullable_to_non_nullable - as List, - maxDuration: null == maxDuration - ? _value.maxDuration - : maxDuration // ignore: cast_nullable_to_non_nullable - as Duration, - fadeOutAudio: null == fadeOutAudio - ? _value.fadeOutAudio - : fadeOutAudio // ignore: cast_nullable_to_non_nullable - as bool, - fadeOutDuration: null == fadeOutDuration - ? _value.fadeOutDuration - : fadeOutDuration // ignore: cast_nullable_to_non_nullable - as Duration, - autoRewindWhenStopped: null == autoRewindWhenStopped - ? _value.autoRewindWhenStopped - : autoRewindWhenStopped // ignore: cast_nullable_to_non_nullable - as bool, - autoRewindDurations: null == autoRewindDurations - ? _value._autoRewindDurations - : autoRewindDurations // ignore: cast_nullable_to_non_nullable - as Map, - autoTurnOnTimer: null == autoTurnOnTimer - ? _value.autoTurnOnTimer - : autoTurnOnTimer // ignore: cast_nullable_to_non_nullable - as bool, - alwaysAutoTurnOnTimer: null == alwaysAutoTurnOnTimer - ? _value.alwaysAutoTurnOnTimer - : alwaysAutoTurnOnTimer // ignore: cast_nullable_to_non_nullable - as bool, - autoTurnOnTime: null == autoTurnOnTime - ? _value.autoTurnOnTime - : autoTurnOnTime // ignore: cast_nullable_to_non_nullable - as Duration, - autoTurnOffTime: null == autoTurnOffTime - ? _value.autoTurnOffTime - : autoTurnOffTime // ignore: cast_nullable_to_non_nullable - as Duration, - )); - } +/// Adds pattern-matching-related methods to [SleepTimerSettings]. +extension SleepTimerSettingsPatterns on SleepTimerSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _SleepTimerSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _SleepTimerSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _SleepTimerSettings value) $default,){ +final _that = this; +switch (_that) { +case _SleepTimerSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _SleepTimerSettings value)? $default,){ +final _that = this; +switch (_that) { +case _SleepTimerSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( Duration defaultDuration, List presetDurations, Duration maxDuration, bool fadeOutAudio, Duration fadeOutDuration, bool autoRewindWhenStopped, Map autoRewindDurations, bool autoTurnOnTimer, bool alwaysAutoTurnOnTimer, Duration autoTurnOnTime, Duration autoTurnOffTime)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _SleepTimerSettings() when $default != null: +return $default(_that.defaultDuration,_that.presetDurations,_that.maxDuration,_that.fadeOutAudio,_that.fadeOutDuration,_that.autoRewindWhenStopped,_that.autoRewindDurations,_that.autoTurnOnTimer,_that.alwaysAutoTurnOnTimer,_that.autoTurnOnTime,_that.autoTurnOffTime);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( Duration defaultDuration, List presetDurations, Duration maxDuration, bool fadeOutAudio, Duration fadeOutDuration, bool autoRewindWhenStopped, Map autoRewindDurations, bool autoTurnOnTimer, bool alwaysAutoTurnOnTimer, Duration autoTurnOnTime, Duration autoTurnOffTime) $default,) {final _that = this; +switch (_that) { +case _SleepTimerSettings(): +return $default(_that.defaultDuration,_that.presetDurations,_that.maxDuration,_that.fadeOutAudio,_that.fadeOutDuration,_that.autoRewindWhenStopped,_that.autoRewindDurations,_that.autoTurnOnTimer,_that.alwaysAutoTurnOnTimer,_that.autoTurnOnTime,_that.autoTurnOffTime);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( Duration defaultDuration, List presetDurations, Duration maxDuration, bool fadeOutAudio, Duration fadeOutDuration, bool autoRewindWhenStopped, Map autoRewindDurations, bool autoTurnOnTimer, bool alwaysAutoTurnOnTimer, Duration autoTurnOnTime, Duration autoTurnOffTime)? $default,) {final _that = this; +switch (_that) { +case _SleepTimerSettings() when $default != null: +return $default(_that.defaultDuration,_that.presetDurations,_that.maxDuration,_that.fadeOutAudio,_that.fadeOutDuration,_that.autoRewindWhenStopped,_that.autoRewindDurations,_that.autoTurnOnTimer,_that.alwaysAutoTurnOnTimer,_that.autoTurnOnTime,_that.autoTurnOffTime);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$SleepTimerSettingsImpl implements _SleepTimerSettings { - const _$SleepTimerSettingsImpl( - {this.defaultDuration = const Duration(minutes: 15), - final List presetDurations = const [ - Duration(minutes: 5), - Duration(minutes: 10), - Duration(minutes: 15), - Duration(minutes: 20), - Duration(minutes: 30) - ], - this.maxDuration = const Duration(minutes: 100), - this.fadeOutAudio = false, - this.fadeOutDuration = const Duration(seconds: 20), - this.autoRewindWhenStopped = false, - final Map autoRewindDurations = const { - 5: Duration(seconds: 10), - 15: Duration(seconds: 30), - 45: Duration(seconds: 45), - 60: Duration(minutes: 1), - 120: Duration(minutes: 2) - }, - this.autoTurnOnTimer = false, - this.alwaysAutoTurnOnTimer = false, - this.autoTurnOnTime = const Duration(hours: 22, minutes: 0), - this.autoTurnOffTime = const Duration(hours: 6, minutes: 0)}) - : _presetDurations = presetDurations, - _autoRewindDurations = autoRewindDurations; - factory _$SleepTimerSettingsImpl.fromJson(Map json) => - _$$SleepTimerSettingsImplFromJson(json); +class _SleepTimerSettings implements SleepTimerSettings { + const _SleepTimerSettings({this.defaultDuration = const Duration(minutes: 15), final List presetDurations = const [Duration(minutes: 5), Duration(minutes: 10), Duration(minutes: 15), Duration(minutes: 20), Duration(minutes: 30)], this.maxDuration = const Duration(minutes: 100), this.fadeOutAudio = false, this.fadeOutDuration = const Duration(seconds: 20), this.autoRewindWhenStopped = false, final Map autoRewindDurations = const {5 : Duration(seconds: 10), 15 : Duration(seconds: 30), 45 : Duration(seconds: 45), 60 : Duration(minutes: 1), 120 : Duration(minutes: 2)}, this.autoTurnOnTimer = false, this.alwaysAutoTurnOnTimer = false, this.autoTurnOnTime = const Duration(hours: 22, minutes: 0), this.autoTurnOffTime = const Duration(hours: 6, minutes: 0)}): _presetDurations = presetDurations,_autoRewindDurations = autoRewindDurations; + factory _SleepTimerSettings.fromJson(Map json) => _$SleepTimerSettingsFromJson(json); - @override - @JsonKey() - final Duration defaultDuration; - final List _presetDurations; - @override - @JsonKey() - List get presetDurations { - if (_presetDurations is EqualUnmodifiableListView) return _presetDurations; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_presetDurations); - } - - @override - @JsonKey() - final Duration maxDuration; - @override - @JsonKey() - final bool fadeOutAudio; - @override - @JsonKey() - final Duration fadeOutDuration; - - /// if true, the player will automatically rewind the audio when the sleep timer is stopped - @override - @JsonKey() - final bool autoRewindWhenStopped; - - /// the key is the duration in minutes - final Map _autoRewindDurations; - - /// the key is the duration in minutes - @override - @JsonKey() - Map get autoRewindDurations { - if (_autoRewindDurations is EqualUnmodifiableMapView) - return _autoRewindDurations; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_autoRewindDurations); - } - - /// auto turn on timer settings - @override - @JsonKey() - final bool autoTurnOnTimer; - - /// always auto turn on timer settings or during specific times - @override - @JsonKey() - final bool alwaysAutoTurnOnTimer; - - /// auto timer settings, only used if [alwaysAutoTurnOnTimer] is false - /// - /// duration is the time from 00:00 - @override - @JsonKey() - final Duration autoTurnOnTime; - @override - @JsonKey() - final Duration autoTurnOffTime; - - @override - String toString() { - return 'SleepTimerSettings(defaultDuration: $defaultDuration, presetDurations: $presetDurations, maxDuration: $maxDuration, fadeOutAudio: $fadeOutAudio, fadeOutDuration: $fadeOutDuration, autoRewindWhenStopped: $autoRewindWhenStopped, autoRewindDurations: $autoRewindDurations, autoTurnOnTimer: $autoTurnOnTimer, alwaysAutoTurnOnTimer: $alwaysAutoTurnOnTimer, autoTurnOnTime: $autoTurnOnTime, autoTurnOffTime: $autoTurnOffTime)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$SleepTimerSettingsImpl && - (identical(other.defaultDuration, defaultDuration) || - other.defaultDuration == defaultDuration) && - const DeepCollectionEquality() - .equals(other._presetDurations, _presetDurations) && - (identical(other.maxDuration, maxDuration) || - other.maxDuration == maxDuration) && - (identical(other.fadeOutAudio, fadeOutAudio) || - other.fadeOutAudio == fadeOutAudio) && - (identical(other.fadeOutDuration, fadeOutDuration) || - other.fadeOutDuration == fadeOutDuration) && - (identical(other.autoRewindWhenStopped, autoRewindWhenStopped) || - other.autoRewindWhenStopped == autoRewindWhenStopped) && - const DeepCollectionEquality() - .equals(other._autoRewindDurations, _autoRewindDurations) && - (identical(other.autoTurnOnTimer, autoTurnOnTimer) || - other.autoTurnOnTimer == autoTurnOnTimer) && - (identical(other.alwaysAutoTurnOnTimer, alwaysAutoTurnOnTimer) || - other.alwaysAutoTurnOnTimer == alwaysAutoTurnOnTimer) && - (identical(other.autoTurnOnTime, autoTurnOnTime) || - other.autoTurnOnTime == autoTurnOnTime) && - (identical(other.autoTurnOffTime, autoTurnOffTime) || - other.autoTurnOffTime == autoTurnOffTime)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - defaultDuration, - const DeepCollectionEquality().hash(_presetDurations), - maxDuration, - fadeOutAudio, - fadeOutDuration, - autoRewindWhenStopped, - const DeepCollectionEquality().hash(_autoRewindDurations), - autoTurnOnTimer, - alwaysAutoTurnOnTimer, - autoTurnOnTime, - autoTurnOffTime); - - /// Create a copy of SleepTimerSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$SleepTimerSettingsImplCopyWith<_$SleepTimerSettingsImpl> get copyWith => - __$$SleepTimerSettingsImplCopyWithImpl<_$SleepTimerSettingsImpl>( - this, _$identity); - - @override - Map toJson() { - return _$$SleepTimerSettingsImplToJson( - this, - ); - } +@override@JsonKey() final Duration defaultDuration; + final List _presetDurations; +@override@JsonKey() List get presetDurations { + if (_presetDurations is EqualUnmodifiableListView) return _presetDurations; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_presetDurations); } -abstract class _SleepTimerSettings implements SleepTimerSettings { - const factory _SleepTimerSettings( - {final Duration defaultDuration, - final List presetDurations, - final Duration maxDuration, - final bool fadeOutAudio, - final Duration fadeOutDuration, - final bool autoRewindWhenStopped, - final Map autoRewindDurations, - final bool autoTurnOnTimer, - final bool alwaysAutoTurnOnTimer, - final Duration autoTurnOnTime, - final Duration autoTurnOffTime}) = _$SleepTimerSettingsImpl; - - factory _SleepTimerSettings.fromJson(Map json) = - _$SleepTimerSettingsImpl.fromJson; - - @override - Duration get defaultDuration; - @override - List get presetDurations; - @override - Duration get maxDuration; - @override - bool get fadeOutAudio; - @override - Duration get fadeOutDuration; - - /// if true, the player will automatically rewind the audio when the sleep timer is stopped - @override - bool get autoRewindWhenStopped; - - /// the key is the duration in minutes - @override - Map get autoRewindDurations; - - /// auto turn on timer settings - @override - bool get autoTurnOnTimer; - - /// always auto turn on timer settings or during specific times - @override - bool get alwaysAutoTurnOnTimer; - - /// auto timer settings, only used if [alwaysAutoTurnOnTimer] is false - /// - /// duration is the time from 00:00 - @override - Duration get autoTurnOnTime; - @override - Duration get autoTurnOffTime; - - /// Create a copy of SleepTimerSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$SleepTimerSettingsImplCopyWith<_$SleepTimerSettingsImpl> get copyWith => - throw _privateConstructorUsedError; +@override@JsonKey() final Duration maxDuration; +@override@JsonKey() final bool fadeOutAudio; +@override@JsonKey() final Duration fadeOutDuration; +/// if true, the player will automatically rewind the audio when the sleep timer is stopped +@override@JsonKey() final bool autoRewindWhenStopped; +/// the key is the duration in minutes + final Map _autoRewindDurations; +/// the key is the duration in minutes +@override@JsonKey() Map get autoRewindDurations { + if (_autoRewindDurations is EqualUnmodifiableMapView) return _autoRewindDurations; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_autoRewindDurations); } -DownloadSettings _$DownloadSettingsFromJson(Map json) { - return _DownloadSettings.fromJson(json); +/// auto turn on timer settings +@override@JsonKey() final bool autoTurnOnTimer; +/// always auto turn on timer settings or during specific times +@override@JsonKey() final bool alwaysAutoTurnOnTimer; +/// auto timer settings, only used if [alwaysAutoTurnOnTimer] is false +/// +/// duration is the time from 00:00 +@override@JsonKey() final Duration autoTurnOnTime; +@override@JsonKey() final Duration autoTurnOffTime; + +/// Create a copy of SleepTimerSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SleepTimerSettingsCopyWith<_SleepTimerSettings> get copyWith => __$SleepTimerSettingsCopyWithImpl<_SleepTimerSettings>(this, _$identity); + +@override +Map toJson() { + return _$SleepTimerSettingsToJson(this, ); } +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SleepTimerSettings&&(identical(other.defaultDuration, defaultDuration) || other.defaultDuration == defaultDuration)&&const DeepCollectionEquality().equals(other._presetDurations, _presetDurations)&&(identical(other.maxDuration, maxDuration) || other.maxDuration == maxDuration)&&(identical(other.fadeOutAudio, fadeOutAudio) || other.fadeOutAudio == fadeOutAudio)&&(identical(other.fadeOutDuration, fadeOutDuration) || other.fadeOutDuration == fadeOutDuration)&&(identical(other.autoRewindWhenStopped, autoRewindWhenStopped) || other.autoRewindWhenStopped == autoRewindWhenStopped)&&const DeepCollectionEquality().equals(other._autoRewindDurations, _autoRewindDurations)&&(identical(other.autoTurnOnTimer, autoTurnOnTimer) || other.autoTurnOnTimer == autoTurnOnTimer)&&(identical(other.alwaysAutoTurnOnTimer, alwaysAutoTurnOnTimer) || other.alwaysAutoTurnOnTimer == alwaysAutoTurnOnTimer)&&(identical(other.autoTurnOnTime, autoTurnOnTime) || other.autoTurnOnTime == autoTurnOnTime)&&(identical(other.autoTurnOffTime, autoTurnOffTime) || other.autoTurnOffTime == autoTurnOffTime)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,defaultDuration,const DeepCollectionEquality().hash(_presetDurations),maxDuration,fadeOutAudio,fadeOutDuration,autoRewindWhenStopped,const DeepCollectionEquality().hash(_autoRewindDurations),autoTurnOnTimer,alwaysAutoTurnOnTimer,autoTurnOnTime,autoTurnOffTime); + +@override +String toString() { + return 'SleepTimerSettings(defaultDuration: $defaultDuration, presetDurations: $presetDurations, maxDuration: $maxDuration, fadeOutAudio: $fadeOutAudio, fadeOutDuration: $fadeOutDuration, autoRewindWhenStopped: $autoRewindWhenStopped, autoRewindDurations: $autoRewindDurations, autoTurnOnTimer: $autoTurnOnTimer, alwaysAutoTurnOnTimer: $alwaysAutoTurnOnTimer, autoTurnOnTime: $autoTurnOnTime, autoTurnOffTime: $autoTurnOffTime)'; +} + + +} + +/// @nodoc +abstract mixin class _$SleepTimerSettingsCopyWith<$Res> implements $SleepTimerSettingsCopyWith<$Res> { + factory _$SleepTimerSettingsCopyWith(_SleepTimerSettings value, $Res Function(_SleepTimerSettings) _then) = __$SleepTimerSettingsCopyWithImpl; +@override @useResult +$Res call({ + Duration defaultDuration, List presetDurations, Duration maxDuration, bool fadeOutAudio, Duration fadeOutDuration, bool autoRewindWhenStopped, Map autoRewindDurations, bool autoTurnOnTimer, bool alwaysAutoTurnOnTimer, Duration autoTurnOnTime, Duration autoTurnOffTime +}); + + + + +} +/// @nodoc +class __$SleepTimerSettingsCopyWithImpl<$Res> + implements _$SleepTimerSettingsCopyWith<$Res> { + __$SleepTimerSettingsCopyWithImpl(this._self, this._then); + + final _SleepTimerSettings _self; + final $Res Function(_SleepTimerSettings) _then; + +/// Create a copy of SleepTimerSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? defaultDuration = null,Object? presetDurations = null,Object? maxDuration = null,Object? fadeOutAudio = null,Object? fadeOutDuration = null,Object? autoRewindWhenStopped = null,Object? autoRewindDurations = null,Object? autoTurnOnTimer = null,Object? alwaysAutoTurnOnTimer = null,Object? autoTurnOnTime = null,Object? autoTurnOffTime = null,}) { + return _then(_SleepTimerSettings( +defaultDuration: null == defaultDuration ? _self.defaultDuration : defaultDuration // ignore: cast_nullable_to_non_nullable +as Duration,presetDurations: null == presetDurations ? _self._presetDurations : presetDurations // ignore: cast_nullable_to_non_nullable +as List,maxDuration: null == maxDuration ? _self.maxDuration : maxDuration // ignore: cast_nullable_to_non_nullable +as Duration,fadeOutAudio: null == fadeOutAudio ? _self.fadeOutAudio : fadeOutAudio // ignore: cast_nullable_to_non_nullable +as bool,fadeOutDuration: null == fadeOutDuration ? _self.fadeOutDuration : fadeOutDuration // ignore: cast_nullable_to_non_nullable +as Duration,autoRewindWhenStopped: null == autoRewindWhenStopped ? _self.autoRewindWhenStopped : autoRewindWhenStopped // ignore: cast_nullable_to_non_nullable +as bool,autoRewindDurations: null == autoRewindDurations ? _self._autoRewindDurations : autoRewindDurations // ignore: cast_nullable_to_non_nullable +as Map,autoTurnOnTimer: null == autoTurnOnTimer ? _self.autoTurnOnTimer : autoTurnOnTimer // ignore: cast_nullable_to_non_nullable +as bool,alwaysAutoTurnOnTimer: null == alwaysAutoTurnOnTimer ? _self.alwaysAutoTurnOnTimer : alwaysAutoTurnOnTimer // ignore: cast_nullable_to_non_nullable +as bool,autoTurnOnTime: null == autoTurnOnTime ? _self.autoTurnOnTime : autoTurnOnTime // ignore: cast_nullable_to_non_nullable +as Duration,autoTurnOffTime: null == autoTurnOffTime ? _self.autoTurnOffTime : autoTurnOffTime // ignore: cast_nullable_to_non_nullable +as Duration, + )); +} + + +} + + /// @nodoc mixin _$DownloadSettings { - bool get requiresWiFi => throw _privateConstructorUsedError; - int get retries => throw _privateConstructorUsedError; - bool get allowPause => throw _privateConstructorUsedError; - int get maxConcurrent => throw _privateConstructorUsedError; - int get maxConcurrentByHost => throw _privateConstructorUsedError; - int get maxConcurrentByGroup => throw _privateConstructorUsedError; + + bool get requiresWiFi; int get retries; bool get allowPause; int get maxConcurrent; int get maxConcurrentByHost; int get maxConcurrentByGroup; +/// Create a copy of DownloadSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$DownloadSettingsCopyWith get copyWith => _$DownloadSettingsCopyWithImpl(this as DownloadSettings, _$identity); /// Serializes this DownloadSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is DownloadSettings&&(identical(other.requiresWiFi, requiresWiFi) || other.requiresWiFi == requiresWiFi)&&(identical(other.retries, retries) || other.retries == retries)&&(identical(other.allowPause, allowPause) || other.allowPause == allowPause)&&(identical(other.maxConcurrent, maxConcurrent) || other.maxConcurrent == maxConcurrent)&&(identical(other.maxConcurrentByHost, maxConcurrentByHost) || other.maxConcurrentByHost == maxConcurrentByHost)&&(identical(other.maxConcurrentByGroup, maxConcurrentByGroup) || other.maxConcurrentByGroup == maxConcurrentByGroup)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,requiresWiFi,retries,allowPause,maxConcurrent,maxConcurrentByHost,maxConcurrentByGroup); + +@override +String toString() { + return 'DownloadSettings(requiresWiFi: $requiresWiFi, retries: $retries, allowPause: $allowPause, maxConcurrent: $maxConcurrent, maxConcurrentByHost: $maxConcurrentByHost, maxConcurrentByGroup: $maxConcurrentByGroup)'; +} + - /// Create a copy of DownloadSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $DownloadSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $DownloadSettingsCopyWith<$Res> { - factory $DownloadSettingsCopyWith( - DownloadSettings value, $Res Function(DownloadSettings) then) = - _$DownloadSettingsCopyWithImpl<$Res, DownloadSettings>; - @useResult - $Res call( - {bool requiresWiFi, - int retries, - bool allowPause, - int maxConcurrent, - int maxConcurrentByHost, - int maxConcurrentByGroup}); -} +abstract mixin class $DownloadSettingsCopyWith<$Res> { + factory $DownloadSettingsCopyWith(DownloadSettings value, $Res Function(DownloadSettings) _then) = _$DownloadSettingsCopyWithImpl; +@useResult +$Res call({ + bool requiresWiFi, int retries, bool allowPause, int maxConcurrent, int maxConcurrentByHost, int maxConcurrentByGroup +}); + + + +} /// @nodoc -class _$DownloadSettingsCopyWithImpl<$Res, $Val extends DownloadSettings> +class _$DownloadSettingsCopyWithImpl<$Res> implements $DownloadSettingsCopyWith<$Res> { - _$DownloadSettingsCopyWithImpl(this._value, this._then); + _$DownloadSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final DownloadSettings _self; + final $Res Function(DownloadSettings) _then; - /// Create a copy of DownloadSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? requiresWiFi = null, - Object? retries = null, - Object? allowPause = null, - Object? maxConcurrent = null, - Object? maxConcurrentByHost = null, - Object? maxConcurrentByGroup = null, - }) { - return _then(_value.copyWith( - requiresWiFi: null == requiresWiFi - ? _value.requiresWiFi - : requiresWiFi // ignore: cast_nullable_to_non_nullable - as bool, - retries: null == retries - ? _value.retries - : retries // ignore: cast_nullable_to_non_nullable - as int, - allowPause: null == allowPause - ? _value.allowPause - : allowPause // ignore: cast_nullable_to_non_nullable - as bool, - maxConcurrent: null == maxConcurrent - ? _value.maxConcurrent - : maxConcurrent // ignore: cast_nullable_to_non_nullable - as int, - maxConcurrentByHost: null == maxConcurrentByHost - ? _value.maxConcurrentByHost - : maxConcurrentByHost // ignore: cast_nullable_to_non_nullable - as int, - maxConcurrentByGroup: null == maxConcurrentByGroup - ? _value.maxConcurrentByGroup - : maxConcurrentByGroup // ignore: cast_nullable_to_non_nullable - as int, - ) as $Val); - } +/// Create a copy of DownloadSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? requiresWiFi = null,Object? retries = null,Object? allowPause = null,Object? maxConcurrent = null,Object? maxConcurrentByHost = null,Object? maxConcurrentByGroup = null,}) { + return _then(_self.copyWith( +requiresWiFi: null == requiresWiFi ? _self.requiresWiFi : requiresWiFi // ignore: cast_nullable_to_non_nullable +as bool,retries: null == retries ? _self.retries : retries // ignore: cast_nullable_to_non_nullable +as int,allowPause: null == allowPause ? _self.allowPause : allowPause // ignore: cast_nullable_to_non_nullable +as bool,maxConcurrent: null == maxConcurrent ? _self.maxConcurrent : maxConcurrent // ignore: cast_nullable_to_non_nullable +as int,maxConcurrentByHost: null == maxConcurrentByHost ? _self.maxConcurrentByHost : maxConcurrentByHost // ignore: cast_nullable_to_non_nullable +as int,maxConcurrentByGroup: null == maxConcurrentByGroup ? _self.maxConcurrentByGroup : maxConcurrentByGroup // ignore: cast_nullable_to_non_nullable +as int, + )); } -/// @nodoc -abstract class _$$DownloadSettingsImplCopyWith<$Res> - implements $DownloadSettingsCopyWith<$Res> { - factory _$$DownloadSettingsImplCopyWith(_$DownloadSettingsImpl value, - $Res Function(_$DownloadSettingsImpl) then) = - __$$DownloadSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {bool requiresWiFi, - int retries, - bool allowPause, - int maxConcurrent, - int maxConcurrentByHost, - int maxConcurrentByGroup}); } -/// @nodoc -class __$$DownloadSettingsImplCopyWithImpl<$Res> - extends _$DownloadSettingsCopyWithImpl<$Res, _$DownloadSettingsImpl> - implements _$$DownloadSettingsImplCopyWith<$Res> { - __$$DownloadSettingsImplCopyWithImpl(_$DownloadSettingsImpl _value, - $Res Function(_$DownloadSettingsImpl) _then) - : super(_value, _then); - /// Create a copy of DownloadSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? requiresWiFi = null, - Object? retries = null, - Object? allowPause = null, - Object? maxConcurrent = null, - Object? maxConcurrentByHost = null, - Object? maxConcurrentByGroup = null, - }) { - return _then(_$DownloadSettingsImpl( - requiresWiFi: null == requiresWiFi - ? _value.requiresWiFi - : requiresWiFi // ignore: cast_nullable_to_non_nullable - as bool, - retries: null == retries - ? _value.retries - : retries // ignore: cast_nullable_to_non_nullable - as int, - allowPause: null == allowPause - ? _value.allowPause - : allowPause // ignore: cast_nullable_to_non_nullable - as bool, - maxConcurrent: null == maxConcurrent - ? _value.maxConcurrent - : maxConcurrent // ignore: cast_nullable_to_non_nullable - as int, - maxConcurrentByHost: null == maxConcurrentByHost - ? _value.maxConcurrentByHost - : maxConcurrentByHost // ignore: cast_nullable_to_non_nullable - as int, - maxConcurrentByGroup: null == maxConcurrentByGroup - ? _value.maxConcurrentByGroup - : maxConcurrentByGroup // ignore: cast_nullable_to_non_nullable - as int, - )); - } +/// Adds pattern-matching-related methods to [DownloadSettings]. +extension DownloadSettingsPatterns on DownloadSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _DownloadSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _DownloadSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _DownloadSettings value) $default,){ +final _that = this; +switch (_that) { +case _DownloadSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _DownloadSettings value)? $default,){ +final _that = this; +switch (_that) { +case _DownloadSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( bool requiresWiFi, int retries, bool allowPause, int maxConcurrent, int maxConcurrentByHost, int maxConcurrentByGroup)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _DownloadSettings() when $default != null: +return $default(_that.requiresWiFi,_that.retries,_that.allowPause,_that.maxConcurrent,_that.maxConcurrentByHost,_that.maxConcurrentByGroup);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( bool requiresWiFi, int retries, bool allowPause, int maxConcurrent, int maxConcurrentByHost, int maxConcurrentByGroup) $default,) {final _that = this; +switch (_that) { +case _DownloadSettings(): +return $default(_that.requiresWiFi,_that.retries,_that.allowPause,_that.maxConcurrent,_that.maxConcurrentByHost,_that.maxConcurrentByGroup);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool requiresWiFi, int retries, bool allowPause, int maxConcurrent, int maxConcurrentByHost, int maxConcurrentByGroup)? $default,) {final _that = this; +switch (_that) { +case _DownloadSettings() when $default != null: +return $default(_that.requiresWiFi,_that.retries,_that.allowPause,_that.maxConcurrent,_that.maxConcurrentByHost,_that.maxConcurrentByGroup);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$DownloadSettingsImpl implements _DownloadSettings { - const _$DownloadSettingsImpl( - {this.requiresWiFi = true, - this.retries = 3, - this.allowPause = true, - this.maxConcurrent = 3, - this.maxConcurrentByHost = 3, - this.maxConcurrentByGroup = 3}); - factory _$DownloadSettingsImpl.fromJson(Map json) => - _$$DownloadSettingsImplFromJson(json); +class _DownloadSettings implements DownloadSettings { + const _DownloadSettings({this.requiresWiFi = true, this.retries = 3, this.allowPause = true, this.maxConcurrent = 3, this.maxConcurrentByHost = 3, this.maxConcurrentByGroup = 3}); + factory _DownloadSettings.fromJson(Map json) => _$DownloadSettingsFromJson(json); - @override - @JsonKey() - final bool requiresWiFi; - @override - @JsonKey() - final int retries; - @override - @JsonKey() - final bool allowPause; - @override - @JsonKey() - final int maxConcurrent; - @override - @JsonKey() - final int maxConcurrentByHost; - @override - @JsonKey() - final int maxConcurrentByGroup; +@override@JsonKey() final bool requiresWiFi; +@override@JsonKey() final int retries; +@override@JsonKey() final bool allowPause; +@override@JsonKey() final int maxConcurrent; +@override@JsonKey() final int maxConcurrentByHost; +@override@JsonKey() final int maxConcurrentByGroup; - @override - String toString() { - return 'DownloadSettings(requiresWiFi: $requiresWiFi, retries: $retries, allowPause: $allowPause, maxConcurrent: $maxConcurrent, maxConcurrentByHost: $maxConcurrentByHost, maxConcurrentByGroup: $maxConcurrentByGroup)'; - } +/// Create a copy of DownloadSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$DownloadSettingsCopyWith<_DownloadSettings> get copyWith => __$DownloadSettingsCopyWithImpl<_DownloadSettings>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DownloadSettingsImpl && - (identical(other.requiresWiFi, requiresWiFi) || - other.requiresWiFi == requiresWiFi) && - (identical(other.retries, retries) || other.retries == retries) && - (identical(other.allowPause, allowPause) || - other.allowPause == allowPause) && - (identical(other.maxConcurrent, maxConcurrent) || - other.maxConcurrent == maxConcurrent) && - (identical(other.maxConcurrentByHost, maxConcurrentByHost) || - other.maxConcurrentByHost == maxConcurrentByHost) && - (identical(other.maxConcurrentByGroup, maxConcurrentByGroup) || - other.maxConcurrentByGroup == maxConcurrentByGroup)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, requiresWiFi, retries, - allowPause, maxConcurrent, maxConcurrentByHost, maxConcurrentByGroup); - - /// Create a copy of DownloadSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DownloadSettingsImplCopyWith<_$DownloadSettingsImpl> get copyWith => - __$$DownloadSettingsImplCopyWithImpl<_$DownloadSettingsImpl>( - this, _$identity); - - @override - Map toJson() { - return _$$DownloadSettingsImplToJson( - this, - ); - } +@override +Map toJson() { + return _$DownloadSettingsToJson(this, ); } -abstract class _DownloadSettings implements DownloadSettings { - const factory _DownloadSettings( - {final bool requiresWiFi, - final int retries, - final bool allowPause, - final int maxConcurrent, - final int maxConcurrentByHost, - final int maxConcurrentByGroup}) = _$DownloadSettingsImpl; - - factory _DownloadSettings.fromJson(Map json) = - _$DownloadSettingsImpl.fromJson; - - @override - bool get requiresWiFi; - @override - int get retries; - @override - bool get allowPause; - @override - int get maxConcurrent; - @override - int get maxConcurrentByHost; - @override - int get maxConcurrentByGroup; - - /// Create a copy of DownloadSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DownloadSettingsImplCopyWith<_$DownloadSettingsImpl> get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _DownloadSettings&&(identical(other.requiresWiFi, requiresWiFi) || other.requiresWiFi == requiresWiFi)&&(identical(other.retries, retries) || other.retries == retries)&&(identical(other.allowPause, allowPause) || other.allowPause == allowPause)&&(identical(other.maxConcurrent, maxConcurrent) || other.maxConcurrent == maxConcurrent)&&(identical(other.maxConcurrentByHost, maxConcurrentByHost) || other.maxConcurrentByHost == maxConcurrentByHost)&&(identical(other.maxConcurrentByGroup, maxConcurrentByGroup) || other.maxConcurrentByGroup == maxConcurrentByGroup)); } -NotificationSettings _$NotificationSettingsFromJson(Map json) { - return _NotificationSettings.fromJson(json); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,requiresWiFi,retries,allowPause,maxConcurrent,maxConcurrentByHost,maxConcurrentByGroup); + +@override +String toString() { + return 'DownloadSettings(requiresWiFi: $requiresWiFi, retries: $retries, allowPause: $allowPause, maxConcurrent: $maxConcurrent, maxConcurrentByHost: $maxConcurrentByHost, maxConcurrentByGroup: $maxConcurrentByGroup)'; } + +} + +/// @nodoc +abstract mixin class _$DownloadSettingsCopyWith<$Res> implements $DownloadSettingsCopyWith<$Res> { + factory _$DownloadSettingsCopyWith(_DownloadSettings value, $Res Function(_DownloadSettings) _then) = __$DownloadSettingsCopyWithImpl; +@override @useResult +$Res call({ + bool requiresWiFi, int retries, bool allowPause, int maxConcurrent, int maxConcurrentByHost, int maxConcurrentByGroup +}); + + + + +} +/// @nodoc +class __$DownloadSettingsCopyWithImpl<$Res> + implements _$DownloadSettingsCopyWith<$Res> { + __$DownloadSettingsCopyWithImpl(this._self, this._then); + + final _DownloadSettings _self; + final $Res Function(_DownloadSettings) _then; + +/// Create a copy of DownloadSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? requiresWiFi = null,Object? retries = null,Object? allowPause = null,Object? maxConcurrent = null,Object? maxConcurrentByHost = null,Object? maxConcurrentByGroup = null,}) { + return _then(_DownloadSettings( +requiresWiFi: null == requiresWiFi ? _self.requiresWiFi : requiresWiFi // ignore: cast_nullable_to_non_nullable +as bool,retries: null == retries ? _self.retries : retries // ignore: cast_nullable_to_non_nullable +as int,allowPause: null == allowPause ? _self.allowPause : allowPause // ignore: cast_nullable_to_non_nullable +as bool,maxConcurrent: null == maxConcurrent ? _self.maxConcurrent : maxConcurrent // ignore: cast_nullable_to_non_nullable +as int,maxConcurrentByHost: null == maxConcurrentByHost ? _self.maxConcurrentByHost : maxConcurrentByHost // ignore: cast_nullable_to_non_nullable +as int,maxConcurrentByGroup: null == maxConcurrentByGroup ? _self.maxConcurrentByGroup : maxConcurrentByGroup // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + + /// @nodoc mixin _$NotificationSettings { - Duration get fastForwardInterval => throw _privateConstructorUsedError; - Duration get rewindInterval => throw _privateConstructorUsedError; - bool get progressBarIsChapterProgress => throw _privateConstructorUsedError; - String get primaryTitle => throw _privateConstructorUsedError; - String get secondaryTitle => throw _privateConstructorUsedError; - List get mediaControls => - throw _privateConstructorUsedError; + + Duration get fastForwardInterval; Duration get rewindInterval; bool get progressBarIsChapterProgress; String get primaryTitle; String get secondaryTitle; List get mediaControls; +/// Create a copy of NotificationSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$NotificationSettingsCopyWith get copyWith => _$NotificationSettingsCopyWithImpl(this as NotificationSettings, _$identity); /// Serializes this NotificationSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationSettings&&(identical(other.fastForwardInterval, fastForwardInterval) || other.fastForwardInterval == fastForwardInterval)&&(identical(other.rewindInterval, rewindInterval) || other.rewindInterval == rewindInterval)&&(identical(other.progressBarIsChapterProgress, progressBarIsChapterProgress) || other.progressBarIsChapterProgress == progressBarIsChapterProgress)&&(identical(other.primaryTitle, primaryTitle) || other.primaryTitle == primaryTitle)&&(identical(other.secondaryTitle, secondaryTitle) || other.secondaryTitle == secondaryTitle)&&const DeepCollectionEquality().equals(other.mediaControls, mediaControls)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,fastForwardInterval,rewindInterval,progressBarIsChapterProgress,primaryTitle,secondaryTitle,const DeepCollectionEquality().hash(mediaControls)); + +@override +String toString() { + return 'NotificationSettings(fastForwardInterval: $fastForwardInterval, rewindInterval: $rewindInterval, progressBarIsChapterProgress: $progressBarIsChapterProgress, primaryTitle: $primaryTitle, secondaryTitle: $secondaryTitle, mediaControls: $mediaControls)'; +} + - /// Create a copy of NotificationSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $NotificationSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $NotificationSettingsCopyWith<$Res> { - factory $NotificationSettingsCopyWith(NotificationSettings value, - $Res Function(NotificationSettings) then) = - _$NotificationSettingsCopyWithImpl<$Res, NotificationSettings>; - @useResult - $Res call( - {Duration fastForwardInterval, - Duration rewindInterval, - bool progressBarIsChapterProgress, - String primaryTitle, - String secondaryTitle, - List mediaControls}); -} +abstract mixin class $NotificationSettingsCopyWith<$Res> { + factory $NotificationSettingsCopyWith(NotificationSettings value, $Res Function(NotificationSettings) _then) = _$NotificationSettingsCopyWithImpl; +@useResult +$Res call({ + Duration fastForwardInterval, Duration rewindInterval, bool progressBarIsChapterProgress, String primaryTitle, String secondaryTitle, List mediaControls +}); + + + +} /// @nodoc -class _$NotificationSettingsCopyWithImpl<$Res, - $Val extends NotificationSettings> +class _$NotificationSettingsCopyWithImpl<$Res> implements $NotificationSettingsCopyWith<$Res> { - _$NotificationSettingsCopyWithImpl(this._value, this._then); + _$NotificationSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final NotificationSettings _self; + final $Res Function(NotificationSettings) _then; - /// Create a copy of NotificationSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? fastForwardInterval = null, - Object? rewindInterval = null, - Object? progressBarIsChapterProgress = null, - Object? primaryTitle = null, - Object? secondaryTitle = null, - Object? mediaControls = null, - }) { - return _then(_value.copyWith( - fastForwardInterval: null == fastForwardInterval - ? _value.fastForwardInterval - : fastForwardInterval // ignore: cast_nullable_to_non_nullable - as Duration, - rewindInterval: null == rewindInterval - ? _value.rewindInterval - : rewindInterval // ignore: cast_nullable_to_non_nullable - as Duration, - progressBarIsChapterProgress: null == progressBarIsChapterProgress - ? _value.progressBarIsChapterProgress - : progressBarIsChapterProgress // ignore: cast_nullable_to_non_nullable - as bool, - primaryTitle: null == primaryTitle - ? _value.primaryTitle - : primaryTitle // ignore: cast_nullable_to_non_nullable - as String, - secondaryTitle: null == secondaryTitle - ? _value.secondaryTitle - : secondaryTitle // ignore: cast_nullable_to_non_nullable - as String, - mediaControls: null == mediaControls - ? _value.mediaControls - : mediaControls // ignore: cast_nullable_to_non_nullable - as List, - ) as $Val); - } +/// Create a copy of NotificationSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? fastForwardInterval = null,Object? rewindInterval = null,Object? progressBarIsChapterProgress = null,Object? primaryTitle = null,Object? secondaryTitle = null,Object? mediaControls = null,}) { + return _then(_self.copyWith( +fastForwardInterval: null == fastForwardInterval ? _self.fastForwardInterval : fastForwardInterval // ignore: cast_nullable_to_non_nullable +as Duration,rewindInterval: null == rewindInterval ? _self.rewindInterval : rewindInterval // ignore: cast_nullable_to_non_nullable +as Duration,progressBarIsChapterProgress: null == progressBarIsChapterProgress ? _self.progressBarIsChapterProgress : progressBarIsChapterProgress // ignore: cast_nullable_to_non_nullable +as bool,primaryTitle: null == primaryTitle ? _self.primaryTitle : primaryTitle // ignore: cast_nullable_to_non_nullable +as String,secondaryTitle: null == secondaryTitle ? _self.secondaryTitle : secondaryTitle // ignore: cast_nullable_to_non_nullable +as String,mediaControls: null == mediaControls ? _self.mediaControls : mediaControls // ignore: cast_nullable_to_non_nullable +as List, + )); } -/// @nodoc -abstract class _$$NotificationSettingsImplCopyWith<$Res> - implements $NotificationSettingsCopyWith<$Res> { - factory _$$NotificationSettingsImplCopyWith(_$NotificationSettingsImpl value, - $Res Function(_$NotificationSettingsImpl) then) = - __$$NotificationSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {Duration fastForwardInterval, - Duration rewindInterval, - bool progressBarIsChapterProgress, - String primaryTitle, - String secondaryTitle, - List mediaControls}); } -/// @nodoc -class __$$NotificationSettingsImplCopyWithImpl<$Res> - extends _$NotificationSettingsCopyWithImpl<$Res, _$NotificationSettingsImpl> - implements _$$NotificationSettingsImplCopyWith<$Res> { - __$$NotificationSettingsImplCopyWithImpl(_$NotificationSettingsImpl _value, - $Res Function(_$NotificationSettingsImpl) _then) - : super(_value, _then); - /// Create a copy of NotificationSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? fastForwardInterval = null, - Object? rewindInterval = null, - Object? progressBarIsChapterProgress = null, - Object? primaryTitle = null, - Object? secondaryTitle = null, - Object? mediaControls = null, - }) { - return _then(_$NotificationSettingsImpl( - fastForwardInterval: null == fastForwardInterval - ? _value.fastForwardInterval - : fastForwardInterval // ignore: cast_nullable_to_non_nullable - as Duration, - rewindInterval: null == rewindInterval - ? _value.rewindInterval - : rewindInterval // ignore: cast_nullable_to_non_nullable - as Duration, - progressBarIsChapterProgress: null == progressBarIsChapterProgress - ? _value.progressBarIsChapterProgress - : progressBarIsChapterProgress // ignore: cast_nullable_to_non_nullable - as bool, - primaryTitle: null == primaryTitle - ? _value.primaryTitle - : primaryTitle // ignore: cast_nullable_to_non_nullable - as String, - secondaryTitle: null == secondaryTitle - ? _value.secondaryTitle - : secondaryTitle // ignore: cast_nullable_to_non_nullable - as String, - mediaControls: null == mediaControls - ? _value._mediaControls - : mediaControls // ignore: cast_nullable_to_non_nullable - as List, - )); - } +/// Adds pattern-matching-related methods to [NotificationSettings]. +extension NotificationSettingsPatterns on NotificationSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _NotificationSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _NotificationSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _NotificationSettings value) $default,){ +final _that = this; +switch (_that) { +case _NotificationSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _NotificationSettings value)? $default,){ +final _that = this; +switch (_that) { +case _NotificationSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( Duration fastForwardInterval, Duration rewindInterval, bool progressBarIsChapterProgress, String primaryTitle, String secondaryTitle, List mediaControls)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _NotificationSettings() when $default != null: +return $default(_that.fastForwardInterval,_that.rewindInterval,_that.progressBarIsChapterProgress,_that.primaryTitle,_that.secondaryTitle,_that.mediaControls);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( Duration fastForwardInterval, Duration rewindInterval, bool progressBarIsChapterProgress, String primaryTitle, String secondaryTitle, List mediaControls) $default,) {final _that = this; +switch (_that) { +case _NotificationSettings(): +return $default(_that.fastForwardInterval,_that.rewindInterval,_that.progressBarIsChapterProgress,_that.primaryTitle,_that.secondaryTitle,_that.mediaControls);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( Duration fastForwardInterval, Duration rewindInterval, bool progressBarIsChapterProgress, String primaryTitle, String secondaryTitle, List mediaControls)? $default,) {final _that = this; +switch (_that) { +case _NotificationSettings() when $default != null: +return $default(_that.fastForwardInterval,_that.rewindInterval,_that.progressBarIsChapterProgress,_that.primaryTitle,_that.secondaryTitle,_that.mediaControls);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$NotificationSettingsImpl implements _NotificationSettings { - const _$NotificationSettingsImpl( - {this.fastForwardInterval = const Duration(seconds: 30), - this.rewindInterval = const Duration(seconds: 10), - this.progressBarIsChapterProgress = true, - this.primaryTitle = '\$bookTitle', - this.secondaryTitle = '\$author', - final List mediaControls = const [ - NotificationMediaControl.rewind, - NotificationMediaControl.fastForward, - NotificationMediaControl.skipToPreviousChapter, - NotificationMediaControl.skipToNextChapter - ]}) - : _mediaControls = mediaControls; - factory _$NotificationSettingsImpl.fromJson(Map json) => - _$$NotificationSettingsImplFromJson(json); +class _NotificationSettings implements NotificationSettings { + const _NotificationSettings({this.fastForwardInterval = const Duration(seconds: 30), this.rewindInterval = const Duration(seconds: 10), this.progressBarIsChapterProgress = true, this.primaryTitle = '\$bookTitle', this.secondaryTitle = '\$author', final List mediaControls = const [NotificationMediaControl.rewind, NotificationMediaControl.fastForward, NotificationMediaControl.skipToPreviousChapter, NotificationMediaControl.skipToNextChapter]}): _mediaControls = mediaControls; + factory _NotificationSettings.fromJson(Map json) => _$NotificationSettingsFromJson(json); - @override - @JsonKey() - final Duration fastForwardInterval; - @override - @JsonKey() - final Duration rewindInterval; - @override - @JsonKey() - final bool progressBarIsChapterProgress; - @override - @JsonKey() - final String primaryTitle; - @override - @JsonKey() - final String secondaryTitle; - final List _mediaControls; - @override - @JsonKey() - List get mediaControls { - if (_mediaControls is EqualUnmodifiableListView) return _mediaControls; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_mediaControls); - } - - @override - String toString() { - return 'NotificationSettings(fastForwardInterval: $fastForwardInterval, rewindInterval: $rewindInterval, progressBarIsChapterProgress: $progressBarIsChapterProgress, primaryTitle: $primaryTitle, secondaryTitle: $secondaryTitle, mediaControls: $mediaControls)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$NotificationSettingsImpl && - (identical(other.fastForwardInterval, fastForwardInterval) || - other.fastForwardInterval == fastForwardInterval) && - (identical(other.rewindInterval, rewindInterval) || - other.rewindInterval == rewindInterval) && - (identical(other.progressBarIsChapterProgress, - progressBarIsChapterProgress) || - other.progressBarIsChapterProgress == - progressBarIsChapterProgress) && - (identical(other.primaryTitle, primaryTitle) || - other.primaryTitle == primaryTitle) && - (identical(other.secondaryTitle, secondaryTitle) || - other.secondaryTitle == secondaryTitle) && - const DeepCollectionEquality() - .equals(other._mediaControls, _mediaControls)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - fastForwardInterval, - rewindInterval, - progressBarIsChapterProgress, - primaryTitle, - secondaryTitle, - const DeepCollectionEquality().hash(_mediaControls)); - - /// Create a copy of NotificationSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$NotificationSettingsImplCopyWith<_$NotificationSettingsImpl> - get copyWith => - __$$NotificationSettingsImplCopyWithImpl<_$NotificationSettingsImpl>( - this, _$identity); - - @override - Map toJson() { - return _$$NotificationSettingsImplToJson( - this, - ); - } +@override@JsonKey() final Duration fastForwardInterval; +@override@JsonKey() final Duration rewindInterval; +@override@JsonKey() final bool progressBarIsChapterProgress; +@override@JsonKey() final String primaryTitle; +@override@JsonKey() final String secondaryTitle; + final List _mediaControls; +@override@JsonKey() List get mediaControls { + if (_mediaControls is EqualUnmodifiableListView) return _mediaControls; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_mediaControls); } -abstract class _NotificationSettings implements NotificationSettings { - const factory _NotificationSettings( - {final Duration fastForwardInterval, - final Duration rewindInterval, - final bool progressBarIsChapterProgress, - final String primaryTitle, - final String secondaryTitle, - final List mediaControls}) = - _$NotificationSettingsImpl; - factory _NotificationSettings.fromJson(Map json) = - _$NotificationSettingsImpl.fromJson; +/// Create a copy of NotificationSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NotificationSettingsCopyWith<_NotificationSettings> get copyWith => __$NotificationSettingsCopyWithImpl<_NotificationSettings>(this, _$identity); - @override - Duration get fastForwardInterval; - @override - Duration get rewindInterval; - @override - bool get progressBarIsChapterProgress; - @override - String get primaryTitle; - @override - String get secondaryTitle; - @override - List get mediaControls; - - /// Create a copy of NotificationSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$NotificationSettingsImplCopyWith<_$NotificationSettingsImpl> - get copyWith => throw _privateConstructorUsedError; +@override +Map toJson() { + return _$NotificationSettingsToJson(this, ); } -ShakeDetectionSettings _$ShakeDetectionSettingsFromJson( - Map json) { - return _ShakeDetectionSettings.fromJson(json); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationSettings&&(identical(other.fastForwardInterval, fastForwardInterval) || other.fastForwardInterval == fastForwardInterval)&&(identical(other.rewindInterval, rewindInterval) || other.rewindInterval == rewindInterval)&&(identical(other.progressBarIsChapterProgress, progressBarIsChapterProgress) || other.progressBarIsChapterProgress == progressBarIsChapterProgress)&&(identical(other.primaryTitle, primaryTitle) || other.primaryTitle == primaryTitle)&&(identical(other.secondaryTitle, secondaryTitle) || other.secondaryTitle == secondaryTitle)&&const DeepCollectionEquality().equals(other._mediaControls, _mediaControls)); } +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,fastForwardInterval,rewindInterval,progressBarIsChapterProgress,primaryTitle,secondaryTitle,const DeepCollectionEquality().hash(_mediaControls)); + +@override +String toString() { + return 'NotificationSettings(fastForwardInterval: $fastForwardInterval, rewindInterval: $rewindInterval, progressBarIsChapterProgress: $progressBarIsChapterProgress, primaryTitle: $primaryTitle, secondaryTitle: $secondaryTitle, mediaControls: $mediaControls)'; +} + + +} + +/// @nodoc +abstract mixin class _$NotificationSettingsCopyWith<$Res> implements $NotificationSettingsCopyWith<$Res> { + factory _$NotificationSettingsCopyWith(_NotificationSettings value, $Res Function(_NotificationSettings) _then) = __$NotificationSettingsCopyWithImpl; +@override @useResult +$Res call({ + Duration fastForwardInterval, Duration rewindInterval, bool progressBarIsChapterProgress, String primaryTitle, String secondaryTitle, List mediaControls +}); + + + + +} +/// @nodoc +class __$NotificationSettingsCopyWithImpl<$Res> + implements _$NotificationSettingsCopyWith<$Res> { + __$NotificationSettingsCopyWithImpl(this._self, this._then); + + final _NotificationSettings _self; + final $Res Function(_NotificationSettings) _then; + +/// Create a copy of NotificationSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? fastForwardInterval = null,Object? rewindInterval = null,Object? progressBarIsChapterProgress = null,Object? primaryTitle = null,Object? secondaryTitle = null,Object? mediaControls = null,}) { + return _then(_NotificationSettings( +fastForwardInterval: null == fastForwardInterval ? _self.fastForwardInterval : fastForwardInterval // ignore: cast_nullable_to_non_nullable +as Duration,rewindInterval: null == rewindInterval ? _self.rewindInterval : rewindInterval // ignore: cast_nullable_to_non_nullable +as Duration,progressBarIsChapterProgress: null == progressBarIsChapterProgress ? _self.progressBarIsChapterProgress : progressBarIsChapterProgress // ignore: cast_nullable_to_non_nullable +as bool,primaryTitle: null == primaryTitle ? _self.primaryTitle : primaryTitle // ignore: cast_nullable_to_non_nullable +as String,secondaryTitle: null == secondaryTitle ? _self.secondaryTitle : secondaryTitle // ignore: cast_nullable_to_non_nullable +as String,mediaControls: null == mediaControls ? _self._mediaControls : mediaControls // ignore: cast_nullable_to_non_nullable +as List, + )); +} + + +} + + /// @nodoc mixin _$ShakeDetectionSettings { - bool get isEnabled => throw _privateConstructorUsedError; - ShakeDirection get direction => throw _privateConstructorUsedError; - double get threshold => throw _privateConstructorUsedError; - ShakeAction get shakeAction => throw _privateConstructorUsedError; - Set get feedback => throw _privateConstructorUsedError; - double get beepVolume => throw _privateConstructorUsedError; - /// the duration to wait before the shake detection is enabled again - Duration get shakeTriggerCoolDown => throw _privateConstructorUsedError; - - /// the number of shakes required to trigger the action - int get shakeTriggerCount => throw _privateConstructorUsedError; - - /// acceleration sampling interval - Duration get samplingPeriod => throw _privateConstructorUsedError; + bool get isEnabled; ShakeDirection get direction; double get threshold; ShakeAction get shakeAction; Set get feedback; double get beepVolume;/// the duration to wait before the shake detection is enabled again + Duration get shakeTriggerCoolDown;/// the number of shakes required to trigger the action + int get shakeTriggerCount;/// acceleration sampling interval + Duration get samplingPeriod; +/// Create a copy of ShakeDetectionSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ShakeDetectionSettingsCopyWith get copyWith => _$ShakeDetectionSettingsCopyWithImpl(this as ShakeDetectionSettings, _$identity); /// Serializes this ShakeDetectionSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ShakeDetectionSettings&&(identical(other.isEnabled, isEnabled) || other.isEnabled == isEnabled)&&(identical(other.direction, direction) || other.direction == direction)&&(identical(other.threshold, threshold) || other.threshold == threshold)&&(identical(other.shakeAction, shakeAction) || other.shakeAction == shakeAction)&&const DeepCollectionEquality().equals(other.feedback, feedback)&&(identical(other.beepVolume, beepVolume) || other.beepVolume == beepVolume)&&(identical(other.shakeTriggerCoolDown, shakeTriggerCoolDown) || other.shakeTriggerCoolDown == shakeTriggerCoolDown)&&(identical(other.shakeTriggerCount, shakeTriggerCount) || other.shakeTriggerCount == shakeTriggerCount)&&(identical(other.samplingPeriod, samplingPeriod) || other.samplingPeriod == samplingPeriod)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,isEnabled,direction,threshold,shakeAction,const DeepCollectionEquality().hash(feedback),beepVolume,shakeTriggerCoolDown,shakeTriggerCount,samplingPeriod); + +@override +String toString() { + return 'ShakeDetectionSettings(isEnabled: $isEnabled, direction: $direction, threshold: $threshold, shakeAction: $shakeAction, feedback: $feedback, beepVolume: $beepVolume, shakeTriggerCoolDown: $shakeTriggerCoolDown, shakeTriggerCount: $shakeTriggerCount, samplingPeriod: $samplingPeriod)'; +} + - /// Create a copy of ShakeDetectionSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ShakeDetectionSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $ShakeDetectionSettingsCopyWith<$Res> { - factory $ShakeDetectionSettingsCopyWith(ShakeDetectionSettings value, - $Res Function(ShakeDetectionSettings) then) = - _$ShakeDetectionSettingsCopyWithImpl<$Res, ShakeDetectionSettings>; - @useResult - $Res call( - {bool isEnabled, - ShakeDirection direction, - double threshold, - ShakeAction shakeAction, - Set feedback, - double beepVolume, - Duration shakeTriggerCoolDown, - int shakeTriggerCount, - Duration samplingPeriod}); -} +abstract mixin class $ShakeDetectionSettingsCopyWith<$Res> { + factory $ShakeDetectionSettingsCopyWith(ShakeDetectionSettings value, $Res Function(ShakeDetectionSettings) _then) = _$ShakeDetectionSettingsCopyWithImpl; +@useResult +$Res call({ + bool isEnabled, ShakeDirection direction, double threshold, ShakeAction shakeAction, Set feedback, double beepVolume, Duration shakeTriggerCoolDown, int shakeTriggerCount, Duration samplingPeriod +}); + + + +} /// @nodoc -class _$ShakeDetectionSettingsCopyWithImpl<$Res, - $Val extends ShakeDetectionSettings> +class _$ShakeDetectionSettingsCopyWithImpl<$Res> implements $ShakeDetectionSettingsCopyWith<$Res> { - _$ShakeDetectionSettingsCopyWithImpl(this._value, this._then); + _$ShakeDetectionSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final ShakeDetectionSettings _self; + final $Res Function(ShakeDetectionSettings) _then; - /// Create a copy of ShakeDetectionSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? isEnabled = null, - Object? direction = null, - Object? threshold = null, - Object? shakeAction = null, - Object? feedback = null, - Object? beepVolume = null, - Object? shakeTriggerCoolDown = null, - Object? shakeTriggerCount = null, - Object? samplingPeriod = null, - }) { - return _then(_value.copyWith( - isEnabled: null == isEnabled - ? _value.isEnabled - : isEnabled // ignore: cast_nullable_to_non_nullable - as bool, - direction: null == direction - ? _value.direction - : direction // ignore: cast_nullable_to_non_nullable - as ShakeDirection, - threshold: null == threshold - ? _value.threshold - : threshold // ignore: cast_nullable_to_non_nullable - as double, - shakeAction: null == shakeAction - ? _value.shakeAction - : shakeAction // ignore: cast_nullable_to_non_nullable - as ShakeAction, - feedback: null == feedback - ? _value.feedback - : feedback // ignore: cast_nullable_to_non_nullable - as Set, - beepVolume: null == beepVolume - ? _value.beepVolume - : beepVolume // ignore: cast_nullable_to_non_nullable - as double, - shakeTriggerCoolDown: null == shakeTriggerCoolDown - ? _value.shakeTriggerCoolDown - : shakeTriggerCoolDown // ignore: cast_nullable_to_non_nullable - as Duration, - shakeTriggerCount: null == shakeTriggerCount - ? _value.shakeTriggerCount - : shakeTriggerCount // ignore: cast_nullable_to_non_nullable - as int, - samplingPeriod: null == samplingPeriod - ? _value.samplingPeriod - : samplingPeriod // ignore: cast_nullable_to_non_nullable - as Duration, - ) as $Val); - } +/// Create a copy of ShakeDetectionSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? isEnabled = null,Object? direction = null,Object? threshold = null,Object? shakeAction = null,Object? feedback = null,Object? beepVolume = null,Object? shakeTriggerCoolDown = null,Object? shakeTriggerCount = null,Object? samplingPeriod = null,}) { + return _then(_self.copyWith( +isEnabled: null == isEnabled ? _self.isEnabled : isEnabled // ignore: cast_nullable_to_non_nullable +as bool,direction: null == direction ? _self.direction : direction // ignore: cast_nullable_to_non_nullable +as ShakeDirection,threshold: null == threshold ? _self.threshold : threshold // ignore: cast_nullable_to_non_nullable +as double,shakeAction: null == shakeAction ? _self.shakeAction : shakeAction // ignore: cast_nullable_to_non_nullable +as ShakeAction,feedback: null == feedback ? _self.feedback : feedback // ignore: cast_nullable_to_non_nullable +as Set,beepVolume: null == beepVolume ? _self.beepVolume : beepVolume // ignore: cast_nullable_to_non_nullable +as double,shakeTriggerCoolDown: null == shakeTriggerCoolDown ? _self.shakeTriggerCoolDown : shakeTriggerCoolDown // ignore: cast_nullable_to_non_nullable +as Duration,shakeTriggerCount: null == shakeTriggerCount ? _self.shakeTriggerCount : shakeTriggerCount // ignore: cast_nullable_to_non_nullable +as int,samplingPeriod: null == samplingPeriod ? _self.samplingPeriod : samplingPeriod // ignore: cast_nullable_to_non_nullable +as Duration, + )); } -/// @nodoc -abstract class _$$ShakeDetectionSettingsImplCopyWith<$Res> - implements $ShakeDetectionSettingsCopyWith<$Res> { - factory _$$ShakeDetectionSettingsImplCopyWith( - _$ShakeDetectionSettingsImpl value, - $Res Function(_$ShakeDetectionSettingsImpl) then) = - __$$ShakeDetectionSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {bool isEnabled, - ShakeDirection direction, - double threshold, - ShakeAction shakeAction, - Set feedback, - double beepVolume, - Duration shakeTriggerCoolDown, - int shakeTriggerCount, - Duration samplingPeriod}); } -/// @nodoc -class __$$ShakeDetectionSettingsImplCopyWithImpl<$Res> - extends _$ShakeDetectionSettingsCopyWithImpl<$Res, - _$ShakeDetectionSettingsImpl> - implements _$$ShakeDetectionSettingsImplCopyWith<$Res> { - __$$ShakeDetectionSettingsImplCopyWithImpl( - _$ShakeDetectionSettingsImpl _value, - $Res Function(_$ShakeDetectionSettingsImpl) _then) - : super(_value, _then); - /// Create a copy of ShakeDetectionSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? isEnabled = null, - Object? direction = null, - Object? threshold = null, - Object? shakeAction = null, - Object? feedback = null, - Object? beepVolume = null, - Object? shakeTriggerCoolDown = null, - Object? shakeTriggerCount = null, - Object? samplingPeriod = null, - }) { - return _then(_$ShakeDetectionSettingsImpl( - isEnabled: null == isEnabled - ? _value.isEnabled - : isEnabled // ignore: cast_nullable_to_non_nullable - as bool, - direction: null == direction - ? _value.direction - : direction // ignore: cast_nullable_to_non_nullable - as ShakeDirection, - threshold: null == threshold - ? _value.threshold - : threshold // ignore: cast_nullable_to_non_nullable - as double, - shakeAction: null == shakeAction - ? _value.shakeAction - : shakeAction // ignore: cast_nullable_to_non_nullable - as ShakeAction, - feedback: null == feedback - ? _value._feedback - : feedback // ignore: cast_nullable_to_non_nullable - as Set, - beepVolume: null == beepVolume - ? _value.beepVolume - : beepVolume // ignore: cast_nullable_to_non_nullable - as double, - shakeTriggerCoolDown: null == shakeTriggerCoolDown - ? _value.shakeTriggerCoolDown - : shakeTriggerCoolDown // ignore: cast_nullable_to_non_nullable - as Duration, - shakeTriggerCount: null == shakeTriggerCount - ? _value.shakeTriggerCount - : shakeTriggerCount // ignore: cast_nullable_to_non_nullable - as int, - samplingPeriod: null == samplingPeriod - ? _value.samplingPeriod - : samplingPeriod // ignore: cast_nullable_to_non_nullable - as Duration, - )); - } +/// Adds pattern-matching-related methods to [ShakeDetectionSettings]. +extension ShakeDetectionSettingsPatterns on ShakeDetectionSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _ShakeDetectionSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ShakeDetectionSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _ShakeDetectionSettings value) $default,){ +final _that = this; +switch (_that) { +case _ShakeDetectionSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _ShakeDetectionSettings value)? $default,){ +final _that = this; +switch (_that) { +case _ShakeDetectionSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( bool isEnabled, ShakeDirection direction, double threshold, ShakeAction shakeAction, Set feedback, double beepVolume, Duration shakeTriggerCoolDown, int shakeTriggerCount, Duration samplingPeriod)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ShakeDetectionSettings() when $default != null: +return $default(_that.isEnabled,_that.direction,_that.threshold,_that.shakeAction,_that.feedback,_that.beepVolume,_that.shakeTriggerCoolDown,_that.shakeTriggerCount,_that.samplingPeriod);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( bool isEnabled, ShakeDirection direction, double threshold, ShakeAction shakeAction, Set feedback, double beepVolume, Duration shakeTriggerCoolDown, int shakeTriggerCount, Duration samplingPeriod) $default,) {final _that = this; +switch (_that) { +case _ShakeDetectionSettings(): +return $default(_that.isEnabled,_that.direction,_that.threshold,_that.shakeAction,_that.feedback,_that.beepVolume,_that.shakeTriggerCoolDown,_that.shakeTriggerCount,_that.samplingPeriod);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool isEnabled, ShakeDirection direction, double threshold, ShakeAction shakeAction, Set feedback, double beepVolume, Duration shakeTriggerCoolDown, int shakeTriggerCount, Duration samplingPeriod)? $default,) {final _that = this; +switch (_that) { +case _ShakeDetectionSettings() when $default != null: +return $default(_that.isEnabled,_that.direction,_that.threshold,_that.shakeAction,_that.feedback,_that.beepVolume,_that.shakeTriggerCoolDown,_that.shakeTriggerCount,_that.samplingPeriod);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$ShakeDetectionSettingsImpl implements _ShakeDetectionSettings { - const _$ShakeDetectionSettingsImpl( - {this.isEnabled = true, - this.direction = ShakeDirection.horizontal, - this.threshold = 5, - this.shakeAction = ShakeAction.resetSleepTimer, - final Set feedback = const { - ShakeDetectedFeedback.vibrate - }, - this.beepVolume = 0.5, - this.shakeTriggerCoolDown = const Duration(seconds: 2), - this.shakeTriggerCount = 2, - this.samplingPeriod = const Duration(milliseconds: 100)}) - : _feedback = feedback; - factory _$ShakeDetectionSettingsImpl.fromJson(Map json) => - _$$ShakeDetectionSettingsImplFromJson(json); +class _ShakeDetectionSettings implements ShakeDetectionSettings { + const _ShakeDetectionSettings({this.isEnabled = true, this.direction = ShakeDirection.horizontal, this.threshold = 5, this.shakeAction = ShakeAction.resetSleepTimer, final Set feedback = const {ShakeDetectedFeedback.vibrate}, this.beepVolume = 0.5, this.shakeTriggerCoolDown = const Duration(seconds: 2), this.shakeTriggerCount = 2, this.samplingPeriod = const Duration(milliseconds: 100)}): _feedback = feedback; + factory _ShakeDetectionSettings.fromJson(Map json) => _$ShakeDetectionSettingsFromJson(json); - @override - @JsonKey() - final bool isEnabled; - @override - @JsonKey() - final ShakeDirection direction; - @override - @JsonKey() - final double threshold; - @override - @JsonKey() - final ShakeAction shakeAction; - final Set _feedback; - @override - @JsonKey() - Set get feedback { - if (_feedback is EqualUnmodifiableSetView) return _feedback; - // ignore: implicit_dynamic_type - return EqualUnmodifiableSetView(_feedback); - } - - @override - @JsonKey() - final double beepVolume; - - /// the duration to wait before the shake detection is enabled again - @override - @JsonKey() - final Duration shakeTriggerCoolDown; - - /// the number of shakes required to trigger the action - @override - @JsonKey() - final int shakeTriggerCount; - - /// acceleration sampling interval - @override - @JsonKey() - final Duration samplingPeriod; - - @override - String toString() { - return 'ShakeDetectionSettings(isEnabled: $isEnabled, direction: $direction, threshold: $threshold, shakeAction: $shakeAction, feedback: $feedback, beepVolume: $beepVolume, shakeTriggerCoolDown: $shakeTriggerCoolDown, shakeTriggerCount: $shakeTriggerCount, samplingPeriod: $samplingPeriod)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ShakeDetectionSettingsImpl && - (identical(other.isEnabled, isEnabled) || - other.isEnabled == isEnabled) && - (identical(other.direction, direction) || - other.direction == direction) && - (identical(other.threshold, threshold) || - other.threshold == threshold) && - (identical(other.shakeAction, shakeAction) || - other.shakeAction == shakeAction) && - const DeepCollectionEquality().equals(other._feedback, _feedback) && - (identical(other.beepVolume, beepVolume) || - other.beepVolume == beepVolume) && - (identical(other.shakeTriggerCoolDown, shakeTriggerCoolDown) || - other.shakeTriggerCoolDown == shakeTriggerCoolDown) && - (identical(other.shakeTriggerCount, shakeTriggerCount) || - other.shakeTriggerCount == shakeTriggerCount) && - (identical(other.samplingPeriod, samplingPeriod) || - other.samplingPeriod == samplingPeriod)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - isEnabled, - direction, - threshold, - shakeAction, - const DeepCollectionEquality().hash(_feedback), - beepVolume, - shakeTriggerCoolDown, - shakeTriggerCount, - samplingPeriod); - - /// Create a copy of ShakeDetectionSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ShakeDetectionSettingsImplCopyWith<_$ShakeDetectionSettingsImpl> - get copyWith => __$$ShakeDetectionSettingsImplCopyWithImpl< - _$ShakeDetectionSettingsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$ShakeDetectionSettingsImplToJson( - this, - ); - } +@override@JsonKey() final bool isEnabled; +@override@JsonKey() final ShakeDirection direction; +@override@JsonKey() final double threshold; +@override@JsonKey() final ShakeAction shakeAction; + final Set _feedback; +@override@JsonKey() Set get feedback { + if (_feedback is EqualUnmodifiableSetView) return _feedback; + // ignore: implicit_dynamic_type + return EqualUnmodifiableSetView(_feedback); } -abstract class _ShakeDetectionSettings implements ShakeDetectionSettings { - const factory _ShakeDetectionSettings( - {final bool isEnabled, - final ShakeDirection direction, - final double threshold, - final ShakeAction shakeAction, - final Set feedback, - final double beepVolume, - final Duration shakeTriggerCoolDown, - final int shakeTriggerCount, - final Duration samplingPeriod}) = _$ShakeDetectionSettingsImpl; +@override@JsonKey() final double beepVolume; +/// the duration to wait before the shake detection is enabled again +@override@JsonKey() final Duration shakeTriggerCoolDown; +/// the number of shakes required to trigger the action +@override@JsonKey() final int shakeTriggerCount; +/// acceleration sampling interval +@override@JsonKey() final Duration samplingPeriod; - factory _ShakeDetectionSettings.fromJson(Map json) = - _$ShakeDetectionSettingsImpl.fromJson; +/// Create a copy of ShakeDetectionSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ShakeDetectionSettingsCopyWith<_ShakeDetectionSettings> get copyWith => __$ShakeDetectionSettingsCopyWithImpl<_ShakeDetectionSettings>(this, _$identity); - @override - bool get isEnabled; - @override - ShakeDirection get direction; - @override - double get threshold; - @override - ShakeAction get shakeAction; - @override - Set get feedback; - @override - double get beepVolume; - - /// the duration to wait before the shake detection is enabled again - @override - Duration get shakeTriggerCoolDown; - - /// the number of shakes required to trigger the action - @override - int get shakeTriggerCount; - - /// acceleration sampling interval - @override - Duration get samplingPeriod; - - /// Create a copy of ShakeDetectionSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ShakeDetectionSettingsImplCopyWith<_$ShakeDetectionSettingsImpl> - get copyWith => throw _privateConstructorUsedError; +@override +Map toJson() { + return _$ShakeDetectionSettingsToJson(this, ); } -HomePageSettings _$HomePageSettingsFromJson(Map json) { - return _HomePageSettings.fromJson(json); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ShakeDetectionSettings&&(identical(other.isEnabled, isEnabled) || other.isEnabled == isEnabled)&&(identical(other.direction, direction) || other.direction == direction)&&(identical(other.threshold, threshold) || other.threshold == threshold)&&(identical(other.shakeAction, shakeAction) || other.shakeAction == shakeAction)&&const DeepCollectionEquality().equals(other._feedback, _feedback)&&(identical(other.beepVolume, beepVolume) || other.beepVolume == beepVolume)&&(identical(other.shakeTriggerCoolDown, shakeTriggerCoolDown) || other.shakeTriggerCoolDown == shakeTriggerCoolDown)&&(identical(other.shakeTriggerCount, shakeTriggerCount) || other.shakeTriggerCount == shakeTriggerCount)&&(identical(other.samplingPeriod, samplingPeriod) || other.samplingPeriod == samplingPeriod)); } +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,isEnabled,direction,threshold,shakeAction,const DeepCollectionEquality().hash(_feedback),beepVolume,shakeTriggerCoolDown,shakeTriggerCount,samplingPeriod); + +@override +String toString() { + return 'ShakeDetectionSettings(isEnabled: $isEnabled, direction: $direction, threshold: $threshold, shakeAction: $shakeAction, feedback: $feedback, beepVolume: $beepVolume, shakeTriggerCoolDown: $shakeTriggerCoolDown, shakeTriggerCount: $shakeTriggerCount, samplingPeriod: $samplingPeriod)'; +} + + +} + +/// @nodoc +abstract mixin class _$ShakeDetectionSettingsCopyWith<$Res> implements $ShakeDetectionSettingsCopyWith<$Res> { + factory _$ShakeDetectionSettingsCopyWith(_ShakeDetectionSettings value, $Res Function(_ShakeDetectionSettings) _then) = __$ShakeDetectionSettingsCopyWithImpl; +@override @useResult +$Res call({ + bool isEnabled, ShakeDirection direction, double threshold, ShakeAction shakeAction, Set feedback, double beepVolume, Duration shakeTriggerCoolDown, int shakeTriggerCount, Duration samplingPeriod +}); + + + + +} +/// @nodoc +class __$ShakeDetectionSettingsCopyWithImpl<$Res> + implements _$ShakeDetectionSettingsCopyWith<$Res> { + __$ShakeDetectionSettingsCopyWithImpl(this._self, this._then); + + final _ShakeDetectionSettings _self; + final $Res Function(_ShakeDetectionSettings) _then; + +/// Create a copy of ShakeDetectionSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? isEnabled = null,Object? direction = null,Object? threshold = null,Object? shakeAction = null,Object? feedback = null,Object? beepVolume = null,Object? shakeTriggerCoolDown = null,Object? shakeTriggerCount = null,Object? samplingPeriod = null,}) { + return _then(_ShakeDetectionSettings( +isEnabled: null == isEnabled ? _self.isEnabled : isEnabled // ignore: cast_nullable_to_non_nullable +as bool,direction: null == direction ? _self.direction : direction // ignore: cast_nullable_to_non_nullable +as ShakeDirection,threshold: null == threshold ? _self.threshold : threshold // ignore: cast_nullable_to_non_nullable +as double,shakeAction: null == shakeAction ? _self.shakeAction : shakeAction // ignore: cast_nullable_to_non_nullable +as ShakeAction,feedback: null == feedback ? _self._feedback : feedback // ignore: cast_nullable_to_non_nullable +as Set,beepVolume: null == beepVolume ? _self.beepVolume : beepVolume // ignore: cast_nullable_to_non_nullable +as double,shakeTriggerCoolDown: null == shakeTriggerCoolDown ? _self.shakeTriggerCoolDown : shakeTriggerCoolDown // ignore: cast_nullable_to_non_nullable +as Duration,shakeTriggerCount: null == shakeTriggerCount ? _self.shakeTriggerCount : shakeTriggerCount // ignore: cast_nullable_to_non_nullable +as int,samplingPeriod: null == samplingPeriod ? _self.samplingPeriod : samplingPeriod // ignore: cast_nullable_to_non_nullable +as Duration, + )); +} + + +} + + /// @nodoc mixin _$HomePageSettings { - bool get showPlayButtonOnContinueListeningShelf => - throw _privateConstructorUsedError; - bool get showPlayButtonOnContinueSeriesShelf => - throw _privateConstructorUsedError; - bool get showPlayButtonOnAllRemainingShelves => - throw _privateConstructorUsedError; - bool get showPlayButtonOnListenAgainShelf => - throw _privateConstructorUsedError; + + bool get showPlayButtonOnContinueListeningShelf; bool get showPlayButtonOnContinueSeriesShelf; bool get showPlayButtonOnAllRemainingShelves; bool get showPlayButtonOnListenAgainShelf; +/// Create a copy of HomePageSettings +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$HomePageSettingsCopyWith get copyWith => _$HomePageSettingsCopyWithImpl(this as HomePageSettings, _$identity); /// Serializes this HomePageSettings to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is HomePageSettings&&(identical(other.showPlayButtonOnContinueListeningShelf, showPlayButtonOnContinueListeningShelf) || other.showPlayButtonOnContinueListeningShelf == showPlayButtonOnContinueListeningShelf)&&(identical(other.showPlayButtonOnContinueSeriesShelf, showPlayButtonOnContinueSeriesShelf) || other.showPlayButtonOnContinueSeriesShelf == showPlayButtonOnContinueSeriesShelf)&&(identical(other.showPlayButtonOnAllRemainingShelves, showPlayButtonOnAllRemainingShelves) || other.showPlayButtonOnAllRemainingShelves == showPlayButtonOnAllRemainingShelves)&&(identical(other.showPlayButtonOnListenAgainShelf, showPlayButtonOnListenAgainShelf) || other.showPlayButtonOnListenAgainShelf == showPlayButtonOnListenAgainShelf)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,showPlayButtonOnContinueListeningShelf,showPlayButtonOnContinueSeriesShelf,showPlayButtonOnAllRemainingShelves,showPlayButtonOnListenAgainShelf); + +@override +String toString() { + return 'HomePageSettings(showPlayButtonOnContinueListeningShelf: $showPlayButtonOnContinueListeningShelf, showPlayButtonOnContinueSeriesShelf: $showPlayButtonOnContinueSeriesShelf, showPlayButtonOnAllRemainingShelves: $showPlayButtonOnAllRemainingShelves, showPlayButtonOnListenAgainShelf: $showPlayButtonOnListenAgainShelf)'; +} + - /// Create a copy of HomePageSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $HomePageSettingsCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $HomePageSettingsCopyWith<$Res> { - factory $HomePageSettingsCopyWith( - HomePageSettings value, $Res Function(HomePageSettings) then) = - _$HomePageSettingsCopyWithImpl<$Res, HomePageSettings>; - @useResult - $Res call( - {bool showPlayButtonOnContinueListeningShelf, - bool showPlayButtonOnContinueSeriesShelf, - bool showPlayButtonOnAllRemainingShelves, - bool showPlayButtonOnListenAgainShelf}); -} +abstract mixin class $HomePageSettingsCopyWith<$Res> { + factory $HomePageSettingsCopyWith(HomePageSettings value, $Res Function(HomePageSettings) _then) = _$HomePageSettingsCopyWithImpl; +@useResult +$Res call({ + bool showPlayButtonOnContinueListeningShelf, bool showPlayButtonOnContinueSeriesShelf, bool showPlayButtonOnAllRemainingShelves, bool showPlayButtonOnListenAgainShelf +}); + + + +} /// @nodoc -class _$HomePageSettingsCopyWithImpl<$Res, $Val extends HomePageSettings> +class _$HomePageSettingsCopyWithImpl<$Res> implements $HomePageSettingsCopyWith<$Res> { - _$HomePageSettingsCopyWithImpl(this._value, this._then); + _$HomePageSettingsCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final HomePageSettings _self; + final $Res Function(HomePageSettings) _then; - /// Create a copy of HomePageSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? showPlayButtonOnContinueListeningShelf = null, - Object? showPlayButtonOnContinueSeriesShelf = null, - Object? showPlayButtonOnAllRemainingShelves = null, - Object? showPlayButtonOnListenAgainShelf = null, - }) { - return _then(_value.copyWith( - showPlayButtonOnContinueListeningShelf: null == - showPlayButtonOnContinueListeningShelf - ? _value.showPlayButtonOnContinueListeningShelf - : showPlayButtonOnContinueListeningShelf // ignore: cast_nullable_to_non_nullable - as bool, - showPlayButtonOnContinueSeriesShelf: null == - showPlayButtonOnContinueSeriesShelf - ? _value.showPlayButtonOnContinueSeriesShelf - : showPlayButtonOnContinueSeriesShelf // ignore: cast_nullable_to_non_nullable - as bool, - showPlayButtonOnAllRemainingShelves: null == - showPlayButtonOnAllRemainingShelves - ? _value.showPlayButtonOnAllRemainingShelves - : showPlayButtonOnAllRemainingShelves // ignore: cast_nullable_to_non_nullable - as bool, - showPlayButtonOnListenAgainShelf: null == showPlayButtonOnListenAgainShelf - ? _value.showPlayButtonOnListenAgainShelf - : showPlayButtonOnListenAgainShelf // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } +/// Create a copy of HomePageSettings +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? showPlayButtonOnContinueListeningShelf = null,Object? showPlayButtonOnContinueSeriesShelf = null,Object? showPlayButtonOnAllRemainingShelves = null,Object? showPlayButtonOnListenAgainShelf = null,}) { + return _then(_self.copyWith( +showPlayButtonOnContinueListeningShelf: null == showPlayButtonOnContinueListeningShelf ? _self.showPlayButtonOnContinueListeningShelf : showPlayButtonOnContinueListeningShelf // ignore: cast_nullable_to_non_nullable +as bool,showPlayButtonOnContinueSeriesShelf: null == showPlayButtonOnContinueSeriesShelf ? _self.showPlayButtonOnContinueSeriesShelf : showPlayButtonOnContinueSeriesShelf // ignore: cast_nullable_to_non_nullable +as bool,showPlayButtonOnAllRemainingShelves: null == showPlayButtonOnAllRemainingShelves ? _self.showPlayButtonOnAllRemainingShelves : showPlayButtonOnAllRemainingShelves // ignore: cast_nullable_to_non_nullable +as bool,showPlayButtonOnListenAgainShelf: null == showPlayButtonOnListenAgainShelf ? _self.showPlayButtonOnListenAgainShelf : showPlayButtonOnListenAgainShelf // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$HomePageSettingsImplCopyWith<$Res> - implements $HomePageSettingsCopyWith<$Res> { - factory _$$HomePageSettingsImplCopyWith(_$HomePageSettingsImpl value, - $Res Function(_$HomePageSettingsImpl) then) = - __$$HomePageSettingsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {bool showPlayButtonOnContinueListeningShelf, - bool showPlayButtonOnContinueSeriesShelf, - bool showPlayButtonOnAllRemainingShelves, - bool showPlayButtonOnListenAgainShelf}); } -/// @nodoc -class __$$HomePageSettingsImplCopyWithImpl<$Res> - extends _$HomePageSettingsCopyWithImpl<$Res, _$HomePageSettingsImpl> - implements _$$HomePageSettingsImplCopyWith<$Res> { - __$$HomePageSettingsImplCopyWithImpl(_$HomePageSettingsImpl _value, - $Res Function(_$HomePageSettingsImpl) _then) - : super(_value, _then); - /// Create a copy of HomePageSettings - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? showPlayButtonOnContinueListeningShelf = null, - Object? showPlayButtonOnContinueSeriesShelf = null, - Object? showPlayButtonOnAllRemainingShelves = null, - Object? showPlayButtonOnListenAgainShelf = null, - }) { - return _then(_$HomePageSettingsImpl( - showPlayButtonOnContinueListeningShelf: null == - showPlayButtonOnContinueListeningShelf - ? _value.showPlayButtonOnContinueListeningShelf - : showPlayButtonOnContinueListeningShelf // ignore: cast_nullable_to_non_nullable - as bool, - showPlayButtonOnContinueSeriesShelf: null == - showPlayButtonOnContinueSeriesShelf - ? _value.showPlayButtonOnContinueSeriesShelf - : showPlayButtonOnContinueSeriesShelf // ignore: cast_nullable_to_non_nullable - as bool, - showPlayButtonOnAllRemainingShelves: null == - showPlayButtonOnAllRemainingShelves - ? _value.showPlayButtonOnAllRemainingShelves - : showPlayButtonOnAllRemainingShelves // ignore: cast_nullable_to_non_nullable - as bool, - showPlayButtonOnListenAgainShelf: null == showPlayButtonOnListenAgainShelf - ? _value.showPlayButtonOnListenAgainShelf - : showPlayButtonOnListenAgainShelf // ignore: cast_nullable_to_non_nullable - as bool, - )); - } +/// Adds pattern-matching-related methods to [HomePageSettings]. +extension HomePageSettingsPatterns on HomePageSettings { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _HomePageSettings value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _HomePageSettings() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _HomePageSettings value) $default,){ +final _that = this; +switch (_that) { +case _HomePageSettings(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _HomePageSettings value)? $default,){ +final _that = this; +switch (_that) { +case _HomePageSettings() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( bool showPlayButtonOnContinueListeningShelf, bool showPlayButtonOnContinueSeriesShelf, bool showPlayButtonOnAllRemainingShelves, bool showPlayButtonOnListenAgainShelf)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _HomePageSettings() when $default != null: +return $default(_that.showPlayButtonOnContinueListeningShelf,_that.showPlayButtonOnContinueSeriesShelf,_that.showPlayButtonOnAllRemainingShelves,_that.showPlayButtonOnListenAgainShelf);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( bool showPlayButtonOnContinueListeningShelf, bool showPlayButtonOnContinueSeriesShelf, bool showPlayButtonOnAllRemainingShelves, bool showPlayButtonOnListenAgainShelf) $default,) {final _that = this; +switch (_that) { +case _HomePageSettings(): +return $default(_that.showPlayButtonOnContinueListeningShelf,_that.showPlayButtonOnContinueSeriesShelf,_that.showPlayButtonOnAllRemainingShelves,_that.showPlayButtonOnListenAgainShelf);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool showPlayButtonOnContinueListeningShelf, bool showPlayButtonOnContinueSeriesShelf, bool showPlayButtonOnAllRemainingShelves, bool showPlayButtonOnListenAgainShelf)? $default,) {final _that = this; +switch (_that) { +case _HomePageSettings() when $default != null: +return $default(_that.showPlayButtonOnContinueListeningShelf,_that.showPlayButtonOnContinueSeriesShelf,_that.showPlayButtonOnAllRemainingShelves,_that.showPlayButtonOnListenAgainShelf);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$HomePageSettingsImpl implements _HomePageSettings { - const _$HomePageSettingsImpl( - {this.showPlayButtonOnContinueListeningShelf = true, - this.showPlayButtonOnContinueSeriesShelf = false, - this.showPlayButtonOnAllRemainingShelves = false, - this.showPlayButtonOnListenAgainShelf = false}); - factory _$HomePageSettingsImpl.fromJson(Map json) => - _$$HomePageSettingsImplFromJson(json); +class _HomePageSettings implements HomePageSettings { + const _HomePageSettings({this.showPlayButtonOnContinueListeningShelf = true, this.showPlayButtonOnContinueSeriesShelf = false, this.showPlayButtonOnAllRemainingShelves = false, this.showPlayButtonOnListenAgainShelf = false}); + factory _HomePageSettings.fromJson(Map json) => _$HomePageSettingsFromJson(json); - @override - @JsonKey() - final bool showPlayButtonOnContinueListeningShelf; - @override - @JsonKey() - final bool showPlayButtonOnContinueSeriesShelf; - @override - @JsonKey() - final bool showPlayButtonOnAllRemainingShelves; - @override - @JsonKey() - final bool showPlayButtonOnListenAgainShelf; +@override@JsonKey() final bool showPlayButtonOnContinueListeningShelf; +@override@JsonKey() final bool showPlayButtonOnContinueSeriesShelf; +@override@JsonKey() final bool showPlayButtonOnAllRemainingShelves; +@override@JsonKey() final bool showPlayButtonOnListenAgainShelf; - @override - String toString() { - return 'HomePageSettings(showPlayButtonOnContinueListeningShelf: $showPlayButtonOnContinueListeningShelf, showPlayButtonOnContinueSeriesShelf: $showPlayButtonOnContinueSeriesShelf, showPlayButtonOnAllRemainingShelves: $showPlayButtonOnAllRemainingShelves, showPlayButtonOnListenAgainShelf: $showPlayButtonOnListenAgainShelf)'; - } +/// Create a copy of HomePageSettings +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$HomePageSettingsCopyWith<_HomePageSettings> get copyWith => __$HomePageSettingsCopyWithImpl<_HomePageSettings>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$HomePageSettingsImpl && - (identical(other.showPlayButtonOnContinueListeningShelf, - showPlayButtonOnContinueListeningShelf) || - other.showPlayButtonOnContinueListeningShelf == - showPlayButtonOnContinueListeningShelf) && - (identical(other.showPlayButtonOnContinueSeriesShelf, - showPlayButtonOnContinueSeriesShelf) || - other.showPlayButtonOnContinueSeriesShelf == - showPlayButtonOnContinueSeriesShelf) && - (identical(other.showPlayButtonOnAllRemainingShelves, - showPlayButtonOnAllRemainingShelves) || - other.showPlayButtonOnAllRemainingShelves == - showPlayButtonOnAllRemainingShelves) && - (identical(other.showPlayButtonOnListenAgainShelf, - showPlayButtonOnListenAgainShelf) || - other.showPlayButtonOnListenAgainShelf == - showPlayButtonOnListenAgainShelf)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - showPlayButtonOnContinueListeningShelf, - showPlayButtonOnContinueSeriesShelf, - showPlayButtonOnAllRemainingShelves, - showPlayButtonOnListenAgainShelf); - - /// Create a copy of HomePageSettings - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$HomePageSettingsImplCopyWith<_$HomePageSettingsImpl> get copyWith => - __$$HomePageSettingsImplCopyWithImpl<_$HomePageSettingsImpl>( - this, _$identity); - - @override - Map toJson() { - return _$$HomePageSettingsImplToJson( - this, - ); - } +@override +Map toJson() { + return _$HomePageSettingsToJson(this, ); } -abstract class _HomePageSettings implements HomePageSettings { - const factory _HomePageSettings( - {final bool showPlayButtonOnContinueListeningShelf, - final bool showPlayButtonOnContinueSeriesShelf, - final bool showPlayButtonOnAllRemainingShelves, - final bool showPlayButtonOnListenAgainShelf}) = _$HomePageSettingsImpl; - - factory _HomePageSettings.fromJson(Map json) = - _$HomePageSettingsImpl.fromJson; - - @override - bool get showPlayButtonOnContinueListeningShelf; - @override - bool get showPlayButtonOnContinueSeriesShelf; - @override - bool get showPlayButtonOnAllRemainingShelves; - @override - bool get showPlayButtonOnListenAgainShelf; - - /// Create a copy of HomePageSettings - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$HomePageSettingsImplCopyWith<_$HomePageSettingsImpl> get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _HomePageSettings&&(identical(other.showPlayButtonOnContinueListeningShelf, showPlayButtonOnContinueListeningShelf) || other.showPlayButtonOnContinueListeningShelf == showPlayButtonOnContinueListeningShelf)&&(identical(other.showPlayButtonOnContinueSeriesShelf, showPlayButtonOnContinueSeriesShelf) || other.showPlayButtonOnContinueSeriesShelf == showPlayButtonOnContinueSeriesShelf)&&(identical(other.showPlayButtonOnAllRemainingShelves, showPlayButtonOnAllRemainingShelves) || other.showPlayButtonOnAllRemainingShelves == showPlayButtonOnAllRemainingShelves)&&(identical(other.showPlayButtonOnListenAgainShelf, showPlayButtonOnListenAgainShelf) || other.showPlayButtonOnListenAgainShelf == showPlayButtonOnListenAgainShelf)); } + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,showPlayButtonOnContinueListeningShelf,showPlayButtonOnContinueSeriesShelf,showPlayButtonOnAllRemainingShelves,showPlayButtonOnListenAgainShelf); + +@override +String toString() { + return 'HomePageSettings(showPlayButtonOnContinueListeningShelf: $showPlayButtonOnContinueListeningShelf, showPlayButtonOnContinueSeriesShelf: $showPlayButtonOnContinueSeriesShelf, showPlayButtonOnAllRemainingShelves: $showPlayButtonOnAllRemainingShelves, showPlayButtonOnListenAgainShelf: $showPlayButtonOnListenAgainShelf)'; +} + + +} + +/// @nodoc +abstract mixin class _$HomePageSettingsCopyWith<$Res> implements $HomePageSettingsCopyWith<$Res> { + factory _$HomePageSettingsCopyWith(_HomePageSettings value, $Res Function(_HomePageSettings) _then) = __$HomePageSettingsCopyWithImpl; +@override @useResult +$Res call({ + bool showPlayButtonOnContinueListeningShelf, bool showPlayButtonOnContinueSeriesShelf, bool showPlayButtonOnAllRemainingShelves, bool showPlayButtonOnListenAgainShelf +}); + + + + +} +/// @nodoc +class __$HomePageSettingsCopyWithImpl<$Res> + implements _$HomePageSettingsCopyWith<$Res> { + __$HomePageSettingsCopyWithImpl(this._self, this._then); + + final _HomePageSettings _self; + final $Res Function(_HomePageSettings) _then; + +/// Create a copy of HomePageSettings +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? showPlayButtonOnContinueListeningShelf = null,Object? showPlayButtonOnContinueSeriesShelf = null,Object? showPlayButtonOnAllRemainingShelves = null,Object? showPlayButtonOnListenAgainShelf = null,}) { + return _then(_HomePageSettings( +showPlayButtonOnContinueListeningShelf: null == showPlayButtonOnContinueListeningShelf ? _self.showPlayButtonOnContinueListeningShelf : showPlayButtonOnContinueListeningShelf // ignore: cast_nullable_to_non_nullable +as bool,showPlayButtonOnContinueSeriesShelf: null == showPlayButtonOnContinueSeriesShelf ? _self.showPlayButtonOnContinueSeriesShelf : showPlayButtonOnContinueSeriesShelf // ignore: cast_nullable_to_non_nullable +as bool,showPlayButtonOnAllRemainingShelves: null == showPlayButtonOnAllRemainingShelves ? _self.showPlayButtonOnAllRemainingShelves : showPlayButtonOnAllRemainingShelves // ignore: cast_nullable_to_non_nullable +as bool,showPlayButtonOnListenAgainShelf: null == showPlayButtonOnListenAgainShelf ? _self.showPlayButtonOnListenAgainShelf : showPlayButtonOnListenAgainShelf // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/settings/models/app_settings.g.dart b/lib/settings/models/app_settings.g.dart index 131458c..003dac8 100644 --- a/lib/settings/models/app_settings.g.dart +++ b/lib/settings/models/app_settings.g.dart @@ -6,39 +6,41 @@ part of 'app_settings.dart'; // JsonSerializableGenerator // ************************************************************************** -_$AppSettingsImpl _$$AppSettingsImplFromJson(Map json) => - _$AppSettingsImpl( - themeSettings: json['themeSettings'] == null - ? const ThemeSettings() - : ThemeSettings.fromJson( - json['themeSettings'] as Map), - playerSettings: json['playerSettings'] == null - ? const PlayerSettings() - : PlayerSettings.fromJson( - json['playerSettings'] as Map), - sleepTimerSettings: json['sleepTimerSettings'] == null - ? const SleepTimerSettings() - : SleepTimerSettings.fromJson( - json['sleepTimerSettings'] as Map), - downloadSettings: json['downloadSettings'] == null - ? const DownloadSettings() - : DownloadSettings.fromJson( - json['downloadSettings'] as Map), - notificationSettings: json['notificationSettings'] == null - ? const NotificationSettings() - : NotificationSettings.fromJson( - json['notificationSettings'] as Map), - shakeDetectionSettings: json['shakeDetectionSettings'] == null - ? const ShakeDetectionSettings() - : ShakeDetectionSettings.fromJson( - json['shakeDetectionSettings'] as Map), - homePageSettings: json['homePageSettings'] == null - ? const HomePageSettings() - : HomePageSettings.fromJson( - json['homePageSettings'] as Map), - ); +_AppSettings _$AppSettingsFromJson(Map json) => _AppSettings( + themeSettings: json['themeSettings'] == null + ? const ThemeSettings() + : ThemeSettings.fromJson(json['themeSettings'] as Map), + playerSettings: json['playerSettings'] == null + ? const PlayerSettings() + : PlayerSettings.fromJson(json['playerSettings'] as Map), + sleepTimerSettings: json['sleepTimerSettings'] == null + ? const SleepTimerSettings() + : SleepTimerSettings.fromJson( + json['sleepTimerSettings'] as Map, + ), + downloadSettings: json['downloadSettings'] == null + ? const DownloadSettings() + : DownloadSettings.fromJson( + json['downloadSettings'] as Map, + ), + notificationSettings: json['notificationSettings'] == null + ? const NotificationSettings() + : NotificationSettings.fromJson( + json['notificationSettings'] as Map, + ), + shakeDetectionSettings: json['shakeDetectionSettings'] == null + ? const ShakeDetectionSettings() + : ShakeDetectionSettings.fromJson( + json['shakeDetectionSettings'] as Map, + ), + homePageSettings: json['homePageSettings'] == null + ? const HomePageSettings() + : HomePageSettings.fromJson( + json['homePageSettings'] as Map, + ), +); -Map _$$AppSettingsImplToJson(_$AppSettingsImpl instance) => +Map _$AppSettingsToJson(_AppSettings instance) => { 'themeSettings': instance.themeSettings, 'playerSettings': instance.playerSettings, @@ -49,9 +51,10 @@ Map _$$AppSettingsImplToJson(_$AppSettingsImpl instance) => 'homePageSettings': instance.homePageSettings, }; -_$ThemeSettingsImpl _$$ThemeSettingsImplFromJson(Map json) => - _$ThemeSettingsImpl( - themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']) ?? +_ThemeSettings _$ThemeSettingsFromJson(Map json) => + _ThemeSettings( + themeMode: + $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']) ?? ThemeMode.system, highContrast: json['highContrast'] as bool? ?? false, useMaterialThemeFromSystem: @@ -63,7 +66,7 @@ _$ThemeSettingsImpl _$$ThemeSettingsImplFromJson(Map json) => json['useCurrentPlayerThemeThroughoutApp'] as bool? ?? true, ); -Map _$$ThemeSettingsImplToJson(_$ThemeSettingsImpl instance) => +Map _$ThemeSettingsToJson(_ThemeSettings instance) => { 'themeMode': _$ThemeModeEnumMap[instance.themeMode]!, 'highContrast': instance.highContrast, @@ -80,96 +83,97 @@ const _$ThemeModeEnumMap = { ThemeMode.dark: 'dark', }; -_$PlayerSettingsImpl _$$PlayerSettingsImplFromJson(Map json) => - _$PlayerSettingsImpl( - miniPlayerSettings: json['miniPlayerSettings'] == null - ? const MinimizedPlayerSettings() - : MinimizedPlayerSettings.fromJson( - json['miniPlayerSettings'] as Map), - expandedPlayerSettings: json['expandedPlayerSettings'] == null - ? const ExpandedPlayerSettings() - : ExpandedPlayerSettings.fromJson( - json['expandedPlayerSettings'] as Map), - preferredDefaultVolume: - (json['preferredDefaultVolume'] as num?)?.toDouble() ?? 1, - preferredDefaultSpeed: - (json['preferredDefaultSpeed'] as num?)?.toDouble() ?? 1, - speedOptions: (json['speedOptions'] as List?) - ?.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, - ); +_PlayerSettings _$PlayerSettingsFromJson( + Map json, +) => _PlayerSettings( + miniPlayerSettings: json['miniPlayerSettings'] == null + ? const MinimizedPlayerSettings() + : MinimizedPlayerSettings.fromJson( + json['miniPlayerSettings'] as Map, + ), + expandedPlayerSettings: json['expandedPlayerSettings'] == null + ? const ExpandedPlayerSettings() + : ExpandedPlayerSettings.fromJson( + json['expandedPlayerSettings'] as Map, + ), + preferredDefaultVolume: + (json['preferredDefaultVolume'] as num?)?.toDouble() ?? 1, + preferredDefaultSpeed: + (json['preferredDefaultSpeed'] as num?)?.toDouble() ?? 1, + speedOptions: + (json['speedOptions'] as List?) + ?.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 _$$PlayerSettingsImplToJson( - _$PlayerSettingsImpl instance) => - { - '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, - }; +Map _$PlayerSettingsToJson( + _PlayerSettings instance, +) => { + '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 json) => - _$ExpandedPlayerSettingsImpl( - showTotalProgress: json['showTotalProgress'] as bool? ?? false, - showChapterProgress: json['showChapterProgress'] as bool? ?? true, - ); +_ExpandedPlayerSettings _$ExpandedPlayerSettingsFromJson( + Map json, +) => _ExpandedPlayerSettings( + showTotalProgress: json['showTotalProgress'] as bool? ?? false, + showChapterProgress: json['showChapterProgress'] as bool? ?? true, +); -Map _$$ExpandedPlayerSettingsImplToJson( - _$ExpandedPlayerSettingsImpl instance) => - { - 'showTotalProgress': instance.showTotalProgress, - 'showChapterProgress': instance.showChapterProgress, - }; +Map _$ExpandedPlayerSettingsToJson( + _ExpandedPlayerSettings instance, +) => { + 'showTotalProgress': instance.showTotalProgress, + 'showChapterProgress': instance.showChapterProgress, +}; -_$MinimizedPlayerSettingsImpl _$$MinimizedPlayerSettingsImplFromJson( - Map json) => - _$MinimizedPlayerSettingsImpl( - useChapterInfo: json['useChapterInfo'] as bool? ?? false, - ); +_MinimizedPlayerSettings _$MinimizedPlayerSettingsFromJson( + Map json, +) => _MinimizedPlayerSettings( + useChapterInfo: json['useChapterInfo'] as bool? ?? false, +); -Map _$$MinimizedPlayerSettingsImplToJson( - _$MinimizedPlayerSettingsImpl instance) => - { - 'useChapterInfo': instance.useChapterInfo, - }; +Map _$MinimizedPlayerSettingsToJson( + _MinimizedPlayerSettings instance, +) => {'useChapterInfo': instance.useChapterInfo}; -_$SleepTimerSettingsImpl _$$SleepTimerSettingsImplFromJson( - Map json) => - _$SleepTimerSettingsImpl( +_SleepTimerSettings _$SleepTimerSettingsFromJson(Map json) => + _SleepTimerSettings( defaultDuration: json['defaultDuration'] == null ? const Duration(minutes: 15) : Duration(microseconds: (json['defaultDuration'] as num).toInt()), - presetDurations: (json['presetDurations'] as List?) + presetDurations: + (json['presetDurations'] as List?) ?.map((e) => Duration(microseconds: (e as num).toInt())) .toList() ?? const [ @@ -177,7 +181,7 @@ _$SleepTimerSettingsImpl _$$SleepTimerSettingsImplFromJson( Duration(minutes: 10), Duration(minutes: 15), Duration(minutes: 20), - Duration(minutes: 30) + Duration(minutes: 30), ], maxDuration: json['maxDuration'] == null ? const Duration(minutes: 100) @@ -189,16 +193,18 @@ _$SleepTimerSettingsImpl _$$SleepTimerSettingsImplFromJson( autoRewindWhenStopped: json['autoRewindWhenStopped'] as bool? ?? false, autoRewindDurations: (json['autoRewindDurations'] as Map?)?.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) - }, + (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 @@ -209,27 +215,27 @@ _$SleepTimerSettingsImpl _$$SleepTimerSettingsImplFromJson( : Duration(microseconds: (json['autoTurnOffTime'] as num).toInt()), ); -Map _$$SleepTimerSettingsImplToJson( - _$SleepTimerSettingsImpl instance) => +Map _$SleepTimerSettingsToJson(_SleepTimerSettings instance) => { 'defaultDuration': instance.defaultDuration.inMicroseconds, - 'presetDurations': - instance.presetDurations.map((e) => e.inMicroseconds).toList(), + '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)), + '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 json) => - _$DownloadSettingsImpl( +_DownloadSettings _$DownloadSettingsFromJson(Map json) => + _DownloadSettings( requiresWiFi: json['requiresWiFi'] as bool? ?? true, retries: (json['retries'] as num?)?.toInt() ?? 3, allowPause: json['allowPause'] as bool? ?? true, @@ -239,8 +245,7 @@ _$DownloadSettingsImpl _$$DownloadSettingsImplFromJson( (json['maxConcurrentByGroup'] as num?)?.toInt() ?? 3, ); -Map _$$DownloadSettingsImplToJson( - _$DownloadSettingsImpl instance) => +Map _$DownloadSettingsToJson(_DownloadSettings instance) => { 'requiresWiFi': instance.requiresWiFi, 'retries': instance.retries, @@ -250,43 +255,43 @@ Map _$$DownloadSettingsImplToJson( 'maxConcurrentByGroup': instance.maxConcurrentByGroup, }; -_$NotificationSettingsImpl _$$NotificationSettingsImplFromJson( - Map 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?) - ?.map((e) => $enumDecode(_$NotificationMediaControlEnumMap, e)) - .toList() ?? - const [ - NotificationMediaControl.rewind, - NotificationMediaControl.fastForward, - NotificationMediaControl.skipToPreviousChapter, - NotificationMediaControl.skipToNextChapter - ], - ); +_NotificationSettings _$NotificationSettingsFromJson( + Map json, +) => _NotificationSettings( + 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?) + ?.map((e) => $enumDecode(_$NotificationMediaControlEnumMap, e)) + .toList() ?? + const [ + NotificationMediaControl.rewind, + NotificationMediaControl.fastForward, + NotificationMediaControl.skipToPreviousChapter, + NotificationMediaControl.skipToNextChapter, + ], +); -Map _$$NotificationSettingsImplToJson( - _$NotificationSettingsImpl instance) => - { - '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(), - }; +Map _$NotificationSettingsToJson( + _NotificationSettings instance, +) => { + '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', @@ -297,47 +302,47 @@ const _$NotificationMediaControlEnumMap = { NotificationMediaControl.skipToPreviousChapter: 'skipToPreviousChapter', }; -_$ShakeDetectionSettingsImpl _$$ShakeDetectionSettingsImplFromJson( - Map 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?) - ?.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()), - ); +_ShakeDetectionSettings _$ShakeDetectionSettingsFromJson( + Map json, +) => _ShakeDetectionSettings( + 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?) + ?.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 _$$ShakeDetectionSettingsImplToJson( - _$ShakeDetectionSettingsImpl instance) => - { - '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, - }; +Map _$ShakeDetectionSettingsToJson( + _ShakeDetectionSettings instance, +) => { + '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', @@ -357,9 +362,8 @@ const _$ShakeDetectedFeedbackEnumMap = { ShakeDetectedFeedback.beep: 'beep', }; -_$HomePageSettingsImpl _$$HomePageSettingsImplFromJson( - Map json) => - _$HomePageSettingsImpl( +_HomePageSettings _$HomePageSettingsFromJson(Map json) => + _HomePageSettings( showPlayButtonOnContinueListeningShelf: json['showPlayButtonOnContinueListeningShelf'] as bool? ?? true, showPlayButtonOnContinueSeriesShelf: @@ -370,15 +374,14 @@ _$HomePageSettingsImpl _$$HomePageSettingsImplFromJson( json['showPlayButtonOnListenAgainShelf'] as bool? ?? false, ); -Map _$$HomePageSettingsImplToJson( - _$HomePageSettingsImpl instance) => - { - 'showPlayButtonOnContinueListeningShelf': - instance.showPlayButtonOnContinueListeningShelf, - 'showPlayButtonOnContinueSeriesShelf': - instance.showPlayButtonOnContinueSeriesShelf, - 'showPlayButtonOnAllRemainingShelves': - instance.showPlayButtonOnAllRemainingShelves, - 'showPlayButtonOnListenAgainShelf': - instance.showPlayButtonOnListenAgainShelf, - }; +Map _$HomePageSettingsToJson( + _HomePageSettings instance, +) => { + 'showPlayButtonOnContinueListeningShelf': + instance.showPlayButtonOnContinueListeningShelf, + 'showPlayButtonOnContinueSeriesShelf': + instance.showPlayButtonOnContinueSeriesShelf, + 'showPlayButtonOnAllRemainingShelves': + instance.showPlayButtonOnAllRemainingShelves, + 'showPlayButtonOnListenAgainShelf': instance.showPlayButtonOnListenAgainShelf, +}; diff --git a/lib/settings/models/audiobookshelf_server.dart b/lib/settings/models/audiobookshelf_server.dart index 0c97e41..cbc14a2 100644 --- a/lib/settings/models/audiobookshelf_server.dart +++ b/lib/settings/models/audiobookshelf_server.dart @@ -7,7 +7,7 @@ typedef AudiobookShelfUri = Uri; /// Represents a audiobookshelf server @freezed -class AudiobookShelfServer with _$AudiobookShelfServer { +sealed class AudiobookShelfServer with _$AudiobookShelfServer { const factory AudiobookShelfServer({ required AudiobookShelfUri serverUrl, // String? serverName, diff --git a/lib/settings/models/audiobookshelf_server.freezed.dart b/lib/settings/models/audiobookshelf_server.freezed.dart index 39f095a..26ec5c4 100644 --- a/lib/settings/models/audiobookshelf_server.freezed.dart +++ b/lib/settings/models/audiobookshelf_server.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // 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 @@ -9,161 +9,263 @@ part of 'audiobookshelf_server.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(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 json) { - return _AudiobookShelfServer.fromJson(json); -} - /// @nodoc mixin _$AudiobookShelfServer { - Uri get serverUrl => throw _privateConstructorUsedError; + + AudiobookShelfUri get serverUrl; +/// Create a copy of AudiobookShelfServer +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$AudiobookShelfServerCopyWith get copyWith => _$AudiobookShelfServerCopyWithImpl(this as AudiobookShelfServer, _$identity); /// Serializes this AudiobookShelfServer to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is AudiobookShelfServer&&(identical(other.serverUrl, serverUrl) || other.serverUrl == serverUrl)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,serverUrl); + +@override +String toString() { + return 'AudiobookShelfServer(serverUrl: $serverUrl)'; +} + - /// Create a copy of AudiobookShelfServer - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $AudiobookShelfServerCopyWith 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}); -} +abstract mixin class $AudiobookShelfServerCopyWith<$Res> { + factory $AudiobookShelfServerCopyWith(AudiobookShelfServer value, $Res Function(AudiobookShelfServer) _then) = _$AudiobookShelfServerCopyWithImpl; +@useResult +$Res call({ + AudiobookShelfUri serverUrl +}); + + + +} /// @nodoc -class _$AudiobookShelfServerCopyWithImpl<$Res, - $Val extends AudiobookShelfServer> +class _$AudiobookShelfServerCopyWithImpl<$Res> implements $AudiobookShelfServerCopyWith<$Res> { - _$AudiobookShelfServerCopyWithImpl(this._value, this._then); + _$AudiobookShelfServerCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final AudiobookShelfServer _self; + final $Res Function(AudiobookShelfServer) _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); - } +/// 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(_self.copyWith( +serverUrl: null == serverUrl ? _self.serverUrl : serverUrl // ignore: cast_nullable_to_non_nullable +as AudiobookShelfUri, + )); } -/// @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, - )); - } +/// Adds pattern-matching-related methods to [AudiobookShelfServer]. +extension AudiobookShelfServerPatterns on AudiobookShelfServer { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _AudiobookShelfServer value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _AudiobookShelfServer() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _AudiobookShelfServer value) $default,){ +final _that = this; +switch (_that) { +case _AudiobookShelfServer(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _AudiobookShelfServer value)? $default,){ +final _that = this; +switch (_that) { +case _AudiobookShelfServer() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( AudiobookShelfUri serverUrl)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _AudiobookShelfServer() when $default != null: +return $default(_that.serverUrl);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( AudiobookShelfUri serverUrl) $default,) {final _that = this; +switch (_that) { +case _AudiobookShelfServer(): +return $default(_that.serverUrl);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( AudiobookShelfUri serverUrl)? $default,) {final _that = this; +switch (_that) { +case _AudiobookShelfServer() when $default != null: +return $default(_that.serverUrl);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$AudiobookShelfServerImpl implements _AudiobookShelfServer { - const _$AudiobookShelfServerImpl({required this.serverUrl}); - factory _$AudiobookShelfServerImpl.fromJson(Map json) => - _$$AudiobookShelfServerImplFromJson(json); +class _AudiobookShelfServer implements AudiobookShelfServer { + const _AudiobookShelfServer({required this.serverUrl}); + factory _AudiobookShelfServer.fromJson(Map json) => _$AudiobookShelfServerFromJson(json); - @override - final Uri serverUrl; +@override final AudiobookShelfUri serverUrl; - @override - String toString() { - return 'AudiobookShelfServer(serverUrl: $serverUrl)'; - } +/// Create a copy of AudiobookShelfServer +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AudiobookShelfServerCopyWith<_AudiobookShelfServer> get copyWith => __$AudiobookShelfServerCopyWithImpl<_AudiobookShelfServer>(this, _$identity); - @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 toJson() { - return _$$AudiobookShelfServerImplToJson( - this, - ); - } +@override +Map toJson() { + return _$AudiobookShelfServerToJson(this, ); } -abstract class _AudiobookShelfServer implements AudiobookShelfServer { - const factory _AudiobookShelfServer({required final Uri serverUrl}) = - _$AudiobookShelfServerImpl; - - factory _AudiobookShelfServer.fromJson(Map 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; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AudiobookShelfServer&&(identical(other.serverUrl, serverUrl) || other.serverUrl == serverUrl)); } + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,serverUrl); + +@override +String toString() { + return 'AudiobookShelfServer(serverUrl: $serverUrl)'; +} + + +} + +/// @nodoc +abstract mixin class _$AudiobookShelfServerCopyWith<$Res> implements $AudiobookShelfServerCopyWith<$Res> { + factory _$AudiobookShelfServerCopyWith(_AudiobookShelfServer value, $Res Function(_AudiobookShelfServer) _then) = __$AudiobookShelfServerCopyWithImpl; +@override @useResult +$Res call({ + AudiobookShelfUri serverUrl +}); + + + + +} +/// @nodoc +class __$AudiobookShelfServerCopyWithImpl<$Res> + implements _$AudiobookShelfServerCopyWith<$Res> { + __$AudiobookShelfServerCopyWithImpl(this._self, this._then); + + final _AudiobookShelfServer _self; + final $Res Function(_AudiobookShelfServer) _then; + +/// Create a copy of AudiobookShelfServer +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? serverUrl = null,}) { + return _then(_AudiobookShelfServer( +serverUrl: null == serverUrl ? _self.serverUrl : serverUrl // ignore: cast_nullable_to_non_nullable +as AudiobookShelfUri, + )); +} + + +} + +// dart format on diff --git a/lib/settings/models/audiobookshelf_server.g.dart b/lib/settings/models/audiobookshelf_server.g.dart index a876683..e8504ec 100644 --- a/lib/settings/models/audiobookshelf_server.g.dart +++ b/lib/settings/models/audiobookshelf_server.g.dart @@ -6,14 +6,10 @@ part of 'audiobookshelf_server.dart'; // JsonSerializableGenerator // ************************************************************************** -_$AudiobookShelfServerImpl _$$AudiobookShelfServerImplFromJson( - Map json) => - _$AudiobookShelfServerImpl( - serverUrl: Uri.parse(json['serverUrl'] as String), - ); +_AudiobookShelfServer _$AudiobookShelfServerFromJson( + Map json, +) => _AudiobookShelfServer(serverUrl: Uri.parse(json['serverUrl'] as String)); -Map _$$AudiobookShelfServerImplToJson( - _$AudiobookShelfServerImpl instance) => - { - 'serverUrl': instance.serverUrl.toString(), - }; +Map _$AudiobookShelfServerToJson( + _AudiobookShelfServer instance, +) => {'serverUrl': instance.serverUrl.toString()}; diff --git a/lib/settings/models/authenticated_user.dart b/lib/settings/models/authenticated_user.dart index 321c885..97613ab 100644 --- a/lib/settings/models/authenticated_user.dart +++ b/lib/settings/models/authenticated_user.dart @@ -6,7 +6,7 @@ part 'authenticated_user.g.dart'; /// authenticated user with server and credentials @freezed -class AuthenticatedUser with _$AuthenticatedUser { +sealed class AuthenticatedUser with _$AuthenticatedUser { const factory AuthenticatedUser({ required AudiobookShelfServer server, required String authToken, diff --git a/lib/settings/models/authenticated_user.freezed.dart b/lib/settings/models/authenticated_user.freezed.dart index 2a7ce53..3010150 100644 --- a/lib/settings/models/authenticated_user.freezed.dart +++ b/lib/settings/models/authenticated_user.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // 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 @@ -9,238 +9,290 @@ part of 'authenticated_user.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(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 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; + + AudiobookShelfServer get server; String get authToken; String get id; String? get username; +/// Create a copy of AuthenticatedUser +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$AuthenticatedUserCopyWith get copyWith => _$AuthenticatedUserCopyWithImpl(this as AuthenticatedUser, _$identity); /// Serializes this AuthenticatedUser to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthenticatedUser&&(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); + +@override +String toString() { + return 'AuthenticatedUser(server: $server, authToken: $authToken, id: $id, username: $username)'; +} + - /// Create a copy of AuthenticatedUser - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $AuthenticatedUserCopyWith 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}); +abstract mixin class $AuthenticatedUserCopyWith<$Res> { + factory $AuthenticatedUserCopyWith(AuthenticatedUser value, $Res Function(AuthenticatedUser) _then) = _$AuthenticatedUserCopyWithImpl; +@useResult +$Res call({ + AudiobookShelfServer server, String authToken, String id, String? username +}); + + +$AudiobookShelfServerCopyWith<$Res> get server; - $AudiobookShelfServerCopyWith<$Res> get server; } - /// @nodoc -class _$AuthenticatedUserCopyWithImpl<$Res, $Val extends AuthenticatedUser> +class _$AuthenticatedUserCopyWithImpl<$Res> implements $AuthenticatedUserCopyWith<$Res> { - _$AuthenticatedUserCopyWithImpl(this._value, this._then); + _$AuthenticatedUserCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final AuthenticatedUser _self; + final $Res Function(AuthenticatedUser) _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); - }); - } +/// 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(_self.copyWith( +server: null == server ? _self.server : server // ignore: cast_nullable_to_non_nullable +as AudiobookShelfServer,authToken: null == authToken ? _self.authToken : authToken // ignore: cast_nullable_to_non_nullable +as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable +as String?, + )); +} +/// 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>(_self.server, (value) { + return _then(_self.copyWith(server: value)); + }); +} } -/// @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; +/// Adds pattern-matching-related methods to [AuthenticatedUser]. +extension AuthenticatedUserPatterns on AuthenticatedUser { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _AuthenticatedUser value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _AuthenticatedUser() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _AuthenticatedUser value) $default,){ +final _that = this; +switch (_that) { +case _AuthenticatedUser(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _AuthenticatedUser value)? $default,){ +final _that = this; +switch (_that) { +case _AuthenticatedUser() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( AudiobookShelfServer server, String authToken, String id, String? username)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _AuthenticatedUser() when $default != null: +return $default(_that.server,_that.authToken,_that.id,_that.username);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( AudiobookShelfServer server, String authToken, String id, String? username) $default,) {final _that = this; +switch (_that) { +case _AuthenticatedUser(): +return $default(_that.server,_that.authToken,_that.id,_that.username);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( AudiobookShelfServer server, String authToken, String id, String? username)? $default,) {final _that = this; +switch (_that) { +case _AuthenticatedUser() when $default != null: +return $default(_that.server,_that.authToken,_that.id,_that.username);case _: + return null; + +} } -/// @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 json) => - _$$AuthenticatedUserImplFromJson(json); +class _AuthenticatedUser implements AuthenticatedUser { + const _AuthenticatedUser({required this.server, required this.authToken, required this.id, this.username}); + factory _AuthenticatedUser.fromJson(Map json) => _$AuthenticatedUserFromJson(json); - @override - final AudiobookShelfServer server; - @override - final String authToken; - @override - final String id; - @override - final String? username; +@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)'; - } +/// Create a copy of AuthenticatedUser +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AuthenticatedUserCopyWith<_AuthenticatedUser> get copyWith => __$AuthenticatedUserCopyWithImpl<_AuthenticatedUser>(this, _$identity); - @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 toJson() { - return _$$AuthenticatedUserImplToJson( - this, - ); - } +@override +Map toJson() { + return _$AuthenticatedUserToJson(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 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; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AuthenticatedUser&&(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); + +@override +String toString() { + return 'AuthenticatedUser(server: $server, authToken: $authToken, id: $id, username: $username)'; +} + + +} + +/// @nodoc +abstract mixin class _$AuthenticatedUserCopyWith<$Res> implements $AuthenticatedUserCopyWith<$Res> { + factory _$AuthenticatedUserCopyWith(_AuthenticatedUser value, $Res Function(_AuthenticatedUser) _then) = __$AuthenticatedUserCopyWithImpl; +@override @useResult +$Res call({ + AudiobookShelfServer server, String authToken, String id, String? username +}); + + +@override $AudiobookShelfServerCopyWith<$Res> get server; + +} +/// @nodoc +class __$AuthenticatedUserCopyWithImpl<$Res> + implements _$AuthenticatedUserCopyWith<$Res> { + __$AuthenticatedUserCopyWithImpl(this._self, this._then); + + final _AuthenticatedUser _self; + final $Res Function(_AuthenticatedUser) _then; + +/// Create a copy of AuthenticatedUser +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? server = null,Object? authToken = null,Object? id = null,Object? username = freezed,}) { + return _then(_AuthenticatedUser( +server: null == server ? _self.server : server // ignore: cast_nullable_to_non_nullable +as AudiobookShelfServer,authToken: null == authToken ? _self.authToken : authToken // ignore: cast_nullable_to_non_nullable +as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +/// 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>(_self.server, (value) { + return _then(_self.copyWith(server: value)); + }); +} +} + +// dart format on diff --git a/lib/settings/models/authenticated_user.g.dart b/lib/settings/models/authenticated_user.g.dart index 4ff5a06..926c7d8 100644 --- a/lib/settings/models/authenticated_user.g.dart +++ b/lib/settings/models/authenticated_user.g.dart @@ -6,18 +6,17 @@ part of 'authenticated_user.dart'; // JsonSerializableGenerator // ************************************************************************** -_$AuthenticatedUserImpl _$$AuthenticatedUserImplFromJson( - Map json) => - _$AuthenticatedUserImpl( - server: - AudiobookShelfServer.fromJson(json['server'] as Map), +_AuthenticatedUser _$AuthenticatedUserFromJson(Map json) => + _AuthenticatedUser( + server: AudiobookShelfServer.fromJson( + json['server'] as Map, + ), authToken: json['authToken'] as String, id: json['id'] as String, username: json['username'] as String?, ); -Map _$$AuthenticatedUserImplToJson( - _$AuthenticatedUserImpl instance) => +Map _$AuthenticatedUserToJson(_AuthenticatedUser instance) => { 'server': instance.server, 'authToken': instance.authToken, diff --git a/lib/shared/widgets/shelves/book_shelf.dart b/lib/shared/widgets/shelves/book_shelf.dart index 4fad4be..7b21820 100644 --- a/lib/shared/widgets/shelves/book_shelf.dart +++ b/lib/shared/widgets/shelves/book_shelf.dart @@ -217,7 +217,7 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { player.book?.libraryItemId == libraryItemId; final isPlayingThisBook = player.playing && isCurrentBookSetInPlayer; - final userProgress = me.valueOrNull?.mediaProgress + final userProgress = me.value?.mediaProgress ?.firstWhereOrNull((element) => element.libraryItemId == libraryItemId); final isBookCompleted = userProgress?.isFinished ?? false; @@ -243,7 +243,7 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { // if current book is set in player, get theme from the cover image data: ThemeData( colorScheme: - coverColorScheme.valueOrNull ?? Theme.of(context).colorScheme, + coverColorScheme.value ?? Theme.of(context).colorScheme, ), child: Padding( padding: EdgeInsets.all(strokeWidth / 2 + 2), diff --git a/lib/theme/providers/system_theme_provider.g.dart b/lib/theme/providers/system_theme_provider.g.dart index 5685c95..a28f0f0 100644 --- a/lib/theme/providers/system_theme_provider.g.dart +++ b/lib/theme/providers/system_theme_provider.g.dart @@ -6,174 +6,91 @@ part of 'system_theme_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$systemThemeHash() => r'c78d3d94683624a80b296594268c5fd4295e77a3'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// copied from [DynamicColorBuilder] -/// -/// Copied from [systemTheme]. + @ProviderFor(systemTheme) -const systemThemeProvider = SystemThemeFamily(); +final systemThemeProvider = SystemThemeFamily._(); /// copied from [DynamicColorBuilder] -/// -/// Copied from [systemTheme]. -class SystemThemeFamily - extends Family> { - /// copied from [DynamicColorBuilder] - /// - /// Copied from [systemTheme]. - const SystemThemeFamily(); +final class SystemThemeProvider + extends + $FunctionalProvider< + AsyncValue<(ColorScheme, ColorScheme)?>, + (ColorScheme, ColorScheme)?, + FutureOr<(ColorScheme, ColorScheme)?> + > + with + $FutureModifier<(ColorScheme, ColorScheme)?>, + $FutureProvider<(ColorScheme, ColorScheme)?> { /// copied from [DynamicColorBuilder] - /// - /// Copied from [systemTheme]. - SystemThemeProvider call({ - bool highContrast = false, - }) { - return SystemThemeProvider( - highContrast: highContrast, - ); + SystemThemeProvider._({ + required SystemThemeFamily super.from, + required bool super.argument, + }) : super( + retry: null, + name: r'systemThemeProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$systemThemeHash(); + + @override + String toString() { + return r'systemThemeProvider' + '' + '($argument)'; } + @$internal @override - SystemThemeProvider getProviderOverride( - covariant SystemThemeProvider provider, - ) { - return call( - highContrast: provider.highContrast, - ); - } - - static const Iterable? _dependencies = null; + $FutureProviderElement<(ColorScheme, ColorScheme)?> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'systemThemeProvider'; -} - -/// copied from [DynamicColorBuilder] -/// -/// Copied from [systemTheme]. -class SystemThemeProvider - extends FutureProvider<(ColorScheme light, ColorScheme dark)?> { - /// copied from [DynamicColorBuilder] - /// - /// Copied from [systemTheme]. - SystemThemeProvider({ - bool highContrast = false, - }) : this._internal( - (ref) => systemTheme( - ref as SystemThemeRef, - highContrast: highContrast, - ), - from: systemThemeProvider, - name: r'systemThemeProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$systemThemeHash, - dependencies: SystemThemeFamily._dependencies, - allTransitiveDependencies: - SystemThemeFamily._allTransitiveDependencies, - highContrast: highContrast, - ); - - SystemThemeProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.highContrast, - }) : super.internal(); - - final bool highContrast; - - @override - Override overrideWith( - FutureOr<(ColorScheme light, ColorScheme dark)?> Function( - SystemThemeRef provider) - create, - ) { - return ProviderOverride( - origin: this, - override: SystemThemeProvider._internal( - (ref) => create(ref as SystemThemeRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - highContrast: highContrast, - ), - ); - } - - @override - FutureProviderElement<(ColorScheme light, ColorScheme dark)?> - createElement() { - return _SystemThemeProviderElement(this); + FutureOr<(ColorScheme, ColorScheme)?> create(Ref ref) { + final argument = this.argument as bool; + return systemTheme(ref, highContrast: argument); } @override bool operator ==(Object other) { - return other is SystemThemeProvider && other.highContrast == highContrast; + return other is SystemThemeProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, highContrast.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin SystemThemeRef - on FutureProviderRef<(ColorScheme light, ColorScheme dark)?> { - /// The parameter `highContrast` of this provider. - bool get highContrast; -} +String _$systemThemeHash() => r'c78d3d94683624a80b296594268c5fd4295e77a3'; -class _SystemThemeProviderElement - extends FutureProviderElement<(ColorScheme light, ColorScheme dark)?> - with SystemThemeRef { - _SystemThemeProviderElement(super.provider); +/// copied from [DynamicColorBuilder] + +final class SystemThemeFamily extends $Family + with + $FunctionalFamilyOverride, bool> { + SystemThemeFamily._() + : super( + retry: null, + name: r'systemThemeProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: false, + ); + + /// copied from [DynamicColorBuilder] + + SystemThemeProvider call({bool highContrast = false}) => + SystemThemeProvider._(argument: highContrast, from: this); @override - bool get highContrast => (origin as SystemThemeProvider).highContrast; + String toString() => r'systemThemeProvider'; } -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/theme/providers/theme_from_cover_provider.g.dart b/lib/theme/providers/theme_from_cover_provider.g.dart index 1289765..844e608 100644 --- a/lib/theme/providers/theme_from_cover_provider.g.dart +++ b/lib/theme/providers/theme_from_cover_provider.g.dart @@ -6,355 +6,197 @@ part of 'theme_from_cover_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$themeFromCoverHash() => r'afdeddc4bfe2fe46a4185143d3a88a23565e33f4'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - -/// See also [themeFromCover]. @ProviderFor(themeFromCover) -const themeFromCoverProvider = ThemeFromCoverFamily(); +final themeFromCoverProvider = ThemeFromCoverFamily._(); -/// See also [themeFromCover]. -class ThemeFromCoverFamily extends Family>> { - /// See also [themeFromCover]. - const ThemeFromCoverFamily(); +final class ThemeFromCoverProvider + extends + $FunctionalProvider< + AsyncValue>, + FutureOr, + FutureOr> + > + with + $FutureModifier>, + $FutureProvider> { + ThemeFromCoverProvider._({ + required ThemeFromCoverFamily super.from, + required (ImageProvider, {Brightness brightness, bool highContrast}) + super.argument, + }) : super( + retry: null, + name: r'themeFromCoverProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// See also [themeFromCover]. - ThemeFromCoverProvider call( - ImageProvider img, { - Brightness brightness = Brightness.dark, - bool highContrast = false, - }) { - return ThemeFromCoverProvider( - img, - brightness: brightness, - highContrast: highContrast, - ); + @override + String debugGetCreateSourceHash() => _$themeFromCoverHash(); + + @override + String toString() { + return r'themeFromCoverProvider' + '' + '$argument'; } + @$internal @override - ThemeFromCoverProvider getProviderOverride( - covariant ThemeFromCoverProvider provider, - ) { - return call( - provider.img, - brightness: provider.brightness, - highContrast: provider.highContrast, + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr> create(Ref ref) { + final argument = + this.argument + as ( + ImageProvider, { + Brightness brightness, + bool highContrast, + }); + return themeFromCover( + ref, + argument.$1, + brightness: argument.brightness, + highContrast: argument.highContrast, ); } - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'themeFromCoverProvider'; -} - -/// See also [themeFromCover]. -class ThemeFromCoverProvider extends FutureProvider> { - /// See also [themeFromCover]. - ThemeFromCoverProvider( - ImageProvider img, { - Brightness brightness = Brightness.dark, - bool highContrast = false, - }) : this._internal( - (ref) => themeFromCover( - ref as ThemeFromCoverRef, - img, - brightness: brightness, - highContrast: highContrast, - ), - from: themeFromCoverProvider, - name: r'themeFromCoverProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$themeFromCoverHash, - dependencies: ThemeFromCoverFamily._dependencies, - allTransitiveDependencies: - ThemeFromCoverFamily._allTransitiveDependencies, - img: img, - brightness: brightness, - highContrast: highContrast, - ); - - ThemeFromCoverProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.img, - required this.brightness, - required this.highContrast, - }) : super.internal(); - - final ImageProvider img; - final Brightness brightness; - final bool highContrast; - - @override - Override overrideWith( - FutureOr> Function(ThemeFromCoverRef provider) - create, - ) { - return ProviderOverride( - origin: this, - override: ThemeFromCoverProvider._internal( - (ref) => create(ref as ThemeFromCoverRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - img: img, - brightness: brightness, - highContrast: highContrast, - ), - ); - } - - @override - FutureProviderElement> createElement() { - return _ThemeFromCoverProviderElement(this); - } - @override bool operator ==(Object other) { - return other is ThemeFromCoverProvider && - other.img == img && - other.brightness == brightness && - other.highContrast == highContrast; + return other is ThemeFromCoverProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, img.hashCode); - hash = _SystemHash.combine(hash, brightness.hashCode); - hash = _SystemHash.combine(hash, highContrast.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin ThemeFromCoverRef on FutureProviderRef> { - /// The parameter `img` of this provider. - ImageProvider get img; +String _$themeFromCoverHash() => r'afdeddc4bfe2fe46a4185143d3a88a23565e33f4'; - /// The parameter `brightness` of this provider. - Brightness get brightness; +final class ThemeFromCoverFamily extends $Family + with + $FunctionalFamilyOverride< + FutureOr>, + (ImageProvider, {Brightness brightness, bool highContrast}) + > { + ThemeFromCoverFamily._() + : super( + retry: null, + name: r'themeFromCoverProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: false, + ); - /// The parameter `highContrast` of this provider. - bool get highContrast; + ThemeFromCoverProvider call( + ImageProvider img, { + Brightness brightness = Brightness.dark, + bool highContrast = false, + }) => ThemeFromCoverProvider._( + argument: (img, brightness: brightness, highContrast: highContrast), + from: this, + ); + + @override + String toString() => r'themeFromCoverProvider'; } -class _ThemeFromCoverProviderElement - extends FutureProviderElement> - with ThemeFromCoverRef { - _ThemeFromCoverProviderElement(super.provider); +@ProviderFor(themeOfLibraryItem) +final themeOfLibraryItemProvider = ThemeOfLibraryItemFamily._(); + +final class ThemeOfLibraryItemProvider + extends + $FunctionalProvider< + AsyncValue, + ColorScheme?, + FutureOr + > + with $FutureModifier, $FutureProvider { + ThemeOfLibraryItemProvider._({ + required ThemeOfLibraryItemFamily super.from, + required (String?, {Brightness brightness, bool highContrast}) + super.argument, + }) : super( + retry: null, + name: r'themeOfLibraryItemProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - ImageProvider get img => (origin as ThemeFromCoverProvider).img; + String debugGetCreateSourceHash() => _$themeOfLibraryItemHash(); + @override - Brightness get brightness => (origin as ThemeFromCoverProvider).brightness; + String toString() { + return r'themeOfLibraryItemProvider' + '' + '$argument'; + } + + @$internal @override - bool get highContrast => (origin as ThemeFromCoverProvider).highContrast; + $FutureProviderElement $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + final argument = + this.argument as (String?, {Brightness brightness, bool highContrast}); + return themeOfLibraryItem( + ref, + argument.$1, + brightness: argument.brightness, + highContrast: argument.highContrast, + ); + } + + @override + bool operator ==(Object other) { + return other is ThemeOfLibraryItemProvider && other.argument == argument; + } + + @override + int get hashCode { + return argument.hashCode; + } } String _$themeOfLibraryItemHash() => r'0b2df397b2938003a9de6beb6d4204401a05370c'; -/// See also [themeOfLibraryItem]. -@ProviderFor(themeOfLibraryItem) -const themeOfLibraryItemProvider = ThemeOfLibraryItemFamily(); +final class ThemeOfLibraryItemFamily extends $Family + with + $FunctionalFamilyOverride< + FutureOr, + (String?, {Brightness brightness, bool highContrast}) + > { + ThemeOfLibraryItemFamily._() + : super( + retry: null, + name: r'themeOfLibraryItemProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: false, + ); -/// See also [themeOfLibraryItem]. -class ThemeOfLibraryItemFamily extends Family> { - /// See also [themeOfLibraryItem]. - const ThemeOfLibraryItemFamily(); - - /// See also [themeOfLibraryItem]. ThemeOfLibraryItemProvider call( String? itemId, { Brightness brightness = Brightness.dark, bool highContrast = false, - }) { - return ThemeOfLibraryItemProvider( - itemId, - brightness: brightness, - highContrast: highContrast, - ); - } + }) => ThemeOfLibraryItemProvider._( + argument: (itemId, brightness: brightness, highContrast: highContrast), + from: this, + ); @override - ThemeOfLibraryItemProvider getProviderOverride( - covariant ThemeOfLibraryItemProvider provider, - ) { - return call( - provider.itemId, - brightness: provider.brightness, - highContrast: provider.highContrast, - ); - } - - static const Iterable? _dependencies = null; - - @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'themeOfLibraryItemProvider'; + String toString() => r'themeOfLibraryItemProvider'; } - -/// See also [themeOfLibraryItem]. -class ThemeOfLibraryItemProvider extends FutureProvider { - /// See also [themeOfLibraryItem]. - ThemeOfLibraryItemProvider( - String? itemId, { - Brightness brightness = Brightness.dark, - bool highContrast = false, - }) : this._internal( - (ref) => themeOfLibraryItem( - ref as ThemeOfLibraryItemRef, - itemId, - brightness: brightness, - highContrast: highContrast, - ), - from: themeOfLibraryItemProvider, - name: r'themeOfLibraryItemProvider', - debugGetCreateSourceHash: - const bool.fromEnvironment('dart.vm.product') - ? null - : _$themeOfLibraryItemHash, - dependencies: ThemeOfLibraryItemFamily._dependencies, - allTransitiveDependencies: - ThemeOfLibraryItemFamily._allTransitiveDependencies, - itemId: itemId, - brightness: brightness, - highContrast: highContrast, - ); - - ThemeOfLibraryItemProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.itemId, - required this.brightness, - required this.highContrast, - }) : super.internal(); - - final String? itemId; - final Brightness brightness; - final bool highContrast; - - @override - Override overrideWith( - FutureOr Function(ThemeOfLibraryItemRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: ThemeOfLibraryItemProvider._internal( - (ref) => create(ref as ThemeOfLibraryItemRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - itemId: itemId, - brightness: brightness, - highContrast: highContrast, - ), - ); - } - - @override - FutureProviderElement createElement() { - return _ThemeOfLibraryItemProviderElement(this); - } - - @override - bool operator ==(Object other) { - return other is ThemeOfLibraryItemProvider && - other.itemId == itemId && - other.brightness == brightness && - other.highContrast == highContrast; - } - - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, itemId.hashCode); - hash = _SystemHash.combine(hash, brightness.hashCode); - hash = _SystemHash.combine(hash, highContrast.hashCode); - - return _SystemHash.finish(hash); - } -} - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin ThemeOfLibraryItemRef on FutureProviderRef { - /// The parameter `itemId` of this provider. - String? get itemId; - - /// The parameter `brightness` of this provider. - Brightness get brightness; - - /// The parameter `highContrast` of this provider. - bool get highContrast; -} - -class _ThemeOfLibraryItemProviderElement - extends FutureProviderElement with ThemeOfLibraryItemRef { - _ThemeOfLibraryItemProviderElement(super.provider); - - @override - String? get itemId => (origin as ThemeOfLibraryItemProvider).itemId; - @override - Brightness get brightness => - (origin as ThemeOfLibraryItemProvider).brightness; - @override - bool get highContrast => (origin as ThemeOfLibraryItemProvider).highContrast; -} -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 606c5a6..f06b290 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,7 +7,7 @@ #include "generated_plugin_registrant.h" #include -#include +#include #include #include @@ -15,9 +15,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) dynamic_color_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); dynamic_color_plugin_register_with_registrar(dynamic_color_registrar); - g_autoptr(FlPluginRegistrar) isar_flutter_libs_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "IsarFlutterLibsPlugin"); - isar_flutter_libs_plugin_register_with_registrar(isar_flutter_libs_registrar); + g_autoptr(FlPluginRegistrar) isar_plus_flutter_libs_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "IsarPlusFlutterLibsPlugin"); + isar_plus_flutter_libs_plugin_register_with_registrar(isar_plus_flutter_libs_registrar); g_autoptr(FlPluginRegistrar) media_kit_libs_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitLibsLinuxPlugin"); media_kit_libs_linux_plugin_register_with_registrar(media_kit_libs_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 6023074..17405b8 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,7 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST dynamic_color - isar_flutter_libs + isar_plus_flutter_libs media_kit_libs_linux url_launcher_linux ) diff --git a/pubspec.lock b/pubspec.lock index f4c775c..03a42ff 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,31 +5,26 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" + sha256: c209688d9f5a5f26b2fb47a188131a6fb9e876ae9e47af3737c0b4f58a93470d url: "https://pub.dev" source: hosted - version: "76.0.0" - _macros: - dependency: transitive - description: dart - source: sdk - version: "0.3.3" + version: "91.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" + sha256: f51c8499b35f9b26820cfe914828a6a98a94efd5cc78b37bb7d03debae3a1d08 url: "https://pub.dev" source: hosted - version: "6.11.0" - analyzer_plugin: + version: "8.4.1" + analyzer_buffer: dependency: transitive description: - name: analyzer_plugin - sha256: "9661b30b13a685efaee9f02e5d01ed9f2b423bd889d28a304d02d704aee69161" + name: analyzer_buffer + sha256: aba2f75e63b3135fd1efaa8b6abefe1aa6e41b6bd9806221620fa48f98156033 url: "https://pub.dev" source: hosted - version: "0.11.3" + version: "0.1.11" animated_list_plus: dependency: "direct main" description: @@ -138,18 +133,18 @@ packages: dependency: transitive description: name: build - sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0 + sha256: c1668065e9ba04752570ad7e038288559d1e2ca5c6d0131c0f5f55e39e777413 url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "4.0.3" build_config: dependency: transitive description: name: build_config - sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + sha256: "4f64382b97504dc2fcdf487d5aae33418e08b4703fc21249e4db6d804a4d0187" url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "1.2.0" build_daemon: dependency: transitive description: @@ -158,30 +153,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.4" - build_resolvers: - dependency: transitive - description: - name: build_resolvers - sha256: b9e4fda21d846e192628e7a4f6deda6888c36b5b69ba02ff291a01fd529140f0 - url: "https://pub.dev" - source: hosted - version: "2.4.4" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "058fe9dce1de7d69c4b84fada934df3e0153dd000758c4d65964d0166779aa99" + sha256: "110c56ef29b5eb367b4d17fc79375fa8c18a6cd7acd92c05bb3986c17a079057" url: "https://pub.dev" source: hosted - version: "2.4.15" - build_runner_core: - dependency: transitive - description: - name: build_runner_core - sha256: "22e3aa1c80e0ada3722fe5b63fd43d9c8990759d0a2cf489c8c5d7b2bdebc021" - url: "https://pub.dev" - source: hosted - version: "8.0.0" + version: "2.10.4" built_collection: dependency: transitive description: @@ -194,10 +173,10 @@ packages: dependency: transitive description: name: built_value - sha256: "7193c909c8608d3e1a263093ff045f7140bcc1bf3f7de2c5ec7ad027891d2d22" + sha256: "426cf75afdb23aa74bd4e471704de3f9393f3c7b04c1e2d9c6f1073ae0b8b139" url: "https://pub.dev" source: hosted - version: "8.10.0" + version: "8.12.1" cached_network_image: dependency: "direct main" description: @@ -246,22 +225,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" - ci: + cli_config: dependency: transitive description: - name: ci - sha256: "145d095ce05cddac4d797a158bc4cf3b6016d1fe63d8c3d2fbd7212590adca13" + name: cli_config + sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec url: "https://pub.dev" source: hosted - version: "0.1.0" - cli_util: - dependency: transitive - description: - name: cli_util - sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c - url: "https://pub.dev" - source: hosted - version: "0.4.2" + version: "0.2.0" clock: dependency: transitive description: @@ -302,6 +273,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.2" + coverage: + dependency: transitive + description: + name: coverage + sha256: "5da775aa218eaf2151c721b16c01c7676fbfdd99cebba2bf64e8b807a28ff94d" + url: "https://pub.dev" + source: hosted + version: "1.15.0" cross_file: dependency: transitive description: @@ -326,46 +305,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" - custom_lint: - dependency: "direct dev" - description: - name: custom_lint - sha256: "3486c470bb93313a9417f926c7dd694a2e349220992d7b9d14534dc49c15bba9" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - custom_lint_builder: - dependency: transitive - description: - name: custom_lint_builder - sha256: "42cdc41994eeeddab0d7a722c7093ec52bd0761921eeb2cbdbf33d192a234759" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - custom_lint_core: - dependency: transitive - description: - name: custom_lint_core - sha256: "02450c3e45e2a6e8b26c4d16687596ab3c4644dd5792e3313aa9ceba5a49b7f5" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - custom_lint_visitor: - dependency: transitive - description: - name: custom_lint_visitor - sha256: bfe9b7a09c4775a587b58d10ebb871d4fe618237639b1e84d5ec62d7dfef25f9 - url: "https://pub.dev" - source: hosted - version: "1.0.0+6.11.0" dart_style: dependency: transitive description: name: dart_style - sha256: "7306ab8a2359a48d22310ad823521d723acfed60ee1f7e37388e8986853b6820" + sha256: a9c30492da18ff84efe2422ba2d319a89942d93e58eb0b73d32abe822ef54b7b url: "https://pub.dev" source: hosted - version: "2.3.8" + version: "3.1.3" device_info_plus: dependency: "direct main" description: @@ -511,10 +458,10 @@ packages: dependency: transitive description: name: flutter_riverpod - sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1" + sha256: "38ec6c303e2c83ee84512f5fc2a82ae311531021938e63d7137eccc107bf3c02" url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "3.1.0" flutter_settings_ui: dependency: "direct main" description: @@ -553,18 +500,18 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "44c19278dd9d89292cf46e97dc0c1e52ce03275f40a97c5a348e802a924bf40e" + sha256: "13065f10e135263a4f5a4391b79a8efc5fb8106f8dd555a9e49b750b45393d77" url: "https://pub.dev" source: hosted - version: "2.5.7" + version: "3.2.3" freezed_annotation: dependency: "direct main" description: name: freezed_annotation - sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8" url: "https://pub.dev" source: hosted - version: "2.4.4" + version: "3.1.0" frontend_server_client: dependency: transitive description: @@ -597,30 +544,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.2" - hive: + hive_plus_secure: dependency: "direct main" description: - name: hive - sha256: "10819524df282842ebae12870e2e0e9ebc3e5c4637bec741ad39b919c589cb20" + name: hive_plus_secure + sha256: "0bf08f07b42bc42137cfb151ee7fbe417c8295db69d13bb316d81abecfb02aed" url: "https://pub.dev" source: hosted - version: "4.0.0-dev.2" + version: "1.1.25" hooks_riverpod: dependency: "direct main" description: name: hooks_riverpod - sha256: "70bba33cfc5670c84b796e6929c54b8bc5be7d0fe15bb28c2560500b9ad06966" + sha256: b880efcd17757af0aa242e5dceac2fb781a014c22a32435a5daa8f17e9d5d8a9 url: "https://pub.dev" source: hosted - version: "2.6.1" - hotreloader: - dependency: transitive - description: - name: hotreloader - sha256: bc167a1163807b03bada490bfe2df25b0d744df359227880220a5cbd04e5734b - url: "https://pub.dev" - source: hosted - version: "4.3.0" + version: "3.1.0" http: dependency: transitive description: @@ -677,22 +616,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" - isar: + isar_plus: dependency: "direct main" description: - name: isar - sha256: ebf74d87c400bd9f7da14acb31932b50c2407edbbd40930da3a6c2a8143f85a8 + name: isar_plus + sha256: "43d874216d2f1fcec06f209ebbc75e7ca9705076d8c7077ec6ac5ea511dad9dd" url: "https://pub.dev" source: hosted - version: "4.0.0-dev.14" - isar_flutter_libs: + version: "1.2.0" + isar_plus_flutter_libs: dependency: "direct main" description: - name: isar_flutter_libs - sha256: "04a3f4035e213ddb6e78d0132a7c80296a085c2088c2a761b4a42ee5add36983" + name: isar_plus_flutter_libs + sha256: e142590a13b5c9d349555ebd72a25ee34901992a2bb32ba6ccfd414519b48adf url: "https://pub.dev" source: hosted - version: "4.0.0-dev.14" + version: "1.2.0" js: dependency: transitive description: @@ -713,10 +652,10 @@ packages: dependency: "direct dev" description: name: json_serializable - sha256: c2fcb3920cf2b6ae6845954186420fca40bc0a8abcc84903b7801f17d7050d7c + sha256: c5b2ee75210a0f263c6c7b9eeea80553dbae96ea1bf57f02484e806a3ffdffa3 url: "https://pub.dev" source: hosted - version: "6.9.0" + version: "6.11.2" just_audio: dependency: "direct main" description: @@ -762,26 +701,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.9" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" lints: dependency: transitive description: @@ -798,6 +737,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.0.3" + logger: + dependency: transitive + description: + name: logger + sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3 + url: "https://pub.dev" + source: hosted + version: "2.6.2" logging: dependency: "direct main" description: @@ -822,14 +769,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.3.1" - macros: - dependency: transitive - description: - name: macros - sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" - url: "https://pub.dev" - source: hosted - version: "0.1.3-main.0" matcher: dependency: transitive description: @@ -882,10 +821,10 @@ packages: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" mime: dependency: transitive description: @@ -903,6 +842,22 @@ packages: url: "https://github.com/Dr-Blank/miniplayer.git" source: git version: "1.0.3" + mockito: + dependency: transitive + description: + name: mockito + sha256: dac24d461418d363778d53198d9ac0510b9d073869f078450f195766ec48d05e + url: "https://pub.dev" + source: hosted + version: "5.6.1" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" numberpicker: dependency: "direct main" description: @@ -1107,42 +1062,34 @@ packages: dependency: transitive description: name: riverpod - sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959" + sha256: "16ff608d21e8ea64364f2b7c049c94a02ab81668f78845862b6e88b71dd4935a" url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "3.1.0" riverpod_analyzer_utils: dependency: transitive description: name: riverpod_analyzer_utils - sha256: c6b8222b2b483cb87ae77ad147d6408f400c64f060df7a225b127f4afef4f8c8 + sha256: "947b05d04c52a546a2ac6b19ef2a54b08520ff6bdf9f23d67957a4c8df1c3bc0" url: "https://pub.dev" source: hosted - version: "0.5.8" + version: "1.0.0-dev.8" riverpod_annotation: dependency: "direct main" description: name: riverpod_annotation - sha256: e14b0bf45b71326654e2705d462f21b958f987087be850afd60578fcd502d1b8 + sha256: cc1474bc2df55ec3c1da1989d139dcef22cd5e2bd78da382e867a69a8eca2e46 url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "4.0.0" riverpod_generator: dependency: "direct dev" description: name: riverpod_generator - sha256: "63546d70952015f0981361636bf8f356d9cfd9d7f6f0815e3c07789a41233188" + sha256: e43b1537229cc8f487f09b0c20d15dba840acbadcf5fc6dad7ad5e8ab75950dc url: "https://pub.dev" source: hosted - version: "2.6.3" - riverpod_lint: - dependency: "direct dev" - description: - name: riverpod_lint - sha256: "83e4caa337a9840469b7b9bd8c2351ce85abad80f570d84146911b32086fbd99" - url: "https://pub.dev" - source: hosted - version: "2.6.3" + version: "4.0.0+1" rxdart: dependency: transitive description: @@ -1207,6 +1154,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.2" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 + url: "https://pub.dev" + source: hosted + version: "1.1.3" shelf_web_socket: dependency: transitive description: @@ -1255,18 +1218,34 @@ packages: dependency: transitive description: name: source_gen - sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + sha256: "07b277b67e0096c45196cbddddf2d8c6ffc49342e88bf31d460ce04605ddac75" url: "https://pub.dev" source: hosted - version: "1.5.0" + version: "4.1.1" source_helper: dependency: transitive description: name: source_helper - sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c" + sha256: "6a3c6cc82073a8797f8c4dc4572146114a39652851c157db37e964d9c7038723" url: "https://pub.dev" source: hosted - version: "1.3.5" + version: "1.3.8" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812" + url: "https://pub.dev" + source: hosted + version: "0.10.13" source_span: dependency: transitive description: @@ -1379,22 +1358,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.2" + test: + dependency: transitive + description: + name: test + sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" + url: "https://pub.dev" + source: hosted + version: "1.26.3" test_api: dependency: transitive description: name: test_api - sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 url: "https://pub.dev" source: hosted - version: "0.7.4" - timing: + version: "0.7.7" + test_core: dependency: transitive description: - name: timing - sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" + name: test_core + sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "0.6.12" typed_data: dependency: transitive description: @@ -1495,10 +1482,10 @@ packages: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vibration: dependency: "direct main" description: @@ -1555,6 +1542,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" win32: dependency: transitive description: @@ -1596,5 +1591,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.7.0 <4.0.0" - flutter: ">=3.32.8" + dart: ">=3.10.0 <4.0.0" + flutter: "3.38.6" diff --git a/pubspec.yaml b/pubspec.yaml index 7ccbe61..ae2b03f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,8 +19,8 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 0.0.18+9 environment: - sdk: ">=3.3.4 <4.0.0" - flutter: 3.32.8 + sdk: ">=3.10.0 <4.0.0" + flutter: 3.38.6 # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -53,12 +53,12 @@ dependencies: flutter_hooks: ^0.21.2 flutter_settings_ui: ^3.0.1 font_awesome_flutter: ^10.7.0 - freezed_annotation: ^2.4.1 + freezed_annotation: ^3.1.0 go_router: ^14.0.2 - hive: ^4.0.0-dev.2 - hooks_riverpod: ^2.5.1 - isar: ^4.0.0-dev.13 - isar_flutter_libs: ^4.0.0-dev.13 + hive_plus_secure: ^1.1.25 + hooks_riverpod: ^3.0.0 + isar_plus: ^1.1.0 + isar_plus_flutter_libs: ^1.1.0 json_annotation: ^4.9.0 just_audio: ^0.9.37 just_audio_background: @@ -85,7 +85,7 @@ dependencies: path: ^1.9.0 path_provider: ^2.1.0 permission_handler: ^11.3.1 - riverpod_annotation: ^2.3.5 + riverpod_annotation: 4.0.0 scroll_loop_auto_scroll: ^0.0.5 sensors_plus: ^6.0.1 share_plus: ^10.0.2 @@ -96,14 +96,13 @@ dependencies: vibration: ^3.1.3 dev_dependencies: build_runner: ^2.4.9 - custom_lint: ^0.7.0 + # custom_lint: ^0.8.1 flutter_lints: ^5.0.0 flutter_test: sdk: flutter - freezed: ^2.5.2 + freezed: ^3.1.0 json_serializable: ^6.8.0 - riverpod_generator: ^2.4.2 - riverpod_lint: ^2.3.10 + riverpod_generator: ^4.0.0+1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/shelfsdk b/shelfsdk index e1848a4..34b2b98 160000 --- a/shelfsdk +++ b/shelfsdk @@ -1 +1 @@ -Subproject commit e1848a42c27257146015a33e9427f197f522fe03 +Subproject commit 34b2b98a90e3851f50f9657b1ff5bae5f385dbf9 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index de21556..050981d 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,7 +7,7 @@ #include "generated_plugin_registrant.h" #include -#include +#include #include #include #include @@ -16,8 +16,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { DynamicColorPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); - IsarFlutterLibsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("IsarFlutterLibsPlugin")); + IsarPlusFlutterLibsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("IsarPlusFlutterLibsPlugin")); MediaKitLibsWindowsAudioPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("MediaKitLibsWindowsAudioPluginCApi")); PermissionHandlerWindowsPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 13d504d..5b8e406 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,7 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST dynamic_color - isar_flutter_libs + isar_plus_flutter_libs media_kit_libs_windows_audio permission_handler_windows share_plus From e23c0b6c5f1cc55f3d75ea96b6b218037e5d6fee Mon Sep 17 00:00:00 2001 From: "Dr.Blank" <64108942+Dr-Blank@users.noreply.github.com> Date: Sat, 10 Jan 2026 16:51:05 +0530 Subject: [PATCH 3/3] chore: run `dart format` --- lib/api/api_provider.dart | 48 +-- lib/api/authenticated_users_provider.dart | 20 +- lib/api/image_provider.dart | 7 +- lib/api/library_item_provider.dart | 3 +- lib/api/library_provider.dart | 5 +- lib/api/server_provider.dart | 8 +- lib/db/available_boxes.dart | 15 +- lib/db/init.dart | 7 +- .../downloads/core/download_manager.dart | 11 +- .../downloads/providers/download_manager.dart | 85 ++-- .../downloads/view/downloads_page.dart | 4 +- lib/features/explore/view/explore_page.dart | 64 ++- .../explore/view/search_result_page.dart | 39 +- .../view/library_item_actions.dart | 123 ++---- .../view/library_item_hero_section.dart | 95 ++--- .../view/library_item_metadata.dart | 41 +- .../item_viewer/view/library_item_page.dart | 93 ++--- .../view/library_item_sliver_app_bar.dart | 38 +- .../view/library_browser_page.dart | 72 ++-- .../logging/providers/logs_provider.dart | 6 +- lib/features/logging/view/logs_page.dart | 10 +- .../onboarding/providers/oauth_provider.dart | 6 +- .../onboarding/view/callback_page.dart | 34 +- .../view/onboarding_single_page.dart | 48 +-- lib/features/onboarding/view/user_login.dart | 147 ++++--- .../view/user_login_with_open_id.dart | 14 +- .../view/user_login_with_password.dart | 58 ++- .../view/user_login_with_token.dart | 12 +- .../core/playback_reporter.dart | 4 +- .../providers/playback_reporter_provider.dart | 5 +- .../player/core/audiobook_player.dart | 62 ++- lib/features/player/core/init.dart | 25 +- lib/features/player/playlist.dart | 4 +- .../player/providers/audiobook_player.dart | 5 +- .../player/providers/player_form.dart | 17 +- .../player/view/audiobook_player.dart | 69 ++-- .../player/view/player_when_expanded.dart | 29 +- .../player/view/player_when_minimized.dart | 25 +- .../widgets/audiobook_player_seek_button.dart | 5 +- .../audiobook_player_seek_chapter_button.dart | 18 +- .../widgets/chapter_selection_button.dart | 75 ++-- .../widgets/player_speed_adjust_button.dart | 22 +- .../view/widgets/playing_indicator_icon.dart | 96 ++--- .../player/view/widgets/speed_selector.dart | 74 ++-- .../shake_detection/core/shake_detector.dart | 37 +- .../providers/shake_detector.dart | 40 +- .../sleep_timer/core/sleep_timer.dart | 4 +- .../sleep_timer/view/sleep_timer_button.dart | 91 ++-- lib/features/you/view/server_manager.dart | 130 +++--- .../you/view/widgets/library_switch_chip.dart | 25 +- lib/features/you/view/you_page.dart | 22 +- lib/hacks/fix_autofill_losing_focus.dart | 11 +- lib/main.dart | 19 +- lib/pages/home_page.dart | 47 ++- lib/pages/library_page.dart | 20 +- lib/router/constants.dart | 30 +- lib/router/router.dart | 389 +++++++++--------- lib/router/transitions/slide.dart | 35 +- lib/settings/app_settings_provider.dart | 6 +- lib/settings/metadata/metadata_provider.dart | 133 +++--- lib/settings/view/app_settings_page.dart | 73 ++-- .../view/auto_sleep_timer_settings_page.dart | 29 +- lib/settings/view/buttons.dart | 15 +- .../view/home_page_settings_page.dart | 9 +- .../view/notification_settings_page.dart | 57 +-- lib/settings/view/player_settings_page.dart | 117 +++--- .../view/shake_detector_settings_page.dart | 50 ++- lib/settings/view/simple_settings_page.dart | 26 +- lib/settings/view/theme_settings_page.dart | 32 +- .../widgets/navigation_with_switch_tile.dart | 5 +- lib/shared/extensions/enum.dart | 5 +- lib/shared/extensions/model_conversions.dart | 4 +- lib/shared/extensions/obfuscation.dart | 25 +- lib/shared/extensions/time_of_day.dart | 5 +- lib/shared/hooks.dart | 22 +- lib/shared/icons/abs_icons.dart | 140 +++++-- lib/shared/widgets/add_new_server.dart | 17 +- lib/shared/widgets/drawer.dart | 9 +- .../widgets/expandable_description.dart | 11 +- lib/shared/widgets/not_implemented.dart | 5 +- lib/shared/widgets/shelves/author_shelf.dart | 15 +- lib/shared/widgets/shelves/book_shelf.dart | 114 +++-- lib/shared/widgets/shelves/home_shelf.dart | 21 +- .../providers/system_theme_provider.dart | 17 +- 84 files changed, 1565 insertions(+), 1945 deletions(-) diff --git a/lib/api/api_provider.dart b/lib/api/api_provider.dart index a991727..8994644 100644 --- a/lib/api/api_provider.dart +++ b/lib/api/api_provider.dart @@ -16,10 +16,8 @@ import 'package:vaani/shared/extensions/obfuscation.dart'; part 'api_provider.g.dart'; // TODO: workaround for https://github.com/rrousselGit/riverpod/issues/3718 -typedef ResponseErrorHandler = void Function( - Response response, [ - Object? error, -]); +typedef ResponseErrorHandler = + void Function(Response response, [Object? error]); final _logger = Logger('api_provider'); @@ -39,9 +37,7 @@ AudiobookshelfApi audiobookshelfApi(Ref ref, Uri? baseUrl) { // try to get the base url from app settings final apiSettings = ref.watch(apiSettingsProvider); baseUrl ??= apiSettings.activeServer?.serverUrl; - return AudiobookshelfApi( - baseUrl: makeBaseUrl(baseUrl.toString()), - ); + return AudiobookshelfApi(baseUrl: makeBaseUrl(baseUrl.toString())); } /// get the api instance for the authenticated user @@ -68,9 +64,9 @@ FutureOr isServerAlive(Ref ref, String address) async { } try { - return await AudiobookshelfApi(baseUrl: makeBaseUrl(address)) - .server - .ping() ?? + return await AudiobookshelfApi( + baseUrl: makeBaseUrl(address), + ).server.ping() ?? false; } catch (e) { return false; @@ -86,8 +82,9 @@ FutureOr serverStatus( ]) async { _logger.fine('fetching server status: ${baseUrl.obfuscate()}'); final api = ref.watch(audiobookshelfApiProvider(baseUrl)); - final res = - await api.server.status(responseErrorHandler: responseErrorHandler); + final res = await api.server.status( + responseErrorHandler: responseErrorHandler, + ); _logger.fine('server status: $res'); return res; } @@ -113,7 +110,9 @@ class PersonalizedView extends _$PersonalizedView { yield []; return; } - ref.read(apiSettingsProvider.notifier).updateState( + ref + .read(apiSettingsProvider.notifier) + .updateState( apiSettings.copyWith(activeLibraryId: login.userDefaultLibraryId), ); yield []; @@ -122,9 +121,8 @@ class PersonalizedView extends _$PersonalizedView { // try to find in cache // final cacheKey = 'personalizedView:${apiSettings.activeLibraryId}'; final key = 'personalizedView:${apiSettings.activeLibraryId! + user.id}'; - final cachedRes = await apiResponseCacheManager.getFileFromMemory( - key, - ) ?? + final cachedRes = + await apiResponseCacheManager.getFileFromMemory(key) ?? await apiResponseCacheManager.getFileFromCache(key); if (cachedRes != null) { _logger.fine('reading from cache: $cachedRes for key: $key'); @@ -143,8 +141,9 @@ class PersonalizedView extends _$PersonalizedView { // ! exaggerated delay // await Future.delayed(const Duration(seconds: 2)); - final res = await api.libraries - .getPersonalized(libraryId: apiSettings.activeLibraryId!); + final res = await api.libraries.getPersonalized( + libraryId: apiSettings.activeLibraryId!, + ); // debugPrint('personalizedView: ${res!.map((e) => e).toSet()}'); // save to cache if (res != null) { @@ -172,9 +171,7 @@ class PersonalizedView extends _$PersonalizedView { /// fetch continue listening audiobooks @riverpod -FutureOr fetchContinueListening( - Ref ref, -) async { +FutureOr fetchContinueListening(Ref ref) async { final api = ref.watch(authenticatedApiProvider); final res = await api.me.getSessions(); // debugPrint( @@ -184,9 +181,7 @@ FutureOr fetchContinueListening( } @riverpod -FutureOr me( - Ref ref, -) async { +FutureOr me(Ref ref) async { final api = ref.watch(authenticatedApiProvider); final errorResponseHandler = ErrorResponseHandler(); final res = await api.me.getUser( @@ -202,10 +197,7 @@ FutureOr me( } @riverpod -FutureOr login( - Ref ref, { - AuthenticatedUser? user, -}) async { +FutureOr login(Ref ref, {AuthenticatedUser? user}) async { if (user == null) { // try to get the user from settings final apiSettings = ref.watch(apiSettingsProvider); diff --git a/lib/api/authenticated_users_provider.dart b/lib/api/authenticated_users_provider.dart index 7f74ae4..6d437e0 100644 --- a/lib/api/authenticated_users_provider.dart +++ b/lib/api/authenticated_users_provider.dart @@ -35,9 +35,7 @@ class AuthenticatedUsers extends _$AuthenticatedUsers { Set readFromBoxOrCreate() { if (_box.isNotEmpty) { final foundData = _box.getRange(0, _box.length); - _logger.fine( - 'found users in box: ${foundData.obfuscate()}', - ); + _logger.fine('found users in box: ${foundData.obfuscate()}'); return foundData.toSet(); } else { _logger.fine('no settings found in box'); @@ -59,11 +57,9 @@ class AuthenticatedUsers extends _$AuthenticatedUsers { ref.invalidateSelf(); if (setActive) { final apiSettings = ref.read(apiSettingsProvider); - ref.read(apiSettingsProvider.notifier).updateState( - apiSettings.copyWith( - activeUser: user, - ), - ); + ref + .read(apiSettingsProvider.notifier) + .updateState(apiSettings.copyWith(activeUser: user)); } } @@ -86,11 +82,9 @@ class AuthenticatedUsers extends _$AuthenticatedUsers { // replace the active user with the first user in the list // or null if there are no users left final newActiveUser = state.isNotEmpty ? state.first : null; - ref.read(apiSettingsProvider.notifier).updateState( - apiSettings.copyWith( - activeUser: newActiveUser, - ), - ); + ref + .read(apiSettingsProvider.notifier) + .updateState(apiSettings.copyWith(activeUser: newActiveUser)); } } } diff --git a/lib/api/image_provider.dart b/lib/api/image_provider.dart index 9707542..79fac06 100644 --- a/lib/api/image_provider.dart +++ b/lib/api/image_provider.dart @@ -27,7 +27,8 @@ class CoverImage extends _$CoverImage { // await Future.delayed(const Duration(seconds: 2)); // try to get the image from the cache - final file = await imageCacheManager.getFileFromMemory(itemId) ?? + final file = + await imageCacheManager.getFileFromMemory(itemId) ?? await imageCacheManager.getFileFromCache(itemId); if (file != null) { @@ -44,9 +45,7 @@ class CoverImage extends _$CoverImage { ); return; } else { - _logger.fine( - 'cover image stale for $itemId, fetching from the server', - ); + _logger.fine('cover image stale for $itemId, fetching from the server'); } } else { _logger.fine('cover image not found in cache for $itemId'); diff --git a/lib/api/library_item_provider.dart b/lib/api/library_item_provider.dart index 013f62e..5a4b1a3 100644 --- a/lib/api/library_item_provider.dart +++ b/lib/api/library_item_provider.dart @@ -26,7 +26,8 @@ class LibraryItem extends _$LibraryItem { // look for the item in the cache final key = CacheKey.libraryItem(id); - final cachedFile = await apiResponseCacheManager.getFileFromMemory(key) ?? + final cachedFile = + await apiResponseCacheManager.getFileFromMemory(key) ?? await apiResponseCacheManager.getFileFromCache(key); if (cachedFile != null) { _logger.fine( diff --git a/lib/api/library_provider.dart b/lib/api/library_provider.dart index b565d26..3ba5399 100644 --- a/lib/api/library_provider.dart +++ b/lib/api/library_provider.dart @@ -33,8 +33,9 @@ Future library(Ref ref, String id) async { @riverpod Future currentLibrary(Ref ref) async { - final libraryId = - ref.watch(apiSettingsProvider.select((s) => s.activeLibraryId)); + final libraryId = ref.watch( + apiSettingsProvider.select((s) => s.activeLibraryId), + ); if (libraryId == null) { _logger.warning('No active library id found'); return null; diff --git a/lib/api/server_provider.dart b/lib/api/server_provider.dart index 690dcc4..41c82f1 100644 --- a/lib/api/server_provider.dart +++ b/lib/api/server_provider.dart @@ -80,11 +80,9 @@ class AudiobookShelfServer extends _$AudiobookShelfServer { // remove the server from the active server final apiSettings = ref.read(apiSettingsProvider); if (apiSettings.activeServer == server) { - ref.read(apiSettingsProvider.notifier).updateState( - apiSettings.copyWith( - activeServer: null, - ), - ); + ref + .read(apiSettingsProvider.notifier) + .updateState(apiSettings.copyWith(activeServer: null)); } // remove the users of this server if (removeUsers) { diff --git a/lib/db/available_boxes.dart b/lib/db/available_boxes.dart index dc2d5a1..77b0c3f 100644 --- a/lib/db/available_boxes.dart +++ b/lib/db/available_boxes.dart @@ -14,14 +14,17 @@ class AvailableHiveBoxes { static final apiSettingsBox = Hive.box(name: 'apiSettings'); /// stores the a list of [AudiobookShelfServer] - static final serverBox = - Hive.box(name: 'audiobookShelfServer'); + static final serverBox = Hive.box( + name: 'audiobookShelfServer', + ); /// stores the a list of [AuthenticatedUser] - static final authenticatedUserBox = - Hive.box(name: 'authenticatedUser'); + static final authenticatedUserBox = Hive.box( + name: 'authenticatedUser', + ); /// stores the a list of [BookSettings] - static final individualBookSettingsBox = - Hive.box(name: 'bookSettings'); + static final individualBookSettingsBox = Hive.box( + name: 'bookSettings', + ); } diff --git a/lib/db/init.dart b/lib/db/init.dart index 452648e..280144e 100644 --- a/lib/db/init.dart +++ b/lib/db/init.dart @@ -13,12 +13,7 @@ Future initStorage() async { final dir = await getApplicationDocumentsDirectory(); // use vaani as the directory for hive - final storageDir = Directory( - p.join( - dir.path, - AppMetadata.appNameLowerCase, - ), - ); + final storageDir = Directory(p.join(dir.path, AppMetadata.appNameLowerCase)); await storageDir.create(recursive: true); Hive.defaultDirectory = storageDir.path; diff --git a/lib/features/downloads/core/download_manager.dart b/lib/features/downloads/core/download_manager.dart index 0e808b1..e6db077 100644 --- a/lib/features/downloads/core/download_manager.dart +++ b/lib/features/downloads/core/download_manager.dart @@ -67,17 +67,13 @@ class AudiobookDownloadManager { late StreamSubscription _updatesSubscription; - Future queueAudioBookDownload( - LibraryItemExpanded item, - ) async { + Future queueAudioBookDownload(LibraryItemExpanded item) async { _logger.info('queuing download for item: ${item.id}'); // create a download task for each file in the item final directory = await getApplicationSupportDirectory(); for (final file in item.libraryFiles) { // check if the file is already downloaded - if (isFileDownloaded( - constructFilePath(directory, item, file), - )) { + if (isFileDownloaded(constructFilePath(directory, item, file))) { _logger.info('file already downloaded: ${file.metadata.filename}'); continue; } @@ -105,8 +101,7 @@ class AudiobookDownloadManager { Directory directory, LibraryItemExpanded item, LibraryFile file, - ) => - '${directory.path}/${item.relPath}/${file.metadata.filename}'; + ) => '${directory.path}/${item.relPath}/${file.metadata.filename}'; void dispose() { _updatesSubscription.cancel(); diff --git a/lib/features/downloads/providers/download_manager.dart b/lib/features/downloads/providers/download_manager.dart index 7f75a17..7dba395 100644 --- a/lib/features/downloads/providers/download_manager.dart +++ b/lib/features/downloads/providers/download_manager.dart @@ -52,13 +52,9 @@ class DownloadManager extends _$DownloadManager { return manager; } - Future queueAudioBookDownload( - LibraryItemExpanded item, - ) async { + Future queueAudioBookDownload(LibraryItemExpanded item) async { _logger.fine('queueing download for ${item.id}'); - await state.queueAudioBookDownload( - item, - ); + await state.queueAudioBookDownload(item); } Future deleteDownloadedItem(LibraryItemExpanded item) async { @@ -83,58 +79,57 @@ class ItemDownloadProgress extends _$ItemDownloadProgress { Future build(String id) async { final item = await ref.watch(libraryItemProvider(id).future); final manager = ref.read(downloadManagerProvider); - manager.taskUpdateStream.map((taskUpdate) { - if (taskUpdate is! TaskProgressUpdate) { - return null; - } - if (taskUpdate.task.group == id) { - return taskUpdate; - } - }).listen((task) async { - if (task != null) { - final totalSize = item.totalSize; - // if total size is 0, return 0 - if (totalSize == 0) { - state = const AsyncValue.data(0.0); - return; - } - final downloadedFiles = await manager.getDownloadedFilesMetadata(item); - // calculate total size of downloaded files and total size of item, then divide - // to get percentage - final downloadedSize = downloadedFiles.fold( - 0, - (previousValue, element) => previousValue + element.metadata.size, - ); + manager.taskUpdateStream + .map((taskUpdate) { + if (taskUpdate is! TaskProgressUpdate) { + return null; + } + if (taskUpdate.task.group == id) { + return taskUpdate; + } + }) + .listen((task) async { + if (task != null) { + final totalSize = item.totalSize; + // if total size is 0, return 0 + if (totalSize == 0) { + state = const AsyncValue.data(0.0); + return; + } + final downloadedFiles = await manager.getDownloadedFilesMetadata( + item, + ); + // calculate total size of downloaded files and total size of item, then divide + // to get percentage + final downloadedSize = downloadedFiles.fold( + 0, + (previousValue, element) => previousValue + element.metadata.size, + ); - final inProgressFileSize = task.progress * task.expectedFileSize; - final totalDownloadedSize = downloadedSize + inProgressFileSize; - final progress = totalDownloadedSize / totalSize; - // if current progress is more than calculated progress, do not update - if (progress < (state.value ?? 0.0)) { - return; - } + final inProgressFileSize = task.progress * task.expectedFileSize; + final totalDownloadedSize = downloadedSize + inProgressFileSize; + final progress = totalDownloadedSize / totalSize; + // if current progress is more than calculated progress, do not update + if (progress < (state.value ?? 0.0)) { + return; + } - state = AsyncValue.data(progress.clamp(0.0, 1.0)); - } - }); + state = AsyncValue.data(progress.clamp(0.0, 1.0)); + } + }); return null; } } @riverpod -FutureOr> downloadHistory( - Ref ref, { - String? group, -}) async { +FutureOr> downloadHistory(Ref ref, {String? group}) async { return await FileDownloader().database.allRecords(group: group); } @riverpod class IsItemDownloaded extends _$IsItemDownloaded { @override - FutureOr build( - LibraryItemExpanded item, - ) { + FutureOr build(LibraryItemExpanded item) { final manager = ref.watch(downloadManagerProvider); return manager.isItemDownloaded(item); } diff --git a/lib/features/downloads/view/downloads_page.dart b/lib/features/downloads/view/downloads_page.dart index 7c5dbfb..7d2b2cb 100644 --- a/lib/features/downloads/view/downloads_page.dart +++ b/lib/features/downloads/view/downloads_page.dart @@ -11,9 +11,7 @@ class DownloadsPage extends HookConsumerWidget { final downloadHistory = ref.watch(downloadHistoryProvider()); return Scaffold( - appBar: AppBar( - title: const Text('Downloads'), - ), + appBar: AppBar(title: const Text('Downloads')), body: Center( // history of downloads child: downloadHistory.when( diff --git a/lib/features/explore/view/explore_page.dart b/lib/features/explore/view/explore_page.dart index 2ed7b52..e747d26 100644 --- a/lib/features/explore/view/explore_page.dart +++ b/lib/features/explore/view/explore_page.dart @@ -28,18 +28,14 @@ class ExplorePage extends HookConsumerWidget { final settings = ref.watch(appSettingsProvider); final api = ref.watch(authenticatedApiProvider); return Scaffold( - appBar: AppBar( - title: const Text('Explore'), - ), + appBar: AppBar(title: const Text('Explore')), body: const MySearchBar(), ); } } class MySearchBar extends HookConsumerWidget { - const MySearchBar({ - super.key, - }); + const MySearchBar({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -61,8 +57,11 @@ class MySearchBar extends HookConsumerWidget { currentQuery = query; // In a real application, there should be some error handling here. - final options = await api.libraries - .search(libraryId: settings.activeLibraryId!, query: query, limit: 3); + final options = await api.libraries.search( + libraryId: settings.activeLibraryId!, + query: query, + limit: 3, + ); // If another search happened after this one, throw away these options. if (currentQuery != query) { @@ -97,11 +96,10 @@ class MySearchBar extends HookConsumerWidget { // opacity: 0.5 for the hint text hintStyle: WidgetStatePropertyAll( Theme.of(context).textTheme.bodyMedium!.copyWith( - color: Theme.of(context) - .colorScheme - .onSurface - .withValues(alpha: 0.5), - ), + color: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.5), + ), ), textInputAction: TextInputAction.search, onTapOutside: (_) { @@ -120,12 +118,7 @@ class MySearchBar extends HookConsumerWidget { ); }, viewOnSubmitted: (value) { - context.pushNamed( - Routes.search.name, - queryParameters: { - 'q': value, - }, - ); + context.pushNamed(Routes.search.name, queryParameters: {'q': value}); }, suggestionsBuilder: (context, controller) async { // check if the search controller is empty @@ -191,14 +184,12 @@ List buildBookSearchResult( SearchResultMiniSection( // title: 'Books', category: SearchResultCategory.books, - options: options.book.map( - (result) { - // convert result to a book object - final book = result.libraryItem.media.asBookExpanded; - final metadata = book.metadata.asBookMetadataExpanded; - return BookSearchResultMini(book: book, metadata: metadata); - }, - ), + options: options.book.map((result) { + // convert result to a book object + final book = result.libraryItem.media.asBookExpanded; + final metadata = book.metadata.asBookMetadataExpanded; + return BookSearchResultMini(book: book, metadata: metadata); + }), ), ); } @@ -207,11 +198,9 @@ List buildBookSearchResult( SearchResultMiniSection( // title: 'Authors', category: SearchResultCategory.authors, - options: options.authors.map( - (result) { - return ListTile(title: Text(result.name)); - }, - ), + options: options.authors.map((result) { + return ListTile(title: Text(result.name)); + }), ), ); } @@ -245,10 +234,7 @@ class BookSearchResultMini extends HookConsumerWidget { child: ClipRRect( borderRadius: BorderRadius.circular(5), child: image.when( - data: (bytes) => Image.memory( - bytes, - fit: BoxFit.cover, - ), + data: (bytes) => Image.memory(bytes, fit: BoxFit.cover), loading: () => const BookCoverSkeleton(), error: (error, _) => const Icon(Icons.error), ), @@ -259,11 +245,7 @@ class BookSearchResultMini extends HookConsumerWidget { subtitle: Text( maxLines: 1, overflow: TextOverflow.ellipsis, - metadata.authors - .map( - (author) => author.name, - ) - .join(', '), + metadata.authors.map((author) => author.name).join(', '), ), onTap: () { // navigate to the book details page diff --git a/lib/features/explore/view/search_result_page.dart b/lib/features/explore/view/search_result_page.dart index 10a8a39..fef097e 100644 --- a/lib/features/explore/view/search_result_page.dart +++ b/lib/features/explore/view/search_result_page.dart @@ -5,13 +5,7 @@ import 'package:vaani/features/explore/providers/search_result_provider.dart'; import 'package:vaani/features/explore/view/explore_page.dart'; import 'package:vaani/shared/extensions/model_conversions.dart'; -enum SearchResultCategory { - books, - authors, - series, - tags, - narrators, -} +enum SearchResultCategory { books, authors, series, tags, narrators } class SearchResultPage extends HookConsumerWidget { const SearchResultPage({ @@ -41,9 +35,7 @@ class SearchResultPage extends HookConsumerWidget { body: results.when( data: (options) { if (options == null) { - return Container( - child: const Text('No data found'), - ); + return Container(child: const Text('No data found')); } if (options is BookLibrarySearchResponse) { if (category == null) { @@ -51,18 +43,15 @@ class SearchResultPage extends HookConsumerWidget { } return switch (category!) { SearchResultCategory.books => ListView.builder( - itemCount: options.book.length, - itemBuilder: (context, index) { - final book = - options.book[index].libraryItem.media.asBookExpanded; - final metadata = book.metadata.asBookMetadataExpanded; + itemCount: options.book.length, + itemBuilder: (context, index) { + final book = + options.book[index].libraryItem.media.asBookExpanded; + final metadata = book.metadata.asBookMetadataExpanded; - return BookSearchResultMini( - book: book, - metadata: metadata, - ); - }, - ), + return BookSearchResultMini(book: book, metadata: metadata); + }, + ), SearchResultCategory.authors => Container(), SearchResultCategory.series => Container(), SearchResultCategory.tags => Container(), @@ -71,12 +60,8 @@ class SearchResultPage extends HookConsumerWidget { } return null; }, - loading: () => const Center( - child: CircularProgressIndicator(), - ), - error: (error, stackTrace) => Center( - child: Text('Error: $error'), - ), + loading: () => const Center(child: CircularProgressIndicator()), + error: (error, stackTrace) => Center(child: Text('Error: $error')), ), ); } diff --git a/lib/features/item_viewer/view/library_item_actions.dart b/lib/features/item_viewer/view/library_item_actions.dart index 7299e5c..50ef9c2 100644 --- a/lib/features/item_viewer/view/library_item_actions.dart +++ b/lib/features/item_viewer/view/library_item_actions.dart @@ -26,10 +26,7 @@ import 'package:vaani/shared/extensions/model_conversions.dart'; import 'package:vaani/shared/utils.dart'; class LibraryItemActions extends HookConsumerWidget { - const LibraryItemActions({ - super.key, - required this.id, - }); + const LibraryItemActions({super.key, required this.id}); final String id; @@ -68,9 +65,7 @@ class LibraryItemActions extends HookConsumerWidget { // read list button IconButton( onPressed: () {}, - icon: const Icon( - Icons.playlist_add_rounded, - ), + icon: const Icon(Icons.playlist_add_rounded), ), // share button IconButton( @@ -79,8 +74,9 @@ class LibraryItemActions extends HookConsumerWidget { var currentServerUrl = apiSettings.activeServer!.serverUrl; if (!currentServerUrl.hasScheme) { - currentServerUrl = - Uri.https(currentServerUrl.toString()); + currentServerUrl = Uri.https( + currentServerUrl.toString(), + ); } handleLaunchUrl( Uri.parse( @@ -140,7 +136,8 @@ class LibraryItemActions extends HookConsumerWidget { .database .deleteRecordWithId( record - .task.taskId, + .task + .taskId, ); Navigator.pop(context); }, @@ -161,8 +158,8 @@ class LibraryItemActions extends HookConsumerWidget { // open the file location final didOpen = await FileDownloader().openFile( - task: record.task, - ); + task: record.task, + ); if (!didOpen) { appLogger.warning( @@ -182,16 +179,13 @@ class LibraryItemActions extends HookConsumerWidget { loading: () => const Center( child: CircularProgressIndicator(), ), - error: (error, stackTrace) => Center( - child: Text('Error: $error'), - ), + error: (error, stackTrace) => + Center(child: Text('Error: $error')), ); }, ); }, - icon: const Icon( - Icons.more_vert_rounded, - ), + icon: const Icon(Icons.more_vert_rounded), ), ], ), @@ -206,10 +200,7 @@ class LibraryItemActions extends HookConsumerWidget { } class LibItemDownloadButton extends HookConsumerWidget { - const LibItemDownloadButton({ - super.key, - required this.item, - }); + const LibItemDownloadButton({super.key, required this.item}); final shelfsdk.LibraryItemExpanded item; @@ -222,9 +213,7 @@ class LibItemDownloadButton extends HookConsumerWidget { final isItemDownloading = ref.watch(isItemDownloadingProvider(item.id)); return isItemDownloading - ? ItemCurrentlyInDownloadQueue( - item: item, - ) + ? ItemCurrentlyInDownloadQueue(item: item) : IconButton( onPressed: () { appLogger.fine('Pressed download button'); @@ -233,18 +222,13 @@ class LibItemDownloadButton extends HookConsumerWidget { .read(downloadManagerProvider.notifier) .queueAudioBookDownload(item); }, - icon: const Icon( - Icons.download_rounded, - ), + icon: const Icon(Icons.download_rounded), ); } } class ItemCurrentlyInDownloadQueue extends HookConsumerWidget { - const ItemCurrentlyInDownloadQueue({ - super.key, - required this.item, - }); + const ItemCurrentlyInDownloadQueue({super.key, required this.item}); final shelfsdk.LibraryItemExpanded item; @@ -263,17 +247,12 @@ class ItemCurrentlyInDownloadQueue extends HookConsumerWidget { return Stack( alignment: Alignment.center, children: [ - CircularProgressIndicator( - value: progress, - strokeWidth: 2, - ), + CircularProgressIndicator(value: progress, strokeWidth: 2), const Icon( - Icons.download, - // color: Theme.of(context).progressIndicatorTheme.color, - ) - .animate( - onPlay: (controller) => controller.repeat(), + Icons.download, + // color: Theme.of(context).progressIndicatorTheme.color, ) + .animate(onPlay: (controller) => controller.repeat()) .fade( duration: shimmerDuration, end: 1, @@ -292,10 +271,7 @@ class ItemCurrentlyInDownloadQueue extends HookConsumerWidget { } class AlreadyItemDownloadedButton extends HookConsumerWidget { - const AlreadyItemDownloadedButton({ - super.key, - required this.item, - }); + const AlreadyItemDownloadedButton({super.key, required this.item}); final shelfsdk.LibraryItemExpanded item; @@ -317,25 +293,18 @@ class AlreadyItemDownloadedButton extends HookConsumerWidget { top: 8.0, bottom: (isBookPlaying ? playerMinHeight : 0) + 8, ), - child: DownloadSheet( - item: item, - ), + child: DownloadSheet(item: item), ); }, ); }, - icon: const Icon( - Icons.download_done_rounded, - ), + icon: const Icon(Icons.download_done_rounded), ); } } class DownloadSheet extends HookConsumerWidget { - const DownloadSheet({ - super.key, - required this.item, - }); + const DownloadSheet({super.key, required this.item}); final shelfsdk.LibraryItemExpanded item; @@ -367,9 +336,7 @@ class DownloadSheet extends HookConsumerWidget { // ), ListTile( title: const Text('Delete'), - leading: const Icon( - Icons.delete_rounded, - ), + leading: const Icon(Icons.delete_rounded), onTap: () async { // show the delete dialog final wasDeleted = await showDialog( @@ -387,9 +354,7 @@ class DownloadSheet extends HookConsumerWidget { // delete the file ref .read(downloadManagerProvider.notifier) - .deleteDownloadedItem( - item, - ); + .deleteDownloadedItem(item); GoRouter.of(context).pop(true); }, child: const Text('Yes'), @@ -409,11 +374,7 @@ class DownloadSheet extends HookConsumerWidget { appLogger.fine('Deleted ${item.media.metadata.title}'); GoRouter.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Deleted ${item.media.metadata.title}', - ), - ), + SnackBar(content: Text('Deleted ${item.media.metadata.title}')), ); } }, @@ -424,9 +385,7 @@ class DownloadSheet extends HookConsumerWidget { } class _LibraryItemPlayButton extends HookConsumerWidget { - const _LibraryItemPlayButton({ - required this.item, - }); + const _LibraryItemPlayButton({required this.item}); final shelfsdk.LibraryItemExpanded item; @@ -477,9 +436,7 @@ class _LibraryItemPlayButton extends HookConsumerWidget { ), label: Text(getPlayDisplayText()), style: ElevatedButton.styleFrom( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4), - ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)), ), ); } @@ -502,11 +459,11 @@ class DynamicItemPlayIcon extends StatelessWidget { return Icon( isCurrentBookSetInPlayer ? isPlayingThisBook - ? Icons.pause_rounded - : Icons.play_arrow_rounded + ? Icons.pause_rounded + : Icons.play_arrow_rounded : isBookCompleted - ? Icons.replay_rounded - : Icons.play_arrow_rounded, + ? Icons.replay_rounded + : Icons.play_arrow_rounded, ); } } @@ -529,8 +486,9 @@ Future libraryItemPlayButtonOnPressed({ appLogger.info('Setting the book ${book.libraryItemId}'); appLogger.info('Initial position: ${userMediaProgress?.currentTime}'); final downloadManager = ref.watch(simpleDownloadManagerProvider); - final libItem = - await ref.read(libraryItemProvider(book.libraryItemId).future); + final libItem = await ref.read( + libraryItemProvider(book.libraryItemId).future, + ); final downloadedUris = await downloadManager.getDownloadedFilesUri(libItem); setSourceFuture = player.setSourceAudiobook( book, @@ -546,8 +504,9 @@ Future libraryItemPlayButtonOnPressed({ } } // set the volume as this is the first time playing and dismissing causes the volume to go to 0 - var bookPlayerSettings = - ref.read(bookSettingsProvider(book.libraryItemId)).playerSettings; + var bookPlayerSettings = ref + .read(bookSettingsProvider(book.libraryItemId)) + .playerSettings; var appPlayerSettings = ref.read(appSettingsProvider).playerSettings; var configurePlayerForEveryBook = @@ -559,14 +518,14 @@ Future libraryItemPlayButtonOnPressed({ player.setVolume( configurePlayerForEveryBook ? bookPlayerSettings.preferredDefaultVolume ?? - appPlayerSettings.preferredDefaultVolume + appPlayerSettings.preferredDefaultVolume : appPlayerSettings.preferredDefaultVolume, ), // set the speed player.setSpeed( configurePlayerForEveryBook ? bookPlayerSettings.preferredDefaultSpeed ?? - appPlayerSettings.preferredDefaultSpeed + appPlayerSettings.preferredDefaultSpeed : appPlayerSettings.preferredDefaultSpeed, ), ]); diff --git a/lib/features/item_viewer/view/library_item_hero_section.dart b/lib/features/item_viewer/view/library_item_hero_section.dart index ae83420..a103b7a 100644 --- a/lib/features/item_viewer/view/library_item_hero_section.dart +++ b/lib/features/item_viewer/view/library_item_hero_section.dart @@ -42,14 +42,13 @@ class LibraryItemHeroSection extends HookConsumerWidget { child: Column( children: [ Hero( - tag: HeroTagPrefixes.bookCover + + tag: + HeroTagPrefixes.bookCover + itemId + (extraMap?.heroTagSuffix ?? ''), child: ClipRRect( borderRadius: BorderRadius.circular(16), - child: _BookCover( - itemId: itemId, - ), + child: _BookCover(itemId: itemId), ), ), // a progress bar @@ -59,9 +58,7 @@ class LibraryItemHeroSection extends HookConsumerWidget { right: 8.0, left: 8.0, ), - child: _LibraryItemProgressIndicator( - id: itemId, - ), + child: _LibraryItemProgressIndicator(id: itemId), ), ], ), @@ -77,10 +74,7 @@ class LibraryItemHeroSection extends HookConsumerWidget { } class _BookDetails extends HookConsumerWidget { - const _BookDetails({ - required this.id, - this.extraMap, - }); + const _BookDetails({required this.id, this.extraMap}); final String id; final LibraryItemExtras? extraMap; @@ -99,10 +93,7 @@ class _BookDetails extends HookConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - _BookTitle( - extraMap: extraMap, - itemBookMetadata: itemBookMetadata, - ), + _BookTitle(extraMap: extraMap, itemBookMetadata: itemBookMetadata), Container( margin: const EdgeInsets.symmetric(vertical: 16), child: Column( @@ -134,9 +125,7 @@ class _BookDetails extends HookConsumerWidget { } class _LibraryItemProgressIndicator extends HookConsumerWidget { - const _LibraryItemProgressIndicator({ - required this.id, - }); + const _LibraryItemProgressIndicator({required this.id}); final String id; @@ -157,13 +146,15 @@ class _LibraryItemProgressIndicator extends HookConsumerWidget { Duration remainingTime; if (player.book?.libraryItemId == libraryItem.id) { // final positionStream = useStream(player.slowPositionStream); - progress = (player.positionInBook).inSeconds / + progress = + (player.positionInBook).inSeconds / libraryItem.media.asBookExpanded.duration.inSeconds; remainingTime = libraryItem.media.asBookExpanded.duration - player.positionInBook; } else { progress = mediaProgress?.progress ?? 0; - remainingTime = (libraryItem.media.asBookExpanded.duration - + remainingTime = + (libraryItem.media.asBookExpanded.duration - mediaProgress!.currentTime); } @@ -190,20 +181,17 @@ class _LibraryItemProgressIndicator extends HookConsumerWidget { semanticsLabel: 'Book progress', semanticsValue: '${progressInPercent.toStringAsFixed(2)}%', ), - const SizedBox.square( - dimension: 4.0, - ), + const SizedBox.square(dimension: 4.0), // time remaining Text( // only show 2 decimal places '${remainingTime.smartBinaryFormat} left', style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: Theme.of(context) - .colorScheme - .onSurface - .withValues(alpha: 0.75), - ), + color: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.75), + ), ), ], ), @@ -212,10 +200,7 @@ class _LibraryItemProgressIndicator extends HookConsumerWidget { } class _HeroSectionSubLabelWithIcon extends HookConsumerWidget { - const _HeroSectionSubLabelWithIcon({ - required this.icon, - required this.text, - }); + const _HeroSectionSubLabelWithIcon({required this.icon, required this.text}); final IconData icon; final Widget text; @@ -225,8 +210,10 @@ class _HeroSectionSubLabelWithIcon extends HookConsumerWidget { final themeData = Theme.of(context); final useFontAwesome = icon.runtimeType == FontAwesomeIcons.book.runtimeType; - final useMaterialThemeOnItemPage = - ref.watch(appSettingsProvider).themeSettings.useMaterialThemeOnItemPage; + final useMaterialThemeOnItemPage = ref + .watch(appSettingsProvider) + .themeSettings + .useMaterialThemeOnItemPage; final color = useMaterialThemeOnItemPage ? themeData.colorScheme.primary : themeData.colorScheme.onSurface.withValues(alpha: 0.75); @@ -237,20 +224,10 @@ class _HeroSectionSubLabelWithIcon extends HookConsumerWidget { Container( margin: const EdgeInsets.only(right: 8, top: 2), child: useFontAwesome - ? FaIcon( - icon, - size: 16, - color: color, - ) - : Icon( - icon, - size: 16, - color: color, - ), - ), - Expanded( - child: text, + ? FaIcon(icon, size: 16, color: color) + : Icon(icon, size: 16, color: color), ), + Expanded(child: text), ], ), ); @@ -338,9 +315,7 @@ class _BookNarrators extends StatelessWidget { } class _BookCover extends HookConsumerWidget { - const _BookCover({ - required this.itemId, - }); + const _BookCover({required this.itemId}); final String itemId; @@ -358,7 +333,8 @@ class _BookCover extends HookConsumerWidget { themeOfLibraryItemProvider( itemId, brightness: Theme.of(context).brightness, - highContrast: themeSettings.highContrast || + highContrast: + themeSettings.highContrast || MediaQuery.of(context).highContrast, ), ) @@ -391,15 +367,10 @@ class _BookCover extends HookConsumerWidget { return const Icon(Icons.error); } - return Image.memory( - image, - fit: BoxFit.cover, - ); + return Image.memory(image, fit: BoxFit.cover); }, loading: () { - return const Center( - child: BookCoverSkeleton(), - ); + return const Center(child: BookCoverSkeleton()); }, error: (error, stack) { return const Center(child: Icon(Icons.error)); @@ -411,10 +382,7 @@ class _BookCover extends HookConsumerWidget { } class _BookTitle extends StatelessWidget { - const _BookTitle({ - required this.extraMap, - required this.itemBookMetadata, - }); + const _BookTitle({required this.extraMap, required this.itemBookMetadata}); final LibraryItemExtras? extraMap; final shelfsdk.BookMetadataExpanded? itemBookMetadata; @@ -426,7 +394,8 @@ class _BookTitle extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Hero( - tag: HeroTagPrefixes.bookTitle + + tag: + HeroTagPrefixes.bookTitle + // itemId + (extraMap?.heroTagSuffix ?? ''), child: Text( diff --git a/lib/features/item_viewer/view/library_item_metadata.dart b/lib/features/item_viewer/view/library_item_metadata.dart index 753a38e..e12a997 100644 --- a/lib/features/item_viewer/view/library_item_metadata.dart +++ b/lib/features/item_viewer/view/library_item_metadata.dart @@ -4,10 +4,7 @@ import 'package:vaani/api/library_item_provider.dart'; import 'package:vaani/shared/extensions/model_conversions.dart'; class LibraryItemMetadata extends HookConsumerWidget { - const LibraryItemMetadata({ - super.key, - required this.id, - }); + const LibraryItemMetadata({super.key, required this.id}); final String id; @@ -72,7 +69,8 @@ class LibraryItemMetadata extends HookConsumerWidget { ), _MetadataItem( title: 'Published', - value: itemBookMetadata?.publishedDate ?? + value: + itemBookMetadata?.publishedDate ?? itemBookMetadata?.publishedYear ?? 'Unknown', ), @@ -87,22 +85,18 @@ class LibraryItemMetadata extends HookConsumerWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, // alternate between metadata and vertical divider - children: List.generate( - children.length * 2 - 1, - (index) { - if (index.isEven) { - return children[index ~/ 2]; - } - return VerticalDivider( - indent: 6, - endIndent: 6, - color: Theme.of(context) - .colorScheme - .onSurface - .withValues(alpha: 0.6), - ); - }, - ), + children: List.generate(children.length * 2 - 1, (index) { + if (index.isEven) { + return children[index ~/ 2]; + } + return VerticalDivider( + indent: 6, + endIndent: 6, + color: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.6), + ); + }), ), ), ); @@ -111,10 +105,7 @@ class LibraryItemMetadata extends HookConsumerWidget { /// key-value pair to display as column class _MetadataItem extends StatelessWidget { - const _MetadataItem({ - required this.title, - required this.value, - }); + const _MetadataItem({required this.title, required this.value}); final String title; final String value; diff --git a/lib/features/item_viewer/view/library_item_page.dart b/lib/features/item_viewer/view/library_item_page.dart index b685a6a..6974bc6 100644 --- a/lib/features/item_viewer/view/library_item_page.dart +++ b/lib/features/item_viewer/view/library_item_page.dart @@ -16,49 +16,43 @@ import 'library_item_hero_section.dart'; import 'library_item_metadata.dart'; class LibraryItemPage extends HookConsumerWidget { - const LibraryItemPage({ - super.key, - required this.itemId, - this.extra, - }); + const LibraryItemPage({super.key, required this.itemId, this.extra}); final String itemId; final Object? extra; static const double _showFabThreshold = 300.0; @override Widget build(BuildContext context, WidgetRef ref) { - final additionalItemData = - extra is LibraryItemExtras ? extra as LibraryItemExtras : null; + final additionalItemData = extra is LibraryItemExtras + ? extra as LibraryItemExtras + : null; final scrollController = useScrollController(); final showFab = useState(false); // Effect to listen to scroll changes and update FAB visibility - useEffect( - () { - void listener() { - if (!scrollController.hasClients) { - return; // Ensure controller is attached - } - final shouldShow = scrollController.offset > _showFabThreshold; - // Update state only if it changes and widget is still mounted - if (showFab.value != shouldShow && context.mounted) { - showFab.value = shouldShow; - } + useEffect(() { + void listener() { + if (!scrollController.hasClients) { + return; // Ensure controller is attached } + final shouldShow = scrollController.offset > _showFabThreshold; + // Update state only if it changes and widget is still mounted + if (showFab.value != shouldShow && context.mounted) { + showFab.value = shouldShow; + } + } - scrollController.addListener(listener); - // Initial check in case the view starts scrolled (less likely but safe) - WidgetsBinding.instance.addPostFrameCallback((_) { - if (scrollController.hasClients && context.mounted) { - listener(); - } - }); + scrollController.addListener(listener); + // Initial check in case the view starts scrolled (less likely but safe) + WidgetsBinding.instance.addPostFrameCallback((_) { + if (scrollController.hasClients && context.mounted) { + listener(); + } + }); - // Cleanup: remove the listener when the widget is disposed - return () => scrollController.removeListener(listener); - }, - [scrollController], - ); // Re-run effect if scrollController changes + // Cleanup: remove the listener when the widget is disposed + return () => scrollController.removeListener(listener); + }, [scrollController]); // Re-run effect if scrollController changes // --- FAB Scroll-to-Top Logic --- void scrollToTop() { @@ -82,10 +76,7 @@ class LibraryItemPage extends HookConsumerWidget { transitionBuilder: (Widget child, Animation animation) { return ScaleTransition( scale: animation, - child: FadeTransition( - opacity: animation, - child: child, - ), + child: FadeTransition(opacity: animation, child: child), ); }, child: showFab.value @@ -96,9 +87,7 @@ class LibraryItemPage extends HookConsumerWidget { tooltip: 'Scroll to top', child: const Icon(Icons.arrow_upward), ) - : const SizedBox.shrink( - key: ValueKey('fab-empty'), - ), + : const SizedBox.shrink(key: ValueKey('fab-empty')), ), body: CustomScrollView( controller: scrollController, @@ -115,17 +104,11 @@ class LibraryItemPage extends HookConsumerWidget { ), ), // a horizontal display with dividers of metadata - SliverToBoxAdapter( - child: LibraryItemMetadata(id: itemId), - ), + SliverToBoxAdapter(child: LibraryItemMetadata(id: itemId)), // a row of actions like play, download, share, etc - SliverToBoxAdapter( - child: LibraryItemActions(id: itemId), - ), + SliverToBoxAdapter(child: LibraryItemActions(id: itemId)), // a expandable section for book description - SliverToBoxAdapter( - child: LibraryItemDescription(id: itemId), - ), + SliverToBoxAdapter(child: LibraryItemDescription(id: itemId)), // a padding at the bottom to make sure the last item is not hidden by mini player const SliverToBoxAdapter(child: MiniPlayerBottomPadding()), ], @@ -137,10 +120,7 @@ class LibraryItemPage extends HookConsumerWidget { } class LibraryItemDescription extends HookConsumerWidget { - const LibraryItemDescription({ - super.key, - required this.id, - }); + const LibraryItemDescription({super.key, required this.id}); final String id; @override @@ -160,16 +140,21 @@ class LibraryItemDescription extends HookConsumerWidget { double calculateWidth( BuildContext context, BoxConstraints constraints, { + /// width ratio of the cover image to the available width double widthRatio = 0.4, /// height ratio of the cover image to the available height double maxHeightToUse = 0.25, }) { - final availHeight = - min(constraints.maxHeight, MediaQuery.of(context).size.height); - final availWidth = - min(constraints.maxWidth, MediaQuery.of(context).size.width); + final availHeight = min( + constraints.maxHeight, + MediaQuery.of(context).size.height, + ); + final availWidth = min( + constraints.maxWidth, + MediaQuery.of(context).size.width, + ); // make the width widthRatio of the available width var width = availWidth * widthRatio; diff --git a/lib/features/item_viewer/view/library_item_sliver_app_bar.dart b/lib/features/item_viewer/view/library_item_sliver_app_bar.dart index 5616a96..5090160 100644 --- a/lib/features/item_viewer/view/library_item_sliver_app_bar.dart +++ b/lib/features/item_viewer/view/library_item_sliver_app_bar.dart @@ -21,28 +21,26 @@ class LibraryItemSliverAppBar extends HookConsumerWidget { final showTitle = useState(false); - useEffect( - () { - void listener() { - final shouldShow = scrollController.hasClients && - scrollController.offset > _showTitleThreshold; - if (showTitle.value != shouldShow) { - showTitle.value = shouldShow; - } + useEffect(() { + void listener() { + final shouldShow = + scrollController.hasClients && + scrollController.offset > _showTitleThreshold; + if (showTitle.value != shouldShow) { + showTitle.value = shouldShow; } + } - scrollController.addListener(listener); - // Trigger listener once initially in case the view starts scrolled - // (though unlikely for this specific use case, it's good practice) - WidgetsBinding.instance.addPostFrameCallback((_) { - if (scrollController.hasClients) { - listener(); - } - }); - return () => scrollController.removeListener(listener); - }, - [scrollController], - ); + scrollController.addListener(listener); + // Trigger listener once initially in case the view starts scrolled + // (though unlikely for this specific use case, it's good practice) + WidgetsBinding.instance.addPostFrameCallback((_) { + if (scrollController.hasClients) { + listener(); + } + }); + return () => scrollController.removeListener(listener); + }, [scrollController]); return SliverAppBar( elevation: 0, diff --git a/lib/features/library_browser/view/library_browser_page.dart b/lib/features/library_browser/view/library_browser_page.dart index 26cb2df..aa03fa8 100644 --- a/lib/features/library_browser/view/library_browser_page.dart +++ b/lib/features/library_browser/view/library_browser_page.dart @@ -41,43 +41,41 @@ class LibraryBrowserPage extends HookConsumerWidget { title: Text(appBarTitle), ), SliverList( - delegate: SliverChildListDelegate( - [ - ListTile( - title: const Text('Authors'), - leading: const Icon(Icons.person), - trailing: const Icon(Icons.chevron_right), - onTap: () { - showNotImplementedToast(context); - }, - ), - ListTile( - title: const Text('Genres'), - leading: const Icon(Icons.category), - trailing: const Icon(Icons.chevron_right), - onTap: () { - showNotImplementedToast(context); - }, - ), - ListTile( - title: const Text('Series'), - leading: const Icon(Icons.list), - trailing: const Icon(Icons.chevron_right), - onTap: () { - showNotImplementedToast(context); - }, - ), - // Downloads - ListTile( - title: const Text('Downloads'), - leading: const Icon(Icons.download), - trailing: const Icon(Icons.chevron_right), - onTap: () { - GoRouter.of(context).pushNamed(Routes.downloads.name); - }, - ), - ], - ), + delegate: SliverChildListDelegate([ + ListTile( + title: const Text('Authors'), + leading: const Icon(Icons.person), + trailing: const Icon(Icons.chevron_right), + onTap: () { + showNotImplementedToast(context); + }, + ), + ListTile( + title: const Text('Genres'), + leading: const Icon(Icons.category), + trailing: const Icon(Icons.chevron_right), + onTap: () { + showNotImplementedToast(context); + }, + ), + ListTile( + title: const Text('Series'), + leading: const Icon(Icons.list), + trailing: const Icon(Icons.chevron_right), + onTap: () { + showNotImplementedToast(context); + }, + ), + // Downloads + ListTile( + title: const Text('Downloads'), + leading: const Icon(Icons.download), + trailing: const Icon(Icons.chevron_right), + onTap: () { + GoRouter.of(context).pushNamed(Routes.downloads.name); + }, + ), + ]), ), ], ), diff --git a/lib/features/logging/providers/logs_provider.dart b/lib/features/logging/providers/logs_provider.dart index 9fd9e4a..763fa90 100644 --- a/lib/features/logging/providers/logs_provider.dart +++ b/lib/features/logging/providers/logs_provider.dart @@ -59,8 +59,10 @@ String generateZipFileName() { } Level parseLevel(String level) { - return Level.LEVELS - .firstWhere((l) => l.name == level, orElse: () => Level.ALL); + return Level.LEVELS.firstWhere( + (l) => l.name == level, + orElse: () => Level.ALL, + ); } LogRecord parseLogLine(String line) { diff --git a/lib/features/logging/view/logs_page.dart b/lib/features/logging/view/logs_page.dart index 74d1ad3..978fd19 100644 --- a/lib/features/logging/view/logs_page.dart +++ b/lib/features/logging/view/logs_page.dart @@ -54,8 +54,9 @@ class LogsPage extends HookConsumerWidget { icon: const Icon(Icons.share), onPressed: () async { appLogger.info('Preparing logs for sharing'); - final zipLogFilePath = - await ref.read(logsProvider.notifier).getZipFilePath(); + final zipLogFilePath = await ref + .read(logsProvider.notifier) + .getZipFilePath(); // submit logs final result = await Share.shareXFiles([XFile(zipLogFilePath)]); @@ -169,7 +170,6 @@ class LogsPage extends HookConsumerWidget { children: [ // a filter for log levels, loggers, and search // TODO: implement filters and search - Expanded( child: logs.when( data: (logRecords) { @@ -243,9 +243,7 @@ class LogRecordTile extends StatelessWidget { style: const TextStyle(fontStyle: FontStyle.italic), ), const TextSpan(text: '\n\n'), - TextSpan( - text: logRecord.message, - ), + TextSpan(text: logRecord.message), ], ), ), diff --git a/lib/features/onboarding/providers/oauth_provider.dart b/lib/features/onboarding/providers/oauth_provider.dart index fb7856b..38446fa 100644 --- a/lib/features/onboarding/providers/oauth_provider.dart +++ b/lib/features/onboarding/providers/oauth_provider.dart @@ -53,8 +53,10 @@ class OauthFlows extends _$OauthFlows { } state = { ...state, - oauthState: state[oauthState]! - .copyWith(isFlowComplete: true, authToken: authToken), + oauthState: state[oauthState]!.copyWith( + isFlowComplete: true, + authToken: authToken, + ), }; } } diff --git a/lib/features/onboarding/view/callback_page.dart b/lib/features/onboarding/view/callback_page.dart index f4bb098..bb4e139 100644 --- a/lib/features/onboarding/view/callback_page.dart +++ b/lib/features/onboarding/view/callback_page.dart @@ -27,9 +27,7 @@ class CallbackPage extends HookConsumerWidget { // check if the state is in the flows if (!flows.containsKey(state)) { - return const _SomethingWentWrong( - message: 'State not found', - ); + return const _SomethingWentWrong(message: 'State not found'); } // get the token @@ -45,26 +43,21 @@ class CallbackPage extends HookConsumerWidget { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('Contacting server...\nPlease wait\n\nGot:' - '\nState: $state\nCode: $code'), + Text( + 'Contacting server...\nPlease wait\n\nGot:' + '\nState: $state\nCode: $code', + ), loginAuthToken.when( data: (authenticationToken) { if (authenticationToken == null) { - handleServerError( - context, - serverErrorResponse, - ); + handleServerError(context, serverErrorResponse); return const BackToLoginButton(); } return Text('Token: $authenticationToken'); }, loading: () => const CircularProgressIndicator(), error: (error, _) { - handleServerError( - context, - serverErrorResponse, - e: error, - ); + handleServerError(context, serverErrorResponse, e: error); return Column( children: [ Text('Error with OAuth flow: $error'), @@ -81,9 +74,7 @@ class CallbackPage extends HookConsumerWidget { } class BackToLoginButton extends StatelessWidget { - const BackToLoginButton({ - super.key, - }); + const BackToLoginButton({super.key}); @override Widget build(BuildContext context) { @@ -97,9 +88,7 @@ class BackToLoginButton extends StatelessWidget { } class _SomethingWentWrong extends StatelessWidget { - const _SomethingWentWrong({ - this.message = 'Error with OAuth flow', - }); + const _SomethingWentWrong({this.message = 'Error with OAuth flow'}); final String message; @@ -109,10 +98,7 @@ class _SomethingWentWrong extends StatelessWidget { body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(message), - const BackToLoginButton(), - ], + children: [Text(message), const BackToLoginButton()], ), ), ); diff --git a/lib/features/onboarding/view/onboarding_single_page.dart b/lib/features/onboarding/view/onboarding_single_page.dart index b9a7eb5..c0e701a 100644 --- a/lib/features/onboarding/view/onboarding_single_page.dart +++ b/lib/features/onboarding/view/onboarding_single_page.dart @@ -9,9 +9,7 @@ import 'package:vaani/shared/utils.dart'; import 'package:vaani/shared/widgets/add_new_server.dart'; class OnboardingSinglePage extends HookConsumerWidget { - const OnboardingSinglePage({ - super.key, - }); + const OnboardingSinglePage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -23,8 +21,9 @@ class OnboardingSinglePage extends HookConsumerWidget { child: ConstrainedBox( constraints: BoxConstraints( maxWidth: 600, - minWidth: - constraints.maxWidth < 600 ? constraints.maxWidth : 0, + minWidth: constraints.maxWidth < 600 + ? constraints.maxWidth + : 0, ), child: const Padding( padding: EdgeInsets.symmetric(vertical: 20.0), @@ -39,10 +38,7 @@ class OnboardingSinglePage extends HookConsumerWidget { } } -Widget fadeSlideTransitionBuilder( - Widget child, - Animation animation, -) { +Widget fadeSlideTransitionBuilder(Widget child, Animation animation) { return FadeTransition( opacity: animation, child: SlideTransition( @@ -56,9 +52,7 @@ Widget fadeSlideTransitionBuilder( } class OnboardingBody extends HookConsumerWidget { - const OnboardingBody({ - super.key, - }); + const OnboardingBody({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -81,9 +75,7 @@ class OnboardingBody extends HookConsumerWidget { style: Theme.of(context).textTheme.headlineSmall, ), ), - const SizedBox.square( - dimension: 16.0, - ), + const SizedBox.square(dimension: 16.0), Padding( padding: const EdgeInsets.all(8.0), child: AnimatedSwitcher( @@ -112,21 +104,17 @@ class OnboardingBody extends HookConsumerWidget { }, ), ), - const SizedBox.square( - dimension: 16.0, - ), + const SizedBox.square(dimension: 16.0), AnimatedSwitcher( duration: 500.ms, transitionBuilder: fadeSlideTransitionBuilder, child: canUserLogin.value - ? UserLoginWidget( - server: audiobookshelfUri, - ) + ? UserLoginWidget(server: audiobookshelfUri) // ).animate().fade(duration: 600.ms).slideY(begin: 0.3, end: 0) : const RedirectToABS().animate().fadeIn().slideY( - curve: Curves.easeInOut, - duration: 500.ms, - ), + curve: Curves.easeInOut, + duration: 500.ms, + ), ), ], ); @@ -134,9 +122,7 @@ class OnboardingBody extends HookConsumerWidget { } class RedirectToABS extends StatelessWidget { - const RedirectToABS({ - super.key, - }); + const RedirectToABS({super.key}); @override Widget build(BuildContext context) { @@ -152,18 +138,14 @@ class RedirectToABS extends StatelessWidget { isSemanticButton: false, style: ButtonStyle( elevation: WidgetStateProperty.all(0), - padding: WidgetStateProperty.all( - const EdgeInsets.all(0), - ), + padding: WidgetStateProperty.all(const EdgeInsets.all(0)), ), onPressed: () async { // open the github page // ignore: avoid_print print('Opening the github page'); await handleLaunchUrl( - Uri.parse( - 'https://www.audiobookshelf.org', - ), + Uri.parse('https://www.audiobookshelf.org'), ); }, child: const Text('Click here'), diff --git a/lib/features/onboarding/view/user_login.dart b/lib/features/onboarding/view/user_login.dart index 8aeff14..7428953 100644 --- a/lib/features/onboarding/view/user_login.dart +++ b/lib/features/onboarding/view/user_login.dart @@ -22,11 +22,7 @@ import 'package:vaani/settings/api_settings_provider.dart' import 'package:vaani/settings/models/models.dart' as model; class UserLoginWidget extends HookConsumerWidget { - const UserLoginWidget({ - super.key, - required this.server, - this.onSuccess, - }); + const UserLoginWidget({super.key, required this.server, this.onSuccess}); final Uri server; final Function(model.AuthenticatedUser)? onSuccess; @@ -34,8 +30,9 @@ class UserLoginWidget extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final serverStatusError = useMemoized(() => ErrorResponseHandler(), []); - final serverStatus = - ref.watch(serverStatusProvider(server, serverStatusError.storeError)); + final serverStatus = ref.watch( + serverStatusProvider(server, serverStatusError.storeError), + ); return serverStatus.when( data: (value) { @@ -55,9 +52,7 @@ class UserLoginWidget extends HookConsumerWidget { ); }, loading: () { - return const Center( - child: CircularProgressIndicator(), - ); + return const Center(child: CircularProgressIndicator()); }, error: (error, _) { return Center( @@ -68,10 +63,7 @@ class UserLoginWidget extends HookConsumerWidget { ElevatedButton( onPressed: () { ref.invalidate( - serverStatusProvider( - server, - serverStatusError.storeError, - ), + serverStatusProvider(server, serverStatusError.storeError), ); }, child: const Text('Try again'), @@ -84,11 +76,7 @@ class UserLoginWidget extends HookConsumerWidget { } } -enum AuthMethodChoice { - local, - openid, - authToken, -} +enum AuthMethodChoice { local, openid, authToken } class UserLoginMultipleAuth extends HookConsumerWidget { const UserLoginMultipleAuth({ @@ -117,21 +105,17 @@ class UserLoginMultipleAuth extends HookConsumerWidget { ); model.AudiobookShelfServer addServer() { - var newServer = model.AudiobookShelfServer( - serverUrl: server, - ); + var newServer = model.AudiobookShelfServer(serverUrl: server); try { // add the server to the list of servers - ref.read(audiobookShelfServerProvider.notifier).addServer( - newServer, - ); + ref.read(audiobookShelfServerProvider.notifier).addServer(newServer); } on ServerAlreadyExistsException catch (e) { newServer = e.server; } finally { - ref.read(apiSettingsProvider.notifier).updateState( - ref.read(apiSettingsProvider).copyWith( - activeServer: newServer, - ), + ref + .read(apiSettingsProvider.notifier) + .updateState( + ref.read(apiSettingsProvider).copyWith(activeServer: newServer), ); } return newServer; @@ -150,42 +134,49 @@ class UserLoginMultipleAuth extends HookConsumerWidget { runAlignment: WrapAlignment.center, runSpacing: 10, alignment: WrapAlignment.center, - children: [ - // a small label to show the user what to do - if (localAvailable) - ChoiceChip( - label: const Text('Local'), - selected: methodChoice.value == AuthMethodChoice.local, - onSelected: (selected) { - if (selected) { - methodChoice.value = AuthMethodChoice.local; - } - }, - ), - if (openIDAvailable) - ChoiceChip( - label: const Text('OpenID'), - selected: methodChoice.value == AuthMethodChoice.openid, - onSelected: (selected) { - if (selected) { - methodChoice.value = AuthMethodChoice.openid; - } - }, - ), - ChoiceChip( - label: const Text('Token'), - selected: - methodChoice.value == AuthMethodChoice.authToken, - onSelected: (selected) { - if (selected) { - methodChoice.value = AuthMethodChoice.authToken; - } - }, - ), - ].animate(interval: 100.ms).fadeIn( - duration: 150.ms, - curve: Curves.easeIn, - ), + children: + [ + // a small label to show the user what to do + if (localAvailable) + ChoiceChip( + label: const Text('Local'), + selected: + methodChoice.value == + AuthMethodChoice.local, + onSelected: (selected) { + if (selected) { + methodChoice.value = AuthMethodChoice.local; + } + }, + ), + if (openIDAvailable) + ChoiceChip( + label: const Text('OpenID'), + selected: + methodChoice.value == + AuthMethodChoice.openid, + onSelected: (selected) { + if (selected) { + methodChoice.value = + AuthMethodChoice.openid; + } + }, + ), + ChoiceChip( + label: const Text('Token'), + selected: + methodChoice.value == + AuthMethodChoice.authToken, + onSelected: (selected) { + if (selected) { + methodChoice.value = + AuthMethodChoice.authToken; + } + }, + ), + ] + .animate(interval: 100.ms) + .fadeIn(duration: 150.ms, curve: Curves.easeIn), ), ), Padding( @@ -195,21 +186,21 @@ class UserLoginMultipleAuth extends HookConsumerWidget { transitionBuilder: fadeSlideTransitionBuilder, child: switch (methodChoice.value) { AuthMethodChoice.authToken => UserLoginWithToken( - server: server, - addServer: addServer, - onSuccess: onSuccess, - ), + server: server, + addServer: addServer, + onSuccess: onSuccess, + ), AuthMethodChoice.local => UserLoginWithPassword( - server: server, - addServer: addServer, - onSuccess: onSuccess, - ), + server: server, + addServer: addServer, + onSuccess: onSuccess, + ), AuthMethodChoice.openid => UserLoginWithOpenID( - server: server, - addServer: addServer, - openIDButtonText: openIDButtonText, - onSuccess: onSuccess, - ), + server: server, + addServer: addServer, + openIDButtonText: openIDButtonText, + onSuccess: onSuccess, + ), }, ), ), diff --git a/lib/features/onboarding/view/user_login_with_open_id.dart b/lib/features/onboarding/view/user_login_with_open_id.dart index b3a1d9e..339b6c5 100644 --- a/lib/features/onboarding/view/user_login_with_open_id.dart +++ b/lib/features/onboarding/view/user_login_with_open_id.dart @@ -54,9 +54,9 @@ class UserLoginWithOpenID extends HookConsumerWidget { if (openIDLoginEndpoint == null) { if (responseErrorHandler.response.statusCode == 400 && - responseErrorHandler.response.body - .toLowerCase() - .contains(RegExp(r'invalid.*redirect.*uri'))) { + responseErrorHandler.response.body.toLowerCase().contains( + RegExp(r'invalid.*redirect.*uri'), + )) { // show error handleServerError( context, @@ -97,16 +97,16 @@ class UserLoginWithOpenID extends HookConsumerWidget { ); // add the flow to the provider - ref.read(oauthFlowsProvider.notifier).addFlow( + ref + .read(oauthFlowsProvider.notifier) + .addFlow( oauthState, verifier: verifier, serverUri: server, cookie: Cookie.fromSetCookieValue(authCookie!), ); - await handleLaunchUrl( - openIDLoginEndpoint, - ); + await handleLaunchUrl(openIDLoginEndpoint); } return Column( diff --git a/lib/features/onboarding/view/user_login_with_password.dart b/lib/features/onboarding/view/user_login_with_password.dart index 210da77..20d2613 100644 --- a/lib/features/onboarding/view/user_login_with_password.dart +++ b/lib/features/onboarding/view/user_login_with_password.dart @@ -39,17 +39,14 @@ class UserLoginWithPassword extends HookConsumerWidget { final api = ref.watch(audiobookshelfApiProvider(server)); // forward animation when the password visibility changes - useEffect( - () { - if (isPasswordVisible.value) { - isPasswordVisibleAnimationController.forward(); - } else { - isPasswordVisibleAnimationController.reverse(); - } - return null; - }, - [isPasswordVisible.value], - ); + useEffect(() { + if (isPasswordVisible.value) { + isPasswordVisibleAnimationController.forward(); + } else { + isPasswordVisibleAnimationController.reverse(); + } + return null; + }, [isPasswordVisible.value]); /// Login to the server and save the user Future loginAndSave() async { @@ -109,10 +106,9 @@ class UserLoginWithPassword extends HookConsumerWidget { decoration: InputDecoration( labelText: 'Username', labelStyle: TextStyle( - color: Theme.of(context) - .colorScheme - .onSurface - .withValues(alpha: 0.8), + color: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.8), ), border: const OutlineInputBorder(), ), @@ -129,18 +125,16 @@ class UserLoginWithPassword extends HookConsumerWidget { decoration: InputDecoration( labelText: 'Password', labelStyle: TextStyle( - color: Theme.of(context) - .colorScheme - .onSurface - .withValues(alpha: 0.8), + color: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.8), ), border: const OutlineInputBorder(), suffixIcon: ColorFiltered( colorFilter: ColorFilter.mode( - Theme.of(context) - .colorScheme - .primary - .withValues(alpha: 0.8), + Theme.of( + context, + ).colorScheme.primary.withValues(alpha: 0.8), BlendMode.srcIn, ), child: InkWell( @@ -157,9 +151,7 @@ class UserLoginWithPassword extends HookConsumerWidget { ), ), ), - suffixIconConstraints: const BoxConstraints( - maxHeight: 45, - ), + suffixIconConstraints: const BoxConstraints(maxHeight: 45), ), ), const SizedBox(height: 30), @@ -197,10 +189,12 @@ Future handleServerError( context: context, builder: (context) => AlertDialog( title: const Text('Error'), - content: SelectableText('$title\n' - 'Got response: ${responseErrorHandler.response.body} (${responseErrorHandler.response.statusCode})\n' - 'Stacktrace: $e\n\n' - '$body\n\n'), + content: SelectableText( + '$title\n' + 'Got response: ${responseErrorHandler.response.body} (${responseErrorHandler.response.statusCode})\n' + 'Stacktrace: $e\n\n' + '$body\n\n', + ), actions: [ if (outLink != null) TextButton( @@ -214,8 +208,8 @@ Future handleServerError( // open an issue on the github page handleLaunchUrl( AppMetadata.githubRepo - // append the issue url - .replace( + // append the issue url + .replace( path: '${AppMetadata.githubRepo.path}/issues/new', ), ); diff --git a/lib/features/onboarding/view/user_login_with_token.dart b/lib/features/onboarding/view/user_login_with_token.dart index 7d2fcfb..fb5a1fa 100644 --- a/lib/features/onboarding/view/user_login_with_token.dart +++ b/lib/features/onboarding/view/user_login_with_token.dart @@ -89,10 +89,9 @@ class UserLoginWithToken extends HookConsumerWidget { decoration: InputDecoration( labelText: 'API Token', labelStyle: TextStyle( - color: Theme.of(context) - .colorScheme - .onSurface - .withValues(alpha: 0.8), + color: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.8), ), border: const OutlineInputBorder(), ), @@ -107,10 +106,7 @@ class UserLoginWithToken extends HookConsumerWidget { }, ), const SizedBox(height: 10), - ElevatedButton( - onPressed: loginAndSave, - child: const Text('Login'), - ), + ElevatedButton(onPressed: loginAndSave, child: const Text('Login')), ], ), ); diff --git a/lib/features/playback_reporting/core/playback_reporter.dart b/lib/features/playback_reporting/core/playback_reporter.dart index b2be336..e140bf6 100644 --- a/lib/features/playback_reporting/core/playback_reporter.dart +++ b/lib/features/playback_reporting/core/playback_reporter.dart @@ -126,9 +126,7 @@ class PlaybackReporter { } Future tryReportPlayback(_) async { - _logger.fine( - 'callback called when elapsed ${_stopwatch.elapsed}', - ); + _logger.fine('callback called when elapsed ${_stopwatch.elapsed}'); if (player.book != null && player.positionInBook >= player.book!.duration - markCompleteWhenTimeLeft) { diff --git a/lib/features/playback_reporting/providers/playback_reporter_provider.dart b/lib/features/playback_reporting/providers/playback_reporter_provider.dart index a7ca1d5..1bee521 100644 --- a/lib/features/playback_reporting/providers/playback_reporter_provider.dart +++ b/lib/features/playback_reporting/providers/playback_reporter_provider.dart @@ -20,8 +20,9 @@ class PlaybackReporter extends _$PlaybackReporter { final deviceName = await ref.watch(deviceNameProvider.future); final deviceModel = await ref.watch(deviceModelProvider.future); final deviceSdkVersion = await ref.watch(deviceSdkVersionProvider.future); - final deviceManufacturer = - await ref.watch(deviceManufacturerProvider.future); + final deviceManufacturer = await ref.watch( + deviceManufacturerProvider.future, + ); final reporter = core.PlaybackReporter( player, diff --git a/lib/features/player/core/audiobook_player.dart b/lib/features/player/core/audiobook_player.dart index 87247fe..c3d7b46 100644 --- a/lib/features/player/core/audiobook_player.dart +++ b/lib/features/player/core/audiobook_player.dart @@ -23,7 +23,9 @@ Duration sumOfTracks(BookExpanded book, int? index) { _logger.warning('Index is null or less than 0, returning 0'); return Duration.zero; } - final total = book.tracks.sublist(0, index).fold( + final total = book.tracks + .sublist(0, index) + .fold( Duration.zero, (previousValue, element) => previousValue + element.duration, ); @@ -34,13 +36,10 @@ Duration sumOfTracks(BookExpanded book, int? index) { /// returns the [AudioTrack] to play based on the [position] in the [book] AudioTrack getTrackToPlay(BookExpanded book, Duration position) { _logger.fine('Getting track to play for position: $position'); - final track = book.tracks.firstWhere( - (element) { - return element.startOffset <= position && - (element.startOffset + element.duration) >= position; - }, - orElse: () => book.tracks.last, - ); + final track = book.tracks.firstWhere((element) { + return element.startOffset <= position && + (element.startOffset + element.duration) >= position; + }, orElse: () => book.tracks.last); _logger.fine('Track to play for position: $position is $track'); return track; } @@ -126,8 +125,12 @@ class AudiobookPlayer extends AudioPlayer { ConcatenatingAudioSource( useLazyPreparation: true, children: book.tracks.map((track) { - final retrievedUri = - _getUri(track, downloadedUris, baseUrl: baseUrl, token: token); + final retrievedUri = _getUri( + track, + downloadedUris, + baseUrl: baseUrl, + token: token, + ); _logger.fine( 'Setting source for track: ${track.title}, URI: ${retrievedUri.obfuscate()}', ); @@ -141,7 +144,8 @@ class AudiobookPlayer extends AudioPlayer { .formatNotificationTitle(book), album: appSettings.notificationSettings.secondaryTitle .formatNotificationTitle(book), - artUri: artworkUri ?? + artUri: + artworkUri ?? Uri.parse( '$baseUrl/api/items/${book.libraryItemId}/cover?token=$token&width=800', ), @@ -255,12 +259,9 @@ class AudiobookPlayer extends AudioPlayer { if (_book!.chapters.isEmpty) { return null; } - return _book!.chapters.firstWhere( - (element) { - return element.start <= positionInBook && element.end >= positionInBook; - }, - orElse: () => _book!.chapters.first, - ); + return _book!.chapters.firstWhere((element) { + return element.start <= positionInBook && element.end >= positionInBook; + }, orElse: () => _book!.chapters.first); } } @@ -271,11 +272,9 @@ Uri _getUri( required String token, }) { // check if the track is in the downloadedUris - final uri = downloadedUris?.firstWhereOrNull( - (element) { - return element.pathSegments.last == track.metadata?.filename; - }, - ); + final uri = downloadedUris?.firstWhereOrNull((element) { + return element.pathSegments.last == track.metadata?.filename; + }); return uri ?? Uri.parse('${baseUrl.toString()}${track.contentUrl}?token=$token'); @@ -283,17 +282,14 @@ Uri _getUri( extension FormatNotificationTitle on String { String formatNotificationTitle(BookExpanded book) { - return replaceAllMapped( - RegExp(r'\$(\w+)'), - (match) { - final type = match.group(1); - return NotificationTitleType.values - .firstWhere((element) => element.name == type) - .extractFrom(book) ?? - match.group(0) ?? - ''; - }, - ); + return replaceAllMapped(RegExp(r'\$(\w+)'), (match) { + final type = match.group(1); + return NotificationTitleType.values + .firstWhere((element) => element.name == type) + .extractFrom(book) ?? + match.group(0) ?? + ''; + }); } } diff --git a/lib/features/player/core/init.dart b/lib/features/player/core/init.dart index abcf013..a95f3c7 100644 --- a/lib/features/player/core/init.dart +++ b/lib/features/player/core/init.dart @@ -30,23 +30,28 @@ Future configurePlayer() async { androidShowNotificationBadge: false, notificationConfigBuilder: (state) { final controls = [ - if (appSettings.notificationSettings.mediaControls - .contains(NotificationMediaControl.skipToPreviousChapter) && + if (appSettings.notificationSettings.mediaControls.contains( + NotificationMediaControl.skipToPreviousChapter, + ) && state.hasPrevious) MediaControl.skipToPrevious, - if (appSettings.notificationSettings.mediaControls - .contains(NotificationMediaControl.rewind)) + if (appSettings.notificationSettings.mediaControls.contains( + NotificationMediaControl.rewind, + )) MediaControl.rewind, if (state.playing) MediaControl.pause else MediaControl.play, - if (appSettings.notificationSettings.mediaControls - .contains(NotificationMediaControl.fastForward)) + if (appSettings.notificationSettings.mediaControls.contains( + NotificationMediaControl.fastForward, + )) MediaControl.fastForward, - if (appSettings.notificationSettings.mediaControls - .contains(NotificationMediaControl.skipToNextChapter) && + if (appSettings.notificationSettings.mediaControls.contains( + NotificationMediaControl.skipToNextChapter, + ) && state.hasNext) MediaControl.skipToNext, - if (appSettings.notificationSettings.mediaControls - .contains(NotificationMediaControl.stop)) + if (appSettings.notificationSettings.mediaControls.contains( + NotificationMediaControl.stop, + )) MediaControl.stop, ]; return NotificationConfig( diff --git a/lib/features/player/playlist.dart b/lib/features/player/playlist.dart index 61c2326..c8baedd 100644 --- a/lib/features/player/playlist.dart +++ b/lib/features/player/playlist.dart @@ -62,8 +62,8 @@ class AudiobookPlaylist { this.books = const [], currentIndex = 0, subCurrentIndex = 0, - }) : _currentIndex = currentIndex, - _subCurrentIndex = subCurrentIndex; + }) : _currentIndex = currentIndex, + _subCurrentIndex = subCurrentIndex; // most important method, gets the audio file to play // this is needed as a library item is a list of audio files diff --git a/lib/features/player/providers/audiobook_player.dart b/lib/features/player/providers/audiobook_player.dart index 91b6483..29fede9 100644 --- a/lib/features/player/providers/audiobook_player.dart +++ b/lib/features/player/providers/audiobook_player.dart @@ -16,10 +16,7 @@ class SimpleAudiobookPlayer extends _$SimpleAudiobookPlayer { @override core.AudiobookPlayer build() { final api = ref.watch(authenticatedApiProvider); - final player = core.AudiobookPlayer( - api.token!, - api.baseUrl, - ); + final player = core.AudiobookPlayer(api.token!, api.baseUrl); ref.onDispose(player.dispose); _logger.finer('created simple player'); diff --git a/lib/features/player/providers/player_form.dart b/lib/features/player/providers/player_form.dart index 73d6bdc..9652486 100644 --- a/lib/features/player/providers/player_form.dart +++ b/lib/features/player/providers/player_form.dart @@ -26,11 +26,10 @@ extension on Ref { } @Riverpod(keepAlive: true) -Raw> playerExpandProgressNotifier( - Ref ref, -) { - final ValueNotifier playerExpandProgress = - ValueNotifier(playerMinHeight); +Raw> playerExpandProgressNotifier(Ref ref) { + final ValueNotifier playerExpandProgress = ValueNotifier( + playerMinHeight, + ); return ref.disposeAndListenChangeNotifier(playerExpandProgress); } @@ -46,9 +45,7 @@ Raw> playerExpandProgressNotifier( // a provider that will listen to the playerExpandProgressNotifier and return the percentage of the player expanded @Riverpod(keepAlive: true) -double playerHeight( - Ref ref, -) { +double playerHeight(Ref ref) { final playerExpandProgress = ref.watch(playerExpandProgressProvider); // on change of the playerExpandProgress invalidate @@ -63,9 +60,7 @@ double playerHeight( final audioBookMiniplayerController = MiniplayerController(); @Riverpod(keepAlive: true) -bool isPlayerActive( - Ref ref, -) { +bool isPlayerActive(Ref ref) { try { final player = ref.watch(audiobookPlayerProvider); if (player.book != null) { diff --git a/lib/features/player/view/audiobook_player.dart b/lib/features/player/view/audiobook_player.dart index 2909a9b..e80202a 100644 --- a/lib/features/player/view/audiobook_player.dart +++ b/lib/features/player/view/audiobook_player.dart @@ -31,19 +31,15 @@ class AudiobookPlayer extends HookConsumerWidget { if (currentBook == null) { return const SizedBox.shrink(); } - final itemBeingPlayed = - ref.watch(libraryItemProvider(currentBook.libraryItemId)); + final itemBeingPlayed = ref.watch( + libraryItemProvider(currentBook.libraryItemId), + ); final player = ref.watch(audiobookPlayerProvider); final imageOfItemBeingPlayed = itemBeingPlayed.value != null - ? ref.watch( - coverImageProvider(itemBeingPlayed.value!.id), - ) + ? ref.watch(coverImageProvider(itemBeingPlayed.value!.id)) : null; final imgWidget = imageOfItemBeingPlayed?.value != null - ? Image.memory( - imageOfItemBeingPlayed!.value!, - fit: BoxFit.cover, - ) + ? Image.memory(imageOfItemBeingPlayed!.value!, fit: BoxFit.cover) : const BookCoverSkeleton(); final playPauseController = useAnimationController( @@ -65,7 +61,8 @@ class AudiobookPlayer extends HookConsumerWidget { themeOfLibraryItemProvider( itemBeingPlayed.value?.id, brightness: Theme.of(context).brightness, - highContrast: appSettings.themeSettings.highContrast || + highContrast: + appSettings.themeSettings.highContrast || MediaQuery.of(context).highContrast, ), ); @@ -88,8 +85,9 @@ class AudiobookPlayer extends HookConsumerWidget { onDragDown: (percentage) async { // preferred volume // set volume to 0 when dragging down - await player - .setVolume(preferredVolume * (1 - percentage.clamp(0, .75))); + await player.setVolume( + preferredVolume * (1 - percentage.clamp(0, .75)), + ); }, minHeight: playerMinHeight, // subtract the height of notches and other system UI @@ -109,17 +107,14 @@ class AudiobookPlayer extends HookConsumerWidget { // also at this point the image should be at its max size and in the center of the player final miniplayerPercentageDeclaration = (maxImgSize - playerMinHeight) / - (playerMaxHeight - playerMinHeight); + (playerMaxHeight - playerMinHeight); final bool isFormMiniplayer = percentage < miniplayerPercentageDeclaration; if (!isFormMiniplayer) { // this calculation needs a refactor var percentageExpandedPlayer = percentage - .inverseLerp( - miniplayerPercentageDeclaration, - 1, - ) + .inverseLerp(miniplayerPercentageDeclaration, 1) .clamp(0.0, 1.0); return PlayerWhenExpanded( @@ -164,37 +159,33 @@ class AudiobookPlayerPlayPauseButton extends HookConsumerWidget { return switch (player.processingState) { ProcessingState.loading || ProcessingState.buffering => const Padding( - padding: EdgeInsets.all(8.0), - child: CircularProgressIndicator(), - ), + padding: EdgeInsets.all(8.0), + child: CircularProgressIndicator(), + ), ProcessingState.completed => IconButton( - onPressed: () async { - await player.seek(const Duration(seconds: 0)); - await player.play(); - }, - icon: const Icon( - Icons.replay, - ), - ), + onPressed: () async { + await player.seek(const Duration(seconds: 0)); + await player.play(); + }, + icon: const Icon(Icons.replay), + ), ProcessingState.ready => IconButton( - onPressed: () async { - await player.togglePlayPause(); - }, - iconSize: iconSize, - icon: AnimatedIcon( - icon: AnimatedIcons.play_pause, - progress: playPauseController, - ), + onPressed: () async { + await player.togglePlayPause(); + }, + iconSize: iconSize, + icon: AnimatedIcon( + icon: AnimatedIcons.play_pause, + progress: playPauseController, ), + ), ProcessingState.idle => const SizedBox.shrink(), }; } } class AudiobookChapterProgressBar extends HookConsumerWidget { - const AudiobookChapterProgressBar({ - super.key, - }); + const AudiobookChapterProgressBar({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { diff --git a/lib/features/player/view/player_when_expanded.dart b/lib/features/player/view/player_when_expanded.dart index 0deda52..28e6993 100644 --- a/lib/features/player/view/player_when_expanded.dart +++ b/lib/features/player/view/player_when_expanded.dart @@ -38,10 +38,7 @@ class PlayerWhenExpanded extends HookConsumerWidget { const lateStart = 0.4; const earlyEnd = 1; final earlyPercentage = percentageExpandedPlayer - .inverseLerp( - lateStart, - earlyEnd, - ) + .inverseLerp(lateStart, earlyEnd) .clamp(0.0, 1.0); final currentChapter = ref.watch(currentPlayingChapterProvider); final currentBookMetadata = ref.watch(currentBookMetadataProvider); @@ -49,15 +46,11 @@ class PlayerWhenExpanded extends HookConsumerWidget { return Column( children: [ // sized box for system status bar; not needed as not full screen - SizedBox( - height: MediaQuery.of(context).padding.top * earlyPercentage, - ), + SizedBox(height: MediaQuery.of(context).padding.top * earlyPercentage), // a row with a down arrow to minimize the player, a pill shaped container to drag the player, and a cast button ConstrainedBox( - constraints: BoxConstraints( - maxHeight: 100 * earlyPercentage, - ), + constraints: BoxConstraints(maxHeight: 100 * earlyPercentage), child: Opacity( opacity: earlyPercentage, child: Padding( @@ -104,10 +97,9 @@ class PlayerWhenExpanded extends HookConsumerWidget { decoration: BoxDecoration( boxShadow: [ BoxShadow( - color: Theme.of(context) - .colorScheme - .primary - .withValues(alpha: 0.1), + color: Theme.of( + context, + ).colorScheme.primary.withValues(alpha: 0.1), blurRadius: 32 * earlyPercentage, spreadRadius: 8 * earlyPercentage, // offset: Offset(0, 16 * earlyPercentage), @@ -170,11 +162,10 @@ class PlayerWhenExpanded extends HookConsumerWidget { currentBookMetadata?.authorName ?? '', ].join(' - '), style: Theme.of(context).textTheme.titleMedium?.copyWith( - color: Theme.of(context) - .colorScheme - .onSurface - .withValues(alpha: 0.7), - ), + color: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.7), + ), maxLines: 1, overflow: TextOverflow.ellipsis, ), diff --git a/lib/features/player/view/player_when_minimized.dart b/lib/features/player/view/player_when_minimized.dart index 1a5774b..9729fe2 100644 --- a/lib/features/player/view/player_when_minimized.dart +++ b/lib/features/player/view/player_when_minimized.dart @@ -32,8 +32,10 @@ class PlayerWhenMinimized extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final player = ref.watch(audiobookPlayerProvider); final vanishingPercentage = 1 - percentageMiniplayer; - final progress = - useStream(player.slowPositionStream, initialData: Duration.zero); + final progress = useStream( + player.slowPositionStream, + initialData: Duration.zero, + ); final bookMetaExpanded = ref.watch(currentBookMetadataProvider); @@ -61,9 +63,7 @@ class PlayerWhenMinimized extends HookConsumerWidget { ); }, child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: maxImgSize, - ), + constraints: BoxConstraints(maxWidth: maxImgSize), child: imgWidget, ), ), @@ -80,7 +80,8 @@ class PlayerWhenMinimized extends HookConsumerWidget { // AutoScrollText( Text( bookMetaExpanded?.title ?? '', - maxLines: 1, overflow: TextOverflow.ellipsis, + maxLines: 1, + overflow: TextOverflow.ellipsis, // velocity: // const Velocity(pixelsPerSecond: Offset(16, 0)), style: Theme.of(context).textTheme.bodyLarge, @@ -90,11 +91,10 @@ class PlayerWhenMinimized extends HookConsumerWidget { maxLines: 1, overflow: TextOverflow.ellipsis, style: Theme.of(context).textTheme.bodyMedium!.copyWith( - color: Theme.of(context) - .colorScheme - .onSurface - .withValues(alpha: 0.7), - ), + color: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.7), + ), ), ], ), @@ -135,7 +135,8 @@ class PlayerWhenMinimized extends HookConsumerWidget { SizedBox( height: barHeight, child: LinearProgressIndicator( - value: (progress.data ?? Duration.zero).inSeconds / + value: + (progress.data ?? Duration.zero).inSeconds / player.book!.duration.inSeconds, color: Theme.of(context).colorScheme.onPrimaryContainer, backgroundColor: Theme.of(context).colorScheme.primaryContainer, diff --git a/lib/features/player/view/widgets/audiobook_player_seek_button.dart b/lib/features/player/view/widgets/audiobook_player_seek_button.dart index ac1ec20..d1d1edc 100644 --- a/lib/features/player/view/widgets/audiobook_player_seek_button.dart +++ b/lib/features/player/view/widgets/audiobook_player_seek_button.dart @@ -4,10 +4,7 @@ import 'package:vaani/constants/sizes.dart'; import 'package:vaani/features/player/providers/audiobook_player.dart'; class AudiobookPlayerSeekButton extends HookConsumerWidget { - const AudiobookPlayerSeekButton({ - super.key, - required this.isForward, - }); + const AudiobookPlayerSeekButton({super.key, required this.isForward}); /// if true, the button seeks forward, else it seeks backwards final bool isForward; diff --git a/lib/features/player/view/widgets/audiobook_player_seek_chapter_button.dart b/lib/features/player/view/widgets/audiobook_player_seek_chapter_button.dart index ad47e8b..16127ad 100644 --- a/lib/features/player/view/widgets/audiobook_player_seek_chapter_button.dart +++ b/lib/features/player/view/widgets/audiobook_player_seek_chapter_button.dart @@ -5,10 +5,7 @@ import 'package:vaani/constants/sizes.dart'; import 'package:vaani/features/player/providers/audiobook_player.dart'; class AudiobookPlayerSeekChapterButton extends HookConsumerWidget { - const AudiobookPlayerSeekChapterButton({ - super.key, - required this.isForward, - }); + const AudiobookPlayerSeekChapterButton({super.key, required this.isForward}); /// if true, the button seeks forward, else it seeks backwards final bool isForward; @@ -27,9 +24,7 @@ class AudiobookPlayerSeekChapterButton extends HookConsumerWidget { void seekForward() { final index = player.book!.chapters.indexOf(player.currentChapter!); if (index < player.book!.chapters.length - 1) { - player.seek( - player.book!.chapters[index + 1].start + offset, - ); + player.seek(player.book!.chapters[index + 1].start + offset); } else { player.seek(player.currentChapter!.end); } @@ -37,8 +32,9 @@ class AudiobookPlayerSeekChapterButton extends HookConsumerWidget { /// seek backward to the previous chapter or the start of the current chapter void seekBackward() { - final currentPlayingChapterIndex = - player.book!.chapters.indexOf(player.currentChapter!); + final currentPlayingChapterIndex = player.book!.chapters.indexOf( + player.currentChapter!, + ); final chapterPosition = player.positionInBook - player.currentChapter!.start; BookChapter chapterToSeekTo; @@ -49,9 +45,7 @@ class AudiobookPlayerSeekChapterButton extends HookConsumerWidget { } else { chapterToSeekTo = player.currentChapter!; } - player.seek( - chapterToSeekTo.start + offset, - ); + player.seek(chapterToSeekTo.start + offset); } return IconButton( diff --git a/lib/features/player/view/widgets/chapter_selection_button.dart b/lib/features/player/view/widgets/chapter_selection_button.dart index 04cbd0e..ea2154e 100644 --- a/lib/features/player/view/widgets/chapter_selection_button.dart +++ b/lib/features/player/view/widgets/chapter_selection_button.dart @@ -15,9 +15,7 @@ import 'package:vaani/shared/extensions/duration_format.dart' import 'package:vaani/shared/hooks.dart' show useTimer; class ChapterSelectionButton extends HookConsumerWidget { - const ChapterSelectionButton({ - super.key, - }); + const ChapterSelectionButton({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -49,9 +47,7 @@ class ChapterSelectionButton extends HookConsumerWidget { } class ChapterSelectionModal extends HookConsumerWidget { - const ChapterSelectionModal({ - super.key, - }); + const ChapterSelectionModal({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -87,41 +83,40 @@ class ChapterSelectionModal extends HookConsumerWidget { child: currentBook?.chapters == null ? const Text('No chapters found') : Column( - children: currentBook!.chapters.map( - (chapter) { - final isCurrent = currentChapterIndex == chapter.id; - final isPlayed = currentChapterIndex != null && - chapter.id < currentChapterIndex; - return ListTile( - autofocus: isCurrent, - iconColor: isPlayed && !isCurrent - ? theme.disabledColor + children: currentBook!.chapters.map((chapter) { + final isCurrent = currentChapterIndex == chapter.id; + final isPlayed = + currentChapterIndex != null && + chapter.id < currentChapterIndex; + return ListTile( + autofocus: isCurrent, + iconColor: isPlayed && !isCurrent + ? theme.disabledColor + : null, + title: Text( + chapter.title, + style: isPlayed && !isCurrent + ? TextStyle(color: theme.disabledColor) : null, - title: Text( - chapter.title, - style: isPlayed && !isCurrent - ? TextStyle(color: theme.disabledColor) - : null, - ), - subtitle: Text( - '(${chapter.duration.smartBinaryFormat})', - style: isPlayed && !isCurrent - ? TextStyle(color: theme.disabledColor) - : null, - ), - trailing: isCurrent - ? const PlayingIndicatorIcon() - : const Icon(Icons.play_arrow), - selected: isCurrent, - key: isCurrent ? chapterKey : null, - onTap: () { - Navigator.of(context).pop(); - notifier.seek(chapter.start + 90.ms); - notifier.play(); - }, - ); - }, - ).toList(), + ), + subtitle: Text( + '(${chapter.duration.smartBinaryFormat})', + style: isPlayed && !isCurrent + ? TextStyle(color: theme.disabledColor) + : null, + ), + trailing: isCurrent + ? const PlayingIndicatorIcon() + : const Icon(Icons.play_arrow), + selected: isCurrent, + key: isCurrent ? chapterKey : null, + onTap: () { + Navigator.of(context).pop(); + notifier.seek(chapter.start + 90.ms); + notifier.play(); + }, + ); + }).toList(), ), ), ), diff --git a/lib/features/player/view/widgets/player_speed_adjust_button.dart b/lib/features/player/view/widgets/player_speed_adjust_button.dart index 36b7cd7..021f999 100644 --- a/lib/features/player/view/widgets/player_speed_adjust_button.dart +++ b/lib/features/player/view/widgets/player_speed_adjust_button.dart @@ -10,9 +10,7 @@ import 'package:vaani/settings/app_settings_provider.dart'; final _logger = Logger('PlayerSpeedAdjustButton'); class PlayerSpeedAdjustButton extends HookConsumerWidget { - const PlayerSpeedAdjustButton({ - super.key, - }); + const PlayerSpeedAdjustButton({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -35,21 +33,19 @@ class PlayerSpeedAdjustButton extends HookConsumerWidget { notifier.setSpeed(speed); if (appSettings.playerSettings.configurePlayerForEveryBook) { ref - .read( - bookSettingsProvider(bookId).notifier, - ) + .read(bookSettingsProvider(bookId).notifier) .update( - bookSettings.copyWith - .playerSettings(preferredDefaultSpeed: speed), + bookSettings.copyWith.playerSettings( + preferredDefaultSpeed: speed, + ), ); } else { ref - .read( - appSettingsProvider.notifier, - ) + .read(appSettingsProvider.notifier) .update( - appSettings.copyWith - .playerSettings(preferredDefaultSpeed: speed), + appSettings.copyWith.playerSettings( + preferredDefaultSpeed: speed, + ), ); } }, diff --git a/lib/features/player/view/widgets/playing_indicator_icon.dart b/lib/features/player/view/widgets/playing_indicator_icon.dart index d179797..35c47fc 100644 --- a/lib/features/player/view/widgets/playing_indicator_icon.dart +++ b/lib/features/player/view/widgets/playing_indicator_icon.dart @@ -59,8 +59,11 @@ class _PlayingIndicatorIconState extends State { @override void initState() { super.initState(); - _animationParams = - List.generate(widget.barCount, _createRandomParams, growable: false); + _animationParams = List.generate( + widget.barCount, + _createRandomParams, + growable: false, + ); } // Helper to generate random parameters for one bar's animation cycle @@ -72,10 +75,12 @@ class _PlayingIndicatorIconState extends State { // Note: These factors represent the scale relative to the *half-height* // if centerSymmetric is true, controlled by the alignment in scaleY. - final targetHeightFactor1 = widget.minHeightFactor + + final targetHeightFactor1 = + widget.minHeightFactor + _random.nextDouble() * (widget.maxHeightFactor - widget.minHeightFactor); - final targetHeightFactor2 = widget.minHeightFactor + + final targetHeightFactor2 = + widget.minHeightFactor + _random.nextDouble() * (widget.maxHeightFactor - widget.minHeightFactor); @@ -95,7 +100,8 @@ class _PlayingIndicatorIconState extends State { @override Widget build(BuildContext context) { - final color = widget.color ?? + final color = + widget.color ?? IconTheme.of(context).color ?? Theme.of(context).colorScheme.primary; @@ -110,8 +116,9 @@ class _PlayingIndicatorIconState extends State { final double maxHeight = widget.size; // Determine the alignment for scaling based on the symmetric flag - final Alignment scaleAlignment = - widget.centerSymmetric ? Alignment.center : Alignment.bottomCenter; + final Alignment scaleAlignment = widget.centerSymmetric + ? Alignment.center + : Alignment.bottomCenter; // Determine the cross axis alignment for the Row final CrossAxisAlignment rowAlignment = widget.centerSymmetric @@ -129,47 +136,40 @@ class _PlayingIndicatorIconState extends State { crossAxisAlignment: rowAlignment, // Use spaceEvenly for better distribution, especially with center alignment mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: List.generate( - widget.barCount, - (index) { - final params = _animationParams[index]; - // The actual bar widget that will be animated - return Container( - width: barWidth, - // Set initial height to the max potential height - // The scaleY animation will control the visible height - height: maxHeight, - decoration: BoxDecoration( - color: color, - borderRadius: BorderRadius.circular(barWidth / 2), - ), - ) - .animate( - delay: params.initialDelay, - onPlay: (controller) => controller.repeat( - reverse: true, - ), - ) - // 1. Scale to targetHeightFactor1 - .scaleY( - begin: - widget.minHeightFactor, // Scale factor starts near min - end: params.targetHeightFactor1, - duration: params.duration1, - curve: Curves.easeInOutCirc, - alignment: scaleAlignment, // Apply chosen alignment - ) - // 2. Then scale to targetHeightFactor2 - .then() - .scaleY( - end: params.targetHeightFactor2, - duration: params.duration2, - curve: Curves.easeInOutCirc, - alignment: scaleAlignment, // Apply chosen alignment - ); - }, - growable: false, - ), + children: List.generate(widget.barCount, (index) { + final params = _animationParams[index]; + // The actual bar widget that will be animated + return Container( + width: barWidth, + // Set initial height to the max potential height + // The scaleY animation will control the visible height + height: maxHeight, + decoration: BoxDecoration( + color: color, + borderRadius: BorderRadius.circular(barWidth / 2), + ), + ) + .animate( + delay: params.initialDelay, + onPlay: (controller) => controller.repeat(reverse: true), + ) + // 1. Scale to targetHeightFactor1 + .scaleY( + begin: widget.minHeightFactor, // Scale factor starts near min + end: params.targetHeightFactor1, + duration: params.duration1, + curve: Curves.easeInOutCirc, + alignment: scaleAlignment, // Apply chosen alignment + ) + // 2. Then scale to targetHeightFactor2 + .then() + .scaleY( + end: params.targetHeightFactor2, + duration: params.duration2, + curve: Curves.easeInOutCirc, + alignment: scaleAlignment, // Apply chosen alignment + ); + }, growable: false), ), ), ); diff --git a/lib/features/player/view/widgets/speed_selector.dart b/lib/features/player/view/widgets/speed_selector.dart index ab564b1..f14604a 100644 --- a/lib/features/player/view/widgets/speed_selector.dart +++ b/lib/features/player/view/widgets/speed_selector.dart @@ -10,10 +10,7 @@ import 'package:vaani/settings/app_settings_provider.dart'; const double itemExtent = 25; class SpeedSelector extends HookConsumerWidget { - const SpeedSelector({ - super.key, - required this.onSpeedSelected, - }); + const SpeedSelector({super.key, required this.onSpeedSelected}); final void Function(double speed) onSpeedSelected; @@ -26,34 +23,22 @@ class SpeedSelector extends HookConsumerWidget { final speedState = useState(currentSpeed); // hook the onSpeedSelected function to the state - useEffect( - () { - onSpeedSelected(speedState.value); - return null; - }, - [speedState.value], - ); + useEffect(() { + onSpeedSelected(speedState.value); + return null; + }, [speedState.value]); // the speed options - final minSpeed = min( - speeds.reduce(min), - playerSettings.minSpeed, - ); - final maxSpeed = max( - speeds.reduce(max), - playerSettings.maxSpeed, - ); + final minSpeed = min(speeds.reduce(min), playerSettings.minSpeed); + final maxSpeed = max(speeds.reduce(max), playerSettings.maxSpeed); final speedIncrement = playerSettings.speedIncrement; final availableSpeeds = ((maxSpeed - minSpeed) / speedIncrement).ceil() + 1; - final availableSpeedsList = List.generate( - availableSpeeds, - (index) { - // need to round to 2 decimal place to avoid floating point errors - return double.parse( - (minSpeed + index * speedIncrement).toStringAsFixed(2), - ); - }, - ); + final availableSpeedsList = List.generate(availableSpeeds, (index) { + // need to round to 2 decimal place to avoid floating point errors + return double.parse( + (minSpeed + index * speedIncrement).toStringAsFixed(2), + ); + }); final scrollController = useFixedExtentScrollController( initialItem: availableSpeedsList.indexOf(currentSpeed), @@ -107,18 +92,19 @@ class SpeedSelector extends HookConsumerWidget { (speed) => TextButton( style: speed == speedState.value ? TextButton.styleFrom( - backgroundColor: - Theme.of(context).colorScheme.primaryContainer, - foregroundColor: Theme.of(context) - .colorScheme - .onPrimaryContainer, + backgroundColor: Theme.of( + context, + ).colorScheme.primaryContainer, + foregroundColor: Theme.of( + context, + ).colorScheme.onPrimaryContainer, ) // border if not selected : TextButton.styleFrom( side: BorderSide( - color: Theme.of(context) - .colorScheme - .primaryContainer, + color: Theme.of( + context, + ).colorScheme.primaryContainer, ), ), onPressed: () async { @@ -195,14 +181,13 @@ class SpeedWheel extends StatelessWidget { controller: scrollController, scrollDirection: Axis.horizontal, itemExtent: itemExtent, - diameterRatio: 1.5, squeeze: 1.2, + diameterRatio: 1.5, + squeeze: 1.2, // useMagnifier: true, // magnification: 1.5, physics: const FixedExtentScrollPhysics(), children: availableSpeedsList - .map( - (speed) => SpeedLine(speed: speed), - ) + .map((speed) => SpeedLine(speed: speed)) .toList(), onSelectedItemChanged: (index) { speedState.value = availableSpeedsList[index]; @@ -232,10 +217,7 @@ class SpeedWheel extends StatelessWidget { } class SpeedLine extends StatelessWidget { - const SpeedLine({ - super.key, - required this.speed, - }); + const SpeedLine({super.key, required this.speed}); final double speed; @@ -250,8 +232,8 @@ class SpeedLine extends StatelessWidget { width: speed % 0.5 == 0 ? 3 : speed % 0.25 == 0 - ? 2 - : 0.5, + ? 2 + : 0.5, color: Theme.of(context).colorScheme.onSurface, ), ), diff --git a/lib/features/shake_detection/core/shake_detector.dart b/lib/features/shake_detection/core/shake_detector.dart index 023a8ab..effa131 100644 --- a/lib/features/shake_detection/core/shake_detector.dart +++ b/lib/features/shake_detection/core/shake_detector.dart @@ -29,7 +29,7 @@ class ShakeDetector { DateTime _lastShakeTime = DateTime.now(); final StreamController - _detectedShakeStreamController = StreamController.broadcast(); + _detectedShakeStreamController = StreamController.broadcast(); void start() { if (_accelerometerSubscription != null) { @@ -37,26 +37,27 @@ class ShakeDetector { return; } _accelerometerSubscription = - userAccelerometerEventStream(samplingPeriod: _settings.samplingPeriod) - .listen((event) { - _logger.finest('RMS: ${event.rms}'); - if (event.rms > _settings.threshold) { - _currentShakeCount++; + userAccelerometerEventStream( + samplingPeriod: _settings.samplingPeriod, + ).listen((event) { + _logger.finest('RMS: ${event.rms}'); + if (event.rms > _settings.threshold) { + _currentShakeCount++; - if (_currentShakeCount >= _settings.shakeTriggerCount && - !isCoolDownNeeded()) { - _logger.fine('Shake detected $_currentShakeCount times'); + if (_currentShakeCount >= _settings.shakeTriggerCount && + !isCoolDownNeeded()) { + _logger.fine('Shake detected $_currentShakeCount times'); - onShakeDetected?.call(); - _detectedShakeStreamController.add(event); + onShakeDetected?.call(); + _detectedShakeStreamController.add(event); - _lastShakeTime = DateTime.now(); - _currentShakeCount = 0; - } - } else { - _currentShakeCount = 0; - } - }); + _lastShakeTime = DateTime.now(); + _currentShakeCount = 0; + } + } else { + _currentShakeCount = 0; + } + }); _logger.fine('ShakeDetector started'); } diff --git a/lib/features/shake_detection/providers/shake_detector.dart b/lib/features/shake_detection/providers/shake_detector.dart index 8892a92..fa17920 100644 --- a/lib/features/shake_detection/providers/shake_detector.dart +++ b/lib/features/shake_detection/providers/shake_detector.dart @@ -59,34 +59,29 @@ class ShakeDetector extends _$ShakeDetector { final sleepTimer = ref.watch(sleepTimerProvider); if (!shakeDetectionSettings.shakeAction.isPlaybackManagementEnabled && sleepTimer == null) { - _logger - .config('No playback management is enabled and sleep timer is off, ' - 'so shake detection is disabled'); + _logger.config( + 'No playback management is enabled and sleep timer is off, ' + 'so shake detection is disabled', + ); return null; } _logger.config('Creating shake detector'); - final detector = core.ShakeDetector( - shakeDetectionSettings, - () { - final wasActionComplete = doShakeAction( - shakeDetectionSettings.shakeAction, - ref: ref, - ); - if (wasActionComplete) { - shakeDetectionSettings.feedback.forEach(postShakeFeedback); - } - }, - ); + final detector = core.ShakeDetector(shakeDetectionSettings, () { + final wasActionComplete = doShakeAction( + shakeDetectionSettings.shakeAction, + ref: ref, + ); + if (wasActionComplete) { + shakeDetectionSettings.feedback.forEach(postShakeFeedback); + } + }); ref.onDispose(detector.dispose); return detector; } /// Perform the shake action and return whether the action was successful - bool doShakeAction( - ShakeAction shakeAction, { - required Ref ref, - }) { + bool doShakeAction(ShakeAction shakeAction, {required Ref ref}) { final player = ref.read(simpleAudiobookPlayerProvider); if (player.book == null && shakeAction.isPlaybackManagementEnabled) { _logger.warning('No book is loaded'); @@ -166,8 +161,11 @@ extension on ShakeAction { } bool get isPlaybackManagementEnabled { - return {ShakeAction.playPause, ShakeAction.fastForward, ShakeAction.rewind} - .contains(this); + return { + ShakeAction.playPause, + ShakeAction.fastForward, + ShakeAction.rewind, + }.contains(this); } bool get shouldActOnSleepTimer { diff --git a/lib/features/sleep_timer/core/sleep_timer.dart b/lib/features/sleep_timer/core/sleep_timer.dart index 2d9ea31..b774062 100644 --- a/lib/features/sleep_timer/core/sleep_timer.dart +++ b/lib/features/sleep_timer/core/sleep_timer.dart @@ -94,9 +94,7 @@ class SleepTimer { } /// starts the timer with the given duration or the default duration - void startCountDown([ - Duration? forDuration, - ]) { + void startCountDown([Duration? forDuration]) { clearCountDownTimer(); duration = forDuration ?? duration; timer = Timer(duration, () { diff --git a/lib/features/sleep_timer/view/sleep_timer_button.dart b/lib/features/sleep_timer/view/sleep_timer_button.dart index 9712813..0f33b72 100644 --- a/lib/features/sleep_timer/view/sleep_timer_button.dart +++ b/lib/features/sleep_timer/view/sleep_timer_button.dart @@ -13,9 +13,7 @@ import 'package:vaani/settings/app_settings_provider.dart'; import 'package:vaani/shared/extensions/duration_format.dart'; class SleepTimerButton extends HookConsumerWidget { - const SleepTimerButton({ - super.key, - }); + const SleepTimerButton({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -47,8 +45,9 @@ class SleepTimerButton extends HookConsumerWidget { ); pendingPlayerModals--; ref.read(sleepTimerProvider.notifier).setTimer(durationState.value); - appLogger - .fine('Sleep Timer dialog closed with ${durationState.value}'); + appLogger.fine( + 'Sleep Timer dialog closed with ${durationState.value}', + ); }, child: AnimatedSwitcher( duration: const Duration(milliseconds: 300), @@ -57,9 +56,7 @@ class SleepTimerButton extends HookConsumerWidget { Symbols.bedtime, color: Theme.of(context).colorScheme.onSurface, ) - : RemainingSleepTimeDisplay( - timer: sleepTimer, - ), + : RemainingSleepTimeDisplay(timer: sleepTimer), ), ), ); @@ -67,10 +64,7 @@ class SleepTimerButton extends HookConsumerWidget { } class SleepTimerBottomSheet extends HookConsumerWidget { - const SleepTimerBottomSheet({ - super.key, - this.onDurationSelected, - }); + const SleepTimerBottomSheet({super.key, this.onDurationSelected}); final void Function(Duration?)? onDurationSelected; @@ -91,8 +85,9 @@ class SleepTimerBottomSheet extends HookConsumerWidget { ]; final scrollController = useFixedExtentScrollController( - initialItem: - allPossibleDurations.indexOf(sleepTimer?.duration ?? minDuration), + initialItem: allPossibleDurations.indexOf( + sleepTimer?.duration ?? minDuration, + ), ); final durationState = useState( @@ -100,13 +95,10 @@ class SleepTimerBottomSheet extends HookConsumerWidget { ); // useEffect to rebuild the sleep timer when the duration changes - useEffect( - () { - onDurationSelected?.call(durationState.value); - return null; - }, - [durationState.value], - ); + useEffect(() { + onDurationSelected?.call(durationState.value); + return null; + }, [durationState.value]); return Column( mainAxisSize: MainAxisSize.min, @@ -171,18 +163,19 @@ class SleepTimerBottomSheet extends HookConsumerWidget { (timerDuration) => TextButton( style: timerDuration == durationState.value ? TextButton.styleFrom( - backgroundColor: - Theme.of(context).colorScheme.primaryContainer, - foregroundColor: Theme.of(context) - .colorScheme - .onPrimaryContainer, + backgroundColor: Theme.of( + context, + ).colorScheme.primaryContainer, + foregroundColor: Theme.of( + context, + ).colorScheme.onPrimaryContainer, ) // border if not selected : TextButton.styleFrom( side: BorderSide( - color: Theme.of(context) - .colorScheme - .primaryContainer, + color: Theme.of( + context, + ).colorScheme.primaryContainer, ), ), onPressed: () async { @@ -215,10 +208,7 @@ class SleepTimerBottomSheet extends HookConsumerWidget { } class RemainingSleepTimeDisplay extends HookConsumerWidget { - const RemainingSleepTimeDisplay({ - super.key, - required this.timer, - }); + const RemainingSleepTimeDisplay({super.key, required this.timer}); final SleepTimer timer; @@ -230,17 +220,14 @@ class RemainingSleepTimeDisplay extends HookConsumerWidget { color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular(16), ), - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), child: Text( timer.timer == null ? timer.duration.smartBinaryFormat : remainingTime?.smartBinaryFormat ?? '', style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Theme.of(context).colorScheme.onPrimary, - ), + color: Theme.of(context).colorScheme.onPrimary, + ), ), ); } @@ -272,8 +259,9 @@ class SleepTimerWheel extends StatelessWidget { icon: const Icon(Icons.remove), onPressed: () { // animate to index - 1 - final index = availableDurations - .indexOf(durationState.value ?? Duration.zero); + final index = availableDurations.indexOf( + durationState.value ?? Duration.zero, + ); if (index > 0) { scrollController.animateToItem( index - 1, @@ -289,14 +277,13 @@ class SleepTimerWheel extends StatelessWidget { controller: scrollController, scrollDirection: Axis.horizontal, itemExtent: itemExtent, - diameterRatio: 1.5, squeeze: 1.2, + diameterRatio: 1.5, + squeeze: 1.2, // useMagnifier: true, // magnification: 1.5, physics: const FixedExtentScrollPhysics(), children: availableDurations - .map( - (duration) => DurationLine(duration: duration), - ) + .map((duration) => DurationLine(duration: duration)) .toList(), onSelectedItemChanged: (index) { durationState.value = availableDurations[index]; @@ -310,8 +297,9 @@ class SleepTimerWheel extends StatelessWidget { icon: const Icon(Icons.add), onPressed: () { // animate to index + 1 - final index = availableDurations - .indexOf(durationState.value ?? Duration.zero); + final index = availableDurations.indexOf( + durationState.value ?? Duration.zero, + ); if (index < availableDurations.length - 1) { scrollController.animateToItem( index + 1, @@ -327,10 +315,7 @@ class SleepTimerWheel extends StatelessWidget { } class DurationLine extends StatelessWidget { - const DurationLine({ - super.key, - required this.duration, - }); + const DurationLine({super.key, required this.duration}); final Duration duration; @@ -345,8 +330,8 @@ class DurationLine extends StatelessWidget { width: duration.inMinutes % 5 == 0 ? 3 : duration.inMinutes % 2.5 == 0 - ? 2 - : 0.5, + ? 2 + : 0.5, color: Theme.of(context).colorScheme.onSurface, ), ), diff --git a/lib/features/you/view/server_manager.dart b/lib/features/you/view/server_manager.dart index 75e3f43..f8d13b0 100644 --- a/lib/features/you/view/server_manager.dart +++ b/lib/features/you/view/server_manager.dart @@ -20,16 +20,12 @@ import 'package:vaani/shared/extensions/obfuscation.dart' show ObfuscateSet; import 'package:vaani/shared/widgets/add_new_server.dart' show AddNewServer; class ServerManagerPage extends HookConsumerWidget { - const ServerManagerPage({ - super.key, - }); + const ServerManagerPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { return Scaffold( - appBar: AppBar( - title: const Text('Manage Accounts'), - ), + appBar: AppBar(title: const Text('Manage Accounts')), body: Center( child: Padding( padding: const EdgeInsets.all(8.0), @@ -41,9 +37,7 @@ class ServerManagerPage extends HookConsumerWidget { } class ServerManagerBody extends HookConsumerWidget { - const ServerManagerBody({ - super.key, - }); + const ServerManagerBody({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -61,9 +55,7 @@ class ServerManagerBody extends HookConsumerWidget { // crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: [ - const Text( - 'Registered Servers', - ), + const Text('Registered Servers'), Expanded( child: ListView.builder( itemCount: registeredServers.length, @@ -76,21 +68,17 @@ class ServerManagerBody extends HookConsumerWidget { 'Users: ${availableUsers.where((element) => element.server == registeredServer).length}', ), // children are list of users of this server - children: availableUsers - .where( - (element) => element.server == registeredServer, - ) - .map( - (e) => AvailableUserTile(user: e), - ) - .nonNulls - .toList() - - // add buttons of delete server and add user to server at the end - ..addAll([ - AddUserTile(server: registeredServer), - DeleteServerTile(server: registeredServer), - ]), + children: + availableUsers + .where((element) => element.server == registeredServer) + .map((e) => AvailableUserTile(user: e)) + .nonNulls + .toList() + // add buttons of delete server and add user to server at the end + ..addAll([ + AddUserTile(server: registeredServer), + DeleteServerTile(server: registeredServer), + ]), ); }, ), @@ -111,28 +99,24 @@ class ServerManagerBody extends HookConsumerWidget { final newServer = model.AudiobookShelfServer( serverUrl: makeBaseUrl(serverURIController.text), ); - ref.read(audiobookShelfServerProvider.notifier).addServer( - newServer, - ); - ref.read(apiSettingsProvider.notifier).updateState( - apiSettings.copyWith( - activeServer: newServer, - ), + ref + .read(audiobookShelfServerProvider.notifier) + .addServer(newServer); + ref + .read(apiSettingsProvider.notifier) + .updateState( + apiSettings.copyWith(activeServer: newServer), ); serverURIController.clear(); } on ServerAlreadyExistsException catch (e) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(e.toString()), - ), - ); + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(e.toString()))); } } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Invalid URL'), - ), - ); + ScaffoldMessenger.of( + context, + ).showSnackBar(const SnackBar(content: Text('Invalid URL'))); } }, ), @@ -144,10 +128,7 @@ class ServerManagerBody extends HookConsumerWidget { } class DeleteServerTile extends HookConsumerWidget { - const DeleteServerTile({ - super.key, - required this.server, - }); + const DeleteServerTile({super.key, required this.server}); final model.AudiobookShelfServer server; @@ -167,9 +148,7 @@ class DeleteServerTile extends HookConsumerWidget { child: Text.rich( TextSpan( children: [ - const TextSpan( - text: 'This will remove the server ', - ), + const TextSpan(text: 'This will remove the server '), TextSpan( text: server.serverUrl.host, style: TextStyle( @@ -194,13 +173,8 @@ class DeleteServerTile extends HookConsumerWidget { TextButton( onPressed: () { ref - .read( - audiobookShelfServerProvider.notifier, - ) - .removeServer( - server, - removeUsers: true, - ); + .read(audiobookShelfServerProvider.notifier) + .removeServer(server, removeUsers: true); Navigator.of(context).pop(); }, child: const Text('Delete'), @@ -215,10 +189,7 @@ class DeleteServerTile extends HookConsumerWidget { } class AddUserTile extends HookConsumerWidget { - const AddUserTile({ - super.key, - required this.server, - }); + const AddUserTile({super.key, required this.server}); final model.AudiobookShelfServer server; @@ -252,10 +223,12 @@ class AddUserTile extends HookConsumerWidget { label: 'Switch', onPressed: () { // Switch to the new user - ref.read(apiSettingsProvider.notifier).updateState( - ref.read(apiSettingsProvider).copyWith( - activeUser: user, - ), + ref + .read(apiSettingsProvider.notifier) + .updateState( + ref + .read(apiSettingsProvider) + .copyWith(activeUser: user), ); context.goNamed(Routes.home.name); }, @@ -283,10 +256,7 @@ class AddUserTile extends HookConsumerWidget { } class AvailableUserTile extends HookConsumerWidget { - const AvailableUserTile({ - super.key, - required this.user, - }); + const AvailableUserTile({super.key, required this.user}); final model.AuthenticatedUser user; @@ -303,18 +273,14 @@ class AvailableUserTile extends HookConsumerWidget { onTap: apiSettings.activeUser == user ? null : () { - ref.read(apiSettingsProvider.notifier).updateState( - apiSettings.copyWith( - activeUser: user, - ), - ); + ref + .read(apiSettingsProvider.notifier) + .updateState(apiSettings.copyWith(activeUser: user)); // pop all routes and go to the home page // while (context.canPop()) { // context.pop(); // } - context.goNamed( - Routes.home.name, - ); + context.goNamed(Routes.home.name); }, trailing: IconButton( icon: const Icon(Icons.delete), @@ -337,9 +303,7 @@ class AvailableUserTile extends HookConsumerWidget { color: Theme.of(context).colorScheme.primary, ), ), - const TextSpan( - text: ' from this app.', - ), + const TextSpan(text: ' from this app.'), ], ), ), @@ -353,9 +317,7 @@ class AvailableUserTile extends HookConsumerWidget { TextButton( onPressed: () { ref - .read( - authenticatedUsersProvider.notifier, - ) + .read(authenticatedUsersProvider.notifier) .removeUser(user); Navigator.of(context).pop(); }, diff --git a/lib/features/you/view/widgets/library_switch_chip.dart b/lib/features/you/view/widgets/library_switch_chip.dart index a673332..2255c7a 100644 --- a/lib/features/you/view/widgets/library_switch_chip.dart +++ b/lib/features/you/view/widgets/library_switch_chip.dart @@ -11,10 +11,7 @@ import 'package:flutter/foundation.dart'; import 'package:vaani/main.dart' show appLogger; class LibrarySwitchChip extends HookConsumerWidget { - const LibrarySwitchChip({ - super.key, - required this.libraries, - }); + const LibrarySwitchChip({super.key, required this.libraries}); final List libraries; @override @@ -26,30 +23,22 @@ class LibrarySwitchChip extends HookConsumerWidget { AbsIcons.getIconByName( apiSettings.activeLibraryId != null ? libraries - .firstWhere( - (lib) => lib.id == apiSettings.activeLibraryId, - ) - .icon + .firstWhere((lib) => lib.id == apiSettings.activeLibraryId) + .icon : libraries.first.icon, ), ), // Replace with your icon label: const Text('Change Library'), // Enable only if libraries are loaded and not empty onPressed: libraries.isNotEmpty - ? () => showLibrarySwitcher( - context, - ref, - ) + ? () => showLibrarySwitcher(context, ref) : null, // Disable if no libraries ); } } // --- Helper Function to Show the Switcher --- -void showLibrarySwitcher( - BuildContext context, - WidgetRef ref, -) { +void showLibrarySwitcher(BuildContext context, WidgetRef ref) { final content = _LibrarySelectionContent(); // --- Platform-Specific UI --- @@ -209,7 +198,9 @@ class _LibrarySelectionContent extends ConsumerWidget { // Get current settings state final currentSettings = ref.read(apiSettingsProvider); // Update the active library ID - ref.read(apiSettingsProvider.notifier).updateState( + ref + .read(apiSettingsProvider.notifier) + .updateState( currentSettings.copyWith(activeLibraryId: library.id), ); // Close the dialog/bottom sheet diff --git a/lib/features/you/view/you_page.dart b/lib/features/you/view/you_page.dart index ca789db..fba9048 100644 --- a/lib/features/you/view/you_page.dart +++ b/lib/features/you/view/you_page.dart @@ -12,9 +12,7 @@ import 'package:vaani/shared/widgets/not_implemented.dart'; import 'package:vaani/shared/widgets/vaani_logo.dart'; class YouPage extends HookConsumerWidget { - const YouPage({ - super.key, - }); + const YouPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -88,8 +86,9 @@ class YouPage extends HookConsumerWidget { // Maybe show error details or allow retry ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: - Text('Failed to load libraries: $error'), + content: Text( + 'Failed to load libraries: $error', + ), ), ); }, @@ -159,9 +158,7 @@ class YouPage extends HookConsumerWidget { Theme.of(context).colorScheme.primary, BlendMode.srcIn, ), - child: const VaaniLogo( - size: 48, - ), + child: const VaaniLogo(size: 48), ), ), ], @@ -176,9 +173,7 @@ class YouPage extends HookConsumerWidget { } class UserBar extends HookConsumerWidget { - const UserBar({ - super.key, - }); + const UserBar({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -217,8 +212,9 @@ class UserBar extends HookConsumerWidget { Text( api.baseUrl.toString(), style: textTheme.bodyMedium?.copyWith( - color: - themeData.colorScheme.onSurface.withValues(alpha: 0.6), + color: themeData.colorScheme.onSurface.withValues( + alpha: 0.6, + ), ), ), ], diff --git a/lib/hacks/fix_autofill_losing_focus.dart b/lib/hacks/fix_autofill_losing_focus.dart index ffa7da6..3763654 100644 --- a/lib/hacks/fix_autofill_losing_focus.dart +++ b/lib/hacks/fix_autofill_losing_focus.dart @@ -14,10 +14,7 @@ import 'package:flutter/material.dart'; class InactiveFocusScopeObserver extends StatefulWidget { final Widget child; - const InactiveFocusScopeObserver({ - super.key, - required this.child, - }); + const InactiveFocusScopeObserver({super.key, required this.child}); @override State createState() => @@ -39,10 +36,8 @@ class _InactiveFocusScopeObserverState } @override - Widget build(BuildContext context) => FocusScope( - node: _focusScope, - child: widget.child, - ); + Widget build(BuildContext context) => + FocusScope(node: _focusScope, child: widget.child); @override void dispose() { diff --git a/lib/main.dart b/lib/main.dart index b67d8a9..0eb4cc0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -33,11 +33,7 @@ void main() async { await configurePlayer(); // run the app - runApp( - const ProviderScope( - child: _EagerInitialization(child: MyApp()), - ), - ); + runApp(const ProviderScope(child: _EagerInitialization(child: MyApp()))); } var routerConfig = const MyAppRouter().config; @@ -65,17 +61,14 @@ class MyApp extends ConsumerWidget { themeSettings.highContrast || MediaQuery.of(context).highContrast; if (shouldUseHighContrast) { - lightColorScheme = lightColorScheme.copyWith( - surface: Colors.white, - ); - darkColorScheme = darkColorScheme.copyWith( - surface: Colors.black, - ); + lightColorScheme = lightColorScheme.copyWith(surface: Colors.white); + darkColorScheme = darkColorScheme.copyWith(surface: Colors.black); } if (themeSettings.useMaterialThemeFromSystem) { - var themes = - ref.watch(systemThemeProvider(highContrast: shouldUseHighContrast)); + var themes = ref.watch( + systemThemeProvider(highContrast: shouldUseHighContrast), + ); if (themes.value != null) { lightColorScheme = themes.value!.$1; darkColorScheme = themes.value!.$2; diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 3ba1d98..202ee79 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -52,7 +52,9 @@ class HomePage extends HookConsumerWidget { // try again button ElevatedButton( onPressed: () { - ref.read(apiSettingsProvider.notifier).updateState( + ref + .read(apiSettingsProvider.notifier) + .updateState( apiSettings.copyWith(activeLibraryId: null), ); ref.invalidate(personalizedViewProvider); @@ -66,24 +68,25 @@ class HomePage extends HookConsumerWidget { final shelvesToDisplay = data // .where((element) => !element.id.contains('discover')) .map((shelf) { - appLogger.fine('building shelf ${shelf.label}'); - // check if showPlayButton is enabled for the shelf - // using the id of the shelf - final showPlayButton = switch (shelf.id) { - 'continue-listening' => - homePageSettings.showPlayButtonOnContinueListeningShelf, - 'continue-series' => - homePageSettings.showPlayButtonOnContinueSeriesShelf, - 'listen-again' => - homePageSettings.showPlayButtonOnListenAgainShelf, - _ => homePageSettings.showPlayButtonOnAllRemainingShelves, - }; - return HomeShelf( - title: shelf.label, - shelf: shelf, - showPlayButton: showPlayButton, - ); - }).toList(); + appLogger.fine('building shelf ${shelf.label}'); + // check if showPlayButton is enabled for the shelf + // using the id of the shelf + final showPlayButton = switch (shelf.id) { + 'continue-listening' => + homePageSettings.showPlayButtonOnContinueListeningShelf, + 'continue-series' => + homePageSettings.showPlayButtonOnContinueSeriesShelf, + 'listen-again' => + homePageSettings.showPlayButtonOnListenAgainShelf, + _ => homePageSettings.showPlayButtonOnAllRemainingShelves, + }; + return HomeShelf( + title: shelf.label, + shelf: shelf, + showPlayButton: showPlayButton, + ); + }) + .toList(); return RefreshIndicator( onRefresh: () async { return ref.refresh(personalizedViewProvider); @@ -132,10 +135,6 @@ class HomePageSkeleton extends StatelessWidget { @override Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: CircularProgressIndicator(), - ), - ); + return const Scaffold(body: Center(child: CircularProgressIndicator())); } } diff --git a/lib/pages/library_page.dart b/lib/pages/library_page.dart index a6950a6..d203987 100644 --- a/lib/pages/library_page.dart +++ b/lib/pages/library_page.dart @@ -17,7 +17,9 @@ class LibraryPage extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { // set the library id as the active library if (libraryId != null) { - ref.read(apiSettingsProvider.notifier).updateState( + ref + .read(apiSettingsProvider.notifier) + .updateState( ref.watch(apiSettingsProvider).copyWith(activeLibraryId: libraryId), ); } @@ -48,12 +50,10 @@ class LibraryPage extends HookConsumerWidget { final shelvesToDisplay = data // .where((element) => !element.id.contains('discover')) .map((shelf) { - appLogger.fine('building shelf ${shelf.label}'); - return HomeShelf( - title: shelf.label, - shelf: shelf, - ); - }).toList(); + appLogger.fine('building shelf ${shelf.label}'); + return HomeShelf(title: shelf.label, shelf: shelf); + }) + .toList(); return RefreshIndicator( onRefresh: () async { return ref.refresh(personalizedViewProvider); @@ -85,10 +85,6 @@ class LibraryPageSkeleton extends StatelessWidget { @override Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: CircularProgressIndicator(), - ), - ); + return const Scaffold(body: Center(child: CircularProgressIndicator())); } } diff --git a/lib/router/constants.dart b/lib/router/constants.dart index 79c4556..3a556bf 100644 --- a/lib/router/constants.dart +++ b/lib/router/constants.dart @@ -3,14 +3,8 @@ part of 'router.dart'; class Routes { - static const home = _SimpleRoute( - pathName: '', - name: 'home', - ); - static const onboarding = _SimpleRoute( - pathName: 'login', - name: 'onboarding', - ); + static const home = _SimpleRoute(pathName: '', name: 'home'); + static const onboarding = _SimpleRoute(pathName: 'login', name: 'onboarding'); static const library = _SimpleRoute( pathName: 'library', pathParamName: 'libraryId', @@ -23,10 +17,7 @@ class Routes { ); // Local settings - static const settings = _SimpleRoute( - pathName: 'config', - name: 'settings', - ); + static const settings = _SimpleRoute(pathName: 'config', name: 'settings'); static const themeSettings = _SimpleRoute( pathName: 'theme', name: 'themeSettings', @@ -64,10 +55,7 @@ class Routes { name: 'search', // parentRoute: library, ); - static const explore = _SimpleRoute( - pathName: 'explore', - name: 'explore', - ); + static const explore = _SimpleRoute(pathName: 'explore', name: 'explore'); // downloads static const downloads = _SimpleRoute( @@ -83,10 +71,7 @@ class Routes { ); // you page for the user - static const you = _SimpleRoute( - pathName: 'you', - name: 'you', - ); + static const you = _SimpleRoute(pathName: 'you', name: 'you'); // user management static const userManagement = _SimpleRoute( @@ -102,10 +87,7 @@ class Routes { ); // logs page - static const logs = _SimpleRoute( - pathName: 'logs', - name: 'logs', - ); + static const logs = _SimpleRoute(pathName: 'logs', name: 'logs'); } // a class to store path diff --git a/lib/router/router.dart b/lib/router/router.dart index eda348e..949d0ee 100644 --- a/lib/router/router.dart +++ b/lib/router/router.dart @@ -25,8 +25,9 @@ import 'transitions/slide.dart'; part 'constants.dart'; -final GlobalKey rootNavigatorKey = - GlobalKey(debugLabel: 'root'); +final GlobalKey rootNavigatorKey = GlobalKey( + debugLabel: 'root', +); final GlobalKey sectionHomeNavigatorKey = GlobalKey(debugLabel: 'HomeNavigator'); @@ -35,34 +36,35 @@ class MyAppRouter { const MyAppRouter(); GoRouter get config => GoRouter( - initialLocation: Routes.home.localPath, - debugLogDiagnostics: true, + initialLocation: Routes.home.localPath, + debugLogDiagnostics: true, + routes: [ + // sign in page + GoRoute( + path: Routes.onboarding.localPath, + name: Routes.onboarding.name, + builder: (context, state) => const OnboardingSinglePage(), routes: [ - // sign in page + // open id callback GoRoute( - path: Routes.onboarding.localPath, - name: Routes.onboarding.name, - builder: (context, state) => const OnboardingSinglePage(), - routes: [ - // open id callback - GoRoute( - path: Routes.openIDCallback.pathName, - name: Routes.openIDCallback.name, - pageBuilder: handleCallback, - ), - ], - ), - // callback for open id - // need to duplicate because of https://github.com/flutter/flutter/issues/100624 - GoRoute( - path: Routes.openIDCallback.localPath, - // name: Routes.openIDCallback.name, - // builder: handleCallback, + path: Routes.openIDCallback.pathName, + name: Routes.openIDCallback.name, pageBuilder: handleCallback, ), - // The main app shell - StatefulShellRoute.indexedStack( - builder: ( + ], + ), + // callback for open id + // need to duplicate because of https://github.com/flutter/flutter/issues/100624 + GoRoute( + path: Routes.openIDCallback.localPath, + // name: Routes.openIDCallback.name, + // builder: handleCallback, + pageBuilder: handleCallback, + ), + // The main app shell + StatefulShellRoute.indexedStack( + builder: + ( BuildContext context, GoRouterState state, StatefulNavigationShell navigationShell, @@ -73,188 +75,187 @@ class MyAppRouter { // branches in a stateful way. return ScaffoldWithNavBar(navigationShell: navigationShell); }, - branches: [ - // The route branch for the first tab of the bottom navigation bar. - StatefulShellBranch( - navigatorKey: sectionHomeNavigatorKey, - routes: [ - GoRoute( - path: Routes.home.localPath, - name: Routes.home.name, - // builder: (context, state) => const HomePage(), - pageBuilder: defaultPageBuilder(const HomePage()), - ), - GoRoute( - path: Routes.libraryItem.localPath, - name: Routes.libraryItem.name, - // builder: (context, state) { - // final itemId = state - // .pathParameters[Routes.libraryItem.pathParamName]!; - // return LibraryItemPage( - // itemId: itemId, extra: state.extra); - // }, - pageBuilder: (context, state) { - final itemId = state - .pathParameters[Routes.libraryItem.pathParamName]!; - final child = - LibraryItemPage(itemId: itemId, extra: state.extra); - return buildPageWithDefaultTransition( - context: context, - state: state, - child: child, - ); - }, - ), - // downloads page - GoRoute( - path: Routes.downloads.localPath, - name: Routes.downloads.name, - pageBuilder: defaultPageBuilder(const DownloadsPage()), - ), - ], + branches: [ + // The route branch for the first tab of the bottom navigation bar. + StatefulShellBranch( + navigatorKey: sectionHomeNavigatorKey, + routes: [ + GoRoute( + path: Routes.home.localPath, + name: Routes.home.name, + // builder: (context, state) => const HomePage(), + pageBuilder: defaultPageBuilder(const HomePage()), ), - - // Library page - StatefulShellBranch( - routes: [ - GoRoute( - path: Routes.libraryBrowser.localPath, - name: Routes.libraryBrowser.name, - pageBuilder: defaultPageBuilder(const LibraryBrowserPage()), - ), - ], + GoRoute( + path: Routes.libraryItem.localPath, + name: Routes.libraryItem.name, + // builder: (context, state) { + // final itemId = state + // .pathParameters[Routes.libraryItem.pathParamName]!; + // return LibraryItemPage( + // itemId: itemId, extra: state.extra); + // }, + pageBuilder: (context, state) { + final itemId = + state.pathParameters[Routes.libraryItem.pathParamName]!; + final child = LibraryItemPage( + itemId: itemId, + extra: state.extra, + ); + return buildPageWithDefaultTransition( + context: context, + state: state, + child: child, + ); + }, ), - // search/explore page - StatefulShellBranch( - routes: [ - GoRoute( - path: Routes.explore.localPath, - name: Routes.explore.name, - // builder: (context, state) => const ExplorePage(), - pageBuilder: defaultPageBuilder(const ExplorePage()), - ), - // search page - GoRoute( - path: Routes.search.localPath, - name: Routes.search.name, - // builder: (context, state) { - // final libraryId = state - // .pathParameters[Routes.library.pathParamName]!; - // return LibrarySearchPage( - // libraryId: libraryId, - // extra: state.extra, - // ); - // }, - pageBuilder: (context, state) { - final queryParam = state.uri.queryParameters['q']!; - final category = state.uri.queryParameters['category']; - final child = SearchResultPage( - extra: state.extra, - query: queryParam, - category: category != null - ? SearchResultCategory.values.firstWhere( - (e) => e.toString().split('.').last == category, - ) - : null, - ); - return buildPageWithDefaultTransition( - context: context, - state: state, - child: child, - ); - }, - ), - ], - ), - // you page - StatefulShellBranch( - routes: [ - GoRoute( - path: Routes.you.localPath, - name: Routes.you.name, - pageBuilder: defaultPageBuilder(const YouPage()), - ), - GoRoute( - path: Routes.settings.localPath, - name: Routes.settings.name, - // builder: (context, state) => const AppSettingsPage(), - pageBuilder: defaultPageBuilder(const AppSettingsPage()), - routes: [ - GoRoute( - path: Routes.themeSettings.pathName, - name: Routes.themeSettings.name, - pageBuilder: defaultPageBuilder( - const ThemeSettingsPage(), - ), - ), - GoRoute( - path: Routes.autoSleepTimerSettings.pathName, - name: Routes.autoSleepTimerSettings.name, - pageBuilder: defaultPageBuilder( - const AutoSleepTimerSettingsPage(), - ), - ), - GoRoute( - path: Routes.notificationSettings.pathName, - name: Routes.notificationSettings.name, - pageBuilder: defaultPageBuilder( - const NotificationSettingsPage(), - ), - ), - GoRoute( - path: Routes.playerSettings.pathName, - name: Routes.playerSettings.name, - pageBuilder: - defaultPageBuilder(const PlayerSettingsPage()), - ), - GoRoute( - path: Routes.shakeDetectorSettings.pathName, - name: Routes.shakeDetectorSettings.name, - pageBuilder: defaultPageBuilder( - const ShakeDetectorSettingsPage(), - ), - ), - GoRoute( - path: Routes.homePageSettings.pathName, - name: Routes.homePageSettings.name, - pageBuilder: defaultPageBuilder( - const HomePageSettingsPage(), - ), - ), - ], - ), - GoRoute( - path: Routes.userManagement.localPath, - name: Routes.userManagement.name, - // builder: (context, state) => const UserManagementPage(), - pageBuilder: defaultPageBuilder(const ServerManagerPage()), - ), - ], + // downloads page + GoRoute( + path: Routes.downloads.localPath, + name: Routes.downloads.name, + pageBuilder: defaultPageBuilder(const DownloadsPage()), ), ], ), - // loggers page - GoRoute( - path: Routes.logs.localPath, - name: Routes.logs.name, - // builder: (context, state) => const LogsPage(), - pageBuilder: defaultPageBuilder(const LogsPage()), + // Library page + StatefulShellBranch( + routes: [ + GoRoute( + path: Routes.libraryBrowser.localPath, + name: Routes.libraryBrowser.name, + pageBuilder: defaultPageBuilder(const LibraryBrowserPage()), + ), + ], + ), + // search/explore page + StatefulShellBranch( + routes: [ + GoRoute( + path: Routes.explore.localPath, + name: Routes.explore.name, + // builder: (context, state) => const ExplorePage(), + pageBuilder: defaultPageBuilder(const ExplorePage()), + ), + // search page + GoRoute( + path: Routes.search.localPath, + name: Routes.search.name, + // builder: (context, state) { + // final libraryId = state + // .pathParameters[Routes.library.pathParamName]!; + // return LibrarySearchPage( + // libraryId: libraryId, + // extra: state.extra, + // ); + // }, + pageBuilder: (context, state) { + final queryParam = state.uri.queryParameters['q']!; + final category = state.uri.queryParameters['category']; + final child = SearchResultPage( + extra: state.extra, + query: queryParam, + category: category != null + ? SearchResultCategory.values.firstWhere( + (e) => e.toString().split('.').last == category, + ) + : null, + ); + return buildPageWithDefaultTransition( + context: context, + state: state, + child: child, + ); + }, + ), + ], + ), + // you page + StatefulShellBranch( + routes: [ + GoRoute( + path: Routes.you.localPath, + name: Routes.you.name, + pageBuilder: defaultPageBuilder(const YouPage()), + ), + GoRoute( + path: Routes.settings.localPath, + name: Routes.settings.name, + // builder: (context, state) => const AppSettingsPage(), + pageBuilder: defaultPageBuilder(const AppSettingsPage()), + routes: [ + GoRoute( + path: Routes.themeSettings.pathName, + name: Routes.themeSettings.name, + pageBuilder: defaultPageBuilder(const ThemeSettingsPage()), + ), + GoRoute( + path: Routes.autoSleepTimerSettings.pathName, + name: Routes.autoSleepTimerSettings.name, + pageBuilder: defaultPageBuilder( + const AutoSleepTimerSettingsPage(), + ), + ), + GoRoute( + path: Routes.notificationSettings.pathName, + name: Routes.notificationSettings.name, + pageBuilder: defaultPageBuilder( + const NotificationSettingsPage(), + ), + ), + GoRoute( + path: Routes.playerSettings.pathName, + name: Routes.playerSettings.name, + pageBuilder: defaultPageBuilder(const PlayerSettingsPage()), + ), + GoRoute( + path: Routes.shakeDetectorSettings.pathName, + name: Routes.shakeDetectorSettings.name, + pageBuilder: defaultPageBuilder( + const ShakeDetectorSettingsPage(), + ), + ), + GoRoute( + path: Routes.homePageSettings.pathName, + name: Routes.homePageSettings.name, + pageBuilder: defaultPageBuilder( + const HomePageSettingsPage(), + ), + ), + ], + ), + GoRoute( + path: Routes.userManagement.localPath, + name: Routes.userManagement.name, + // builder: (context, state) => const UserManagementPage(), + pageBuilder: defaultPageBuilder(const ServerManagerPage()), + ), + ], ), ], - ); + ), - Page handleCallback( - BuildContext context, - GoRouterState state, - ) { + // loggers page + GoRoute( + path: Routes.logs.localPath, + name: Routes.logs.name, + // builder: (context, state) => const LogsPage(), + pageBuilder: defaultPageBuilder(const LogsPage()), + ), + ], + ); + + Page handleCallback(BuildContext context, GoRouterState state) { // extract the code and state from the uri final code = state.uri.queryParameters['code']; final stateParam = state.uri.queryParameters['state']; appLogger.fine('deep linking callback: code: $code, state: $stateParam'); - var callbackPage = - CallbackPage(code: code, state: stateParam, key: ValueKey(stateParam)); + var callbackPage = CallbackPage( + code: code, + state: stateParam, + key: ValueKey(stateParam), + ); return buildPageWithDefaultTransition( context: context, state: state, diff --git a/lib/router/transitions/slide.dart b/lib/router/transitions/slide.dart index 969edea..79c6364 100644 --- a/lib/router/transitions/slide.dart +++ b/lib/router/transitions/slide.dart @@ -33,29 +33,26 @@ CustomTransitionPage buildPageWithDefaultTransition({ child: child, transitionsBuilder: (context, animation, secondaryAnimation, child) => FadeTransition( - opacity: animation, - child: SlideTransition( - position: animation.drive( - Tween( - begin: const Offset(0, 1.50), - end: Offset.zero, - ).chain( - CurveTween(curve: Curves.easeOut), + opacity: animation, + child: SlideTransition( + position: animation.drive( + Tween( + begin: const Offset(0, 1.50), + end: Offset.zero, + ).chain(CurveTween(curve: Curves.easeOut)), + ), + child: child, ), ), - child: child, - ), - ), ); } Page Function(BuildContext, GoRouterState) defaultPageBuilder( Widget child, -) => - (BuildContext context, GoRouterState state) { - return buildPageWithDefaultTransition( - context: context, - state: state, - child: child, - ); - }; +) => (BuildContext context, GoRouterState state) { + return buildPageWithDefaultTransition( + context: context, + state: state, + child: child, + ); +}; diff --git a/lib/settings/app_settings_provider.dart b/lib/settings/app_settings_provider.dart index fc10f9a..ae843c3 100644 --- a/lib/settings/app_settings_provider.dart +++ b/lib/settings/app_settings_provider.dart @@ -19,8 +19,10 @@ model.AppSettings loadOrCreateAppSettings() { settings = _box.getAt(0); _logger.fine('found settings in box: $settings'); } catch (e) { - _logger.warning('error reading settings from box: $e' - '\nclearing box'); + _logger.warning( + 'error reading settings from box: $e' + '\nclearing box', + ); _box.clear(); } } else { diff --git a/lib/settings/metadata/metadata_provider.dart b/lib/settings/metadata/metadata_provider.dart index 16802da..a1ce12f 100644 --- a/lib/settings/metadata/metadata_provider.dart +++ b/lib/settings/metadata/metadata_provider.dart @@ -12,19 +12,19 @@ Future deviceName(Ref ref) async { // try different keys to get the device name return - // android - data['product'] ?? - // ios - data['name'] ?? - // linux - data['name'] ?? - // windows - data['computerName'] ?? - // macos - data['model'] ?? - // web - data['browserName'] ?? - 'Unknown name'; + // android + data['product'] ?? + // ios + data['name'] ?? + // linux + data['name'] ?? + // windows + data['computerName'] ?? + // macos + data['model'] ?? + // web + data['browserName'] ?? + 'Unknown name'; } @Riverpod(keepAlive: true) @@ -33,19 +33,19 @@ Future deviceModel(Ref ref) async { // try different keys to get the device model return - // android, eg: Google Pixel 4 + // android, eg: Google Pixel 4 + data['model'] ?? + // ios, eg: iPhone 12 Pro + data['name'] ?? + // linux, eg: Linux Mint 20.1 + data['name'] ?? + // windows, eg: Surface Pro 7 + data['productId'] ?? + // macos, eg: MacBook Pro (13-inch, M1, 2020) data['model'] ?? - // ios, eg: iPhone 12 Pro - data['name'] ?? - // linux, eg: Linux Mint 20.1 - data['name'] ?? - // windows, eg: Surface Pro 7 - data['productId'] ?? - // macos, eg: MacBook Pro (13-inch, M1, 2020) - data['model'] ?? - // web, eg: Chrome 87.0.4280.88 - data['browserName'] ?? - 'Unknown model'; + // web, eg: Chrome 87.0.4280.88 + data['browserName'] ?? + 'Unknown model'; } @Riverpod(keepAlive: true) @@ -54,19 +54,19 @@ Future deviceSdkVersion(Ref ref) async { // try different keys to get the device sdk version return - // android, eg: 30 - data['version.sdkInt']?.toString() ?? - // ios, eg: 14.4 - data['systemVersion'] ?? - // linux, eg: 5.4.0-66-generic - data['version'] ?? - // windows, eg: 10.0.19042 - data['displayVersion'] ?? - // macos, eg: 11.2.1 - data['osRelease'] ?? - // web, eg: 87.0.4280.88 - data['appVersion'] ?? - 'Unknown sdk version'; + // android, eg: 30 + data['version.sdkInt']?.toString() ?? + // ios, eg: 14.4 + data['systemVersion'] ?? + // linux, eg: 5.4.0-66-generic + data['version'] ?? + // windows, eg: 10.0.19042 + data['displayVersion'] ?? + // macos, eg: 11.2.1 + data['osRelease'] ?? + // web, eg: 87.0.4280.88 + data['appVersion'] ?? + 'Unknown sdk version'; } @Riverpod(keepAlive: true) @@ -75,19 +75,19 @@ Future deviceManufacturer(Ref ref) async { // try different keys to get the device manufacturer return - // android, eg: Google + // android, eg: Google + data['manufacturer'] ?? + // ios, eg: Apple data['manufacturer'] ?? - // ios, eg: Apple - data['manufacturer'] ?? - // linux, eg: Linux - data['idLike'] ?? - // windows, eg: Microsoft - data['productName'] ?? - // macos, eg: Apple - data['manufacturer'] ?? - // web, eg: Google Inc. - data['vendor'] ?? - 'Unknown manufacturer'; + // linux, eg: Linux + data['idLike'] ?? + // windows, eg: Microsoft + data['productName'] ?? + // macos, eg: Apple + data['manufacturer'] ?? + // web, eg: Google Inc. + data['vendor'] ?? + 'Unknown manufacturer'; } // copied from https://pub.dev/packages/device_info_plus/example @@ -234,25 +234,28 @@ Future> _getDeviceData( deviceData = _readWebBrowserInfo(await deviceInfoPlugin.webBrowserInfo); } else { deviceData = switch (defaultTargetPlatform) { - TargetPlatform.android => - _readAndroidBuildData(await deviceInfoPlugin.androidInfo), - TargetPlatform.iOS => - _readIosDeviceInfo(await deviceInfoPlugin.iosInfo), - TargetPlatform.linux => - _readLinuxDeviceInfo(await deviceInfoPlugin.linuxInfo), - TargetPlatform.windows => - _readWindowsDeviceInfo(await deviceInfoPlugin.windowsInfo), - TargetPlatform.macOS => - _readMacOsDeviceInfo(await deviceInfoPlugin.macOsInfo), + TargetPlatform.android => _readAndroidBuildData( + await deviceInfoPlugin.androidInfo, + ), + TargetPlatform.iOS => _readIosDeviceInfo( + await deviceInfoPlugin.iosInfo, + ), + TargetPlatform.linux => _readLinuxDeviceInfo( + await deviceInfoPlugin.linuxInfo, + ), + TargetPlatform.windows => _readWindowsDeviceInfo( + await deviceInfoPlugin.windowsInfo, + ), + TargetPlatform.macOS => _readMacOsDeviceInfo( + await deviceInfoPlugin.macOsInfo, + ), TargetPlatform.fuchsia => { - errorKey: 'Fuchsia platform isn\'t supported', - }, + errorKey: 'Fuchsia platform isn\'t supported', + }, }; } } on PlatformException { - deviceData = { - errorKey: 'Failed to get platform version.', - }; + deviceData = {errorKey: 'Failed to get platform version.'}; } return deviceData; } diff --git a/lib/settings/view/app_settings_page.dart b/lib/settings/view/app_settings_page.dart index 15386fe..a193752 100644 --- a/lib/settings/view/app_settings_page.dart +++ b/lib/settings/view/app_settings_page.dart @@ -15,9 +15,7 @@ import 'package:vaani/settings/view/simple_settings_page.dart'; import 'package:vaani/settings/view/widgets/navigation_with_switch_tile.dart'; class AppSettingsPage extends HookConsumerWidget { - const AppSettingsPage({ - super.key, - }); + const AppSettingsPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -33,17 +31,12 @@ class AppSettingsPage extends HookConsumerWidget { horizontal: 16.0, vertical: 8.0, ), - title: Text( - 'General', - style: Theme.of(context).textTheme.titleLarge, - ), + title: Text('General', style: Theme.of(context).textTheme.titleLarge), tiles: [ SettingsTile( title: const Text('Player Settings'), leading: const Icon(Icons.play_arrow), - description: const Text( - 'Customize the player settings', - ), + description: const Text('Customize the player settings'), onPressed: (context) { context.pushNamed(Routes.playerSettings.name); }, @@ -61,7 +54,9 @@ class AppSettingsPage extends HookConsumerWidget { }, value: sleepTimerSettings.autoTurnOnTimer, onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.sleepTimerSettings( autoTurnOnTimer: value, ), @@ -71,15 +66,15 @@ class AppSettingsPage extends HookConsumerWidget { NavigationWithSwitchTile( title: const Text('Shake Detector'), leading: const Icon(Icons.vibration), - description: const Text( - 'Customize the shake detector settings', - ), + description: const Text('Customize the shake detector settings'), value: appSettings.shakeDetectionSettings.isEnabled, onPressed: (context) { context.pushNamed(Routes.shakeDetectorSettings.name); }, onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.shakeDetectionSettings( isEnabled: value, ), @@ -103,9 +98,7 @@ class AppSettingsPage extends HookConsumerWidget { SettingsTile.navigation( leading: const Icon(Icons.color_lens), title: const Text('Theme Settings'), - description: const Text( - 'Customize the app theme', - ), + description: const Text('Customize the app theme'), onPressed: (context) { context.pushNamed(Routes.themeSettings.name); }, @@ -123,9 +116,7 @@ class AppSettingsPage extends HookConsumerWidget { SettingsTile.navigation( leading: const Icon(Icons.home_filled), title: const Text('Home Page Settings'), - description: const Text( - 'Customize the home page', - ), + description: const Text('Customize the home page'), onPressed: (context) { context.pushNamed(Routes.homePageSettings.name); }, @@ -147,21 +138,15 @@ class AppSettingsPage extends HookConsumerWidget { SettingsTile( title: const Text('Copy to Clipboard'), leading: const Icon(Icons.copy), - description: const Text( - 'Copy the app settings to the clipboard', - ), + description: const Text('Copy the app settings to the clipboard'), onPressed: (context) async { // copy to clipboard await Clipboard.setData( - ClipboardData( - text: jsonEncode(appSettings.toJson()), - ), + ClipboardData(text: jsonEncode(appSettings.toJson())), ); // show toast ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Settings copied to clipboard'), - ), + const SnackBar(content: Text('Settings copied to clipboard')), ); }, ), @@ -231,9 +216,7 @@ class AppSettingsPage extends HookConsumerWidget { } class RestoreDialogue extends HookConsumerWidget { - const RestoreDialogue({ - super.key, - }); + const RestoreDialogue({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -264,9 +247,7 @@ class RestoreDialogue extends HookConsumerWidget { } try { // try to decode the backup - settings.value = model.AppSettings.fromJson( - jsonDecode(value), - ); + settings.value = model.AppSettings.fromJson(jsonDecode(value)); } catch (e) { return 'Invalid backup'; } @@ -280,27 +261,21 @@ class RestoreDialogue extends HookConsumerWidget { onPressed: () { if (formKey.currentState!.validate()) { if (settings.value == null) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Invalid backup'), - ), - ); + ScaffoldMessenger.of( + context, + ).showSnackBar(const SnackBar(content: Text('Invalid backup'))); return; } ref.read(appSettingsProvider.notifier).update(settings.value!); settingsInputController.clear(); Navigator.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Settings restored'), - ), + const SnackBar(content: Text('Settings restored')), ); } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Invalid backup'), - ), - ); + ScaffoldMessenger.of( + context, + ).showSnackBar(const SnackBar(content: Text('Invalid backup'))); } }, child: const Text('Restore'), diff --git a/lib/settings/view/auto_sleep_timer_settings_page.dart b/lib/settings/view/auto_sleep_timer_settings_page.dart index fe7d4b3..58fcf8e 100644 --- a/lib/settings/view/auto_sleep_timer_settings_page.dart +++ b/lib/settings/view/auto_sleep_timer_settings_page.dart @@ -7,16 +7,15 @@ import 'package:vaani/settings/view/simple_settings_page.dart'; import 'package:vaani/shared/extensions/time_of_day.dart'; class AutoSleepTimerSettingsPage extends HookConsumerWidget { - const AutoSleepTimerSettingsPage({ - super.key, - }); + const AutoSleepTimerSettingsPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { final appSettings = ref.watch(appSettingsProvider); final sleepTimerSettings = appSettings.sleepTimerSettings; - var enabled = sleepTimerSettings.autoTurnOnTimer && + var enabled = + sleepTimerSettings.autoTurnOnTimer && !sleepTimerSettings.alwaysAutoTurnOnTimer; final selectedValueColor = enabled ? Theme.of(context).colorScheme.primary @@ -40,7 +39,9 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget { ? const Icon(Symbols.time_auto) : const Icon(Symbols.timer_off), onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.sleepTimerSettings( autoTurnOnTimer: value, ), @@ -63,7 +64,9 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget { initialTime: sleepTimerSettings.autoTurnOnTime.toTimeOfDay(), ); if (selected != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.sleepTimerSettings( autoTurnOnTime: selected.toDuration(), ), @@ -89,7 +92,9 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget { initialTime: sleepTimerSettings.autoTurnOffTime.toTimeOfDay(), ); if (selected != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.sleepTimerSettings( autoTurnOffTime: selected.toDuration(), ), @@ -97,9 +102,9 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget { } }, trailing: Text( - sleepTimerSettings.autoTurnOffTime - .toTimeOfDay() - .format(context), + sleepTimerSettings.autoTurnOffTime.toTimeOfDay().format( + context, + ), style: TextStyle(color: selectedValueColor), ), ), @@ -112,7 +117,9 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget { 'Always turn on the sleep timer, no matter what', ), onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.sleepTimerSettings( alwaysAutoTurnOnTimer: value, ), diff --git a/lib/settings/view/buttons.dart b/lib/settings/view/buttons.dart index 4a15b41..209dc21 100644 --- a/lib/settings/view/buttons.dart +++ b/lib/settings/view/buttons.dart @@ -1,27 +1,18 @@ import 'package:flutter/material.dart'; class OkButton extends StatelessWidget { - const OkButton({ - super.key, - this.onPressed, - }); + const OkButton({super.key, this.onPressed}); final void Function()? onPressed; @override Widget build(BuildContext context) { - return TextButton( - onPressed: onPressed, - child: const Text('OK'), - ); + return TextButton(onPressed: onPressed, child: const Text('OK')); } } class CancelButton extends StatelessWidget { - const CancelButton({ - super.key, - this.onPressed, - }); + const CancelButton({super.key, this.onPressed}); final void Function()? onPressed; diff --git a/lib/settings/view/home_page_settings_page.dart b/lib/settings/view/home_page_settings_page.dart index 327044d..9b3b3fb 100644 --- a/lib/settings/view/home_page_settings_page.dart +++ b/lib/settings/view/home_page_settings_page.dart @@ -25,7 +25,8 @@ class HomePageSettingsPage extends HookConsumerWidget { tiles: [ SettingsTile.switchTile( initialValue: appSettings - .homePageSettings.showPlayButtonOnContinueListeningShelf, + .homePageSettings + .showPlayButtonOnContinueListeningShelf, title: const Text('Continue Listening'), leading: const Icon(Icons.play_arrow), description: const Text( @@ -48,7 +49,8 @@ class HomePageSettingsPage extends HookConsumerWidget { 'Show play button for books in continue series shelf', ), initialValue: appSettings - .homePageSettings.showPlayButtonOnContinueSeriesShelf, + .homePageSettings + .showPlayButtonOnContinueSeriesShelf, onToggle: (value) { appSettingsNotifier.update( appSettings.copyWith( @@ -66,7 +68,8 @@ class HomePageSettingsPage extends HookConsumerWidget { 'Show play button for all books in all remaining shelves', ), initialValue: appSettings - .homePageSettings.showPlayButtonOnAllRemainingShelves, + .homePageSettings + .showPlayButtonOnAllRemainingShelves, onToggle: (value) { appSettingsNotifier.update( appSettings.copyWith( diff --git a/lib/settings/view/notification_settings_page.dart b/lib/settings/view/notification_settings_page.dart index 140d21c..c306f87 100644 --- a/lib/settings/view/notification_settings_page.dart +++ b/lib/settings/view/notification_settings_page.dart @@ -9,9 +9,7 @@ import 'package:vaani/settings/view/simple_settings_page.dart'; import 'package:vaani/shared/extensions/enum.dart'; class NotificationSettingsPage extends HookConsumerWidget { - const NotificationSettingsPage({ - super.key, - }); + const NotificationSettingsPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -59,7 +57,9 @@ class NotificationSettingsPage extends HookConsumerWidget { }, ); if (selectedTitle != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.notificationSettings( primaryTitle: selectedTitle, ), @@ -97,7 +97,9 @@ class NotificationSettingsPage extends HookConsumerWidget { }, ); if (selectedTitle != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.notificationSettings( secondaryTitle: selectedTitle, ), @@ -118,7 +120,9 @@ class NotificationSettingsPage extends HookConsumerWidget { child: TimeIntervalSlider( defaultValue: notificationSettings.fastForwardInterval, onChangedEnd: (interval) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.notificationSettings( fastForwardInterval: interval, ), @@ -141,7 +145,9 @@ class NotificationSettingsPage extends HookConsumerWidget { child: TimeIntervalSlider( defaultValue: notificationSettings.rewindInterval, onChangedEnd: (interval) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.notificationSettings( rewindInterval: interval, ), @@ -162,26 +168,23 @@ class NotificationSettingsPage extends HookConsumerWidget { trailing: Wrap( spacing: 8.0, children: notificationSettings.mediaControls - .map( - (control) => Icon( - control.icon, - color: primaryColor, - ), - ) + .map((control) => Icon(control.icon, color: primaryColor)) .toList(), ), onPressed: (context) async { final selectedControls = await showDialog>( - context: context, - builder: (context) { - return MediaControlsPicker( - selectedControls: notificationSettings.mediaControls, + context: context, + builder: (context) { + return MediaControlsPicker( + selectedControls: notificationSettings.mediaControls, + ); + }, ); - }, - ); if (selectedControls != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.notificationSettings( mediaControls: selectedControls, ), @@ -194,11 +197,14 @@ class NotificationSettingsPage extends HookConsumerWidget { SettingsTile.switchTile( title: const Text('Show Chapter Progress'), leading: const Icon(Icons.book), - description: - const Text('instead of the overall progress of the book'), + description: const Text( + 'instead of the overall progress of the book', + ), initialValue: notificationSettings.progressBarIsChapterProgress, onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.notificationSettings( progressBarIsChapterProgress: value, ), @@ -213,10 +219,7 @@ class NotificationSettingsPage extends HookConsumerWidget { } class MediaControlsPicker extends HookConsumerWidget { - const MediaControlsPicker({ - super.key, - required this.selectedControls, - }); + const MediaControlsPicker({super.key, required this.selectedControls}); final List selectedControls; diff --git a/lib/settings/view/player_settings_page.dart b/lib/settings/view/player_settings_page.dart index 58b050f..1d93e71 100644 --- a/lib/settings/view/player_settings_page.dart +++ b/lib/settings/view/player_settings_page.dart @@ -9,9 +9,7 @@ import 'package:vaani/settings/view/simple_settings_page.dart'; import 'package:vaani/shared/extensions/duration_format.dart'; class PlayerSettingsPage extends HookConsumerWidget { - const PlayerSettingsPage({ - super.key, - }); + const PlayerSettingsPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -37,7 +35,9 @@ class PlayerSettingsPage extends HookConsumerWidget { ), initialValue: playerSettings.configurePlayerForEveryBook, onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.playerSettings( configurePlayerForEveryBook: value, ), @@ -50,8 +50,10 @@ class PlayerSettingsPage extends HookConsumerWidget { title: const Text('Default Speed'), trailing: Text( '${playerSettings.preferredDefaultSpeed}x', - style: - TextStyle(color: primaryColor, fontWeight: FontWeight.bold), + style: TextStyle( + color: primaryColor, + fontWeight: FontWeight.bold, + ), ), leading: const Icon(Icons.speed), onPressed: (context) async { @@ -62,7 +64,9 @@ class PlayerSettingsPage extends HookConsumerWidget { ), ); if (newSpeed != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.playerSettings( preferredDefaultSpeed: newSpeed, ), @@ -75,8 +79,10 @@ class PlayerSettingsPage extends HookConsumerWidget { title: const Text('Speed Options'), description: Text( playerSettings.speedOptions.map((e) => '${e}x').join(', '), - style: - TextStyle(fontWeight: FontWeight.bold, color: primaryColor), + style: TextStyle( + fontWeight: FontWeight.bold, + color: primaryColor, + ), ), leading: const Icon(Icons.speed), onPressed: (context) async { @@ -87,7 +93,9 @@ class PlayerSettingsPage extends HookConsumerWidget { ), ); if (newSpeedOptions != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.playerSettings( speedOptions: newSpeedOptions..sort(), ), @@ -110,7 +118,8 @@ class PlayerSettingsPage extends HookConsumerWidget { children: [ TextSpan( text: playerSettings - .minimumPositionForReporting.smartBinaryFormat, + .minimumPositionForReporting + .smartBinaryFormat, style: TextStyle( fontWeight: FontWeight.bold, color: primaryColor, @@ -133,7 +142,9 @@ class PlayerSettingsPage extends HookConsumerWidget { }, ); if (newDuration != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.playerSettings( minimumPositionForReporting: newDuration, ), @@ -150,7 +161,8 @@ class PlayerSettingsPage extends HookConsumerWidget { children: [ TextSpan( text: playerSettings - .markCompleteWhenTimeLeft.smartBinaryFormat, + .markCompleteWhenTimeLeft + .smartBinaryFormat, style: TextStyle( fontWeight: FontWeight.bold, color: primaryColor, @@ -173,7 +185,9 @@ class PlayerSettingsPage extends HookConsumerWidget { }, ); if (newDuration != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.playerSettings( markCompleteWhenTimeLeft: newDuration, ), @@ -190,7 +204,8 @@ class PlayerSettingsPage extends HookConsumerWidget { children: [ TextSpan( text: playerSettings - .playbackReportInterval.smartBinaryFormat, + .playbackReportInterval + .smartBinaryFormat, style: TextStyle( fontWeight: FontWeight.bold, color: primaryColor, @@ -213,7 +228,9 @@ class PlayerSettingsPage extends HookConsumerWidget { }, ); if (newDuration != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.playerSettings( playbackReportInterval: newDuration, ), @@ -237,7 +254,9 @@ class PlayerSettingsPage extends HookConsumerWidget { initialValue: playerSettings.expandedPlayerSettings.showTotalProgress, onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.playerSettings .expandedPlayerSettings(showTotalProgress: value), ); @@ -253,7 +272,9 @@ class PlayerSettingsPage extends HookConsumerWidget { initialValue: playerSettings.expandedPlayerSettings.showChapterProgress, onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.playerSettings( expandedPlayerSettings: playerSettings .expandedPlayerSettings @@ -306,17 +327,15 @@ class TimeDurationSelector extends HookConsumerWidget { } class SpeedPicker extends HookConsumerWidget { - const SpeedPicker({ - super.key, - this.initialValue = 1, - }); + const SpeedPicker({super.key, this.initialValue = 1}); final double initialValue; @override Widget build(BuildContext context, WidgetRef ref) { - final speedController = - useTextEditingController(text: initialValue.toString()); + final speedController = useTextEditingController( + text: initialValue.toString(), + ); final speed = useState(initialValue); return AlertDialog( title: const Text('Select Speed'), @@ -368,30 +387,32 @@ class SpeedOptionsPicker extends HookConsumerWidget { Wrap( spacing: 8.0, runSpacing: 8.0, - children: speedOptions.value - .map( - (speed) => Chip( - label: Text('${speed}x'), - onDeleted: speed == 1 - ? null - : () { - speedOptions.value = - speedOptions.value.where((element) { - // speed option 1 can't be removed - return element != speed; - }).toList(); - }, - ), - ) - .toList() - ..sort((a, b) { - // if (a.label == const Text('1x')) { - // return -1; - // } else if (b.label == const Text('1x')) { - // return 1; - // } - return a.label.toString().compareTo(b.label.toString()); - }), + children: + speedOptions.value + .map( + (speed) => Chip( + label: Text('${speed}x'), + onDeleted: speed == 1 + ? null + : () { + speedOptions.value = speedOptions.value.where(( + element, + ) { + // speed option 1 can't be removed + return element != speed; + }).toList(); + }, + ), + ) + .toList() + ..sort((a, b) { + // if (a.label == const Text('1x')) { + // return -1; + // } else if (b.label == const Text('1x')) { + // return 1; + // } + return a.label.toString().compareTo(b.label.toString()); + }), ), TextField( focusNode: focusNode, diff --git a/lib/settings/view/shake_detector_settings_page.dart b/lib/settings/view/shake_detector_settings_page.dart index 98c5b8d..fe39b53 100644 --- a/lib/settings/view/shake_detector_settings_page.dart +++ b/lib/settings/view/shake_detector_settings_page.dart @@ -9,9 +9,7 @@ import 'package:vaani/settings/view/simple_settings_page.dart'; import 'package:vaani/shared/extensions/enum.dart'; class ShakeDetectorSettingsPage extends HookConsumerWidget { - const ShakeDetectorSettingsPage({ - super.key, - }); + const ShakeDetectorSettingsPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -41,7 +39,9 @@ class ShakeDetectorSettingsPage extends HookConsumerWidget { ), initialValue: shakeDetectionSettings.isEnabled, onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.shakeDetectionSettings( isEnabled: value, ), @@ -77,7 +77,9 @@ class ShakeDetectorSettingsPage extends HookConsumerWidget { ); if (newThreshold != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.shakeDetectionSettings( threshold: newThreshold, ), @@ -107,7 +109,9 @@ class ShakeDetectorSettingsPage extends HookConsumerWidget { ); if (newShakeAction != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.shakeDetectionSettings( shakeAction: newShakeAction, ), @@ -131,26 +135,23 @@ class ShakeDetectorSettingsPage extends HookConsumerWidget { ) : Wrap( spacing: 8.0, - children: shakeDetectionSettings.feedback.map( - (feedback) { - return Icon( - feedback.icon, - color: selectedValueColor, - ); - }, - ).toList(), + children: shakeDetectionSettings.feedback.map((feedback) { + return Icon(feedback.icon, color: selectedValueColor); + }).toList(), ), onPressed: (context) async { final newFeedback = await showDialog>( - context: context, - builder: (context) => ShakeFeedbackSelector( - initialValue: shakeDetectionSettings.feedback, - ), - ); + context: context, + builder: (context) => ShakeFeedbackSelector( + initialValue: shakeDetectionSettings.feedback, + ), + ); if (newFeedback != null) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.shakeDetectionSettings( feedback: newFeedback, ), @@ -256,10 +257,7 @@ class ShakeActionSelector extends HookConsumerWidget { } class ShakeForceSelector extends HookConsumerWidget { - const ShakeForceSelector({ - super.key, - this.initialValue = 6, - }); + const ShakeForceSelector({super.key, this.initialValue = 6}); final double initialValue; @@ -291,9 +289,7 @@ class ShakeForceSelector extends HookConsumerWidget { shakeForce.value = 0; }, ), - helper: const Text( - 'Enter a number to set the threshold in m/s²', - ), + helper: const Text('Enter a number to set the threshold in m/s²'), ), ), Wrap( diff --git a/lib/settings/view/simple_settings_page.dart b/lib/settings/view/simple_settings_page.dart index ea9107d..e1f9fd7 100644 --- a/lib/settings/view/simple_settings_page.dart +++ b/lib/settings/view/simple_settings_page.dart @@ -4,11 +4,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:vaani/features/player/view/mini_player_bottom_padding.dart'; class SimpleSettingsPage extends HookConsumerWidget { - const SimpleSettingsPage({ - super.key, - this.title, - this.sections, - }); + const SimpleSettingsPage({super.key, this.title, this.sections}); final Widget? title; final List? sections; @@ -34,18 +30,16 @@ class SimpleSettingsPage extends HookConsumerWidget { ), if (sections != null) SliverList( - delegate: SliverChildListDelegate( - [ - ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(20)), - child: SettingsList( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - sections: sections!, - ), + delegate: SliverChildListDelegate([ + ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(20)), + child: SettingsList( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + sections: sections!, ), - ], - ), + ), + ]), ), // some padding at the bottom const SliverPadding(padding: EdgeInsets.only(bottom: 20)), diff --git a/lib/settings/view/theme_settings_page.dart b/lib/settings/view/theme_settings_page.dart index 315e4fa..8727be7 100644 --- a/lib/settings/view/theme_settings_page.dart +++ b/lib/settings/view/theme_settings_page.dart @@ -10,9 +10,7 @@ import 'package:vaani/settings/view/simple_settings_page.dart'; import 'package:vaani/shared/extensions/enum.dart'; class ThemeSettingsPage extends HookConsumerWidget { - const ThemeSettingsPage({ - super.key, - }); + const ThemeSettingsPage({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -38,7 +36,9 @@ class ThemeSettingsPage extends HookConsumerWidget { selectedIcon: const Icon(Icons.check), selected: {themeSettings.themeMode}, onSelectionChanged: (newSelection) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.themeSettings( themeMode: newSelection.first, ), @@ -66,8 +66,8 @@ class ThemeSettingsPage extends HookConsumerWidget { themeSettings.themeMode == ThemeMode.light ? Icons.light_mode : themeSettings.themeMode == ThemeMode.dark - ? Icons.dark_mode - : Icons.auto_awesome, + ? Icons.dark_mode + : Icons.auto_awesome, ), ), @@ -82,10 +82,10 @@ class ThemeSettingsPage extends HookConsumerWidget { 'Increase the contrast between the background and the text', ), onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( - appSettings.copyWith.themeSettings( - highContrast: value, - ), + ref + .read(appSettingsProvider.notifier) + .update( + appSettings.copyWith.themeSettings(highContrast: value), ); }, ), @@ -103,7 +103,9 @@ class ThemeSettingsPage extends HookConsumerWidget { ? const Icon(Icons.auto_awesome) : const Icon(Icons.auto_fix_off), onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.themeSettings( useMaterialThemeFromSystem: value, ), @@ -164,7 +166,9 @@ class ThemeSettingsPage extends HookConsumerWidget { ? const Icon(Icons.auto_fix_high) : const Icon(Icons.auto_fix_off), onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.themeSettings( useCurrentPlayerThemeThroughoutApp: value, ), @@ -182,7 +186,9 @@ class ThemeSettingsPage extends HookConsumerWidget { ? const Icon(Icons.auto_fix_high) : const Icon(Icons.auto_fix_off), onToggle: (value) { - ref.read(appSettingsProvider.notifier).update( + ref + .read(appSettingsProvider.notifier) + .update( appSettings.copyWith.themeSettings( useMaterialThemeOnItemPage: value, ), diff --git a/lib/settings/view/widgets/navigation_with_switch_tile.dart b/lib/settings/view/widgets/navigation_with_switch_tile.dart index 8851fa1..f2d90f9 100644 --- a/lib/settings/view/widgets/navigation_with_switch_tile.dart +++ b/lib/settings/view/widgets/navigation_with_switch_tile.dart @@ -44,10 +44,7 @@ class NavigationWithSwitchTile extends AbstractSettingsTile { indent: 8.0, endIndent: 8.0, ), - Switch.adaptive( - value: value, - onChanged: onToggle, - ), + Switch.adaptive(value: value, onChanged: onToggle), ], ), ), diff --git a/lib/shared/extensions/enum.dart b/lib/shared/extensions/enum.dart index e0e6c09..0def3ea 100644 --- a/lib/shared/extensions/enum.dart +++ b/lib/shared/extensions/enum.dart @@ -13,10 +13,7 @@ extension TitleCase on Enum { String get pascalCase { // capitalize the first letter of each word return name - .replaceAllMapped( - RegExp(r'([A-Z])'), - (match) => ' ${match.group(0)}', - ) + .replaceAllMapped(RegExp(r'([A-Z])'), (match) => ' ${match.group(0)}') .trim() .split(' ') .map((word) => word[0].toUpperCase() + word.substring(1)) diff --git a/lib/shared/extensions/model_conversions.dart b/lib/shared/extensions/model_conversions.dart index 38403d8..b3ff0aa 100644 --- a/lib/shared/extensions/model_conversions.dart +++ b/lib/shared/extensions/model_conversions.dart @@ -47,8 +47,8 @@ extension ShelfConversion on Shelf { extension UserConversion on User { UserWithSessionAndMostRecentProgress - get asUserWithSessionAndMostRecentProgress => - UserWithSessionAndMostRecentProgress.fromJson(toJson()); + get asUserWithSessionAndMostRecentProgress => + UserWithSessionAndMostRecentProgress.fromJson(toJson()); User get asUser => User.fromJson(toJson()); } diff --git a/lib/shared/extensions/obfuscation.dart b/lib/shared/extensions/obfuscation.dart index 6ff85fe..2a057a4 100644 --- a/lib/shared/extensions/obfuscation.dart +++ b/lib/shared/extensions/obfuscation.dart @@ -80,9 +80,7 @@ extension ObfuscateServer on AudiobookShelfServer { if (!kReleaseMode) { return this; } - return copyWith( - serverUrl: serverUrl.obfuscate(), - ); + return copyWith(serverUrl: serverUrl.obfuscate()); } } @@ -103,10 +101,7 @@ extension ObfuscateRequest on http.BaseRequest { if (!kReleaseMode) { return this; } - return http.Request( - method, - url.obfuscate(), - ); + return http.Request(method, url.obfuscate()); } } @@ -134,9 +129,11 @@ extension ObfuscateResponse on http.Response { // token regex is `"token": "..."` return body .replaceAll( - RegExp(r'(\b\w+@\w+\.\w+\b)|' - r'(\b\d{3}-\d{3}-\d{4}\b)|' - r'(\bhttps?://\S+\b)'), + RegExp( + r'(\b\w+@\w+\.\w+\b)|' + r'(\b\d{3}-\d{3}-\d{4}\b)|' + r'(\bhttps?://\S+\b)', + ), 'obfuscated', ) .replaceAll( @@ -151,9 +148,7 @@ extension ObfuscateLoginResponse on shelfsdk.LoginResponse { if (!kReleaseMode) { return this; } - return copyWith( - user: user.obfuscate(), - ); + return copyWith(user: user.obfuscate()); } } @@ -162,8 +157,6 @@ extension ObfuscateUser on shelfsdk.User { if (!kReleaseMode) { return this; } - return shelfsdk.User.fromJson( - toJson()..['token'] = 'tokenObfuscated', - ); + return shelfsdk.User.fromJson(toJson()..['token'] = 'tokenObfuscated'); } } diff --git a/lib/shared/extensions/time_of_day.dart b/lib/shared/extensions/time_of_day.dart index 9088b46..a0b0f08 100644 --- a/lib/shared/extensions/time_of_day.dart +++ b/lib/shared/extensions/time_of_day.dart @@ -2,10 +2,7 @@ import 'package:flutter/material.dart'; extension ToTimeOfDay on Duration { TimeOfDay toTimeOfDay() { - return TimeOfDay( - hour: inHours % 24, - minute: inMinutes % 60, - ); + return TimeOfDay(hour: inHours % 24, minute: inMinutes % 60); } } diff --git a/lib/shared/hooks.dart b/lib/shared/hooks.dart index 8e27b3a..3b9fd8e 100644 --- a/lib/shared/hooks.dart +++ b/lib/shared/hooks.dart @@ -7,24 +7,18 @@ void useInterval(VoidCallback callback, Duration delay) { final savedCallback = useRef(callback); savedCallback.value = callback; - useEffect( - () { - final timer = Timer.periodic(delay, (_) => savedCallback.value()); - return timer.cancel; - }, - [delay], - ); + useEffect(() { + final timer = Timer.periodic(delay, (_) => savedCallback.value()); + return timer.cancel; + }, [delay]); } void useTimer(VoidCallback callback, Duration delay) { final savedCallback = useRef(callback); savedCallback.value = callback; - useEffect( - () { - final timer = Timer(delay, savedCallback.value); - return timer.cancel; - }, - [delay], - ); + useEffect(() { + final timer = Timer(delay, savedCallback.value); + return timer.cancel; + }, [delay]); } diff --git a/lib/shared/icons/abs_icons.dart b/lib/shared/icons/abs_icons.dart index eca3e1a..ccceb39 100644 --- a/lib/shared/icons/abs_icons.dart +++ b/lib/shared/icons/abs_icons.dart @@ -24,46 +24,106 @@ class AbsIcons { static const _kFontFam = 'AbsIcons'; static const String? _kFontPkg = null; - static const IconData audiobookshelf = - IconData(0xe900, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData microphone_2 = - IconData(0xe901, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData microphone_1 = - IconData(0xe902, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData radio = - IconData(0xe903, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData podcast = - IconData(0xe904, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData books_1 = - IconData(0xe905, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData database_2 = - IconData(0xe906, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData headphones = - IconData(0xe910, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData music = - IconData(0xe911, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData video = - IconData(0xe914, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData microphone_3 = - IconData(0xe91e, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData book = - IconData(0xe91f, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData books_2 = - IconData(0xe920, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData file_picture = - IconData(0xe927, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData database_1 = - IconData(0xe964, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData rocket = - IconData(0xe9a5, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData power = - IconData(0xe9b5, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData star = - IconData(0xe9d9, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData heart = - IconData(0xe9da, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData rss = - IconData(0xea9b, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData audiobookshelf = IconData( + 0xe900, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData microphone_2 = IconData( + 0xe901, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData microphone_1 = IconData( + 0xe902, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData radio = IconData( + 0xe903, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData podcast = IconData( + 0xe904, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData books_1 = IconData( + 0xe905, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData database_2 = IconData( + 0xe906, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData headphones = IconData( + 0xe910, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData music = IconData( + 0xe911, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData video = IconData( + 0xe914, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData microphone_3 = IconData( + 0xe91e, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData book = IconData( + 0xe91f, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData books_2 = IconData( + 0xe920, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData file_picture = IconData( + 0xe927, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData database_1 = IconData( + 0xe964, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData rocket = IconData( + 0xe9a5, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData power = IconData( + 0xe9b5, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData star = IconData( + 0xe9d9, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData heart = IconData( + 0xe9da, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); + static const IconData rss = IconData( + 0xea9b, + fontFamily: _kFontFam, + fontPackage: _kFontPkg, + ); static final Map _iconMap = { 'audiobookshelf': audiobookshelf, diff --git a/lib/shared/widgets/add_new_server.dart b/lib/shared/widgets/add_new_server.dart index 8c31fc1..450874d 100644 --- a/lib/shared/widgets/add_new_server.dart +++ b/lib/shared/widgets/add_new_server.dart @@ -52,7 +52,8 @@ class AddNewServer extends HookConsumerWidget { // do nothing appLogger.severe('Error parsing URI: $e'); } - final canSubmit = !readOnly && + final canSubmit = + !readOnly && (isServerAliveValue || (allowEmpty && newServerURI.text.isEmpty)); return TextFormField( readOnly: readOnly, @@ -71,8 +72,9 @@ class AddNewServer extends HookConsumerWidget { color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.8), ), border: const OutlineInputBorder(), - prefixText: - myController.text.startsWith(httpUrlRegExp) ? '' : 'https://', + prefixText: myController.text.startsWith(httpUrlRegExp) + ? '' + : 'https://', prefixIcon: ServerAliveIcon(server: parsedUri), // add server button @@ -101,10 +103,7 @@ class AddNewServer extends HookConsumerWidget { } class ServerAliveIcon extends HookConsumerWidget { - const ServerAliveIcon({ - super.key, - required this.server, - }); + const ServerAliveIcon({super.key, required this.server}); final Uri server; @@ -121,8 +120,8 @@ class ServerAliveIcon extends HookConsumerWidget { message: server.toString().isEmpty ? 'Server Status' : isServerAliveValue - ? 'Server connected' - : 'Cannot connect to server', + ? 'Server connected' + : 'Cannot connect to server', child: server.toString().isEmpty ? Icon( Icons.cloud_outlined, diff --git a/lib/shared/widgets/drawer.dart b/lib/shared/widgets/drawer.dart index 12aa1c2..56bec1f 100644 --- a/lib/shared/widgets/drawer.dart +++ b/lib/shared/widgets/drawer.dart @@ -4,9 +4,7 @@ import 'package:vaani/features/you/view/server_manager.dart'; import 'package:vaani/router/router.dart'; class MyDrawer extends StatelessWidget { - const MyDrawer({ - super.key, - }); + const MyDrawer({super.key}); @override Widget build(BuildContext context) { @@ -16,10 +14,7 @@ class MyDrawer extends StatelessWidget { const DrawerHeader( child: Text( 'Vaani', - style: TextStyle( - fontStyle: FontStyle.italic, - fontSize: 30, - ), + style: TextStyle(fontStyle: FontStyle.italic, fontSize: 30), ), ), ListTile( diff --git a/lib/shared/widgets/expandable_description.dart b/lib/shared/widgets/expandable_description.dart index 203c7b0..bc2cee9 100644 --- a/lib/shared/widgets/expandable_description.dart +++ b/lib/shared/widgets/expandable_description.dart @@ -55,10 +55,7 @@ class ExpandableDescription extends HookWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // header text - Text( - style: textTheme.titleMedium, - title, - ), + Text(style: textTheme.titleMedium, title), // carrot icon AnimatedRotation( turns: isDescExpanded.value ? 0.5 : 0, @@ -79,11 +76,7 @@ class ExpandableDescription extends HookWidget { child: AnimatedSwitcher( duration: duration * 3, child: isDescExpanded.value - ? Text( - style: textTheme.bodyMedium, - content, - maxLines: null, - ) + ? Text(style: textTheme.bodyMedium, content, maxLines: null) : Text( style: textTheme.bodyMedium, content, diff --git a/lib/shared/widgets/not_implemented.dart b/lib/shared/widgets/not_implemented.dart index 801f152..5c10a60 100644 --- a/lib/shared/widgets/not_implemented.dart +++ b/lib/shared/widgets/not_implemented.dart @@ -2,9 +2,6 @@ import 'package:flutter/material.dart'; void showNotImplementedToast(BuildContext context) { ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Not implemented"), - showCloseIcon: true, - ), + const SnackBar(content: Text("Not implemented"), showCloseIcon: true), ); } diff --git a/lib/shared/widgets/shelves/author_shelf.dart b/lib/shared/widgets/shelves/author_shelf.dart index aa0acce..36dbadf 100644 --- a/lib/shared/widgets/shelves/author_shelf.dart +++ b/lib/shared/widgets/shelves/author_shelf.dart @@ -6,11 +6,7 @@ import 'package:vaani/shared/widgets/shelves/home_shelf.dart'; /// A shelf that displays Authors on the home page class AuthorHomeShelf extends HookConsumerWidget { - const AuthorHomeShelf({ - super.key, - required this.shelf, - required this.title, - }); + const AuthorHomeShelf({super.key, required this.shelf, required this.title}); final String title; final AuthorShelf shelf; @@ -20,9 +16,7 @@ class AuthorHomeShelf extends HookConsumerWidget { return SimpleHomeShelf( title: title, children: shelf.entities - .map( - (item) => AuthorOnShelf(item: item), - ) + .map((item) => AuthorOnShelf(item: item)) .toList(), ); } @@ -30,10 +24,7 @@ class AuthorHomeShelf extends HookConsumerWidget { // a widget to display a item on the shelf class AuthorOnShelf extends HookConsumerWidget { - const AuthorOnShelf({ - super.key, - required this.item, - }); + const AuthorOnShelf({super.key, required this.item}); final Author item; diff --git a/lib/shared/widgets/shelves/book_shelf.dart b/lib/shared/widgets/shelves/book_shelf.dart index 7b21820..0919161 100644 --- a/lib/shared/widgets/shelves/book_shelf.dart +++ b/lib/shared/widgets/shelves/book_shelf.dart @@ -40,11 +40,11 @@ class BookHomeShelf extends HookConsumerWidget { .map( (item) => switch (item.mediaType) { MediaType.book => BookOnShelf( - item: item, - key: ValueKey(shelf.id + item.id), - heroTagSuffix: shelf.id, - showPlayButton: showPlayButton, - ), + item: item, + key: ValueKey(shelf.id + item.id), + heroTagSuffix: shelf.id, + showPlayButton: showPlayButton, + ), _ => Container(), }, ) @@ -83,13 +83,8 @@ class BookOnShelf extends HookConsumerWidget { // open the book context.pushNamed( Routes.libraryItem.name, - pathParameters: { - Routes.libraryItem.pathParamName!: item.id, - }, - extra: LibraryItemExtras( - book: book, - heroTagSuffix: heroTagSuffix, - ), + pathParameters: {Routes.libraryItem.pathParamName!: item.id}, + extra: LibraryItemExtras(book: book, heroTagSuffix: heroTagSuffix), ); } @@ -99,8 +94,11 @@ class BookOnShelf extends HookConsumerWidget { onTap: handleTapOnBook, borderRadius: BorderRadius.circular(10), child: Padding( - padding: - const EdgeInsets.only(bottom: 8.0, right: 4.0, left: 4.0), + padding: const EdgeInsets.only( + bottom: 8.0, + right: 4.0, + left: 4.0, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -112,7 +110,8 @@ class BookOnShelf extends HookConsumerWidget { alignment: Alignment.bottomRight, children: [ Hero( - tag: HeroTagPrefixes.bookCover + + tag: + HeroTagPrefixes.bookCover + item.id + heroTagSuffix, child: ClipRRect( @@ -128,17 +127,19 @@ class BookOnShelf extends HookConsumerWidget { var imageWidget = Image.memory( image, fit: BoxFit.fill, - cacheWidth: (height * - 1.2 * - MediaQuery.of(context) - .devicePixelRatio) - .round(), + cacheWidth: + (height * + 1.2 * + MediaQuery.of( + context, + ).devicePixelRatio) + .round(), ); return Container( decoration: BoxDecoration( - color: Theme.of(context) - .colorScheme - .onPrimaryContainer, + color: Theme.of( + context, + ).colorScheme.onPrimaryContainer, ), child: imageWidget, ); @@ -157,9 +158,7 @@ class BookOnShelf extends HookConsumerWidget { ), // a play button on the book cover if (showPlayButton) - _BookOnShelfPlayButton( - libraryItemId: item.id, - ), + _BookOnShelfPlayButton(libraryItemId: item.id), ], ), ), @@ -202,9 +201,7 @@ class BookOnShelf extends HookConsumerWidget { } class _BookOnShelfPlayButton extends HookConsumerWidget { - const _BookOnShelfPlayButton({ - required this.libraryItemId, - }); + const _BookOnShelfPlayButton({required this.libraryItemId}); /// the id of the library item of the book final String libraryItemId; @@ -217,8 +214,9 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { player.book?.libraryItemId == libraryItemId; final isPlayingThisBook = player.playing && isCurrentBookSetInPlayer; - final userProgress = me.value?.mediaProgress - ?.firstWhereOrNull((element) => element.libraryItemId == libraryItemId); + final userProgress = me.value?.mediaProgress?.firstWhereOrNull( + (element) => element.libraryItemId == libraryItemId, + ); final isBookCompleted = userProgress?.isFinished ?? false; const size = 40.0; @@ -226,8 +224,10 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { // if there is user progress for this book show a circular progress indicator around the play button var strokeWidth = size / 8; - final useMaterialThemeOnItemPage = - ref.watch(appSettingsProvider).themeSettings.useMaterialThemeOnItemPage; + final useMaterialThemeOnItemPage = ref + .watch(appSettingsProvider) + .themeSettings + .useMaterialThemeOnItemPage; AsyncValue coverColorScheme = const AsyncValue.loading(); if (useMaterialThemeOnItemPage && isCurrentBookSetInPlayer) { @@ -242,8 +242,7 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { return Theme( // if current book is set in player, get theme from the cover image data: ThemeData( - colorScheme: - coverColorScheme.value ?? Theme.of(context).colorScheme, + colorScheme: coverColorScheme.value ?? Theme.of(context).colorScheme, ), child: Padding( padding: EdgeInsets.all(strokeWidth / 2 + 2), @@ -258,10 +257,9 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { child: CircularProgressIndicator( value: userProgress.progress, strokeWidth: strokeWidth, - backgroundColor: Theme.of(context) - .colorScheme - .onPrimary - .withValues(alpha: 0.8), + backgroundColor: Theme.of( + context, + ).colorScheme.onPrimary.withValues(alpha: 0.8), valueColor: AlwaysStoppedAnimation( Theme.of(context).colorScheme.primary, ), @@ -272,22 +270,18 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { IconButton( color: Theme.of(context).colorScheme.primary, style: ButtonStyle( - padding: WidgetStateProperty.all( - EdgeInsets.zero, - ), - minimumSize: WidgetStateProperty.all( - const Size(size, size), - ), + padding: WidgetStateProperty.all(EdgeInsets.zero), + minimumSize: WidgetStateProperty.all(const Size(size, size)), backgroundColor: WidgetStateProperty.all( - Theme.of(context) - .colorScheme - .onPrimary - .withValues(alpha: 0.9), + Theme.of( + context, + ).colorScheme.onPrimary.withValues(alpha: 0.9), ), ), onPressed: () async { - final book = - await ref.watch(libraryItemProvider(libraryItemId).future); + final book = await ref.watch( + libraryItemProvider(libraryItemId).future, + ); libraryItemPlayButtonOnPressed( ref: ref, @@ -313,9 +307,7 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { // a skeleton for the book cover class BookCoverSkeleton extends StatelessWidget { - const BookCoverSkeleton({ - super.key, - }); + const BookCoverSkeleton({super.key}); @override Widget build(BuildContext context) { @@ -324,13 +316,13 @@ class BookCoverSkeleton extends StatelessWidget { child: SizedBox( width: 150, child: Shimmer.fromColors( - baseColor: - Theme.of(context).colorScheme.surface.withValues(alpha: 0.3), - highlightColor: - Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.1), - child: Container( - color: Theme.of(context).colorScheme.surface, - ), + baseColor: Theme.of( + context, + ).colorScheme.surface.withValues(alpha: 0.3), + highlightColor: Theme.of( + context, + ).colorScheme.onSurface.withValues(alpha: 0.1), + child: Container(color: Theme.of(context).colorScheme.surface), ), ), ); diff --git a/lib/shared/widgets/shelves/home_shelf.dart b/lib/shared/widgets/shelves/home_shelf.dart index 9a59a54..3770fe1 100644 --- a/lib/shared/widgets/shelves/home_shelf.dart +++ b/lib/shared/widgets/shelves/home_shelf.dart @@ -26,14 +26,14 @@ class HomeShelf extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { return switch (shelf.type) { ShelfType.book => BookHomeShelf( - title: title, - shelf: shelf.asLibraryItemShelf, - showPlayButton: showPlayButton, - ), + title: title, + shelf: shelf.asLibraryItemShelf, + showPlayButton: showPlayButton, + ), ShelfType.authors => AuthorHomeShelf( - title: title, - shelf: shelf.asAuthorShelf, - ), + title: title, + shelf: shelf.asAuthorShelf, + ), _ => Container(), }; } @@ -75,9 +75,7 @@ class SimpleHomeShelf extends HookConsumerWidget { scrollDirection: Axis.horizontal, itemBuilder: (context, index) { if (index == 0 || index == children.length + 1) { - return const SizedBox( - width: 8, - ); + return const SizedBox(width: 8); } return children[index - 1]; }, @@ -88,7 +86,8 @@ class SimpleHomeShelf extends HookConsumerWidget { return const SizedBox(width: 4); }, - itemCount: children.length + + itemCount: + children.length + 2, // add some extra space at the start and end so that the first and last items are not at the edge ), ), diff --git a/lib/theme/providers/system_theme_provider.dart b/lib/theme/providers/system_theme_provider.dart index 529306e..cc01415 100644 --- a/lib/theme/providers/system_theme_provider.dart +++ b/lib/theme/providers/system_theme_provider.dart @@ -53,22 +53,15 @@ FutureOr<(ColorScheme light, ColorScheme dark)?> systemTheme( } if (schemeLight == null || schemeDark == null) { - _logger - .warning('dynamic_color: Dynamic color not detected on this device.'); + _logger.warning( + 'dynamic_color: Dynamic color not detected on this device.', + ); return null; } // set high contrast theme if (highContrast) { - schemeLight = schemeLight - .copyWith( - surface: Colors.white, - ) - .harmonized(); - schemeDark = schemeDark - .copyWith( - surface: Colors.black, - ) - .harmonized(); + schemeLight = schemeLight.copyWith(surface: Colors.white).harmonized(); + schemeDark = schemeDark.copyWith(surface: Colors.black).harmonized(); } return (schemeLight, schemeDark); }