mod: page observer

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-14 11:15:50 +08:00
parent 7dd47736fb
commit 064c8a9dfe
3 changed files with 13 additions and 2 deletions

View File

@@ -65,12 +65,19 @@ class _MainAppState extends State<MainApp>
@override @override
void didPopNext() { void didPopNext() {
WidgetsBinding.instance.addObserver(this);
_mainController.checkUnreadDynamic(); _mainController.checkUnreadDynamic();
_checkDefaultSearch(true); _checkDefaultSearch(true);
_checkUnread(context.orientation == Orientation.portrait); _checkUnread(context.orientation == Orientation.portrait);
super.didPopNext(); super.didPopNext();
} }
@override
void didPushNext() {
WidgetsBinding.instance.removeObserver(this);
super.didPushNext();
}
@override @override
void didChangeAppLifecycleState(AppLifecycleState state) { void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) { if (state == AppLifecycleState.resumed) {

View File

@@ -1003,7 +1003,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
case 1: case 1:
final List<InlineSpan> spanChildren = <InlineSpan>[]; final List<InlineSpan> spanChildren = <InlineSpan>[];
final RegExp urlRegExp = RegExp( final RegExp urlRegExp = RegExp(
'${Constants.urlPattern}|av\\d+|bv\\S+\\b', '${Constants.urlPattern}|av\\d+|bv[a-z\\d]{10}',
caseSensitive: false, caseSensitive: false,
); );
@@ -1030,7 +1030,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
} catch (e) { } catch (e) {
spanChildren.add(TextSpan(text: matchStr)); spanChildren.add(TextSpan(text: matchStr));
} }
} else if (RegExp(r'^bv\S+\b$', caseSensitive: false) } else if (RegExp(r'^bv[a-z\d]{10}$', caseSensitive: false)
.hasMatch(matchStr)) { .hasMatch(matchStr)) {
try { try {
// validate // validate

View File

@@ -393,6 +393,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
return; return;
} }
WidgetsBinding.instance.removeObserver(this);
ScreenBrightness().resetApplicationScreenBrightness(); ScreenBrightness().resetApplicationScreenBrightness();
videoDetailController.positionSubscription?.cancel(); videoDetailController.positionSubscription?.cancel();
@@ -426,6 +428,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
return; return;
} }
WidgetsBinding.instance.addObserver(this);
if (videoDetailController.plPlayerController.playerStatus.status.value == if (videoDetailController.plPlayerController.playerStatus.status.value ==
PlayerStatus.playing && PlayerStatus.playing &&
videoDetailController.playerStatus != PlayerStatus.playing) { videoDetailController.playerStatus != PlayerStatus.playing) {