fix: preserve home screen scroll position on back navigation
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
/// Used by MainScreen to pause expensive work (e.g. animation tickers)
|
||||
/// when the screen's tab is no longer visible, and resume it when shown again.
|
||||
mixin TabVisibilityAware {
|
||||
void onTabShown();
|
||||
void onTabShown({bool scrollToTop = true});
|
||||
void onTabHidden();
|
||||
}
|
||||
|
||||
@@ -379,11 +379,13 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
}
|
||||
|
||||
@override
|
||||
void onTabShown() {
|
||||
void onTabShown({bool scrollToTop = true}) {
|
||||
if (!_isAutoScrollPaused) {
|
||||
_startAutoScroll();
|
||||
}
|
||||
_focusTopBoundary();
|
||||
if (scrollToTop) {
|
||||
_focusTopBoundary();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper method to calculate visible dot range (max 5 dots)
|
||||
|
||||
@@ -796,7 +796,7 @@ class _MainScreenState extends State<MainScreen> with RouteAware, WindowListener
|
||||
// Called when returning to this route from a child route (e.g., from video player)
|
||||
if (_currentIndex == 0 && !_isOffline) {
|
||||
if (_discoverKey.currentState case final TabVisibilityAware aware) {
|
||||
aware.onTabShown();
|
||||
aware.onTabShown(scrollToTop: false);
|
||||
}
|
||||
_onDiscoverBecameVisible();
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:isolate';
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' show VoidCallback;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
@@ -146,7 +143,7 @@ class PlexClient {
|
||||
|
||||
/// Custom response decoder that handles malformed UTF-8 gracefully.
|
||||
/// Large responses are decoded in a background isolate to avoid ANR.
|
||||
static FutureOr<String> _lenientUtf8Decoder(List<int> responseBytes, RequestOptions _, ResponseBody __) {
|
||||
static FutureOr<String> _lenientUtf8Decoder(List<int> responseBytes, RequestOptions _, ResponseBody _a) {
|
||||
if (responseBytes.length > 50 * 1024) {
|
||||
return compute(_decodeUtf8, responseBytes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user