From 7049e5c63ab686ccc2f67b520127ee297bd4749b Mon Sep 17 00:00:00 2001 From: dom Date: Fri, 26 Jun 2026 16:34:02 +0800 Subject: [PATCH] opt ui Signed-off-by: dom --- lib/pages/download/detail/view.dart | 8 ++---- lib/pages/download/downloading/view.dart | 8 ++---- lib/pages/download/search/view.dart | 9 +++---- lib/pages/download/view.dart | 11 +++----- lib/pages/episode_panel/view.dart | 20 +++++++------- lib/pages/fav_folder_sort/view.dart | 2 +- lib/pages/fav_search/view.dart | 9 ++----- lib/pages/fav_sort/view.dart | 2 +- lib/pages/history_search/view.dart | 9 ++----- lib/pages/later_search/view.dart | 5 ++-- lib/pages/member_audio/view.dart | 9 +------ lib/pages/member_favorite/view.dart | 4 +-- lib/pages/member_home/view.dart | 11 +++----- lib/pages/member_home/widgets/fav_item.dart | 4 +-- lib/pages/search_panel/all/view.dart | 2 +- lib/pages/search_panel/pgc/view.dart | 1 - lib/pages/video/download_panel/view.dart | 6 ++--- .../video/introduction/local/controller.dart | 2 +- lib/pages/video/introduction/local/view.dart | 16 +++++------ lib/pages/video/medialist/view.dart | 10 +++---- lib/pages/video/member/view.dart | 6 ++--- lib/pages/video/view_point/view.dart | 6 ++++- lib/utils/grid.dart | 27 +++++++------------ 23 files changed, 71 insertions(+), 116 deletions(-) diff --git a/lib/pages/download/detail/view.dart b/lib/pages/download/detail/view.dart index 26a39322f..1ff40cf8f 100644 --- a/lib/pages/download/detail/view.dart +++ b/lib/pages/download/detail/view.dart @@ -36,7 +36,7 @@ class DownloadDetailPage extends StatefulWidget { } class _DownloadDetailPageState extends State - with BaseMultiSelectMixin { + with BaseMultiSelectMixin, GridMixin { StreamSubscription? _sub; final _downloadItems = RxList(); final _controller = Get.find(); @@ -149,11 +149,7 @@ class _DownloadDetailPageState extends State sliver: Obx(() { if (_downloadItems.isNotEmpty) { return SliverGrid.builder( - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 2, - mainAxisExtent: 100, - maxCrossAxisExtent: Grid.smallCardWidth * 2, - ), + gridDelegate: gridDelegate, itemBuilder: (context, index) { final entry = _downloadItems[index]; return DetailItem( diff --git a/lib/pages/download/downloading/view.dart b/lib/pages/download/downloading/view.dart index 001da6ea9..4483c69ec 100644 --- a/lib/pages/download/downloading/view.dart +++ b/lib/pages/download/downloading/view.dart @@ -22,7 +22,7 @@ class DownloadingPage extends StatefulWidget { } class _DownloadingPageState extends State - with BaseMultiSelectMixin { + with BaseMultiSelectMixin, GridMixin { final _downloadService = Get.find(); late final _waitDownloadQueue = _downloadService.waitDownloadQueue; @override @@ -69,11 +69,7 @@ class _DownloadingPageState extends State sliver: Obx(() { if (_waitDownloadQueue.isNotEmpty) { return SliverGrid.builder( - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 2, - mainAxisExtent: 100, - maxCrossAxisExtent: Grid.smallCardWidth * 2, - ), + gridDelegate: gridDelegate, itemCount: _waitDownloadQueue.length, itemBuilder: (context, index) { final entry = _waitDownloadQueue[index]; diff --git a/lib/pages/download/search/view.dart b/lib/pages/download/search/view.dart index dd4d6dfb3..73de66f33 100644 --- a/lib/pages/download/search/view.dart +++ b/lib/pages/download/search/view.dart @@ -29,7 +29,8 @@ class _DownloadSearchPageState DownloadSearchPage, List, BiliDownloadEntryInfo - > { + > + with GridMixin { @override DownloadSearchController controller = Get.put(DownloadSearchController()); final _downloadService = Get.find(); @@ -84,11 +85,7 @@ class _DownloadSearchPageState Widget buildList(List list) { if (list.isNotEmpty) { return SliverGrid.builder( - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 2, - mainAxisExtent: 100, - maxCrossAxisExtent: Grid.smallCardWidth * 2, - ), + gridDelegate: gridDelegate, itemBuilder: (context, index) { final entry = list[index]; return DetailItem( diff --git a/lib/pages/download/view.dart b/lib/pages/download/view.dart index 150e158bb..b1fbc27ce 100644 --- a/lib/pages/download/view.dart +++ b/lib/pages/download/view.dart @@ -33,7 +33,7 @@ class DownloadPage extends StatefulWidget { State createState() => _DownloadPageState(); } -class _DownloadPageState extends State { +class _DownloadPageState extends State with GridMixin { final _downloadService = Get.find(); final _controller = Get.put(DownloadPageController()); final _progress = ChangeNotifier(); @@ -139,7 +139,7 @@ class _DownloadPageState extends State { ), SliverToBoxAdapter( child: SizedBox( - height: 100, + height: 110, child: DetailItem( entry: entry, progress: _progress, @@ -172,12 +172,7 @@ class _DownloadPageState extends State { ), ), SliverGrid.builder( - gridDelegate: - SliverGridDelegateWithMaxCrossAxisExtent( - mainAxisSpacing: 2, - mainAxisExtent: 100, - maxCrossAxisExtent: Grid.smallCardWidth * 2, - ), + gridDelegate: gridDelegate, itemBuilder: (context, index) { final item = _controller.pages[index]; if (item.entries.length == 1) { diff --git a/lib/pages/episode_panel/view.dart b/lib/pages/episode_panel/view.dart index ee082b0a3..362f6ea75 100644 --- a/lib/pages/episode_panel/view.dart +++ b/lib/pages/episode_panel/view.dart @@ -262,15 +262,15 @@ class _EpisodePanelState extends State } return offset + 7; } else { - return index * 100 + 7; + return index * 112 + 7; } } double _calcItemHeight(ugc.BaseEpisodeItem episode) { if (episode is ugc.EpisodeItem && episode.pages!.length > 1) { - return 145; // 98 + 2 + 10 + 35 + return 157; // 110 + 2 + 10 + 35 } - return 100; + return 112; } Widget _buildBody( @@ -311,7 +311,7 @@ class _EpisodePanelState extends State mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - episodeItem, // 98 + episodeItem, // 110 Padding( padding: const EdgeInsets.symmetric( horizontal: 12, @@ -352,7 +352,7 @@ class _EpisodePanelState extends State isCurrentIndex: isCurrItem, ); }, - itemExtent: 100, + itemExtent: 112, ), ), ], @@ -428,9 +428,9 @@ class _EpisodePanelState extends State return Padding( padding: const EdgeInsets.only(bottom: 2), child: SizedBox( - height: 98, + height: 110, child: Material( - type: MaterialType.transparency, + type: .transparency, child: InkWell( onTap: () { if (episode.badge == "会员" && @@ -462,7 +462,7 @@ class _EpisodePanelState extends State onLongPress: onLongPress, onSecondaryTap: PlatformUtils.isMobile ? null : onLongPress, child: Padding( - padding: const EdgeInsets.symmetric( + padding: const .symmetric( horizontal: Style.safeSpace, vertical: 5, ), @@ -475,8 +475,8 @@ class _EpisodePanelState extends State children: [ NetworkImgLayer( src: cover, - width: 140.8, - height: 88, + width: 160, + height: 100, cacheWidth: cacheWidth, ), if (duration != null && duration > 0) diff --git a/lib/pages/fav_folder_sort/view.dart b/lib/pages/fav_folder_sort/view.dart index 84b4dfa9f..c06bdaa6a 100644 --- a/lib/pages/fav_folder_sort/view.dart +++ b/lib/pages/fav_folder_sort/view.dart @@ -81,7 +81,7 @@ class _FavFolderSortPageState extends State final key = item.id.toString(); return SizedBox( key: Key(key), - height: 98, + height: 110, child: FavVideoItem( heroTag: key, item: item, diff --git a/lib/pages/fav_search/view.dart b/lib/pages/fav_search/view.dart index db843841a..aca90dcf1 100644 --- a/lib/pages/fav_search/view.dart +++ b/lib/pages/fav_search/view.dart @@ -20,11 +20,8 @@ class FavSearchPage extends StatefulWidget { class _FavSearchPageState extends - CommonSearchPageState< - FavSearchPage, - FavDetailData, - FavDetailItemModel - > { + CommonSearchPageState + with GridMixin { @override final FavSearchController controller = Get.put( FavSearchController(), @@ -88,8 +85,6 @@ class _FavSearchPageState ), ]; - late final gridDelegate = Grid.videoCardHDelegate(context, minHeight: 110); - @override Widget buildList(List list) { return SliverGrid.builder( diff --git a/lib/pages/fav_sort/view.dart b/lib/pages/fav_sort/view.dart index 1761ef36a..67674afb1 100644 --- a/lib/pages/fav_sort/view.dart +++ b/lib/pages/fav_sort/view.dart @@ -108,7 +108,7 @@ class _FavSortPageState extends State with ReorderMixin { final item = sortList[index]; return SizedBox( key: ValueKey(item.id), - height: 98, + height: 110, child: FavVideoCardH(item: item), ); }, diff --git a/lib/pages/history_search/view.dart b/lib/pages/history_search/view.dart index 1a50284e8..b5a9ba0f0 100644 --- a/lib/pages/history_search/view.dart +++ b/lib/pages/history_search/view.dart @@ -17,19 +17,14 @@ class HistorySearchPage extends StatefulWidget { class _HistorySearchPageState extends - CommonSearchPageState< - HistorySearchPage, - HistoryData, - HistoryItemModel - > { + CommonSearchPageState + with GridMixin { @override final HistorySearchController controller = Get.put( HistorySearchController(), tag: Utils.generateRandomString(8), ); - late final gridDelegate = Grid.videoCardHDelegate(context, minHeight: 110); - @override Widget buildList(List list) { return SliverGrid.builder( diff --git a/lib/pages/later_search/view.dart b/lib/pages/later_search/view.dart index 8f2f3737b..20646a51c 100644 --- a/lib/pages/later_search/view.dart +++ b/lib/pages/later_search/view.dart @@ -19,7 +19,8 @@ class LaterSearchPage extends StatefulWidget { } class _LaterSearchPageState - extends CommonSearchPageState { + extends CommonSearchPageState + with GridMixin { @override final LaterSearchController controller = Get.put( LaterSearchController(), @@ -58,8 +59,6 @@ class _LaterSearchPageState ]; } - late final gridDelegate = Grid.videoCardHDelegate(context, minHeight: 110); - @override Widget buildList(List list) { return SliverGrid.builder( diff --git a/lib/pages/member_audio/view.dart b/lib/pages/member_audio/view.dart index 78ce6f192..8f8c7d1d2 100644 --- a/lib/pages/member_audio/view.dart +++ b/lib/pages/member_audio/view.dart @@ -26,7 +26,7 @@ class MemberAudio extends StatefulWidget { } class _MemberAudioState extends State - with AutomaticKeepAliveClientMixin { + with AutomaticKeepAliveClientMixin, GridMixin { late final MemberAudioController _controller; @override @@ -63,13 +63,6 @@ class _MemberAudioState extends State @override bool get wantKeepAlive => true; - late final gridDelegate = SliverGridDelegateWithExtentAndRatio( - mainAxisSpacing: 2, - maxCrossAxisExtent: Grid.smallCardWidth * 2, - childAspectRatio: Style.aspectRatio * 2.6, - minHeight: MediaQuery.textScalerOf(context).scale(90), - ); - Widget _buildBody( ColorScheme colorScheme, LoadingState?> loadingState, diff --git a/lib/pages/member_favorite/view.dart b/lib/pages/member_favorite/view.dart index 599f33eae..1ad4b187a 100644 --- a/lib/pages/member_favorite/view.dart +++ b/lib/pages/member_favorite/view.dart @@ -70,7 +70,7 @@ class _MemberFavoriteState extends State Loading() => SliverPadding( padding: const EdgeInsets.only(top: 7), sliver: SliverGrid.builder( - gridDelegate: Grid.videoCardHDelegate(context), + gridDelegate: gridDelegate, itemBuilder: (context, index) => const VideoCardHSkeleton(), itemCount: 10, ), @@ -169,7 +169,7 @@ class _MemberFavoriteState extends State itemBuilder: (context, index) { final item = list[index]; return SizedBox( - height: 98, + height: 110, child: MemberFavItem( item: item, onDelete: (isDeleted) { diff --git a/lib/pages/member_home/view.dart b/lib/pages/member_home/view.dart index d8c6e3acc..113f76a1b 100644 --- a/lib/pages/member_home/view.dart +++ b/lib/pages/member_home/view.dart @@ -52,12 +52,7 @@ class _MemberHomeState extends State mainAxisExtent: MediaQuery.textScalerOf(context).scale(55), ); - late final gridDelegateAudio = SliverGridDelegateWithExtentAndRatio( - mainAxisSpacing: 2, - maxCrossAxisExtent: Grid.smallCardWidth * 2, - childAspectRatio: Style.aspectRatio * 2.6, - minHeight: MediaQuery.textScalerOf(context).scale(90), - ); + late final gridDelegateAudio = Grid.videoCardHDelegate(); late final gridDelegatePgc = SliverGridDelegateWithExtentAndRatio( mainAxisSpacing: Style.cardSpace, @@ -114,7 +109,7 @@ class _MemberHomeState extends State ), SliverToBoxAdapter( child: SizedBox( - height: 98, + height: 110, child: MemberFavItem( item: res.favourite2!.item!.first, ), @@ -183,7 +178,7 @@ class _MemberHomeState extends State ), SliverToBoxAdapter( child: SizedBox( - height: 98, + height: 110, child: MemberArticleItem( item: res.article!.item!.first, ), diff --git a/lib/pages/member_home/widgets/fav_item.dart b/lib/pages/member_home/widgets/fav_item.dart index 138ba9540..1bdcebb3b 100644 --- a/lib/pages/member_home/widgets/fav_item.dart +++ b/lib/pages/member_home/widgets/fav_item.dart @@ -42,8 +42,8 @@ class MemberFavItem extends StatelessWidget { children: [ NetworkImgLayer( src: item.cover, - width: 140.8, - height: 88, + width: 160, + height: 100, ), const SizedBox(width: 10), Expanded( diff --git a/lib/pages/search_panel/all/view.dart b/lib/pages/search_panel/all/view.dart index 5e346822d..fdee2e4a5 100644 --- a/lib/pages/search_panel/all/view.dart +++ b/lib/pages/search_panel/all/view.dart @@ -104,7 +104,7 @@ class _SearchAllPanelState @override Widget get buildLoading => SliverGrid.builder( - gridDelegate: Grid.videoCardHDelegate(context), + gridDelegate: Grid.videoCardHDelegate(), itemBuilder: (context, index) => const VideoCardHSkeleton(), itemCount: 10, ); diff --git a/lib/pages/search_panel/pgc/view.dart b/lib/pages/search_panel/pgc/view.dart index 154f41098..bfa411cee 100644 --- a/lib/pages/search_panel/pgc/view.dart +++ b/lib/pages/search_panel/pgc/view.dart @@ -70,7 +70,6 @@ class _SearchPgcPanelState mainAxisSpacing: 2, maxCrossAxisExtent: Grid.smallCardWidth * 2, childAspectRatio: Style.aspectRatio * 1.5, - minHeight: MediaQuery.textScalerOf(context).scale(155), ), itemBuilder: (context, index) => const MediaPgcSkeleton(), itemCount: 10, diff --git a/lib/pages/video/download_panel/view.dart b/lib/pages/video/download_panel/view.dart index 9f14590b5..01298cf09 100644 --- a/lib/pages/video/download_panel/view.dart +++ b/lib/pages/video/download_panel/view.dart @@ -383,7 +383,7 @@ class _DownloadPanelState extends State { return Padding( padding: const EdgeInsets.only(bottom: 2), child: SizedBox( - height: 98, + height: 110, child: Builder( builder: (context) { return Material( @@ -412,8 +412,8 @@ class _DownloadPanelState extends State { children: [ NetworkImgLayer( src: cover, - width: 140.8, - height: 88, + width: 160, + height: 100, cacheWidth: cacheWidth, ), if (duration != null && duration > 0) diff --git a/lib/pages/video/introduction/local/controller.dart b/lib/pages/video/introduction/local/controller.dart index 31c1050d5..f36a8110d 100644 --- a/lib/pages/video/introduction/local/controller.dart +++ b/lib/pages/video/introduction/local/controller.dart @@ -88,7 +88,7 @@ class LocalIntroController extends CommonIntroController { } final index = (-1).obs; - double get _offset => index * 100 + 7 - 35; + double get _offset => index * 112 + 7 - 35; final list = RxList(); @override diff --git a/lib/pages/video/introduction/local/view.dart b/lib/pages/video/introduction/local/view.dart index 18ff9b717..6f5629ae2 100644 --- a/lib/pages/video/introduction/local/view.dart +++ b/lib/pages/video/introduction/local/view.dart @@ -42,7 +42,7 @@ class _LocalIntroPanelState extends State final item = _controller.list[index]; return _buildItem(theme, currIndex == index, index, item); }, - itemExtent: 100, + itemExtent: 112, ); }); } @@ -59,7 +59,7 @@ class _LocalIntroPanelState extends State return Padding( padding: const EdgeInsets.only(bottom: 2), child: SizedBox( - height: 98, + height: 110, child: Material( type: MaterialType.transparency, child: InkWell( @@ -85,15 +85,15 @@ class _LocalIntroPanelState extends State borderRadius: Style.mdRadius, child: Image.file( cover, - width: 140.8, - height: 88, + width: 160, + height: 100, fit: BoxFit.cover, cacheWidth: cacheWidth - ? 140.8.cacheSize(context) + ? 160.cacheSize(context) : null, cacheHeight: cacheWidth ? null - : 88.cacheSize(context), + : 100.cacheSize(context), colorBlendMode: NetworkImgLayer.reduce ? BlendMode.modulate : null, @@ -104,8 +104,8 @@ class _LocalIntroPanelState extends State ) : NetworkImgLayer( src: entry.cover, - width: 140.8, - height: 88, + width: 160, + height: 100, ), PBadge( text: DurationUtils.formatDuration( diff --git a/lib/pages/video/medialist/view.dart b/lib/pages/video/medialist/view.dart index d322d7316..654ce0b00 100644 --- a/lib/pages/video/medialist/view.dart +++ b/lib/pages/video/medialist/view.dart @@ -57,7 +57,7 @@ class _MediaListPanelState extends State final bvid = widget.bvid; final bvIndex = widget.mediaList.indexWhere((item) => item.bvid == bvid); _controller = ScrollController( - initialScrollOffset: bvIndex <= 0 ? 0 : bvIndex * 100.0 + 7, + initialScrollOffset: bvIndex <= 0 ? 0 : bvIndex * 112.0 + 7, ); } @@ -131,7 +131,7 @@ class _MediaListPanelState extends State ), sliver: Obx( () => SliverFixedExtentList.builder( - itemExtent: 100, + itemExtent: 112, itemCount: widget.mediaList.length, itemBuilder: (context, index) { if (index == widget.mediaList.length - 1 && @@ -166,7 +166,7 @@ class _MediaListPanelState extends State return Padding( padding: const EdgeInsets.only(bottom: 2), child: SizedBox( - height: 98, + height: 110, child: Material( type: MaterialType.transparency, child: InkWell( @@ -196,8 +196,8 @@ class _MediaListPanelState extends State children: [ NetworkImgLayer( src: item.cover, - width: 140.8, - height: 88, + width: 160, + height: 100, ), if (item.badge?.isNotEmpty == true) PBadge( diff --git a/lib/pages/video/member/view.dart b/lib/pages/video/member/view.dart index 4fe42183c..18cf3ccfd 100644 --- a/lib/pages/video/member/view.dart +++ b/lib/pages/video/member/view.dart @@ -66,7 +66,7 @@ class _HorizontalMemberPageState extends State { final index = res.response?.indexWhere((e) => e.bvid == _bvid) ?? -1; if (index != -1) { WidgetsBinding.instance.addPostFrameCallback((_) { - _controller.scrollController.jumpTo(100.0 * index); + _controller.scrollController.jumpTo(112.0 * index); }); } } @@ -177,7 +177,7 @@ class _HorizontalMemberPageState extends State { Loading() => SliverFixedExtentList.builder( itemCount: 10, itemBuilder: (_, _) => const VideoCardHSkeleton(), - itemExtent: 100, + itemExtent: 112, ), Success(:final response) => response != null && response.isNotEmpty @@ -209,7 +209,7 @@ class _HorizontalMemberPageState extends State { ); }, itemCount: response.length, - itemExtent: 100, + itemExtent: 112, ), ], ) diff --git a/lib/pages/video/view_point/view.dart b/lib/pages/video/view_point/view.dart index 58dec4a41..c33d2cafd 100644 --- a/lib/pages/video/view_point/view.dart +++ b/lib/pages/video/view_point/view.dart @@ -144,7 +144,11 @@ class _ViewPointsPageState extends State child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - NetworkImgLayer(src: segment.url, width: 140.8, height: 88), + NetworkImgLayer( + src: segment.url, + width: 160, + height: 100, + ), const SizedBox(width: 10), Expanded( child: Column( diff --git a/lib/utils/grid.dart b/lib/utils/grid.dart index 30f178afd..52b51d144 100644 --- a/lib/utils/grid.dart +++ b/lib/utils/grid.dart @@ -1,13 +1,12 @@ import 'dart:math'; import 'package:PiliPlus/common/skeleton/video_card_h.dart'; -import 'package:PiliPlus/common/style.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -mixin GridMixin on State { - late final gridDelegate = Grid.videoCardHDelegate(context); +mixin GridMixin { + late final gridDelegate = Grid.videoCardHDelegate(); Widget get gridSkeleton => SliverGrid.builder( gridDelegate: gridDelegate, @@ -19,14 +18,12 @@ mixin GridMixin on State { abstract final class Grid { static final double smallCardWidth = Pref.smallCardWidth; - static SliverGridDelegateWithExtentAndRatio videoCardHDelegate( - BuildContext context, { - double minHeight = 90, - }) => SliverGridDelegateWithExtentAndRatio( + static SliverGridDelegateWithMaxCrossAxisExtent videoCardHDelegate({ + double mainAxisExtent = 110, + }) => SliverGridDelegateWithMaxCrossAxisExtent( mainAxisSpacing: 2, + mainAxisExtent: mainAxisExtent, maxCrossAxisExtent: Grid.smallCardWidth * 2, - childAspectRatio: Style.aspectRatio * 2.2, - minHeight: MediaQuery.textScalerOf(context).scale(minHeight), ); } @@ -43,14 +40,10 @@ class SliverGridDelegateWithExtentAndRatio extends SliverGridDelegate { this.crossAxisSpacing = 0.0, this.childAspectRatio = 1.0, this.mainAxisExtent = 0.0, - this.minHeight = 0.0, }) : assert(maxCrossAxisExtent > 0), assert(mainAxisSpacing >= 0), assert(crossAxisSpacing >= 0), - assert(childAspectRatio > 0), - assert(minHeight >= 0); - - final double minHeight; + assert(childAspectRatio > 0); /// The maximum extent of tiles in the cross axis. /// @@ -111,10 +104,8 @@ class SliverGridDelegateWithExtentAndRatio extends SliverGridDelegate { constraints.crossAxisExtent - crossAxisSpacing * (crossAxisCount - 1), ); final double childCrossAxisExtent = usableCrossAxisExtent / crossAxisCount; - final double childMainAxisExtent = max( - minHeight, - childCrossAxisExtent / childAspectRatio + mainAxisExtent, - ); + final double childMainAxisExtent = + childCrossAxisExtent / childAspectRatio + mainAxisExtent; return layoutCache = SliverGridRegularTileLayout( crossAxisCount: crossAxisCount, mainAxisStride: childMainAxisExtent + mainAxisSpacing,