fix: topbar 24px, ok tuslari Actions+DirectionalFocusIntent
Build Windows / build-windows (push) Has been cancelled
Build Windows / build-windows (push) Has been cancelled
This commit is contained in:
1 parent
5be314e857
commit
1658985f9c
6 files changed
+26
-38
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
import 'package:desktop_drop/desktop_drop.dart';
|
import 'package:desktop_drop/desktop_drop.dart';
|
||||||
import '../services/image_manager.dart';
|
import '../services/image_manager.dart';
|
||||||
@@ -25,26 +24,11 @@ class _ViewerScreenState extends State<ViewerScreen> with WindowListener {
|
|||||||
Timer? _pollTimer;
|
Timer? _pollTimer;
|
||||||
Rect _lastBounds = Rect.zero;
|
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
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
windowManager.addListener(this);
|
windowManager.addListener(this);
|
||||||
ImageManager.instance.addListener(_onImageManagerChanged);
|
ImageManager.instance.addListener(_onImageManagerChanged);
|
||||||
HardwareKeyboard.instance.addHandler(_handleKeyEvent);
|
|
||||||
|
|
||||||
if (widget.initialFiles.isNotEmpty) {
|
if (widget.initialFiles.isNotEmpty) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
@@ -78,7 +62,6 @@ class _ViewerScreenState extends State<ViewerScreen> with WindowListener {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
HardwareKeyboard.instance.removeHandler(_handleKeyEvent);
|
|
||||||
windowManager.removeListener(this);
|
windowManager.removeListener(this);
|
||||||
ImageManager.instance.removeListener(_onImageManagerChanged);
|
ImageManager.instance.removeListener(_onImageManagerChanged);
|
||||||
_saveDebounce?.cancel();
|
_saveDebounce?.cancel();
|
||||||
@@ -136,7 +119,7 @@ class _ViewerScreenState extends State<ViewerScreen> with WindowListener {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 16,
|
top: 24,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
|||||||
@@ -11,25 +11,22 @@ class AppShortcuts extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Focus(
|
return Actions(
|
||||||
autofocus: true,
|
actions: {
|
||||||
onKeyEvent: (node, event) {
|
DirectionalFocusIntent: CallbackAction<DirectionalFocusIntent>(
|
||||||
if (event is KeyDownEvent) {
|
onInvoke: (intent) {
|
||||||
switch (event.logicalKey) {
|
switch (intent.direction) {
|
||||||
case LogicalKeyboardKey.arrowLeft:
|
case TraversalDirection.left:
|
||||||
ImageManager.instance.previousImage();
|
ImageManager.instance.previousImage();
|
||||||
return KeyEventResult.handled;
|
return null;
|
||||||
case LogicalKeyboardKey.arrowRight:
|
case TraversalDirection.right:
|
||||||
ImageManager.instance.nextImage();
|
ImageManager.instance.nextImage();
|
||||||
return KeyEventResult.handled;
|
return null;
|
||||||
case LogicalKeyboardKey.escape:
|
default:
|
||||||
windowManager.isFullScreen().then((isFullscreen) {
|
return null;
|
||||||
if (isFullscreen) windowManager.setFullScreen(false);
|
|
||||||
});
|
|
||||||
return KeyEventResult.handled;
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
return KeyEventResult.ignored;
|
),
|
||||||
},
|
},
|
||||||
child: CallbackShortcuts(
|
child: CallbackShortcuts(
|
||||||
bindings: {
|
bindings: {
|
||||||
@@ -47,6 +44,14 @@ class AppShortcuts extends StatelessWidget {
|
|||||||
await windowManager.setFullScreen(!isFullscreen);
|
await windowManager.setFullScreen(!isFullscreen);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Escape
|
||||||
|
const SingleActivator(LogicalKeyboardKey.escape): () async {
|
||||||
|
final isFullscreen = await windowManager.isFullScreen();
|
||||||
|
if (isFullscreen) {
|
||||||
|
await windowManager.setFullScreen(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Quit
|
// Quit
|
||||||
const SingleActivator(
|
const SingleActivator(
|
||||||
LogicalKeyboardKey.keyQ,
|
LogicalKeyboardKey.keyQ,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class CustomTitleBar extends StatelessWidget {
|
|||||||
right: 0,
|
right: 0,
|
||||||
child: DragToMoveArea(
|
child: DragToMoveArea(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 16,
|
height: 24,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
@@ -63,13 +63,13 @@ class _BarButtonState extends State<_BarButton> {
|
|||||||
onEnter: (_) => setState(() => _hovered = true),
|
onEnter: (_) => setState(() => _hovered = true),
|
||||||
onExit: (_) => setState(() => _hovered = false),
|
onExit: (_) => setState(() => _hovered = false),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 24,
|
width: 32,
|
||||||
height: 16,
|
height: 24,
|
||||||
color: _hovered ? Colors.red.withValues(alpha: 0.8) : Colors.transparent,
|
color: _hovered ? Colors.red.withValues(alpha: 0.8) : Colors.transparent,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
widget.icon,
|
widget.icon,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
size: 12,
|
size: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Binary file not shown.
Reference in new issue
Block a user