#437 tv: info page focus
This commit is contained in:
parent
88faad224a
commit
ad86eacd39
2 changed files with 52 additions and 15 deletions
|
@ -248,8 +248,7 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
|
||||||
_overlayVisible.value = true;
|
_overlayVisible.value = true;
|
||||||
}
|
}
|
||||||
} else if (notification is ShowInfoPageNotification) {
|
} else if (notification is ShowInfoPageNotification) {
|
||||||
// remove focus, if any, to prevent viewer shortcuts activation from the Info page
|
_goToVerticalPage(infoPage);
|
||||||
_showInfoPage();
|
|
||||||
} else if (notification is JumpToPreviousEntryNotification) {
|
} else if (notification is JumpToPreviousEntryNotification) {
|
||||||
_jumpToHorizontalPageByDelta(-1);
|
_jumpToHorizontalPageByDelta(-1);
|
||||||
} else if (notification is JumpToNextEntryNotification) {
|
} else if (notification is JumpToNextEntryNotification) {
|
||||||
|
@ -516,12 +515,6 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showInfoPage() {
|
|
||||||
// remove focus, if any, to prevent viewer shortcuts activation from the Info page
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus();
|
|
||||||
_goToVerticalPage(infoPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _goToVerticalPage(int page) async {
|
Future<void> _goToVerticalPage(int page) async {
|
||||||
final animationDuration = context.read<DurationsData>().viewerVerticalPageScrollAnimation;
|
final animationDuration = context.read<DurationsData>().viewerVerticalPageScrollAnimation;
|
||||||
if (animationDuration > Duration.zero) {
|
if (animationDuration > Duration.zero) {
|
||||||
|
|
|
@ -38,11 +38,50 @@ class InfoPage extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _InfoPageState extends State<InfoPage> {
|
class _InfoPageState extends State<InfoPage> {
|
||||||
|
final FocusNode _focusNode = FocusNode();
|
||||||
final ScrollController _scrollController = ScrollController();
|
final ScrollController _scrollController = ScrollController();
|
||||||
bool _scrollStartFromTop = false;
|
bool _scrollStartFromTop = false;
|
||||||
|
|
||||||
static const splitScreenWidthThreshold = 600;
|
static const splitScreenWidthThreshold = 600;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_registerWidget(widget);
|
||||||
|
_onScrollingChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant InfoPage oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
_unregisterWidget(oldWidget);
|
||||||
|
_registerWidget(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_unregisterWidget(widget);
|
||||||
|
_focusNode.dispose();
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _registerWidget(InfoPage widget) {
|
||||||
|
widget.isScrollingNotifier.addListener(_onScrollingChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _unregisterWidget(InfoPage widget) {
|
||||||
|
widget.isScrollingNotifier.removeListener(_onScrollingChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onScrollingChanged() {
|
||||||
|
if (!widget.isScrollingNotifier.value) {
|
||||||
|
// using `autofocus` while scrolling seems to fail for widget built offscreen
|
||||||
|
// so we give focus to this page when the screen is no longer scrolling
|
||||||
|
_focusNode.requestFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -63,13 +102,16 @@ class _InfoPageState extends State<InfoPage> {
|
||||||
final targetEntry = pageEntry ?? mainEntry;
|
final targetEntry = pageEntry ?? mainEntry;
|
||||||
return EmbeddedDataOpener(
|
return EmbeddedDataOpener(
|
||||||
entry: targetEntry,
|
entry: targetEntry,
|
||||||
child: _InfoPageContent(
|
child: Focus(
|
||||||
collection: widget.collection,
|
focusNode: _focusNode,
|
||||||
entry: targetEntry,
|
child: _InfoPageContent(
|
||||||
isScrollingNotifier: widget.isScrollingNotifier,
|
collection: widget.collection,
|
||||||
scrollController: _scrollController,
|
entry: targetEntry,
|
||||||
split: mqWidth > splitScreenWidthThreshold,
|
isScrollingNotifier: widget.isScrollingNotifier,
|
||||||
goToViewer: _goToViewer,
|
scrollController: _scrollController,
|
||||||
|
split: mqWidth > splitScreenWidthThreshold,
|
||||||
|
goToViewer: _goToViewer,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -173,6 +215,8 @@ class _InfoPageContentState extends State<_InfoPageContent> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_metadataNotifier.dispose();
|
||||||
|
_isEditingMetadataNotifier.dispose();
|
||||||
_unregisterWidget(widget);
|
_unregisterWidget(widget);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue