mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
添加语言切换
This commit is contained in:
parent
e0deb84123
commit
e06c834d0e
21 changed files with 1416 additions and 281 deletions
|
|
@ -12,18 +12,17 @@ part 'app_settings.g.dart';
|
|||
@freezed
|
||||
class AppSettings with _$AppSettings {
|
||||
const factory AppSettings({
|
||||
@Default('zh') String language,
|
||||
@Default(ThemeSettings()) ThemeSettings themeSettings,
|
||||
@Default(PlayerSettings()) PlayerSettings playerSettings,
|
||||
@Default(SleepTimerSettings()) SleepTimerSettings sleepTimerSettings,
|
||||
@Default(DownloadSettings()) DownloadSettings downloadSettings,
|
||||
@Default(NotificationSettings()) NotificationSettings notificationSettings,
|
||||
@Default(ShakeDetectionSettings())
|
||||
ShakeDetectionSettings shakeDetectionSettings,
|
||||
@Default(ShakeDetectionSettings()) ShakeDetectionSettings shakeDetectionSettings,
|
||||
@Default(HomePageSettings()) HomePageSettings homePageSettings,
|
||||
}) = _AppSettings;
|
||||
|
||||
factory AppSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$AppSettingsFromJson(json);
|
||||
factory AppSettings.fromJson(Map<String, dynamic> json) => _$AppSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
|
@ -37,17 +36,14 @@ class ThemeSettings with _$ThemeSettings {
|
|||
@Default(true) bool useCurrentPlayerThemeThroughoutApp,
|
||||
}) = _ThemeSettings;
|
||||
|
||||
factory ThemeSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$ThemeSettingsFromJson(json);
|
||||
factory ThemeSettings.fromJson(Map<String, dynamic> json) => _$ThemeSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PlayerSettings with _$PlayerSettings {
|
||||
const factory PlayerSettings({
|
||||
@Default(MinimizedPlayerSettings())
|
||||
MinimizedPlayerSettings miniPlayerSettings,
|
||||
@Default(ExpandedPlayerSettings())
|
||||
ExpandedPlayerSettings expandedPlayerSettings,
|
||||
@Default(MinimizedPlayerSettings()) MinimizedPlayerSettings miniPlayerSettings,
|
||||
@Default(ExpandedPlayerSettings()) ExpandedPlayerSettings expandedPlayerSettings,
|
||||
@Default(1) double preferredDefaultVolume,
|
||||
@Default(1) double preferredDefaultSpeed,
|
||||
@Default([1, 1.25, 1.5, 1.75, 2]) List<double> speedOptions,
|
||||
|
|
@ -60,8 +56,7 @@ class PlayerSettings with _$PlayerSettings {
|
|||
@Default(true) bool configurePlayerForEveryBook,
|
||||
}) = _PlayerSettings;
|
||||
|
||||
factory PlayerSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$PlayerSettingsFromJson(json);
|
||||
factory PlayerSettings.fromJson(Map<String, dynamic> json) => _$PlayerSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
|
@ -144,8 +139,7 @@ class DownloadSettings with _$DownloadSettings {
|
|||
@Default(3) int maxConcurrentByGroup,
|
||||
}) = _DownloadSettings;
|
||||
|
||||
factory DownloadSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$DownloadSettingsFromJson(json);
|
||||
factory DownloadSettings.fromJson(Map<String, dynamic> json) => _$DownloadSettingsFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
|
@ -202,8 +196,7 @@ class ShakeDetectionSettings with _$ShakeDetectionSettings {
|
|||
@Default(ShakeDirection.horizontal) ShakeDirection direction,
|
||||
@Default(5) double threshold,
|
||||
@Default(ShakeAction.resetSleepTimer) ShakeAction shakeAction,
|
||||
@Default({ShakeDetectedFeedback.vibrate})
|
||||
Set<ShakeDetectedFeedback> feedback,
|
||||
@Default({ShakeDetectedFeedback.vibrate}) Set<ShakeDetectedFeedback> feedback,
|
||||
@Default(0.5) double beepVolume,
|
||||
|
||||
/// the duration to wait before the shake detection is enabled again
|
||||
|
|
@ -241,6 +234,5 @@ class HomePageSettings with _$HomePageSettings {
|
|||
@Default(false) bool showPlayButtonOnListenAgainShelf,
|
||||
}) = _HomePageSettings;
|
||||
|
||||
factory HomePageSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$HomePageSettingsFromJson(json);
|
||||
factory HomePageSettings.fromJson(Map<String, dynamic> json) => _$HomePageSettingsFromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ AppSettings _$AppSettingsFromJson(Map<String, dynamic> json) {
|
|||
|
||||
/// @nodoc
|
||||
mixin _$AppSettings {
|
||||
String get language => throw _privateConstructorUsedError;
|
||||
ThemeSettings get themeSettings => throw _privateConstructorUsedError;
|
||||
PlayerSettings get playerSettings => throw _privateConstructorUsedError;
|
||||
SleepTimerSettings get sleepTimerSettings =>
|
||||
|
|
@ -48,7 +49,8 @@ abstract class $AppSettingsCopyWith<$Res> {
|
|||
_$AppSettingsCopyWithImpl<$Res, AppSettings>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{ThemeSettings themeSettings,
|
||||
{String language,
|
||||
ThemeSettings themeSettings,
|
||||
PlayerSettings playerSettings,
|
||||
SleepTimerSettings sleepTimerSettings,
|
||||
DownloadSettings downloadSettings,
|
||||
|
|
@ -80,6 +82,7 @@ class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
|||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? language = null,
|
||||
Object? themeSettings = null,
|
||||
Object? playerSettings = null,
|
||||
Object? sleepTimerSettings = null,
|
||||
|
|
@ -89,6 +92,10 @@ class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
|||
Object? homePageSettings = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
language: null == language
|
||||
? _value.language
|
||||
: language // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
themeSettings: null == themeSettings
|
||||
? _value.themeSettings
|
||||
: themeSettings // ignore: cast_nullable_to_non_nullable
|
||||
|
|
@ -203,7 +210,8 @@ abstract class _$$AppSettingsImplCopyWith<$Res>
|
|||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{ThemeSettings themeSettings,
|
||||
{String language,
|
||||
ThemeSettings themeSettings,
|
||||
PlayerSettings playerSettings,
|
||||
SleepTimerSettings sleepTimerSettings,
|
||||
DownloadSettings downloadSettings,
|
||||
|
|
@ -240,6 +248,7 @@ class __$$AppSettingsImplCopyWithImpl<$Res>
|
|||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? language = null,
|
||||
Object? themeSettings = null,
|
||||
Object? playerSettings = null,
|
||||
Object? sleepTimerSettings = null,
|
||||
|
|
@ -249,6 +258,10 @@ class __$$AppSettingsImplCopyWithImpl<$Res>
|
|||
Object? homePageSettings = null,
|
||||
}) {
|
||||
return _then(_$AppSettingsImpl(
|
||||
language: null == language
|
||||
? _value.language
|
||||
: language // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
themeSettings: null == themeSettings
|
||||
? _value.themeSettings
|
||||
: themeSettings // ignore: cast_nullable_to_non_nullable
|
||||
|
|
@ -285,7 +298,8 @@ class __$$AppSettingsImplCopyWithImpl<$Res>
|
|||
@JsonSerializable()
|
||||
class _$AppSettingsImpl implements _AppSettings {
|
||||
const _$AppSettingsImpl(
|
||||
{this.themeSettings = const ThemeSettings(),
|
||||
{this.language = 'zh',
|
||||
this.themeSettings = const ThemeSettings(),
|
||||
this.playerSettings = const PlayerSettings(),
|
||||
this.sleepTimerSettings = const SleepTimerSettings(),
|
||||
this.downloadSettings = const DownloadSettings(),
|
||||
|
|
@ -296,6 +310,9 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
factory _$AppSettingsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AppSettingsImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final String language;
|
||||
@override
|
||||
@JsonKey()
|
||||
final ThemeSettings themeSettings;
|
||||
|
|
@ -320,7 +337,7 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppSettings(themeSettings: $themeSettings, playerSettings: $playerSettings, sleepTimerSettings: $sleepTimerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings, homePageSettings: $homePageSettings)';
|
||||
return 'AppSettings(language: $language, themeSettings: $themeSettings, playerSettings: $playerSettings, sleepTimerSettings: $sleepTimerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings, homePageSettings: $homePageSettings)';
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -328,6 +345,8 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AppSettingsImpl &&
|
||||
(identical(other.language, language) ||
|
||||
other.language == language) &&
|
||||
(identical(other.themeSettings, themeSettings) ||
|
||||
other.themeSettings == themeSettings) &&
|
||||
(identical(other.playerSettings, playerSettings) ||
|
||||
|
|
@ -348,6 +367,7 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
language,
|
||||
themeSettings,
|
||||
playerSettings,
|
||||
sleepTimerSettings,
|
||||
|
|
@ -374,7 +394,8 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
|
||||
abstract class _AppSettings implements AppSettings {
|
||||
const factory _AppSettings(
|
||||
{final ThemeSettings themeSettings,
|
||||
{final String language,
|
||||
final ThemeSettings themeSettings,
|
||||
final PlayerSettings playerSettings,
|
||||
final SleepTimerSettings sleepTimerSettings,
|
||||
final DownloadSettings downloadSettings,
|
||||
|
|
@ -385,6 +406,8 @@ abstract class _AppSettings implements AppSettings {
|
|||
factory _AppSettings.fromJson(Map<String, dynamic> json) =
|
||||
_$AppSettingsImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get language;
|
||||
@override
|
||||
ThemeSettings get themeSettings;
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ part of 'app_settings.dart';
|
|||
|
||||
_$AppSettingsImpl _$$AppSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||
_$AppSettingsImpl(
|
||||
language: json['language'] as String? ?? 'zh',
|
||||
themeSettings: json['themeSettings'] == null
|
||||
? const ThemeSettings()
|
||||
: ThemeSettings.fromJson(
|
||||
|
|
@ -40,6 +41,7 @@ _$AppSettingsImpl _$$AppSettingsImplFromJson(Map<String, dynamic> json) =>
|
|||
|
||||
Map<String, dynamic> _$$AppSettingsImplToJson(_$AppSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'language': instance.language,
|
||||
'themeSettings': instance.themeSettings,
|
||||
'playerSettings': instance.playerSettings,
|
||||
'sleepTimerSettings': instance.sleepTimerSettings,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue