fix: clean debug prints, ok tuslari Focus.onKeyEvent ile calisiyor
Some checks failed
Build Windows / build-windows (push) Has been cancelled
Some checks failed
Build Windows / build-windows (push) Has been cancelled
This commit is contained in:
@@ -43,18 +43,18 @@ class ImageManager extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void nextImage() {
|
||||
if (_images.isEmpty) return;
|
||||
_currentIndex = (_currentIndex + 1) % _images.length;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void previousImage() {
|
||||
if (_images.isEmpty) return;
|
||||
_currentIndex = (_currentIndex - 1 + _images.length) % _images.length;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void nextImage() {
|
||||
if (_images.isEmpty) return;
|
||||
_currentIndex = (_currentIndex + 1) % _images.length;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Precache needs a BuildContext
|
||||
BuildContext? context;
|
||||
|
||||
|
||||
@@ -11,48 +11,38 @@ class AppShortcuts extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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;
|
||||
}
|
||||
},
|
||||
),
|
||||
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;
|
||||
},
|
||||
child: CallbackShortcuts(
|
||||
bindings: {
|
||||
// Open file dialog
|
||||
const SingleActivator(
|
||||
LogicalKeyboardKey.keyO,
|
||||
control: true,
|
||||
): () {
|
||||
FileHandler.openFileDialog();
|
||||
},
|
||||
|
||||
// Fullscreen toggle
|
||||
const SingleActivator(LogicalKeyboardKey.f11): () async {
|
||||
final isFullscreen = await windowManager.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(
|
||||
LogicalKeyboardKey.keyQ,
|
||||
control: true,
|
||||
|
||||
Reference in New Issue
Block a user