mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
aaa
This commit is contained in:
parent
a737365f26
commit
3c3c381f8a
18 changed files with 1266 additions and 1000 deletions
|
|
@ -51,7 +51,7 @@ class PlayerSettings with _$PlayerSettings {
|
|||
ExpandedPlayerSettings expandedPlayerSettings,
|
||||
@Default(1) double preferredDefaultVolume,
|
||||
@Default(1) double preferredDefaultSpeed,
|
||||
@Default([1, 1.25, 1.5, 1.75, 2]) List<double> speedOptions,
|
||||
@Default([0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]) List<double> speedOptions,
|
||||
@Default(0.05) double speedIncrement,
|
||||
@Default(0.1) double minSpeed,
|
||||
@Default(4) double maxSpeed,
|
||||
|
|
|
|||
|
|
@ -986,7 +986,15 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
|||
this.expandedPlayerSettings = const ExpandedPlayerSettings(),
|
||||
this.preferredDefaultVolume = 1,
|
||||
this.preferredDefaultSpeed = 1,
|
||||
final List<double> speedOptions = const [1, 1.25, 1.5, 1.75, 2],
|
||||
final List<double> speedOptions = const [
|
||||
0.5,
|
||||
0.75,
|
||||
1,
|
||||
1.25,
|
||||
1.5,
|
||||
1.75,
|
||||
2
|
||||
],
|
||||
this.speedIncrement = 0.05,
|
||||
this.minSpeed = 0.1,
|
||||
this.maxSpeed = 4,
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ _$PlayerSettingsImpl _$$PlayerSettingsImplFromJson(Map<String, dynamic> json) =>
|
|||
speedOptions: (json['speedOptions'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toDouble())
|
||||
.toList() ??
|
||||
const [1, 1.25, 1.5, 1.75, 2],
|
||||
const [0.5, 0.75, 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,
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
|||
import 'package:flutter_settings_ui/flutter_settings_ui.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:vaani/generated/l10n.dart';
|
||||
import 'package:vaani/router/router.dart';
|
||||
import 'package:vaani/features/settings/app_settings_provider.dart';
|
||||
import 'package:vaani/features/settings/models/app_settings.dart' as model;
|
||||
import 'package:vaani/features/settings/view/buttons.dart';
|
||||
import 'package:vaani/features/settings/view/simple_settings_page.dart';
|
||||
import 'package:vaani/features/settings/view/widgets/navigation_with_switch_tile.dart';
|
||||
import 'package:vaani/generated/l10n.dart';
|
||||
import 'package:vaani/router/router.dart';
|
||||
import 'package:vaani/shared/widgets/custom_dropdown.dart';
|
||||
|
||||
class AppSettingsPage extends HookConsumerWidget {
|
||||
const AppSettingsPage({
|
||||
|
|
@ -40,22 +41,35 @@ class AppSettingsPage extends HookConsumerWidget {
|
|||
SettingsTile(
|
||||
title: Text(S.of(context).language),
|
||||
leading: const Icon(Icons.language),
|
||||
trailing: DropdownButton(
|
||||
value: appSettings.language,
|
||||
items: S.delegate.supportedLocales.map((locale) {
|
||||
return DropdownMenuItem(
|
||||
value: locale.languageCode,
|
||||
child: Text(locales[locale.languageCode] ?? 'unknown'),
|
||||
);
|
||||
trailing: CustomDropdown<String>(
|
||||
selected: appSettings.language,
|
||||
items: (f, cs) => S.delegate.supportedLocales.map((locale) {
|
||||
return locale.languageCode;
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
ref.read(appSettingsProvider.notifier).update(
|
||||
appSettings.copyWith(
|
||||
language: value!,
|
||||
itemAsString: (item) => locales[item] ?? 'unknown',
|
||||
onChanged: (value) async =>
|
||||
ref.read(appSettingsProvider.notifier).update(
|
||||
appSettings.copyWith(
|
||||
language: value!,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
// trailing: DropdownButton(
|
||||
// value: appSettings.language,
|
||||
// items: S.delegate.supportedLocales.map((locale) {
|
||||
// return DropdownMenuItem(
|
||||
// value: locale.languageCode,
|
||||
// child: Text(locales[locale.languageCode] ?? 'unknown'),
|
||||
// );
|
||||
// }).toList(),
|
||||
// onChanged: (value) {
|
||||
// ref.read(appSettingsProvider.notifier).update(
|
||||
// appSettings.copyWith(
|
||||
// language: value!,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
description: Text(S.of(context).languageDescription),
|
||||
),
|
||||
SettingsTile(
|
||||
|
|
@ -67,9 +81,9 @@ class AppSettingsPage extends HookConsumerWidget {
|
|||
},
|
||||
),
|
||||
SettingsTile(
|
||||
title: Text('下载设置'),
|
||||
title: Text(S.of(context).downloadSettings),
|
||||
leading: const Icon(Icons.download),
|
||||
description: Text('自定义下载设置'),
|
||||
description: Text(S.of(context).downloadSettingsDescription),
|
||||
onPressed: (context) {
|
||||
context.pushNamed(Routes.downloadSettings.name);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:flutter_settings_ui/flutter_settings_ui.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:vaani/constants/sizes.dart';
|
||||
import 'package:vaani/generated/l10n.dart';
|
||||
import 'package:vaani/features/settings/app_settings_provider.dart';
|
||||
import 'package:vaani/features/settings/view/buttons.dart';
|
||||
import 'package:vaani/features/settings/view/simple_settings_page.dart';
|
||||
import 'package:vaani/shared/extensions/duration_format.dart';
|
||||
import 'package:vaani/shared/widgets/custom_dropdown.dart';
|
||||
|
||||
class PlayerSettingsPage extends HookConsumerWidget {
|
||||
const PlayerSettingsPage({
|
||||
|
|
@ -25,8 +27,8 @@ class PlayerSettingsPage extends HookConsumerWidget {
|
|||
sections: [
|
||||
SettingsSection(
|
||||
margin: const EdgeInsetsDirectional.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 8.0,
|
||||
horizontal: AppElementSizes.paddingLarge,
|
||||
vertical: AppElementSizes.paddingRegular,
|
||||
),
|
||||
tiles: [
|
||||
// preferred settings for every book
|
||||
|
|
@ -49,27 +51,26 @@ class PlayerSettingsPage extends HookConsumerWidget {
|
|||
// preferred default speed
|
||||
SettingsTile(
|
||||
title: Text(S.of(context).playerSettingsSpeedDefault),
|
||||
trailing: Text(
|
||||
'${playerSettings.preferredDefaultSpeed}x',
|
||||
style:
|
||||
TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// trailing: Text(
|
||||
// '${playerSettings.preferredDefaultSpeed}x',
|
||||
// style:
|
||||
// TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
trailing: CustomDropdown<double>(
|
||||
selected: playerSettings.preferredDefaultSpeed,
|
||||
items: (f, cs) => playerSettings.speedOptions,
|
||||
itemAsString: (item) => '${item}x',
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref.read(appSettingsProvider.notifier).update(
|
||||
appSettings.copyWith.playerSettings(
|
||||
preferredDefaultSpeed: value,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
leading: const Icon(Icons.speed),
|
||||
onPressed: (context) async {
|
||||
final newSpeed = await showDialog(
|
||||
context: context,
|
||||
builder: (context) => SpeedPicker(
|
||||
initialValue: playerSettings.preferredDefaultSpeed,
|
||||
),
|
||||
);
|
||||
if (newSpeed != null) {
|
||||
ref.read(appSettingsProvider.notifier).update(
|
||||
appSettings.copyWith.playerSettings(
|
||||
preferredDefaultSpeed: newSpeed,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
// preferred speed options
|
||||
SettingsTile(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue