feat: narrow a library page as the reader types in its search box
This commit is contained in:
parent
9d9f09ebc7
commit
95602ac623
5 changed files with 157 additions and 8 deletions
|
|
@ -242,7 +242,10 @@ class _ReaderScreenState extends State<ReaderScreen> {
|
|||
url: page.url,
|
||||
);
|
||||
return MewsPageView(
|
||||
key: ValueKey(page.url),
|
||||
// Our own pages carry their view state in the address, so the key
|
||||
// leaves the query out: narrowing a list as the reader types rebuilds
|
||||
// the page without taking the search box out from under them.
|
||||
key: ValueKey(_viewKey(page.url)),
|
||||
page: page,
|
||||
ownPage: MewsUrls.isInternal(page.url),
|
||||
palette: palette,
|
||||
|
|
@ -252,12 +255,23 @@ class _ReaderScreenState extends State<ReaderScreen> {
|
|||
onLinkTap: (url) => deps.browser.open(url),
|
||||
onFormSubmit: (form, values) =>
|
||||
deps.browser.submitForm(form.action, form.method, values),
|
||||
onFormChange: (form, values) =>
|
||||
deps.browser.narrowWhileTyping(form.action, values),
|
||||
fetchImageBytes: deps.browser.fetchImageBytes,
|
||||
scrollController: _scroll,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// What identifies the open page to the widget tree. One of our own pages
|
||||
/// is identified by its path alone, so a change to its query string, such
|
||||
/// as a search being narrowed, rebuilds the page in place instead of
|
||||
/// building a new one.
|
||||
String _viewKey(String url) {
|
||||
if (!MewsUrls.isInternal(url)) return url;
|
||||
return Uri.parse(url).path;
|
||||
}
|
||||
|
||||
/// Renders a neighboring page for the swipe peek, non-interactive: it is a
|
||||
/// look ahead, and committing the navigation brings the real thing.
|
||||
Widget? _neighborView(MewsPage? page) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue