Skip to content

Commit

Permalink
feat: always on top
Browse files Browse the repository at this point in the history
  • Loading branch information
nini22P committed Dec 14, 2024
1 parent d683ae6 commit c62e408
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,7 @@
"add_webdav_storage": "Add WebDAV Storage",
"edit_webdav_storage": "Edit WebDAV Storage",
"auto_resize": "Auto Resize Window Proportion",
"center_on_resize": "Center On Resize"
"center_on_resize": "Center On Resize",
"always_on_top_on": "Always On Top: On",
"always_on_top_off": "Always On Top: Off"
}
4 changes: 3 additions & 1 deletion lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,7 @@
"add_webdav_storage": "添加 WebDAV 存储",
"edit_webdav_storage": "编辑 WebDAV 存储",
"auto_resize": "自动调整窗口比例",
"center_on_resize": "调整窗口时移动到屏幕中心"
"center_on_resize": "调整窗口时移动到屏幕中心",
"always_on_top_on": "窗口置顶: 开",
"always_on_top_off": "窗口置顶: 关"
}
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main() async {

WindowOptions windowOptions = const WindowOptions(
size: Size(800, 600),
minimumSize: Size(480, 270),
minimumSize: Size(400, 240),
center: true,
backgroundColor: Colors.transparent,
skipTaskbar: false,
Expand Down
1 change: 0 additions & 1 deletion lib/pages/player/iris_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ class IrisPlayer extends HookWidget {
),
],
),
const SizedBox(width: 8),
],
),
),
Expand Down
23 changes: 23 additions & 0 deletions lib/widgets/custom_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:iris/hooks/use_player_core.dart';
import 'package:iris/info.dart';
import 'package:iris/utils/get_localizations.dart';
import 'package:iris/utils/resize_window.dart';
import 'package:window_manager/window_manager.dart';

Expand All @@ -20,6 +21,8 @@ class CustomAppBar extends HookWidget {

@override
Widget build(BuildContext context) {
final t = getLocalizations(context);

bool isDesktop = useMemoized(
(() => Platform.isWindows || Platform.isLinux || Platform.isMacOS));

Expand Down Expand Up @@ -51,6 +54,26 @@ class CustomAppBar extends HookWidget {
children: [
...actions ?? [],
if (isDesktop) ...[
FutureBuilder<bool>(
future: windowManager.isAlwaysOnTop(),
builder: (context, snapshot) {
bool isAlwaysOnTop = snapshot.data ?? false;
return IconButton(
tooltip: isAlwaysOnTop
? t.always_on_top_on
: t.always_on_top_off,
icon: Icon(
isAlwaysOnTop
? Icons.push_pin_rounded
: Icons.push_pin_outlined,
size: 18,
),
onPressed: () =>
windowManager.setAlwaysOnTop(!isAlwaysOnTop),
);
},
),
const SizedBox(width: 8),
IconButton(
onPressed: () => windowManager.minimize(),
icon: const Icon(Icons.remove_rounded),
Expand Down

0 comments on commit c62e408

Please sign in to comment.