opt anim to top

opt refresh

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-23 22:37:57 +08:00
parent 0a9897f6a4
commit 81cfe3efe1
28 changed files with 154 additions and 43 deletions

View File

@@ -37,6 +37,7 @@ class _ArticleListPageState extends State<ArticleListPage> {
child: refreshIndicator(
onRefresh: _controller.onRefresh,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
Obx(() => _buildHeader(theme, _controller.list.value)),
SliverPadding(

View File

@@ -14,6 +14,7 @@ import 'package:PiliPlus/pages/bangumi/controller.dart';
import 'package:PiliPlus/pages/bangumi/widgets/bangumi_card_v.dart';
import 'package:PiliPlus/pages/bangumi/widgets/bangumi_card_v_timeline.dart';
import 'package:PiliPlus/pages/common/common_page.dart';
import 'package:PiliPlus/pages/pgc_index/controller.dart';
import 'package:PiliPlus/pages/pgc_index/view.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/grid.dart';
@@ -241,25 +242,38 @@ class _BangumiPageState extends CommonPageState<BangumiPage, BangumiController>
appBar: AppBar(title: const Text('索引')),
body: DefaultTabController(
length: types.length,
child: Column(
children: [
SafeArea(
top: false,
bottom: false,
child: TabBar(
child: Builder(builder: (context) {
return Column(
children: [
SafeArea(
top: false,
bottom: false,
child: TabBar(
tabs: titles
.map((title) => Tab(text: title))
.toList()),
),
Expanded(
child: tabBarView(
children: types
.map((type) =>
PgcIndexPage(indexType: type))
.toList()),
)
],
),
.toList(),
onTap: (index) {
try {
if (!DefaultTabController.of(context)
.indexIsChanging) {
Get.find<PgcIndexController>(
tag: types[index].toString())
.animateToTop();
}
} catch (_) {}
},
),
),
Expanded(
child: tabBarView(
children: types
.map((type) =>
PgcIndexPage(indexType: type))
.toList()),
)
],
);
}),
),
),
);

View File

@@ -46,6 +46,7 @@ class _DynTopicPageState extends State<DynTopicPage> {
onRefresh: _controller.onRefresh,
child: CustomScrollView(
controller: _controller.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
Obx(() => _buildAppBar(theme, _controller.topState.value)),
Obx(() {

View File

@@ -31,6 +31,8 @@ class _FavArticlePageState extends State<FavArticlePage>
return refreshIndicator(
onRefresh: _favArticleController.onRefresh,
child: CustomScrollView(
controller: _favArticleController.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -36,6 +36,8 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
refreshIndicator(
onRefresh: _favNoteController.onRefresh,
child: CustomScrollView(
controller: _favNoteController.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -1,5 +1,8 @@
import 'package:PiliPlus/pages/fav/note/child_view.dart';
import 'package:PiliPlus/pages/fav/note/controller.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class FavNotePage extends StatefulWidget {
const FavNotePage({super.key});
@@ -58,6 +61,16 @@ class _FavNotePageState extends State<FavNotePage>
const Tab(text: '未发布笔记'),
const Tab(text: '公开笔记'),
],
onTap: (index) {
try {
if (!_tabController.indexIsChanging) {
Get.find<FavNoteController>(
tag: index == 0 ? 'false' : 'true')
.scrollController
.animToTop();
}
} catch (_) {}
},
),
),
// TextButton(

View File

@@ -43,6 +43,8 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
refreshIndicator(
onRefresh: _favPgcController.onRefresh,
child: CustomScrollView(
controller: _favPgcController.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -1,5 +1,8 @@
import 'package:PiliPlus/pages/fav/pgc/child_view.dart';
import 'package:PiliPlus/pages/fav/pgc/controller.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class FavPgcPage extends StatefulWidget {
const FavPgcPage({super.key, required this.type});
@@ -61,6 +64,15 @@ class _FavPgcPageState extends State<FavPgcPage>
Tab(text: '在看'),
Tab(text: '看过'),
],
onTap: (index) {
try {
if (!_tabController.indexIsChanging) {
Get.find<FavPgcController>(
tag: '${widget.type}${index + 1}',
).scrollController.animToTop();
}
} catch (_) {}
},
),
),
// TextButton(

View File

@@ -30,6 +30,8 @@ class _FavTopicPageState extends State<FavTopicPage>
return refreshIndicator(
onRefresh: _controller.onRefresh,
child: CustomScrollView(
controller: _controller.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -2,8 +2,11 @@ import 'package:PiliPlus/common/widgets/scroll_physics.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/common/fav_type.dart';
import 'package:PiliPlus/models/user/fav_folder.dart';
import 'package:PiliPlus/pages/fav/article/controller.dart';
import 'package:PiliPlus/pages/fav/topic/controller.dart';
import 'package:PiliPlus/pages/fav/video/controller.dart';
import 'package:PiliPlus/pages/fav_folder_sort/view.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
@@ -122,6 +125,23 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
isScrollable: true,
tabAlignment: TabAlignment.start,
tabs: FavTabType.values.map((item) => Tab(text: item.title)).toList(),
onTap: (index) {
try {
if (!_tabController.indexIsChanging) {
switch (FavTabType.values[index]) {
case FavTabType.video:
_favController.scrollController.animToTop();
case FavTabType.article:
Get.find<FavArticleController>()
.scrollController
.animToTop();
case FavTabType.topic:
Get.find<FavTopicController>().scrollController.animToTop();
default:
}
}
} catch (_) {}
},
),
),
body: SafeArea(

View File

@@ -40,6 +40,8 @@ class _LiveAreaChildPageState extends State<LiveAreaChildPage>
return refreshIndicator(
onRefresh: _controller.onRefresh,
child: CustomScrollView(
controller: _controller.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -4,6 +4,7 @@ import 'package:PiliPlus/common/widgets/scroll_physics.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/common/image_type.dart';
import 'package:PiliPlus/models/live/live_area_list/area_item.dart';
import 'package:PiliPlus/pages/live_area_detail/child/controller.dart';
import 'package:PiliPlus/pages/live_area_detail/child/view.dart';
import 'package:PiliPlus/pages/live_area_detail/controller.dart';
import 'package:PiliPlus/pages/live_search/view.dart';
@@ -76,6 +77,17 @@ class _LiveAreaDetailPageState extends State<LiveAreaDetailPage> {
tabs: response
.map((e) => Tab(text: e.name ?? ''))
.toList(),
onTap: (index) {
try {
if (!DefaultTabController.of(context)
.indexIsChanging) {
final item = response[index];
Get.find<LiveAreaChildController>(
tag: '${item.id}${item.parentId}')
.animateToTop();
}
} catch (_) {}
},
),
),
iconButton(

View File

@@ -36,6 +36,7 @@ class _LiveFollowPageState extends State<LiveFollowPage> {
child: refreshIndicator(
onRefresh: _controller.onRefresh,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -77,20 +77,32 @@ class _LiveSearchPageState extends State<LiveSearchPage> {
),
),
],
onTap: (index) {
if (!_controller.tabController.indexIsChanging) {
if (index == 0) {
_controller.roomCtr.animateToTop();
} else {
_controller.userCtr.animateToTop();
}
}
},
),
Expanded(
child: tabBarView(
controller: _controller.tabController,
children: [
LiveSearchChildPage(
controller: _controller.roomCtr,
searchType: LiveSearchType.room,
),
LiveSearchChildPage(
controller: _controller.userCtr,
searchType: LiveSearchType.user,
),
],
child: Material(
color: Colors.transparent,
child: tabBarView(
controller: _controller.tabController,
children: [
LiveSearchChildPage(
controller: _controller.roomCtr,
searchType: LiveSearchType.room,
),
LiveSearchChildPage(
controller: _controller.userCtr,
searchType: LiveSearchType.user,
),
],
),
),
),
],

View File

@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: uri_does_not_exist_in_doc_import
/// @docImport 'package:flutter/services.dart';
/// @docImport 'bottom_navigation_bar.dart';
/// @docImport 'navigation_rail.dart';

View File

@@ -39,6 +39,7 @@ class _MemberArticleState extends State<MemberArticle>
return refreshIndicator(
onRefresh: _controller.onRefresh,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -41,6 +41,7 @@ class _MemberFavoriteState extends State<MemberFavorite>
return refreshIndicator(
onRefresh: _controller.onRefresh,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -45,6 +45,7 @@ class _MemberOpusState extends State<MemberOpus>
refreshIndicator(
onRefresh: _controller.onRefresh,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -42,6 +42,7 @@ class _MemberBangumiState extends State<MemberBangumi>
return refreshIndicator(
onRefresh: _controller.onRefresh,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -41,6 +41,7 @@ class _MemberSearchChildPageState extends State<MemberSearchChildPage>
onRefresh: _controller.onRefresh,
child: CustomScrollView(
controller: _controller.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -80,6 +80,15 @@ class _MemberSearchPageState extends State<MemberSearchPage> {
),
),
],
onTap: (index) {
if (!_controller.tabController.indexIsChanging) {
if (index == 0) {
_controller.arcCtr.animateToTop();
} else {
_controller.dynCtr.animateToTop();
}
}
},
),
Expanded(
child: tabBarView(

View File

@@ -7,7 +7,8 @@ import 'package:get/get.dart';
class PgcIndexController extends CommonListController {
PgcIndexController(this.indexType);
int? indexType;
Rx<LoadingState> conditionState = LoadingState.loading().obs;
Rx<LoadingState<PgcIndexCondition>> conditionState =
LoadingState<PgcIndexCondition>.loading().obs;
late final RxBool isExpand = false.obs;

View File

@@ -42,17 +42,18 @@ class _PgcIndexPageState extends State<PgcIndexPage>
: Obx(() => _buildBody(theme, _ctr.conditionState.value));
}
Widget _buildBody(ThemeData theme, LoadingState loadingState) {
Widget _buildBody(
ThemeData theme, LoadingState<PgcIndexCondition> loadingState) {
return switch (loadingState) {
Loading() => loadingWidget,
Success(:var response) => Builder(builder: (context) {
PgcIndexCondition data = response;
int count = (data.order?.isNotEmpty == true ? 1 : 0) +
(data.filter?.length ?? 0);
int count = (response.order?.isNotEmpty == true ? 1 : 0) +
(response.filter?.length ?? 0);
if (count == 0) return const SizedBox.shrink();
return SafeArea(
bottom: false,
child: CustomScrollView(
controller: _ctr.scrollController,
slivers: [
if (widget.indexType != null)
const SliverToBoxAdapter(child: SizedBox(height: 12)),
@@ -62,8 +63,8 @@ class _PgcIndexPageState extends State<PgcIndexPage>
alignment: Alignment.topCenter,
duration: const Duration(milliseconds: 200),
child: count > 5
? Obx(() => _buildSortWidget(theme, count, data))
: _buildSortWidget(theme, count, data),
? Obx(() => _buildSortWidget(theme, count, response))
: _buildSortWidget(theme, count, response),
),
),
SliverPadding(

View File

@@ -40,6 +40,7 @@ class _ZonePageState extends CommonPageState<ZonePage, ZoneController>
onRefresh: controller.onRefresh,
child: CustomScrollView(
controller: controller.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(

View File

@@ -114,6 +114,7 @@ class _SearchTrendingPageState extends State<SearchTrendingPage> {
onRefresh: _controller.onRefresh,
child: CustomScrollView(
controller: _controller.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverToBoxAdapter(
child: Image.asset(

View File

@@ -29,6 +29,7 @@ class _SubPageState extends State<SubPage> {
child: refreshIndicator(
onRefresh: _subController.onRefresh,
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
Obx(() => _buildBody(_subController.loadingState.value)),
SliverToBoxAdapter(

View File

@@ -138,9 +138,6 @@ class _MediaListPanelState
widget.onDelete != null && widget.mediaList.length > 1;
return ScrollablePositionedList.separated(
itemScrollController: _scrollController,
// physics: const PositionRetainedScrollPhysics(
// parent: ClampingScrollPhysics(),
// ),
physics: const AlwaysScrollableScrollPhysics(),
itemCount: widget.mediaList.length,
padding: EdgeInsets.only(

View File

@@ -92,10 +92,7 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
onRefresh: _controller.onRefresh,
child: CustomScrollView(
controller: _controller.scrollController,
// physics: PositionRetainedScrollPhysics(
// shouldRetain: _controller.hasPrev,
// parent: const ClampingScrollPhysics(),
// ),
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
_buildSliverHeader(theme),
Obx(() =>