feat: Navigate in image viewer with keyboard keys
This commit is contained in:
parent
c3c247144f
commit
dfe6717a29
2 changed files with 37 additions and 19 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
|
|
@ -26,6 +27,8 @@ class ImageViewer extends StatefulWidget {
|
|||
}
|
||||
|
||||
class ImageViewerController extends State<ImageViewer> {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -45,6 +48,17 @@ class ImageViewerController extends State<ImageViewer> {
|
|||
|
||||
late final List<Event> allEvents;
|
||||
|
||||
void onKeyEvent(KeyEvent event) {
|
||||
switch (event.logicalKey) {
|
||||
case LogicalKeyboardKey.arrowLeft:
|
||||
if (canGoBack) prevImage();
|
||||
break;
|
||||
case LogicalKeyboardKey.arrowRight:
|
||||
if (canGoNext) nextImage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void prevImage() async {
|
||||
await pageController.previousPage(
|
||||
duration: FluffyThemes.animationDuration,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue