Skip to content

Commit

Permalink
add always ontop menthod
Browse files Browse the repository at this point in the history
  • Loading branch information
Predidit committed May 8, 2024
1 parent b9df38f commit 5f361e5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
34 changes: 23 additions & 11 deletions lib/pages/settings/theme_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {

void resetTheme() {
var defaultDarkTheme = ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
);
useMaterial3: true,
brightness: Brightness.dark,
);
var oledDarkTheme = Utils.oledDarkTheme(defaultDarkTheme);
AdaptiveTheme.of(context).setTheme(
light: ThemeData(
Expand Down Expand Up @@ -196,14 +196,16 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {
dense: false,
title: const Text('配色方案'),
),
Platform.isAndroid ? ListTile(
onTap: () async {
Modular.to.pushNamed('/tab/my/theme/display');
},
dense: false,
title: const Text('屏幕帧率'),
// trailing: const Icon(Icons.navigate_next),
) : Container(),
Platform.isAndroid
? ListTile(
onTap: () async {
Modular.to.pushNamed('/tab/my/theme/display');
},
dense: false,
title: const Text('屏幕帧率'),
// trailing: const Icon(Icons.navigate_next),
)
: Container(),
ListTile(
onTap: () {
SmartDialog.show(
Expand Down Expand Up @@ -284,6 +286,16 @@ class _ThemeSettingsPageState extends State<ThemeSettingsPage> {
defaultVal: false,
),
),
(Platform.isWindows || Platform.isLinux || Platform.isMacOS)
? const InkWell(
child: SetSwitchItem(
title: '窗口置顶',
subTitle: '播放时始终保持在其他窗口上方',
setKey: SettingBoxKey.alwaysOntop,
defaultVal: false,
),
)
: Container(),
],
),
),
Expand Down
5 changes: 5 additions & 0 deletions lib/pages/video/video_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class _VideoPageState extends State<VideoPage> with WindowListener {
WidgetsBinding.instance.addPostFrameCallback((_) {
FocusScope.of(context).requestFocus(_focusNode);
});
bool alwaysOntop = setting.get(SettingBoxKey.alwaysOntop, defaultValue: true);
if (alwaysOntop) {
windowManager.setAlwaysOnTop(true);
}
init();
}

Expand Down Expand Up @@ -121,6 +125,7 @@ class _VideoPageState extends State<VideoPage> with WindowListener {
}
historyController.updateHistory(
videoController.link, videoController.currentPosition.inSeconds);
windowManager.setAlwaysOnTop(false);
windowManager.removeListener(this);
playerController.dispose();
super.dispose();
Expand Down
1 change: 1 addition & 0 deletions lib/utils/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class SettingBoxKey {
searchEnhanceEnable = 'searchEnhanceEnable',
// Todo 检查更新
autoUpdate = 'autoUpdate',
alwaysOntop = 'alwaysOntop',
danmakuEnhance = 'danmakuEnhance',
danmakuBorder = 'danmakuBorder',
danmakuOpacity = 'danmakuOpacity',
Expand Down

0 comments on commit 5f361e5

Please sign in to comment.