fix: topbar 24px, ok tuslari Actions+DirectionalFocusIntent
Some checks failed
Build Windows / build-windows (push) Has been cancelled

This commit is contained in:
Alhan
2026-07-22 05:28:15 +03:00
parent 5be314e857
commit 1658985f9c
6 changed files with 29 additions and 41 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:window_manager/window_manager.dart';
import 'package:desktop_drop/desktop_drop.dart';
import '../services/image_manager.dart';
@@ -25,26 +24,11 @@ class _ViewerScreenState extends State<ViewerScreen> with WindowListener {
Timer? _pollTimer;
Rect _lastBounds = Rect.zero;
bool _handleKeyEvent(KeyEvent event) {
if (event is KeyDownEvent) {
switch (event.logicalKey) {
case LogicalKeyboardKey.arrowLeft:
ImageManager.instance.previousImage();
return true;
case LogicalKeyboardKey.arrowRight:
ImageManager.instance.nextImage();
return true;
}
}
return false;
}
@override
void initState() {
super.initState();
windowManager.addListener(this);
ImageManager.instance.addListener(_onImageManagerChanged);
HardwareKeyboard.instance.addHandler(_handleKeyEvent);
if (widget.initialFiles.isNotEmpty) {
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -78,7 +62,6 @@ class _ViewerScreenState extends State<ViewerScreen> with WindowListener {
@override
void dispose() {
HardwareKeyboard.instance.removeHandler(_handleKeyEvent);
windowManager.removeListener(this);
ImageManager.instance.removeListener(_onImageManagerChanged);
_saveDebounce?.cancel();
@@ -136,7 +119,7 @@ class _ViewerScreenState extends State<ViewerScreen> with WindowListener {
child: Stack(
children: [
Positioned(
top: 16,
top: 24,
left: 0,
right: 0,
bottom: 0,

View File

@@ -11,25 +11,22 @@ class AppShortcuts extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Focus(
autofocus: true,
onKeyEvent: (node, event) {
if (event is KeyDownEvent) {
switch (event.logicalKey) {
case LogicalKeyboardKey.arrowLeft:
ImageManager.instance.previousImage();
return KeyEventResult.handled;
case LogicalKeyboardKey.arrowRight:
ImageManager.instance.nextImage();
return KeyEventResult.handled;
case LogicalKeyboardKey.escape:
windowManager.isFullScreen().then((isFullscreen) {
if (isFullscreen) windowManager.setFullScreen(false);
});
return KeyEventResult.handled;
}
}
return KeyEventResult.ignored;
return Actions(
actions: {
DirectionalFocusIntent: CallbackAction<DirectionalFocusIntent>(
onInvoke: (intent) {
switch (intent.direction) {
case TraversalDirection.left:
ImageManager.instance.previousImage();
return null;
case TraversalDirection.right:
ImageManager.instance.nextImage();
return null;
default:
return null;
}
},
),
},
child: CallbackShortcuts(
bindings: {
@@ -47,6 +44,14 @@ class AppShortcuts extends StatelessWidget {
await windowManager.setFullScreen(!isFullscreen);
},
// Escape
const SingleActivator(LogicalKeyboardKey.escape): () async {
final isFullscreen = await windowManager.isFullScreen();
if (isFullscreen) {
await windowManager.setFullScreen(false);
}
},
// Quit
const SingleActivator(
LogicalKeyboardKey.keyQ,

View File

@@ -12,7 +12,7 @@ class CustomTitleBar extends StatelessWidget {
right: 0,
child: DragToMoveArea(
child: SizedBox(
height: 16,
height: 24,
child: Stack(
children: [
Positioned(
@@ -63,13 +63,13 @@ class _BarButtonState extends State<_BarButton> {
onEnter: (_) => setState(() => _hovered = true),
onExit: (_) => setState(() => _hovered = false),
child: Container(
width: 24,
height: 16,
width: 32,
height: 24,
color: _hovered ? Colors.red.withValues(alpha: 0.8) : Colors.transparent,
child: Icon(
widget.icon,
color: Colors.white,
size: 12,
size: 14,
),
),
),

Binary file not shown.