Skip to content

Commit

Permalink
fix video player setting page formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ggichure authored and hjiangsu committed Nov 27, 2024
1 parent 2238fc6 commit 5bdbdec
Showing 1 changed file with 35 additions and 97 deletions.
132 changes: 35 additions & 97 deletions lib/settings/pages/video_player_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class VideoPlayerSettingsPage extends StatefulWidget {
final LocalSettings? settingToHighlight;

@override
State<VideoPlayerSettingsPage> createState() =>
_VideoPlayerSettingsPageState();
State<VideoPlayerSettingsPage> createState() => _VideoPlayerSettingsPageState();
}

class _VideoPlayerSettingsPageState extends State<VideoPlayerSettingsPage> {
Expand Down Expand Up @@ -97,20 +96,18 @@ class _VideoPlayerSettingsPageState extends State<VideoPlayerSettingsPage> {
break;
case LocalSettings.videoAutoPlay:
await prefs.setString(LocalSettings.videoAutoPlay.name, value);
setState(() => videoAutoPlay =
VideoAutoPlay.values.byName(value ?? VideoAutoPlay.never));
setState(() => videoAutoPlay = VideoAutoPlay.values.byName(value ?? VideoAutoPlay.never));
break;

case LocalSettings.videoDefaultPlaybackSpeed:
await prefs.setString(
LocalSettings.videoDefaultPlaybackSpeed.name, value);
setState(() => videoDefaultPlaybackSpeed = VideoPlayBackSpeed.values
.byName(value ?? VideoPlayBackSpeed.normal));
await prefs.setString(LocalSettings.videoDefaultPlaybackSpeed.name, value);
setState(() => videoDefaultPlaybackSpeed = VideoPlayBackSpeed.values.byName(
value ?? VideoPlayBackSpeed.normal,
));
break;
case LocalSettings.videoPlayerMode:
await prefs.setString(LocalSettings.videoPlayerMode.name, value);
setState(() => videoPlayerMode =
VideoPlayerMode.values.byName(value ?? VideoPlayerMode.inApp));
setState(() => videoPlayerMode = VideoPlayerMode.values.byName(value ?? VideoPlayerMode.inApp));
break;
default:
}
Expand All @@ -124,18 +121,13 @@ class _VideoPlayerSettingsPageState extends State<VideoPlayerSettingsPage> {
final prefs = (await UserPreferences.instance).sharedPreferences;
setState(() {
videoAutoMute = prefs.getBool(LocalSettings.videoAutoMute.name) ?? true;
videoAutoFullscreen =
prefs.getBool(LocalSettings.videoAutoFullscreen.name) ?? false;
videoAutoFullscreen = prefs.getBool(LocalSettings.videoAutoFullscreen.name) ?? false;
videoAutoLoop = prefs.getBool(LocalSettings.videoAutoLoop.name) ?? false;
videoAutoPlay = VideoAutoPlay.values.byName(
prefs.getString(LocalSettings.videoAutoPlay.name) ??
VideoAutoPlay.never.name);
videoAutoPlay = VideoAutoPlay.values.byName(prefs.getString(LocalSettings.videoAutoPlay.name) ?? VideoAutoPlay.never.name);
videoDefaultPlaybackSpeed = VideoPlayBackSpeed.values.byName(
prefs.getString(LocalSettings.videoDefaultPlaybackSpeed.name) ??
VideoPlayBackSpeed.normal.name);
videoPlayerMode = VideoPlayerMode.values.byName(
prefs.getString(LocalSettings.videoPlayerMode.name) ??
VideoPlayerMode.inApp.name);
prefs.getString(LocalSettings.videoDefaultPlaybackSpeed.name) ?? VideoPlayBackSpeed.normal.name,
);
videoPlayerMode = VideoPlayerMode.values.byName(prefs.getString(LocalSettings.videoPlayerMode.name) ?? VideoPlayerMode.inApp.name);
isLoading = false;
});
}
Expand All @@ -158,8 +150,7 @@ class _VideoPlayerSettingsPageState extends State<VideoPlayerSettingsPage> {
value: videoAutoFullscreen,
iconEnabled: Icons.fullscreen,
iconDisabled: Icons.fullscreen_exit,
onToggle: (bool value) => setPreferences(
LocalSettings.videoAutoFullscreen, value),
onToggle: (bool value) => setPreferences(LocalSettings.videoAutoFullscreen, value),
highlightKey: settingToHighlightKey,
setting: LocalSettings.videoAutoFullscreen,
highlightedSetting: settingToHighlight,
Expand All @@ -169,8 +160,7 @@ class _VideoPlayerSettingsPageState extends State<VideoPlayerSettingsPage> {
value: videoAutoMute,
iconEnabled: Icons.volume_off,
iconDisabled: Icons.volume_up,
onToggle: (bool value) =>
setPreferences(LocalSettings.videoAutoMute, value),
onToggle: (bool value) => setPreferences(LocalSettings.videoAutoMute, value),
highlightKey: settingToHighlightKey,
setting: LocalSettings.videoAutoMute,
highlightedSetting: settingToHighlight,
Expand All @@ -180,8 +170,7 @@ class _VideoPlayerSettingsPageState extends State<VideoPlayerSettingsPage> {
value: videoAutoLoop,
iconEnabled: Icons.loop,
iconDisabled: Icons.loop_outlined,
onToggle: (bool value) =>
setPreferences(LocalSettings.videoAutoLoop, value),
onToggle: (bool value) => setPreferences(LocalSettings.videoAutoLoop, value),
highlightKey: settingToHighlightKey,
setting: LocalSettings.videoAutoLoop,
highlightedSetting: settingToHighlight,
Expand All @@ -197,70 +186,31 @@ class _VideoPlayerSettingsPageState extends State<VideoPlayerSettingsPage> {
icon: Icons.video_settings_outlined,
payload: videoAutoPlay),
options: [
ListPickerItem(
icon: Icons.not_interested,
label: l10n.never,
payload: VideoAutoPlay.never),
ListPickerItem(
icon: Icons.play_arrow,
label: l10n.always,
payload: VideoAutoPlay.always),
ListPickerItem(
icon: Icons.wifi,
label: l10n.onWifi,
payload: VideoAutoPlay.onWifi),
ListPickerItem(icon: Icons.not_interested, label: l10n.never, payload: VideoAutoPlay.never),
ListPickerItem(icon: Icons.play_arrow, label: l10n.always, payload: VideoAutoPlay.always),
ListPickerItem(icon: Icons.wifi, label: l10n.onWifi, payload: VideoAutoPlay.onWifi),
],
icon: Icons.play_circle,
onChanged: (value) async => setPreferences(
LocalSettings.videoAutoPlay, value.payload.name),
onChanged: (value) async => setPreferences(LocalSettings.videoAutoPlay, value.payload.name),
highlightKey: settingToHighlightKey,
setting: LocalSettings.videoAutoPlay,
highlightedSetting: settingToHighlight,
),
ListOption(
description: l10n.videoDefaultPlaybackSpeed,
value: ListPickerItem(
label: videoDefaultPlaybackSpeed.label,
icon: Icons.speed,
payload: videoDefaultPlaybackSpeed),
value: ListPickerItem(label: videoDefaultPlaybackSpeed.label, icon: Icons.speed, payload: videoDefaultPlaybackSpeed),
options: [
ListPickerItem(
icon: Icons.speed,
label: VideoPlayBackSpeed.pointTow5x.label,
payload: VideoPlayBackSpeed.pointTow5x),
ListPickerItem(
icon: Icons.speed,
label: VideoPlayBackSpeed.point5x.label,
payload: VideoPlayBackSpeed.point5x),
ListPickerItem(
icon: Icons.speed,
label: VideoPlayBackSpeed.pointSeven5x.label,
payload: VideoPlayBackSpeed.pointSeven5x),
ListPickerItem(
icon: Icons.speed,
label: VideoPlayBackSpeed.normal.label,
payload: VideoPlayBackSpeed.normal),
ListPickerItem(
icon: Icons.speed,
label: VideoPlayBackSpeed.onePointTwo5x.label,
payload: VideoPlayBackSpeed.onePointTwo5x),
ListPickerItem(
icon: Icons.speed,
label: VideoPlayBackSpeed.onePoint5x.label,
payload: VideoPlayBackSpeed.onePoint5x),
ListPickerItem(
icon: Icons.speed,
label: VideoPlayBackSpeed.onePointSeven5x.label,
payload: VideoPlayBackSpeed.onePointSeven5x),
ListPickerItem(
icon: Icons.speed,
label: VideoPlayBackSpeed.twoX.label,
payload: VideoPlayBackSpeed.twoX),
ListPickerItem(icon: Icons.speed, label: VideoPlayBackSpeed.pointTow5x.label, payload: VideoPlayBackSpeed.pointTow5x),
ListPickerItem(icon: Icons.speed, label: VideoPlayBackSpeed.point5x.label, payload: VideoPlayBackSpeed.point5x),
ListPickerItem(icon: Icons.speed, label: VideoPlayBackSpeed.pointSeven5x.label, payload: VideoPlayBackSpeed.pointSeven5x),
ListPickerItem(icon: Icons.speed, label: VideoPlayBackSpeed.normal.label, payload: VideoPlayBackSpeed.normal),
ListPickerItem(icon: Icons.speed, label: VideoPlayBackSpeed.onePointTwo5x.label, payload: VideoPlayBackSpeed.onePointTwo5x),
ListPickerItem(icon: Icons.speed, label: VideoPlayBackSpeed.onePoint5x.label, payload: VideoPlayBackSpeed.onePoint5x),
ListPickerItem(icon: Icons.speed, label: VideoPlayBackSpeed.onePointSeven5x.label, payload: VideoPlayBackSpeed.onePointSeven5x),
ListPickerItem(icon: Icons.speed, label: VideoPlayBackSpeed.twoX.label, payload: VideoPlayBackSpeed.twoX),
],
icon: Icons.speed,
onChanged: (value) async => setPreferences(
LocalSettings.videoDefaultPlaybackSpeed,
value.payload.name),
onChanged: (value) async => setPreferences(LocalSettings.videoDefaultPlaybackSpeed, value.payload.name),
highlightKey: settingToHighlightKey,
setting: LocalSettings.videoDefaultPlaybackSpeed,
highlightedSetting: settingToHighlight,
Expand All @@ -270,31 +220,19 @@ class _VideoPlayerSettingsPageState extends State<VideoPlayerSettingsPage> {
value: ListPickerItem(
label: switch (videoPlayerMode) {
VideoPlayerMode.inApp => l10n.videoPlayerInApp,
VideoPlayerMode.customTabs =>
l10n.linkHandlingCustomTabsShort,
VideoPlayerMode.externalPlayer =>
l10n.linkHandlingExternalShort,
VideoPlayerMode.customTabs => l10n.linkHandlingCustomTabsShort,
VideoPlayerMode.externalPlayer => l10n.linkHandlingExternalShort,
},
payload: videoPlayerMode,
capitalizeLabel: false,
),
options: [
ListPickerItem(
label: l10n.videoPlayerInApp,
icon: Icons.play_circle_fill,
payload: VideoPlayerMode.inApp),
ListPickerItem(
label: l10n.linkHandlingCustomTabs,
icon: Icons.language_rounded,
payload: VideoPlayerMode.customTabs),
ListPickerItem(
label: l10n.videoLinkHandlingExternal,
icon: Icons.open_in_browser_rounded,
payload: VideoPlayerMode.externalPlayer),
ListPickerItem(label: l10n.videoPlayerInApp, icon: Icons.play_circle_fill, payload: VideoPlayerMode.inApp),
ListPickerItem(label: l10n.linkHandlingCustomTabs, icon: Icons.language_rounded, payload: VideoPlayerMode.customTabs),
ListPickerItem(label: l10n.videoLinkHandlingExternal, icon: Icons.open_in_browser_rounded, payload: VideoPlayerMode.externalPlayer),
],
icon: Icons.video_label_outlined,
onChanged: (value) => setPreferences(
LocalSettings.videoPlayerMode, value.payload.name),
onChanged: (value) => setPreferences(LocalSettings.videoPlayerMode, value.payload.name),
highlightKey: settingToHighlightKey,
setting: LocalSettings.videoPlayerMode,
highlightedSetting: settingToHighlight,
Expand Down

0 comments on commit 5bdbdec

Please sign in to comment.