fix: preserve home screen scroll position on back navigation

This commit is contained in:
edde746
2026-03-04 16:34:36 +01:00
parent 8b57e810ab
commit e6ee83d9c2
4 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -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();
}
+4 -2
View File
@@ -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)
+1 -1
View File
@@ -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();
}
+1 -4
View File
@@ -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);
}