Make events page remember scroll position when changing layouts.
This commit is contained in:
parent
92038ed12a
commit
d4d27751eb
@ -7,18 +7,23 @@ class _EventsList extends StatefulWidget {
|
||||
this.topHeight = 0,
|
||||
this.blurOnScroll = false,
|
||||
this.showTopGradient = true,
|
||||
required this.initialScrollOffset,
|
||||
required this.onScroll,
|
||||
}) : super(key: key);
|
||||
final WonderData data;
|
||||
final double topHeight;
|
||||
final bool blurOnScroll;
|
||||
final bool showTopGradient;
|
||||
|
||||
final double initialScrollOffset;
|
||||
final void Function(double offset) onScroll;
|
||||
@override
|
||||
State<_EventsList> createState() => _EventsListState();
|
||||
}
|
||||
|
||||
class _EventsListState extends State<_EventsList> {
|
||||
final ScrollController _scroller = ScrollController();
|
||||
late final ScrollController _scroller = ScrollController(initialScrollOffset: widget.initialScrollOffset)
|
||||
..addListener(() => widget.onScroll(_scroller.offset));
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scroller.dispose();
|
||||
|
@ -24,6 +24,9 @@ class WonderEvents extends StatelessWidget {
|
||||
final WonderType type;
|
||||
late final _data = wondersLogic.getData(type);
|
||||
|
||||
double _scrollPos = 0;
|
||||
void _handleScroll(double pos) => _scrollPos = pos;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
void handleTimelineBtnPressed() => context.push(ScreenPaths.timeline(type));
|
||||
@ -102,6 +105,8 @@ class WonderEvents extends StatelessWidget {
|
||||
data: _data,
|
||||
topHeight: 100,
|
||||
blurOnScroll: false,
|
||||
onScroll: _handleScroll,
|
||||
initialScrollOffset: _scrollPos,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -130,6 +135,8 @@ class WonderEvents extends StatelessWidget {
|
||||
topHeight: topHeight,
|
||||
blurOnScroll: true,
|
||||
showTopGradient: false,
|
||||
onScroll: _handleScroll,
|
||||
initialScrollOffset: _scrollPos,
|
||||
),
|
||||
),
|
||||
Gap($styles.insets.lg),
|
||||
|
Loading…
x
Reference in New Issue
Block a user