mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: nav/searchbar stream
Closes #648 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -294,7 +294,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(
|
||||
title: StreamBuilder(
|
||||
stream: _titleStreamC.stream,
|
||||
stream: _titleStreamC.stream.distinct(),
|
||||
initialData: false,
|
||||
builder: (context, AsyncSnapshot snapshot) {
|
||||
return AnimatedOpacity(
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||
import 'package:PiliPlus/pages/main/controller.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -31,6 +32,7 @@ class _DynamicsTabPageState
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
late bool dynamicsWaterfallFlow;
|
||||
StreamSubscription? _listener;
|
||||
late final MainController _mainController = Get.find<MainController>();
|
||||
|
||||
DynamicsController dynamicsController = Get.put(DynamicsController());
|
||||
@override
|
||||
@@ -43,6 +45,14 @@ class _DynamicsTabPageState
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
void listener() {
|
||||
if (_mainController.selectedIndex.value == 0) {
|
||||
return;
|
||||
}
|
||||
super.listener();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
@@ -156,8 +156,9 @@ class _HomePageState extends State<HomePage>
|
||||
stream: _homeController.hideSearchBar
|
||||
? _mainController.navSearchStreamDebounce
|
||||
? _homeController.searchBarStream?.stream
|
||||
.distinct()
|
||||
.throttle(const Duration(milliseconds: 500))
|
||||
: _homeController.searchBarStream?.stream
|
||||
: _homeController.searchBarStream?.stream.distinct()
|
||||
: null,
|
||||
initialData: true,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
|
||||
@@ -270,8 +270,9 @@ class _MainAppState extends State<MainApp>
|
||||
stream: _mainController.hideTabBar
|
||||
? _mainController.navSearchStreamDebounce
|
||||
? _mainController.bottomBarStream?.stream
|
||||
.distinct()
|
||||
.throttle(const Duration(milliseconds: 500))
|
||||
: _mainController.bottomBarStream?.stream
|
||||
: _mainController.bottomBarStream?.stream.distinct()
|
||||
: null,
|
||||
initialData: true,
|
||||
builder: (context, AsyncSnapshot snapshot) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||
import 'package:PiliPlus/pages/main/controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
@@ -20,10 +21,19 @@ class _MediaPageState extends CommonPageState<MediaPage, MediaController>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
MediaController controller = Get.put(MediaController());
|
||||
late final MainController _mainController = Get.find<MainController>();
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
void listener() {
|
||||
if (_mainController.selectedIndex.value == 0) {
|
||||
return;
|
||||
}
|
||||
super.listener();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
|
||||
@@ -73,7 +73,7 @@ class _MemberPageState extends State<MemberPage> {
|
||||
children: [
|
||||
AppBar(
|
||||
title: StreamBuilder(
|
||||
stream: appbarStream.stream,
|
||||
stream: appbarStream.stream.distinct(),
|
||||
initialData: false,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
return AnimatedOpacity(
|
||||
|
||||
@@ -71,7 +71,7 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
||||
expandedHeight: 215 - MediaQuery.of(context).padding.top,
|
||||
pinned: true,
|
||||
title: StreamBuilder(
|
||||
stream: titleStreamC.stream,
|
||||
stream: titleStreamC.stream.distinct(),
|
||||
initialData: false,
|
||||
builder: (context, AsyncSnapshot snapshot) {
|
||||
return AnimatedOpacity(
|
||||
|
||||
@@ -240,7 +240,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
||||
const Spacer(),
|
||||
StreamBuilder(
|
||||
initialData: false,
|
||||
stream: _publishStream.stream,
|
||||
stream: _publishStream.stream.distinct(),
|
||||
builder: (context, snapshot) => FilledButton.tonal(
|
||||
onPressed: snapshot.data == true ? submitReplyAdd : null,
|
||||
style: FilledButton.styleFrom(
|
||||
|
||||
@@ -82,7 +82,7 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
|
||||
: AppBar(
|
||||
title: StreamBuilder(
|
||||
initialData: null,
|
||||
stream: _titleStream.stream,
|
||||
stream: _titleStream.stream.distinct(),
|
||||
builder: (context, snapshot) => Text(
|
||||
maxLines: 1,
|
||||
snapshot.hasData ? snapshot.data! : _url,
|
||||
@@ -93,7 +93,7 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
|
||||
preferredSize: Size.zero,
|
||||
child: StreamBuilder(
|
||||
initialData: 0.0,
|
||||
stream: _progressStream.stream,
|
||||
stream: _progressStream.stream.distinct(),
|
||||
builder: (context, snapshot) => snapshot.data as double < 1
|
||||
? LinearProgressIndicator(
|
||||
value: snapshot.data as double,
|
||||
|
||||
Reference in New Issue
Block a user