feat(app): left/right arrows step through artifacts and changed files
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// Left and right arrow keys step to the previous and next item (an
|
||||
/// artifact, a changed file) wherever a keyboard is attached. A field that
|
||||
/// takes the arrows itself (a text box) keeps them while it has focus.
|
||||
class ArrowKeyPager extends StatelessWidget {
|
||||
const ArrowKeyPager({
|
||||
super.key,
|
||||
required this.onPrevious,
|
||||
required this.onNext,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
/// Null at the first item.
|
||||
final VoidCallback? onPrevious;
|
||||
|
||||
/// Null at the last item.
|
||||
final VoidCallback? onNext;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => CallbackShortcuts(
|
||||
bindings: {
|
||||
const SingleActivator(LogicalKeyboardKey.arrowLeft): () =>
|
||||
onPrevious?.call(),
|
||||
const SingleActivator(LogicalKeyboardKey.arrowRight): () =>
|
||||
onNext?.call(),
|
||||
},
|
||||
child: Focus(autofocus: true, child: child),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user