mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-20 17:16:29 +08:00
opt search panel
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
enum SearchType {
|
||||
// all,
|
||||
// 视频:video
|
||||
video('视频'),
|
||||
video('视频', hasHeader: true),
|
||||
// 番剧:media_bangumi,
|
||||
media_bangumi('番剧'),
|
||||
// 影视:media_ft
|
||||
@@ -16,14 +16,15 @@ enum SearchType {
|
||||
// 话题:topic
|
||||
// topic,
|
||||
// 用户:bili_user
|
||||
bili_user('用户'),
|
||||
bili_user('用户', hasHeader: true),
|
||||
// 专栏:article
|
||||
article('专栏');
|
||||
article('专栏', hasHeader: true);
|
||||
// 相簿:photo
|
||||
// photo
|
||||
|
||||
final bool hasHeader;
|
||||
final String label;
|
||||
const SearchType(this.label);
|
||||
const SearchType(this.label, {this.hasHeader = false});
|
||||
}
|
||||
|
||||
// 搜索类型为视频、专栏及相簿时
|
||||
|
||||
@@ -37,11 +37,7 @@ class _SearchAllPanelState
|
||||
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<dynamic> list) {
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||
),
|
||||
sliver: SliverWaterfallFlow.extent(
|
||||
return SliverWaterfallFlow.extent(
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
crossAxisSpacing: StyleString.safeSpace,
|
||||
lastChildLayoutTypeBuilder: (index) {
|
||||
@@ -99,7 +95,6 @@ class _SearchAllPanelState
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,8 @@ class _SearchArticlePanelState extends CommonSearchPanelState<
|
||||
);
|
||||
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<SearchArticleItemModel> list) {
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
SliverPersistentHeader(
|
||||
Widget buildHeader(ThemeData theme) {
|
||||
return SliverPersistentHeader(
|
||||
pinned: false,
|
||||
floating: true,
|
||||
delegate: CustomSliverPersistentHeaderDelegate(
|
||||
@@ -84,12 +82,12 @@ class _SearchArticlePanelState extends CommonSearchPanelState<
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||
),
|
||||
sliver: SliverGrid(
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<SearchArticleItemModel> list) {
|
||||
return SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
@@ -100,9 +98,6 @@ class _SearchArticlePanelState extends CommonSearchPanelState<
|
||||
},
|
||||
childCount: list.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,9 @@ class _SearchLivePanelState extends CommonSearchPanelState<SearchLivePanel,
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<SearchLiveItemModel> list) {
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
padding: const EdgeInsets.only(
|
||||
left: StyleString.safeSpace,
|
||||
right: StyleString.safeSpace,
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||
),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||
|
||||
@@ -32,10 +32,7 @@ class _SearchPgcPanelState extends CommonSearchPanelState<SearchPgcPanel,
|
||||
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<SearchMBangumiItemModel> list) {
|
||||
return SliverPadding(
|
||||
padding:
|
||||
EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom + 80),
|
||||
sliver: SliverGrid(
|
||||
return SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
mainAxisExtent: 160,
|
||||
@@ -49,7 +46,6 @@ class _SearchPgcPanelState extends CommonSearchPanelState<SearchPgcPanel,
|
||||
},
|
||||
childCount: list.length,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,8 @@ class _SearchUserPanelState extends CommonSearchPanelState<SearchUserPanel,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<SearchUserItemModel> list) {
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
SliverPersistentHeader(
|
||||
Widget buildHeader(ThemeData theme) {
|
||||
return SliverPersistentHeader(
|
||||
pinned: false,
|
||||
floating: true,
|
||||
delegate: CustomSliverPersistentHeaderDelegate(
|
||||
@@ -84,11 +82,12 @@ class _SearchUserPanelState extends CommonSearchPanelState<SearchUserPanel,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80),
|
||||
sliver: SliverGrid(
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<SearchUserItemModel> list) {
|
||||
return SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
mainAxisExtent: 66,
|
||||
@@ -104,9 +103,6 @@ class _SearchUserPanelState extends CommonSearchPanelState<SearchUserPanel,
|
||||
},
|
||||
childCount: list.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,8 @@ class _SearchVideoPanelState extends CommonSearchPanelState<SearchVideoPanel,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<SearchVideoItemModel> list) {
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
SliverPersistentHeader(
|
||||
Widget buildHeader(ThemeData theme) {
|
||||
return SliverPersistentHeader(
|
||||
pinned: false,
|
||||
floating: true,
|
||||
delegate: CustomSliverPersistentHeaderDelegate(
|
||||
@@ -100,11 +98,12 @@ class _SearchVideoPanelState extends CommonSearchPanelState<SearchVideoPanel,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80),
|
||||
sliver: SliverGrid(
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildList(ThemeData theme, List<SearchVideoItemModel> list) {
|
||||
return SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
@@ -118,9 +117,6 @@ class _SearchVideoPanelState extends CommonSearchPanelState<SearchVideoPanel,
|
||||
},
|
||||
childCount: list.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ abstract class CommonSearchPanelState<
|
||||
controller: controller.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
if (widget.searchType.hasHeader) buildHeader(theme),
|
||||
Obx(() => _buildBody(theme, controller.loadingState.value)),
|
||||
],
|
||||
),
|
||||
@@ -105,7 +106,11 @@ abstract class CommonSearchPanelState<
|
||||
)
|
||||
: _builLoading,
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? buildList(theme, response!)
|
||||
? SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80),
|
||||
sliver: buildList(theme, response!),
|
||||
)
|
||||
: HttpError(
|
||||
onReload: controller.onReload,
|
||||
),
|
||||
@@ -116,5 +121,7 @@ abstract class CommonSearchPanelState<
|
||||
};
|
||||
}
|
||||
|
||||
Widget buildHeader(ThemeData theme) => throw UnimplementedError();
|
||||
|
||||
Widget buildList(ThemeData theme, List<T> list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user