feat: show back and forward swipes as visible page transitions
This commit is contained in:
parent
65e693b9c6
commit
204aee899a
4 changed files with 387 additions and 11 deletions
|
|
@ -12,6 +12,7 @@ import 'fob.dart';
|
|||
import 'mews_page_view.dart';
|
||||
import 'palettes.dart';
|
||||
import 'settings_sheet.dart';
|
||||
import 'swipe_navigator.dart';
|
||||
|
||||
/// The whole v1 UI: an address bar that hides on scroll, the page reader with
|
||||
/// swipe back/forward, a settings FOB that appears on scroll, and error
|
||||
|
|
@ -86,18 +87,24 @@ class _ReaderScreenState extends State<ReaderScreen> {
|
|||
child: SignalBuilder(builder: (context) {
|
||||
final browser = deps.browser;
|
||||
final page = browser.currentPage.value;
|
||||
// The swipe peek uses the current page's palette when there is
|
||||
// one, so the neighbor slides in on matching paper.
|
||||
final peekBackground = page == null
|
||||
? Theme.of(context).scaffoldBackgroundColor
|
||||
: paletteFor(
|
||||
pageVariant: page.variant,
|
||||
readerVariant: deps.settings.variant.value,
|
||||
dark: Theme.of(context).brightness == Brightness.dark,
|
||||
).background;
|
||||
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.deferToChild,
|
||||
onHorizontalDragEnd: (details) {
|
||||
final velocity = details.primaryVelocity ?? 0;
|
||||
// Swipe right goes back, swipe left goes forward.
|
||||
if (velocity > 300) {
|
||||
browser.back();
|
||||
} else if (velocity < -300) {
|
||||
browser.forward();
|
||||
}
|
||||
},
|
||||
return SwipeNavigator(
|
||||
canGoBack: browser.canGoBack,
|
||||
canGoForward: browser.canGoForward,
|
||||
backTitle: browser.backTitle.value,
|
||||
forwardTitle: browser.forwardTitle.value,
|
||||
background: peekBackground,
|
||||
onBack: browser.back,
|
||||
onForward: browser.forward,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(child: _body(context, page)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue