info: floating app bar, scroll to top info when returning to image
This commit is contained in:
parent
77be0b6189
commit
a31fe91ec2
2 changed files with 23 additions and 10 deletions
|
@ -208,7 +208,7 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
||||||
Future<void> _goToVerticalPage(int page) {
|
Future<void> _goToVerticalPage(int page) {
|
||||||
return _verticalPager.animateToPage(
|
return _verticalPager.animateToPage(
|
||||||
page,
|
page,
|
||||||
duration: const Duration(milliseconds: 350),
|
duration: Duration(milliseconds: (300 * timeDilation).toInt()),
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:aves/widgets/fullscreen/info/location_section.dart';
|
||||||
import 'package:aves/widgets/fullscreen/info/metadata_section.dart';
|
import 'package:aves/widgets/fullscreen/info/metadata_section.dart';
|
||||||
import 'package:aves/widgets/fullscreen/info/xmp_section.dart';
|
import 'package:aves/widgets/fullscreen/info/xmp_section.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:outline_material_icons/outline_material_icons.dart';
|
import 'package:outline_material_icons/outline_material_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
@ -28,6 +29,7 @@ class InfoPage extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class InfoPageState extends State<InfoPage> {
|
class InfoPageState extends State<InfoPage> {
|
||||||
|
ScrollController _scrollController = ScrollController();
|
||||||
bool _scrollStartFromTop = false;
|
bool _scrollStartFromTop = false;
|
||||||
|
|
||||||
ImageEntry get entry => widget.entry;
|
ImageEntry get entry => widget.entry;
|
||||||
|
@ -44,14 +46,6 @@ class InfoPageState extends State<InfoPage> {
|
||||||
|
|
||||||
return MediaQueryDataProvider(
|
return MediaQueryDataProvider(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(OMIcons.arrowUpward),
|
|
||||||
onPressed: () => BackUpNotification().dispatch(context),
|
|
||||||
tooltip: 'Back to image',
|
|
||||||
),
|
|
||||||
title: const Text('Info'),
|
|
||||||
),
|
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: NotificationListener(
|
child: NotificationListener(
|
||||||
onNotification: _handleTopScroll,
|
onNotification: _handleTopScroll,
|
||||||
|
@ -63,7 +57,17 @@ class InfoPageState extends State<InfoPage> {
|
||||||
final split = mqWidth > 400;
|
final split = mqWidth > 400;
|
||||||
|
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
|
controller: _scrollController,
|
||||||
slivers: [
|
slivers: [
|
||||||
|
SliverAppBar(
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(OMIcons.arrowUpward),
|
||||||
|
onPressed: _goToImage,
|
||||||
|
tooltip: 'Back to image',
|
||||||
|
),
|
||||||
|
title: const Text('Info'),
|
||||||
|
floating: true,
|
||||||
|
),
|
||||||
const SliverPadding(
|
const SliverPadding(
|
||||||
padding: EdgeInsets.only(top: 8),
|
padding: EdgeInsets.only(top: 8),
|
||||||
),
|
),
|
||||||
|
@ -130,7 +134,7 @@ class InfoPageState extends State<InfoPage> {
|
||||||
_scrollStartFromTop = false;
|
_scrollStartFromTop = false;
|
||||||
} else if (notification is OverscrollNotification) {
|
} else if (notification is OverscrollNotification) {
|
||||||
if (notification.overscroll < 0) {
|
if (notification.overscroll < 0) {
|
||||||
BackUpNotification().dispatch(context);
|
_goToImage();
|
||||||
_scrollStartFromTop = false;
|
_scrollStartFromTop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,6 +142,15 @@ class InfoPageState extends State<InfoPage> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _goToImage() {
|
||||||
|
BackUpNotification().dispatch(context);
|
||||||
|
_scrollController.animateTo(
|
||||||
|
0,
|
||||||
|
duration: Duration(milliseconds: (300 * timeDilation).toInt()),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SectionRow extends StatelessWidget {
|
class SectionRow extends StatelessWidget {
|
||||||
|
|
Loading…
Reference in a new issue