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