61 lines
1.6 KiB
Dart
61 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:window_manager/window_manager.dart';
|
|
import '../services/image_manager.dart';
|
|
import '../services/file_handler.dart';
|
|
|
|
class AppShortcuts extends StatelessWidget {
|
|
final Widget child;
|
|
|
|
const AppShortcuts({super.key, required this.child});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CallbackShortcuts(
|
|
bindings: {
|
|
// Navigate images
|
|
const SingleActivator(LogicalKeyboardKey.arrowLeft): () {
|
|
ImageManager.instance.previousImage();
|
|
},
|
|
const SingleActivator(LogicalKeyboardKey.arrowRight): () {
|
|
ImageManager.instance.nextImage();
|
|
},
|
|
|
|
// 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);
|
|
},
|
|
|
|
// Exit fullscreen
|
|
const SingleActivator(LogicalKeyboardKey.escape): () async {
|
|
final isFullscreen = await windowManager.isFullScreen();
|
|
if (isFullscreen) {
|
|
await windowManager.setFullScreen(false);
|
|
}
|
|
},
|
|
|
|
// Quit
|
|
const SingleActivator(
|
|
LogicalKeyboardKey.keyQ,
|
|
control: true,
|
|
): () {
|
|
windowManager.close();
|
|
},
|
|
},
|
|
child: Focus(
|
|
autofocus: true,
|
|
child: child,
|
|
),
|
|
);
|
|
}
|
|
}
|