mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-06 11:09:28 +00:00
feat: implement per book settings with player configuration and update methods
This commit is contained in:
parent
fd42ee2343
commit
e7dd4de515
19 changed files with 1030 additions and 20 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/foundation.dart' show immutable;
|
import 'package:flutter/foundation.dart' show immutable;
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:vaani/features/per_book_settings/models/book_settings.dart';
|
||||||
import 'package:vaani/settings/models/models.dart';
|
import 'package:vaani/settings/models/models.dart';
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
|
|
@ -19,4 +20,8 @@ class AvailableHiveBoxes {
|
||||||
/// stores the a list of [AuthenticatedUser]
|
/// stores the a list of [AuthenticatedUser]
|
||||||
static final authenticatedUserBox =
|
static final authenticatedUserBox =
|
||||||
Hive.box<AuthenticatedUser>(name: 'authenticatedUser');
|
Hive.box<AuthenticatedUser>(name: 'authenticatedUser');
|
||||||
|
|
||||||
|
/// stores the a list of [BookSettings]
|
||||||
|
static final individualBookSettingsBox =
|
||||||
|
Hive.box<BookSettings>(name: 'bookSettings');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:vaani/features/per_book_settings/models/book_settings.dart';
|
||||||
import 'package:vaani/settings/models/models.dart';
|
import 'package:vaani/settings/models/models.dart';
|
||||||
|
|
||||||
// register all models to Hive for serialization
|
// register all models to Hive for serialization
|
||||||
|
|
@ -19,4 +20,12 @@ Future registerModels() async {
|
||||||
'AuthenticatedUser',
|
'AuthenticatedUser',
|
||||||
((json) => AuthenticatedUser.fromJson(json)),
|
((json) => AuthenticatedUser.fromJson(json)),
|
||||||
);
|
);
|
||||||
|
Hive.registerAdapter<BookSettings>(
|
||||||
|
'BookSettings',
|
||||||
|
((json) => BookSettings.fromJson(json)),
|
||||||
|
);
|
||||||
|
Hive.registerAdapter<BookSettings>(
|
||||||
|
'_\$BookSettingsImpl', // hack because of freezed
|
||||||
|
((json) => BookSettings.fromJson(json)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import 'package:vaani/features/downloads/providers/download_manager.dart'
|
||||||
downloadStatusProvider,
|
downloadStatusProvider,
|
||||||
simpleDownloadManagerProvider;
|
simpleDownloadManagerProvider;
|
||||||
import 'package:vaani/features/item_viewer/view/library_item_page.dart';
|
import 'package:vaani/features/item_viewer/view/library_item_page.dart';
|
||||||
|
import 'package:vaani/features/per_book_settings/providers/book_settings_provider.dart';
|
||||||
import 'package:vaani/features/player/providers/audiobook_player.dart';
|
import 'package:vaani/features/player/providers/audiobook_player.dart';
|
||||||
import 'package:vaani/features/player/providers/player_form.dart';
|
import 'package:vaani/features/player/providers/player_form.dart';
|
||||||
import 'package:vaani/main.dart';
|
import 'package:vaani/main.dart';
|
||||||
|
|
@ -423,6 +424,7 @@ class DynamicItemPlayIcon extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Handles the play button pressed on the library item
|
||||||
Future<void> libraryItemPlayButtonOnPressed({
|
Future<void> libraryItemPlayButtonOnPressed({
|
||||||
required WidgetRef ref,
|
required WidgetRef ref,
|
||||||
required shelfsdk.BookExpanded book,
|
required shelfsdk.BookExpanded book,
|
||||||
|
|
@ -434,6 +436,7 @@ Future<void> libraryItemPlayButtonOnPressed({
|
||||||
final isCurrentBookSetInPlayer = player.book == book;
|
final isCurrentBookSetInPlayer = player.book == book;
|
||||||
final isPlayingThisBook = player.playing && isCurrentBookSetInPlayer;
|
final isPlayingThisBook = player.playing && isCurrentBookSetInPlayer;
|
||||||
|
|
||||||
|
Future<void>? setSourceFuture;
|
||||||
// set the book to the player if not already set
|
// set the book to the player if not already set
|
||||||
if (!isCurrentBookSetInPlayer) {
|
if (!isCurrentBookSetInPlayer) {
|
||||||
debugPrint('Setting the book ${book.libraryItemId}');
|
debugPrint('Setting the book ${book.libraryItemId}');
|
||||||
|
|
@ -442,7 +445,7 @@ Future<void> libraryItemPlayButtonOnPressed({
|
||||||
final libItem =
|
final libItem =
|
||||||
await ref.read(libraryItemProvider(book.libraryItemId).future);
|
await ref.read(libraryItemProvider(book.libraryItemId).future);
|
||||||
final downloadedUris = await downloadManager.getDownloadedFiles(libItem);
|
final downloadedUris = await downloadManager.getDownloadedFiles(libItem);
|
||||||
await player.setSourceAudiobook(
|
setSourceFuture = player.setSourceAudiobook(
|
||||||
book,
|
book,
|
||||||
initialPosition: userMediaProgress?.currentTime,
|
initialPosition: userMediaProgress?.currentTime,
|
||||||
downloadedUris: downloadedUris,
|
downloadedUris: downloadedUris,
|
||||||
|
|
@ -455,10 +458,32 @@ Future<void> libraryItemPlayButtonOnPressed({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 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 appPlayerSettings = ref.read(appSettingsProvider).playerSettings;
|
||||||
|
|
||||||
|
var configurePlayerForEveryBook =
|
||||||
|
appPlayerSettings.configurePlayerForEveryBook;
|
||||||
|
|
||||||
|
await Future.wait([
|
||||||
|
setSourceFuture ?? Future.value(),
|
||||||
|
// set the volume
|
||||||
|
player.setVolume(
|
||||||
|
configurePlayerForEveryBook
|
||||||
|
? bookPlayerSettings.preferredDefaultVolume ??
|
||||||
|
appPlayerSettings.preferredDefaultVolume
|
||||||
|
: appPlayerSettings.preferredDefaultVolume,
|
||||||
|
),
|
||||||
|
// set the speed
|
||||||
|
player.setSpeed(
|
||||||
|
configurePlayerForEveryBook
|
||||||
|
? bookPlayerSettings.preferredDefaultSpeed ??
|
||||||
|
appPlayerSettings.preferredDefaultSpeed
|
||||||
|
: appPlayerSettings.preferredDefaultSpeed,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
// toggle play/pause
|
// toggle play/pause
|
||||||
await player.play();
|
await player.play();
|
||||||
// set the volume as this is the first time playing and dismissing causes the volume to go to 0
|
|
||||||
await player.setVolume(
|
|
||||||
ref.read(appSettingsProvider).playerSettings.preferredDefaultVolume,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
17
lib/features/per_book_settings/models/book_settings.dart
Normal file
17
lib/features/per_book_settings/models/book_settings.dart
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:vaani/features/per_book_settings/models/nullable_player_settings.dart';
|
||||||
|
|
||||||
|
part 'book_settings.freezed.dart';
|
||||||
|
part 'book_settings.g.dart';
|
||||||
|
|
||||||
|
/// per book settings
|
||||||
|
@freezed
|
||||||
|
class BookSettings with _$BookSettings {
|
||||||
|
const factory BookSettings({
|
||||||
|
required String bookId,
|
||||||
|
@Default(NullablePlayerSettings()) NullablePlayerSettings playerSettings,
|
||||||
|
}) = _BookSettings;
|
||||||
|
|
||||||
|
factory BookSettings.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$BookSettingsFromJson(json);
|
||||||
|
}
|
||||||
203
lib/features/per_book_settings/models/book_settings.freezed.dart
Normal file
203
lib/features/per_book_settings/models/book_settings.freezed.dart
Normal file
|
|
@ -0,0 +1,203 @@
|
||||||
|
// coverage:ignore-file
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||||
|
|
||||||
|
part of 'book_settings.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// FreezedGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
|
final _privateConstructorUsedError = UnsupportedError(
|
||||||
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||||
|
|
||||||
|
BookSettings _$BookSettingsFromJson(Map<String, dynamic> json) {
|
||||||
|
return _BookSettings.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$BookSettings {
|
||||||
|
String get bookId => throw _privateConstructorUsedError;
|
||||||
|
NullablePlayerSettings get playerSettings =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Serializes this BookSettings to a JSON map.
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Create a copy of BookSettings
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
$BookSettingsCopyWith<BookSettings> 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});
|
||||||
|
|
||||||
|
$NullablePlayerSettingsCopyWith<$Res> get playerSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$BookSettingsCopyWithImpl<$Res, $Val extends BookSettings>
|
||||||
|
implements $BookSettingsCopyWith<$Res> {
|
||||||
|
_$BookSettingsCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @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<String, dynamic> json) =>
|
||||||
|
_$$BookSettingsImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String bookId;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final NullablePlayerSettings playerSettings;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'BookSettings(bookId: $bookId, playerSettings: $playerSettings)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@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<String, dynamic> toJson() {
|
||||||
|
return _$$BookSettingsImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _BookSettings implements BookSettings {
|
||||||
|
const factory _BookSettings(
|
||||||
|
{required final String bookId,
|
||||||
|
final NullablePlayerSettings playerSettings}) = _$BookSettingsImpl;
|
||||||
|
|
||||||
|
factory _BookSettings.fromJson(Map<String, dynamic> 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;
|
||||||
|
}
|
||||||
22
lib/features/per_book_settings/models/book_settings.g.dart
Normal file
22
lib/features/per_book_settings/models/book_settings.g.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'book_settings.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
_$BookSettingsImpl _$$BookSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$BookSettingsImpl(
|
||||||
|
bookId: json['bookId'] as String,
|
||||||
|
playerSettings: json['playerSettings'] == null
|
||||||
|
? const NullablePlayerSettings()
|
||||||
|
: NullablePlayerSettings.fromJson(
|
||||||
|
json['playerSettings'] as Map<String, dynamic>),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$BookSettingsImplToJson(_$BookSettingsImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'bookId': instance.bookId,
|
||||||
|
'playerSettings': instance.playerSettings,
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:vaani/settings/models/app_settings.dart';
|
||||||
|
|
||||||
|
part 'nullable_player_settings.freezed.dart';
|
||||||
|
part 'nullable_player_settings.g.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class NullablePlayerSettings with _$NullablePlayerSettings {
|
||||||
|
const factory NullablePlayerSettings({
|
||||||
|
MinimizedPlayerSettings? miniPlayerSettings,
|
||||||
|
ExpandedPlayerSettings? expandedPlayerSettings,
|
||||||
|
double? preferredDefaultVolume,
|
||||||
|
double? preferredDefaultSpeed,
|
||||||
|
List<double>? speedOptions,
|
||||||
|
SleepTimerSettings? sleepTimerSettings,
|
||||||
|
Duration? playbackReportInterval,
|
||||||
|
}) = _NullablePlayerSettings;
|
||||||
|
|
||||||
|
factory NullablePlayerSettings.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$NullablePlayerSettingsFromJson(json);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,377 @@
|
||||||
|
// coverage:ignore-file
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||||
|
|
||||||
|
part of 'nullable_player_settings.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// FreezedGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
|
final _privateConstructorUsedError = UnsupportedError(
|
||||||
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||||
|
|
||||||
|
NullablePlayerSettings _$NullablePlayerSettingsFromJson(
|
||||||
|
Map<String, dynamic> 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<double>? get speedOptions => throw _privateConstructorUsedError;
|
||||||
|
SleepTimerSettings? get sleepTimerSettings =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
Duration? get playbackReportInterval => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Serializes this NullablePlayerSettings to a JSON map.
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Create a copy of NullablePlayerSettings
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
$NullablePlayerSettingsCopyWith<NullablePlayerSettings> 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<double>? speedOptions,
|
||||||
|
SleepTimerSettings? sleepTimerSettings,
|
||||||
|
Duration? playbackReportInterval});
|
||||||
|
|
||||||
|
$MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings;
|
||||||
|
$ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings;
|
||||||
|
$SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$NullablePlayerSettingsCopyWithImpl<$Res,
|
||||||
|
$Val extends NullablePlayerSettings>
|
||||||
|
implements $NullablePlayerSettingsCopyWith<$Res> {
|
||||||
|
_$NullablePlayerSettingsCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _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<double>?,
|
||||||
|
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.
|
||||||
|
@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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @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<double>? speedOptions,
|
||||||
|
SleepTimerSettings? sleepTimerSettings,
|
||||||
|
Duration? playbackReportInterval});
|
||||||
|
|
||||||
|
@override
|
||||||
|
$MinimizedPlayerSettingsCopyWith<$Res>? get miniPlayerSettings;
|
||||||
|
@override
|
||||||
|
$ExpandedPlayerSettingsCopyWith<$Res>? get expandedPlayerSettings;
|
||||||
|
@override
|
||||||
|
$SleepTimerSettingsCopyWith<$Res>? get sleepTimerSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @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<double>?,
|
||||||
|
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<double>? speedOptions,
|
||||||
|
this.sleepTimerSettings,
|
||||||
|
this.playbackReportInterval})
|
||||||
|
: _speedOptions = speedOptions;
|
||||||
|
|
||||||
|
factory _$NullablePlayerSettingsImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$NullablePlayerSettingsImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final MinimizedPlayerSettings? miniPlayerSettings;
|
||||||
|
@override
|
||||||
|
final ExpandedPlayerSettings? expandedPlayerSettings;
|
||||||
|
@override
|
||||||
|
final double? preferredDefaultVolume;
|
||||||
|
@override
|
||||||
|
final double? preferredDefaultSpeed;
|
||||||
|
final List<double>? _speedOptions;
|
||||||
|
@override
|
||||||
|
List<double>? 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<String, dynamic> toJson() {
|
||||||
|
return _$$NullablePlayerSettingsImplToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _NullablePlayerSettings implements NullablePlayerSettings {
|
||||||
|
const factory _NullablePlayerSettings(
|
||||||
|
{final MinimizedPlayerSettings? miniPlayerSettings,
|
||||||
|
final ExpandedPlayerSettings? expandedPlayerSettings,
|
||||||
|
final double? preferredDefaultVolume,
|
||||||
|
final double? preferredDefaultSpeed,
|
||||||
|
final List<double>? speedOptions,
|
||||||
|
final SleepTimerSettings? sleepTimerSettings,
|
||||||
|
final Duration? playbackReportInterval}) = _$NullablePlayerSettingsImpl;
|
||||||
|
|
||||||
|
factory _NullablePlayerSettings.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$NullablePlayerSettingsImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
MinimizedPlayerSettings? get miniPlayerSettings;
|
||||||
|
@override
|
||||||
|
ExpandedPlayerSettings? get expandedPlayerSettings;
|
||||||
|
@override
|
||||||
|
double? get preferredDefaultVolume;
|
||||||
|
@override
|
||||||
|
double? get preferredDefaultSpeed;
|
||||||
|
@override
|
||||||
|
List<double>? 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;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'nullable_player_settings.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
_$NullablePlayerSettingsImpl _$$NullablePlayerSettingsImplFromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
_$NullablePlayerSettingsImpl(
|
||||||
|
miniPlayerSettings: json['miniPlayerSettings'] == null
|
||||||
|
? null
|
||||||
|
: MinimizedPlayerSettings.fromJson(
|
||||||
|
json['miniPlayerSettings'] as Map<String, dynamic>),
|
||||||
|
expandedPlayerSettings: json['expandedPlayerSettings'] == null
|
||||||
|
? null
|
||||||
|
: ExpandedPlayerSettings.fromJson(
|
||||||
|
json['expandedPlayerSettings'] as Map<String, dynamic>),
|
||||||
|
preferredDefaultVolume:
|
||||||
|
(json['preferredDefaultVolume'] as num?)?.toDouble(),
|
||||||
|
preferredDefaultSpeed:
|
||||||
|
(json['preferredDefaultSpeed'] as num?)?.toDouble(),
|
||||||
|
speedOptions: (json['speedOptions'] as List<dynamic>?)
|
||||||
|
?.map((e) => (e as num).toDouble())
|
||||||
|
.toList(),
|
||||||
|
sleepTimerSettings: json['sleepTimerSettings'] == null
|
||||||
|
? null
|
||||||
|
: SleepTimerSettings.fromJson(
|
||||||
|
json['sleepTimerSettings'] as Map<String, dynamic>),
|
||||||
|
playbackReportInterval: json['playbackReportInterval'] == null
|
||||||
|
? null
|
||||||
|
: Duration(
|
||||||
|
microseconds: (json['playbackReportInterval'] as num).toInt()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$NullablePlayerSettingsImplToJson(
|
||||||
|
_$NullablePlayerSettingsImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'miniPlayerSettings': instance.miniPlayerSettings,
|
||||||
|
'expandedPlayerSettings': instance.expandedPlayerSettings,
|
||||||
|
'preferredDefaultVolume': instance.preferredDefaultVolume,
|
||||||
|
'preferredDefaultSpeed': instance.preferredDefaultSpeed,
|
||||||
|
'speedOptions': instance.speedOptions,
|
||||||
|
'sleepTimerSettings': instance.sleepTimerSettings,
|
||||||
|
'playbackReportInterval': instance.playbackReportInterval?.inMicroseconds,
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:vaani/db/available_boxes.dart';
|
||||||
|
import 'package:vaani/features/per_book_settings/models/book_settings.dart'
|
||||||
|
as model;
|
||||||
|
import 'package:vaani/features/per_book_settings/models/nullable_player_settings.dart';
|
||||||
|
|
||||||
|
part 'book_settings_provider.g.dart';
|
||||||
|
|
||||||
|
final _box = AvailableHiveBoxes.individualBookSettingsBox;
|
||||||
|
|
||||||
|
final _logger = Logger('BookSettingsProvider');
|
||||||
|
|
||||||
|
model.BookSettings readFromBoxOrCreate(String bookId) {
|
||||||
|
final foundSettings = _box.get(bookId);
|
||||||
|
if (foundSettings != null) {
|
||||||
|
_logger.fine('found book settings for $bookId in box: $foundSettings');
|
||||||
|
return foundSettings;
|
||||||
|
} else {
|
||||||
|
// create a new settings object
|
||||||
|
final settings = model.BookSettings(
|
||||||
|
bookId: bookId,
|
||||||
|
playerSettings: const NullablePlayerSettings(),
|
||||||
|
);
|
||||||
|
_logger.fine('created new book settings for $bookId: $settings');
|
||||||
|
writeToBox(settings);
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeToBox(model.BookSettings newSettings) {
|
||||||
|
_box.put(newSettings.bookId, newSettings);
|
||||||
|
_logger.fine(
|
||||||
|
'wrote book settings for ${newSettings.bookId} to box: $newSettings',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateState(model.BookSettings newSettings, {bool force = false}) {
|
||||||
|
// check if the settings are different
|
||||||
|
final foundSettings = _box.get(newSettings.bookId);
|
||||||
|
if (foundSettings == newSettings && !force) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
writeToBox(newSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
class BookSettings extends _$BookSettings {
|
||||||
|
@override
|
||||||
|
model.BookSettings build(String bookId) {
|
||||||
|
return readFromBoxOrCreate(bookId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(model.BookSettings newSettings, {bool force = false}) {
|
||||||
|
updateState(newSettings, force: force);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,174 @@
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'book_settings_provider.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$bookSettingsHash() => r'b976df954edf98ec6ccb3eb41e9d07dd4a9193eb';
|
||||||
|
|
||||||
|
/// 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<model.BookSettings> {
|
||||||
|
late final String bookId;
|
||||||
|
|
||||||
|
model.BookSettings build(
|
||||||
|
String bookId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [BookSettings].
|
||||||
|
@ProviderFor(BookSettings)
|
||||||
|
const bookSettingsProvider = BookSettingsFamily();
|
||||||
|
|
||||||
|
/// See also [BookSettings].
|
||||||
|
class BookSettingsFamily extends Family<model.BookSettings> {
|
||||||
|
/// See also [BookSettings].
|
||||||
|
const BookSettingsFamily();
|
||||||
|
|
||||||
|
/// See also [BookSettings].
|
||||||
|
BookSettingsProvider call(
|
||||||
|
String bookId,
|
||||||
|
) {
|
||||||
|
return BookSettingsProvider(
|
||||||
|
bookId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
BookSettingsProvider getProviderOverride(
|
||||||
|
covariant BookSettingsProvider provider,
|
||||||
|
) {
|
||||||
|
return call(
|
||||||
|
provider.bookId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'bookSettingsProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [BookSettings].
|
||||||
|
class BookSettingsProvider
|
||||||
|
extends AutoDisposeNotifierProviderImpl<BookSettings, model.BookSettings> {
|
||||||
|
/// 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(
|
||||||
|
origin: this,
|
||||||
|
override: BookSettingsProvider._internal(
|
||||||
|
() => create()..bookId = bookId,
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
bookId: bookId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeNotifierProviderElement<BookSettings, model.BookSettings>
|
||||||
|
createElement() {
|
||||||
|
return _BookSettingsProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is BookSettingsProvider && other.bookId == bookId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, bookId.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mixin BookSettingsRef on AutoDisposeNotifierProviderRef<model.BookSettings> {
|
||||||
|
/// The parameter `bookId` of this provider.
|
||||||
|
String get bookId;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BookSettingsProviderElement
|
||||||
|
extends AutoDisposeNotifierProviderElement<BookSettings, model.BookSettings>
|
||||||
|
with BookSettingsRef {
|
||||||
|
_BookSettingsProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get bookId => (origin as BookSettingsProvider).bookId;
|
||||||
|
}
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:vaani/features/per_book_settings/providers/book_settings_provider.dart';
|
||||||
import 'package:vaani/features/player/providers/audiobook_player.dart';
|
import 'package:vaani/features/player/providers/audiobook_player.dart';
|
||||||
import 'package:vaani/features/player/view/player_when_expanded.dart';
|
import 'package:vaani/features/player/view/player_when_expanded.dart';
|
||||||
import 'package:vaani/features/player/view/widgets/speed_selector.dart';
|
import 'package:vaani/features/player/view/widgets/speed_selector.dart';
|
||||||
|
import 'package:vaani/settings/app_settings_provider.dart';
|
||||||
|
|
||||||
final _logger = Logger('PlayerSpeedAdjustButton');
|
final _logger = Logger('PlayerSpeedAdjustButton');
|
||||||
|
|
||||||
|
|
@ -15,6 +17,9 @@ class PlayerSpeedAdjustButton extends HookConsumerWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final player = ref.watch(audiobookPlayerProvider);
|
final player = ref.watch(audiobookPlayerProvider);
|
||||||
|
final bookId = player.book?.libraryItemId ?? '_';
|
||||||
|
final bookSettings = ref.watch(bookSettingsProvider(bookId));
|
||||||
|
final appSettings = ref.watch(appSettingsProvider);
|
||||||
final notifier = ref.watch(audiobookPlayerProvider.notifier);
|
final notifier = ref.watch(audiobookPlayerProvider.notifier);
|
||||||
return TextButton(
|
return TextButton(
|
||||||
child: Text('${player.speed}x'),
|
child: Text('${player.speed}x'),
|
||||||
|
|
@ -31,6 +36,25 @@ class PlayerSpeedAdjustButton extends HookConsumerWidget {
|
||||||
return SpeedSelector(
|
return SpeedSelector(
|
||||||
onSpeedSelected: (speed) {
|
onSpeedSelected: (speed) {
|
||||||
notifier.setSpeed(speed);
|
notifier.setSpeed(speed);
|
||||||
|
if (appSettings.playerSettings.configurePlayerForEveryBook) {
|
||||||
|
ref
|
||||||
|
.read(
|
||||||
|
bookSettingsProvider(bookId).notifier,
|
||||||
|
)
|
||||||
|
.update(
|
||||||
|
bookSettings.copyWith
|
||||||
|
.playerSettings(preferredDefaultSpeed: speed),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ref
|
||||||
|
.read(
|
||||||
|
appSettingsProvider.notifier,
|
||||||
|
)
|
||||||
|
.update(
|
||||||
|
appSettings.copyWith
|
||||||
|
.playerSettings(preferredDefaultSpeed: speed),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class AppSettings extends _$AppSettings {
|
||||||
.themeSettings(isDarkMode: !state.themeSettings.isDarkMode);
|
.themeSettings(isDarkMode: !state.themeSettings.isDarkMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateState(model.AppSettings newSettings) {
|
void update(model.AppSettings newSettings) {
|
||||||
state = newSettings;
|
state = newSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ part of 'app_settings_provider.dart';
|
||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$appSettingsHash() => r'ab8fa4602242704a71b34dc2bb5dcb0c91092797';
|
String _$appSettingsHash() => r'e0e132b782b97f11d9791d4f1e45bf4ee67dd99b';
|
||||||
|
|
||||||
/// See also [AppSettings].
|
/// See also [AppSettings].
|
||||||
@ProviderFor(AppSettings)
|
@ProviderFor(AppSettings)
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ class PlayerSettings with _$PlayerSettings {
|
||||||
@Default([0.75, 1, 1.25, 1.5, 1.75, 2]) List<double> speedOptions,
|
@Default([0.75, 1, 1.25, 1.5, 1.75, 2]) List<double> speedOptions,
|
||||||
@Default(SleepTimerSettings()) SleepTimerSettings sleepTimerSettings,
|
@Default(SleepTimerSettings()) SleepTimerSettings sleepTimerSettings,
|
||||||
@Default(Duration(seconds: 10)) Duration playbackReportInterval,
|
@Default(Duration(seconds: 10)) Duration playbackReportInterval,
|
||||||
|
@Default(true) bool configurePlayerForEveryBook,
|
||||||
}) = _PlayerSettings;
|
}) = _PlayerSettings;
|
||||||
|
|
||||||
factory PlayerSettings.fromJson(Map<String, dynamic> json) =>
|
factory PlayerSettings.fromJson(Map<String, dynamic> json) =>
|
||||||
|
|
|
||||||
|
|
@ -478,6 +478,7 @@ mixin _$PlayerSettings {
|
||||||
SleepTimerSettings get sleepTimerSettings =>
|
SleepTimerSettings get sleepTimerSettings =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
Duration get playbackReportInterval => throw _privateConstructorUsedError;
|
Duration get playbackReportInterval => throw _privateConstructorUsedError;
|
||||||
|
bool get configurePlayerForEveryBook => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Serializes this PlayerSettings to a JSON map.
|
/// Serializes this PlayerSettings to a JSON map.
|
||||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
|
@ -502,7 +503,8 @@ abstract class $PlayerSettingsCopyWith<$Res> {
|
||||||
double preferredDefaultSpeed,
|
double preferredDefaultSpeed,
|
||||||
List<double> speedOptions,
|
List<double> speedOptions,
|
||||||
SleepTimerSettings sleepTimerSettings,
|
SleepTimerSettings sleepTimerSettings,
|
||||||
Duration playbackReportInterval});
|
Duration playbackReportInterval,
|
||||||
|
bool configurePlayerForEveryBook});
|
||||||
|
|
||||||
$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;
|
$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;
|
||||||
$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings;
|
$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings;
|
||||||
|
|
@ -531,6 +533,7 @@ class _$PlayerSettingsCopyWithImpl<$Res, $Val extends PlayerSettings>
|
||||||
Object? speedOptions = null,
|
Object? speedOptions = null,
|
||||||
Object? sleepTimerSettings = null,
|
Object? sleepTimerSettings = null,
|
||||||
Object? playbackReportInterval = null,
|
Object? playbackReportInterval = null,
|
||||||
|
Object? configurePlayerForEveryBook = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
miniPlayerSettings: null == miniPlayerSettings
|
miniPlayerSettings: null == miniPlayerSettings
|
||||||
|
|
@ -561,6 +564,10 @@ class _$PlayerSettingsCopyWithImpl<$Res, $Val extends PlayerSettings>
|
||||||
? _value.playbackReportInterval
|
? _value.playbackReportInterval
|
||||||
: playbackReportInterval // ignore: cast_nullable_to_non_nullable
|
: playbackReportInterval // ignore: cast_nullable_to_non_nullable
|
||||||
as Duration,
|
as Duration,
|
||||||
|
configurePlayerForEveryBook: null == configurePlayerForEveryBook
|
||||||
|
? _value.configurePlayerForEveryBook
|
||||||
|
: configurePlayerForEveryBook // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
) as $Val);
|
) as $Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -613,7 +620,8 @@ abstract class _$$PlayerSettingsImplCopyWith<$Res>
|
||||||
double preferredDefaultSpeed,
|
double preferredDefaultSpeed,
|
||||||
List<double> speedOptions,
|
List<double> speedOptions,
|
||||||
SleepTimerSettings sleepTimerSettings,
|
SleepTimerSettings sleepTimerSettings,
|
||||||
Duration playbackReportInterval});
|
Duration playbackReportInterval,
|
||||||
|
bool configurePlayerForEveryBook});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;
|
$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;
|
||||||
|
|
@ -643,6 +651,7 @@ class __$$PlayerSettingsImplCopyWithImpl<$Res>
|
||||||
Object? speedOptions = null,
|
Object? speedOptions = null,
|
||||||
Object? sleepTimerSettings = null,
|
Object? sleepTimerSettings = null,
|
||||||
Object? playbackReportInterval = null,
|
Object? playbackReportInterval = null,
|
||||||
|
Object? configurePlayerForEveryBook = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$PlayerSettingsImpl(
|
return _then(_$PlayerSettingsImpl(
|
||||||
miniPlayerSettings: null == miniPlayerSettings
|
miniPlayerSettings: null == miniPlayerSettings
|
||||||
|
|
@ -673,6 +682,10 @@ class __$$PlayerSettingsImplCopyWithImpl<$Res>
|
||||||
? _value.playbackReportInterval
|
? _value.playbackReportInterval
|
||||||
: playbackReportInterval // ignore: cast_nullable_to_non_nullable
|
: playbackReportInterval // ignore: cast_nullable_to_non_nullable
|
||||||
as Duration,
|
as Duration,
|
||||||
|
configurePlayerForEveryBook: null == configurePlayerForEveryBook
|
||||||
|
? _value.configurePlayerForEveryBook
|
||||||
|
: configurePlayerForEveryBook // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -687,7 +700,8 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
this.preferredDefaultSpeed = 1,
|
this.preferredDefaultSpeed = 1,
|
||||||
final List<double> speedOptions = const [0.75, 1, 1.25, 1.5, 1.75, 2],
|
final List<double> speedOptions = const [0.75, 1, 1.25, 1.5, 1.75, 2],
|
||||||
this.sleepTimerSettings = const SleepTimerSettings(),
|
this.sleepTimerSettings = const SleepTimerSettings(),
|
||||||
this.playbackReportInterval = const Duration(seconds: 10)})
|
this.playbackReportInterval = const Duration(seconds: 10),
|
||||||
|
this.configurePlayerForEveryBook = true})
|
||||||
: _speedOptions = speedOptions;
|
: _speedOptions = speedOptions;
|
||||||
|
|
||||||
factory _$PlayerSettingsImpl.fromJson(Map<String, dynamic> json) =>
|
factory _$PlayerSettingsImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
|
@ -720,10 +734,13 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
final Duration playbackReportInterval;
|
final Duration playbackReportInterval;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool configurePlayerForEveryBook;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'PlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, sleepTimerSettings: $sleepTimerSettings, playbackReportInterval: $playbackReportInterval)';
|
return 'PlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, sleepTimerSettings: $sleepTimerSettings, playbackReportInterval: $playbackReportInterval, configurePlayerForEveryBook: $configurePlayerForEveryBook)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -744,7 +761,11 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
(identical(other.sleepTimerSettings, sleepTimerSettings) ||
|
(identical(other.sleepTimerSettings, sleepTimerSettings) ||
|
||||||
other.sleepTimerSettings == sleepTimerSettings) &&
|
other.sleepTimerSettings == sleepTimerSettings) &&
|
||||||
(identical(other.playbackReportInterval, playbackReportInterval) ||
|
(identical(other.playbackReportInterval, playbackReportInterval) ||
|
||||||
other.playbackReportInterval == playbackReportInterval));
|
other.playbackReportInterval == playbackReportInterval) &&
|
||||||
|
(identical(other.configurePlayerForEveryBook,
|
||||||
|
configurePlayerForEveryBook) ||
|
||||||
|
other.configurePlayerForEveryBook ==
|
||||||
|
configurePlayerForEveryBook));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
|
@ -757,7 +778,8 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
preferredDefaultSpeed,
|
preferredDefaultSpeed,
|
||||||
const DeepCollectionEquality().hash(_speedOptions),
|
const DeepCollectionEquality().hash(_speedOptions),
|
||||||
sleepTimerSettings,
|
sleepTimerSettings,
|
||||||
playbackReportInterval);
|
playbackReportInterval,
|
||||||
|
configurePlayerForEveryBook);
|
||||||
|
|
||||||
/// Create a copy of PlayerSettings
|
/// Create a copy of PlayerSettings
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
|
@ -784,7 +806,8 @@ abstract class _PlayerSettings implements PlayerSettings {
|
||||||
final double preferredDefaultSpeed,
|
final double preferredDefaultSpeed,
|
||||||
final List<double> speedOptions,
|
final List<double> speedOptions,
|
||||||
final SleepTimerSettings sleepTimerSettings,
|
final SleepTimerSettings sleepTimerSettings,
|
||||||
final Duration playbackReportInterval}) = _$PlayerSettingsImpl;
|
final Duration playbackReportInterval,
|
||||||
|
final bool configurePlayerForEveryBook}) = _$PlayerSettingsImpl;
|
||||||
|
|
||||||
factory _PlayerSettings.fromJson(Map<String, dynamic> json) =
|
factory _PlayerSettings.fromJson(Map<String, dynamic> json) =
|
||||||
_$PlayerSettingsImpl.fromJson;
|
_$PlayerSettingsImpl.fromJson;
|
||||||
|
|
@ -803,6 +826,8 @@ abstract class _PlayerSettings implements PlayerSettings {
|
||||||
SleepTimerSettings get sleepTimerSettings;
|
SleepTimerSettings get sleepTimerSettings;
|
||||||
@override
|
@override
|
||||||
Duration get playbackReportInterval;
|
Duration get playbackReportInterval;
|
||||||
|
@override
|
||||||
|
bool get configurePlayerForEveryBook;
|
||||||
|
|
||||||
/// Create a copy of PlayerSettings
|
/// Create a copy of PlayerSettings
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ _$PlayerSettingsImpl _$$PlayerSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||||
? const Duration(seconds: 10)
|
? const Duration(seconds: 10)
|
||||||
: Duration(
|
: Duration(
|
||||||
microseconds: (json['playbackReportInterval'] as num).toInt()),
|
microseconds: (json['playbackReportInterval'] as num).toInt()),
|
||||||
|
configurePlayerForEveryBook:
|
||||||
|
json['configurePlayerForEveryBook'] as bool? ?? true,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$$PlayerSettingsImplToJson(
|
Map<String, dynamic> _$$PlayerSettingsImplToJson(
|
||||||
|
|
@ -84,6 +86,7 @@ Map<String, dynamic> _$$PlayerSettingsImplToJson(
|
||||||
'speedOptions': instance.speedOptions,
|
'speedOptions': instance.speedOptions,
|
||||||
'sleepTimerSettings': instance.sleepTimerSettings,
|
'sleepTimerSettings': instance.sleepTimerSettings,
|
||||||
'playbackReportInterval': instance.playbackReportInterval.inMicroseconds,
|
'playbackReportInterval': instance.playbackReportInterval.inMicroseconds,
|
||||||
|
'configurePlayerForEveryBook': instance.configurePlayerForEveryBook,
|
||||||
};
|
};
|
||||||
|
|
||||||
_$ExpandedPlayerSettingsImpl _$$ExpandedPlayerSettingsImplFromJson(
|
_$ExpandedPlayerSettingsImpl _$$ExpandedPlayerSettingsImplFromJson(
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class AppSettingsPage extends HookConsumerWidget {
|
||||||
? const Icon(Icons.auto_fix_high)
|
? const Icon(Icons.auto_fix_high)
|
||||||
: const Icon(Icons.auto_fix_off),
|
: const Icon(Icons.auto_fix_off),
|
||||||
onToggle: (value) {
|
onToggle: (value) {
|
||||||
ref.read(appSettingsProvider.notifier).updateState(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.themeSettings(
|
appSettings.copyWith.themeSettings(
|
||||||
useMaterialThemeOnItemPage: value,
|
useMaterialThemeOnItemPage: value,
|
||||||
),
|
),
|
||||||
|
|
@ -114,7 +114,7 @@ class AppSettingsPage extends HookConsumerWidget {
|
||||||
Switch(
|
Switch(
|
||||||
value: sleepTimerSettings.autoTurnOnTimer,
|
value: sleepTimerSettings.autoTurnOnTimer,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
ref.read(appSettingsProvider.notifier).updateState(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.playerSettings
|
appSettings.copyWith.playerSettings
|
||||||
.sleepTimerSettings(
|
.sleepTimerSettings(
|
||||||
autoTurnOnTimer: value,
|
autoTurnOnTimer: value,
|
||||||
|
|
@ -208,7 +208,7 @@ class AppSettingsPage extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
ref
|
ref
|
||||||
.read(appSettingsProvider.notifier)
|
.read(appSettingsProvider.notifier)
|
||||||
.updateState(newSettings);
|
.update(newSettings);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget {
|
||||||
? const Icon(Icons.timer)
|
? const Icon(Icons.timer)
|
||||||
: const Icon(Icons.timer_off),
|
: const Icon(Icons.timer_off),
|
||||||
onToggle: (value) {
|
onToggle: (value) {
|
||||||
ref.read(appSettingsProvider.notifier).updateState(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.playerSettings.sleepTimerSettings(
|
appSettings.copyWith.playerSettings.sleepTimerSettings(
|
||||||
autoTurnOnTimer: value,
|
autoTurnOnTimer: value,
|
||||||
),
|
),
|
||||||
|
|
@ -59,7 +59,7 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget {
|
||||||
sleepTimerSettings.autoTurnOnTime.toTimeOfDay(),
|
sleepTimerSettings.autoTurnOnTime.toTimeOfDay(),
|
||||||
);
|
);
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
ref.read(appSettingsProvider.notifier).updateState(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.playerSettings
|
appSettings.copyWith.playerSettings
|
||||||
.sleepTimerSettings(
|
.sleepTimerSettings(
|
||||||
autoTurnOnTime: selected.toDuration(),
|
autoTurnOnTime: selected.toDuration(),
|
||||||
|
|
@ -87,7 +87,7 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget {
|
||||||
sleepTimerSettings.autoTurnOffTime.toTimeOfDay(),
|
sleepTimerSettings.autoTurnOffTime.toTimeOfDay(),
|
||||||
);
|
);
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
ref.read(appSettingsProvider.notifier).updateState(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.playerSettings
|
appSettings.copyWith.playerSettings
|
||||||
.sleepTimerSettings(
|
.sleepTimerSettings(
|
||||||
autoTurnOffTime: selected.toDuration(),
|
autoTurnOffTime: selected.toDuration(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue