mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-15 22:56:15 +08:00
118 lines
4.2 KiB
Dart
118 lines
4.2 KiB
Dart
import 'package:PiliPlus/common/constants.dart';
|
|
import 'package:PiliPlus/common/widgets/video_card_h.dart';
|
|
import 'package:PiliPlus/models/search/result.dart';
|
|
import 'package:PiliPlus/pages/bangumi/widgets/bangumi_card_v_search.dart';
|
|
import 'package:PiliPlus/pages/search_panel/all/controller.dart';
|
|
import 'package:PiliPlus/pages/search_panel/pgc/widgets/item.dart';
|
|
import 'package:PiliPlus/pages/search_panel/user/widgets/item.dart';
|
|
import 'package:PiliPlus/pages/search_panel/view.dart';
|
|
import 'package:PiliPlus/utils/grid.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:waterfall_flow/waterfall_flow.dart';
|
|
|
|
class SearchAllPanel extends CommonSearchPanel {
|
|
const SearchAllPanel({
|
|
super.key,
|
|
required super.keyword,
|
|
required super.tag,
|
|
required super.searchType,
|
|
super.hasHeader = false,
|
|
});
|
|
|
|
@override
|
|
State<SearchAllPanel> createState() => _SearchAllPanelState();
|
|
}
|
|
|
|
class _SearchAllPanelState
|
|
extends CommonSearchPanelState<SearchAllPanel, SearchAllModel, dynamic> {
|
|
@override
|
|
late final SearchAllController controller = Get.put(
|
|
SearchAllController(
|
|
keyword: widget.keyword,
|
|
searchType: widget.searchType,
|
|
tag: widget.tag,
|
|
),
|
|
tag: widget.searchType.name + widget.tag,
|
|
);
|
|
|
|
late final TextStyle pgcStyle = TextStyle(fontSize: 13);
|
|
late TextStyle userStyle;
|
|
|
|
@override
|
|
void didChangeDependencies() {
|
|
super.didChangeDependencies();
|
|
userStyle = TextStyle(
|
|
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
|
color: Theme.of(context).colorScheme.outline,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget buildList(List<dynamic> list) {
|
|
return SliverPadding(
|
|
padding: const EdgeInsets.only(bottom: 80),
|
|
sliver: SliverWaterfallFlow.extent(
|
|
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
|
crossAxisSpacing: StyleString.safeSpace,
|
|
lastChildLayoutTypeBuilder: (index) {
|
|
if (index == list.length - 1) {
|
|
controller.onLoadMore();
|
|
}
|
|
return index == list.length
|
|
? LastChildLayoutType.foot
|
|
: LastChildLayoutType.none;
|
|
},
|
|
children: list
|
|
.map(
|
|
(item) => switch (item) {
|
|
SearchVideoItemModel() => SizedBox(
|
|
height: 120,
|
|
child: VideoCardH(
|
|
videoItem: item,
|
|
showPubdate: true,
|
|
),
|
|
),
|
|
List<SearchMBangumiItemModel>() => item.length == 1
|
|
? SizedBox(
|
|
height: 160,
|
|
child: SearchPgcItem(style: pgcStyle, item: item.first),
|
|
)
|
|
: SizedBox(
|
|
height: Grid.smallCardWidth / 2 / 0.75 +
|
|
MediaQuery.textScalerOf(context).scale(60),
|
|
child: ListView.builder(
|
|
padding: const EdgeInsets.only(bottom: 7),
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: item.length,
|
|
itemBuilder: (context, index) {
|
|
return Container(
|
|
width: Grid.smallCardWidth / 2,
|
|
margin: EdgeInsets.only(
|
|
left: StyleString.safeSpace,
|
|
right: index == item.length - 1
|
|
? StyleString.safeSpace
|
|
: 0,
|
|
),
|
|
child: BangumiCardVSearch(item: item[index]),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
SearchUserItemModel() => Padding(
|
|
padding: const EdgeInsets.only(bottom: 5),
|
|
child: SearchUserItem(
|
|
style: userStyle,
|
|
item: item,
|
|
),
|
|
),
|
|
_ => const SizedBox.shrink(),
|
|
},
|
|
)
|
|
.toList(),
|
|
),
|
|
);
|
|
}
|
|
}
|