Created
December 8, 2023 22:09
-
-
Save yjbanov/9274e7d92d7485517a04481fe5d38030 to your computer and use it in GitHub Desktop.
A sketch for a FlutterView focus API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract interface class FlutterView { | |
FlutterViewFocusState get focusState; | |
/// The timing of these events relative to keyboard events | |
/// is such and such. | |
FlutterViewFocusStateChanged get onFocusStateChanged; | |
set onFocusStateChanged(FlutterViewFocusStateChanged callback); | |
} | |
typedef FlutterViewFocusStateChanged = Function( | |
FlutterViewFocusStateChangedNotification notification, | |
); | |
final class FlutterViewFocusState { | |
FlutterViewFocusState({ | |
required this.hasFocus, | |
}); | |
final bool hasFocus; | |
} | |
final class FlutterViewFocusStateChangedNotification { | |
FlutterViewFocusStateChangedNotification({ | |
required this.oldState, | |
required this.newState, | |
required this.direction, | |
}); | |
final FlutterViewFocusState oldState; | |
final FlutterViewFocusState newState; | |
final FocusChangeDirection direction; | |
} | |
enum FocusChangeDirection { | |
// TAB | |
forward, | |
// Shift TAB | |
backward, | |
// Alt+TAB, or focus lost | |
unknown, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment