fix: clean debug prints, ok tuslari Focus.onKeyEvent ile calisiyor
Build Windows / build-windows (push) Has been cancelled
Build Windows / build-windows (push) Has been cancelled
This commit is contained in:
1 parent
1658985f9c
commit
c5679f457d
5 files changed
+25
-35
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -43,18 +43,18 @@ class ImageManager extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nextImage() {
|
|
||||||
if (_images.isEmpty) return;
|
|
||||||
_currentIndex = (_currentIndex + 1) % _images.length;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void previousImage() {
|
void previousImage() {
|
||||||
if (_images.isEmpty) return;
|
if (_images.isEmpty) return;
|
||||||
_currentIndex = (_currentIndex - 1 + _images.length) % _images.length;
|
_currentIndex = (_currentIndex - 1 + _images.length) % _images.length;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nextImage() {
|
||||||
|
if (_images.isEmpty) return;
|
||||||
|
_currentIndex = (_currentIndex + 1) % _images.length;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
// Precache needs a BuildContext
|
// Precache needs a BuildContext
|
||||||
BuildContext? context;
|
BuildContext? context;
|
||||||
|
|
||||||
|
|||||||
@@ -11,48 +11,38 @@ class AppShortcuts extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Actions(
|
return Focus(
|
||||||
actions: {
|
autofocus: true,
|
||||||
DirectionalFocusIntent: CallbackAction<DirectionalFocusIntent>(
|
onKeyEvent: (node, event) {
|
||||||
onInvoke: (intent) {
|
if (event is KeyDownEvent) {
|
||||||
switch (intent.direction) {
|
switch (event.logicalKey) {
|
||||||
case TraversalDirection.left:
|
case LogicalKeyboardKey.arrowLeft:
|
||||||
ImageManager.instance.previousImage();
|
ImageManager.instance.previousImage();
|
||||||
return null;
|
return KeyEventResult.handled;
|
||||||
case TraversalDirection.right:
|
case LogicalKeyboardKey.arrowRight:
|
||||||
ImageManager.instance.nextImage();
|
ImageManager.instance.nextImage();
|
||||||
return null;
|
return KeyEventResult.handled;
|
||||||
default:
|
case LogicalKeyboardKey.escape:
|
||||||
return null;
|
windowManager.isFullScreen().then((isFullscreen) {
|
||||||
}
|
if (isFullscreen) windowManager.setFullScreen(false);
|
||||||
},
|
});
|
||||||
),
|
return KeyEventResult.handled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return KeyEventResult.ignored;
|
||||||
},
|
},
|
||||||
child: CallbackShortcuts(
|
child: CallbackShortcuts(
|
||||||
bindings: {
|
bindings: {
|
||||||
// Open file dialog
|
|
||||||
const SingleActivator(
|
const SingleActivator(
|
||||||
LogicalKeyboardKey.keyO,
|
LogicalKeyboardKey.keyO,
|
||||||
control: true,
|
control: true,
|
||||||
): () {
|
): () {
|
||||||
FileHandler.openFileDialog();
|
FileHandler.openFileDialog();
|
||||||
},
|
},
|
||||||
|
|
||||||
// Fullscreen toggle
|
|
||||||
const SingleActivator(LogicalKeyboardKey.f11): () async {
|
const SingleActivator(LogicalKeyboardKey.f11): () async {
|
||||||
final isFullscreen = await windowManager.isFullScreen();
|
final isFullscreen = await windowManager.isFullScreen();
|
||||||
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
|
|
||||||
const SingleActivator(
|
const SingleActivator(
|
||||||
LogicalKeyboardKey.keyQ,
|
LogicalKeyboardKey.keyQ,
|
||||||
control: true,
|
control: true,
|
||||||
|
|||||||
Binary file not shown.
Reference in new issue
Block a user