refa: video model (#523)

This commit is contained in:
My-Responsitories
2025-03-25 10:12:44 +08:00
committed by GitHub
parent bf464994df
commit 7a6085e923
52 changed files with 761 additions and 1494 deletions

View File

@@ -65,8 +65,8 @@ class _FavSearchPageState extends State<FavSearchPage> {
return switch (loadingState) {
Loading() => errorWidget(),
Success() => (loadingState.response as List?)?.isNotEmpty == true
? _favSearchCtr.searchType == SearchType.fav
? CustomScrollView(
? switch (_favSearchCtr.searchType) {
SearchType.fav => CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: _favSearchCtr.scrollController,
slivers: [
@@ -120,54 +120,54 @@ class _FavSearchPageState extends State<FavSearchPage> {
),
),
],
)
: _favSearchCtr.searchType == SearchType.follow
? ListView.builder(
),
SearchType.follow => ListView.builder(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom + 80,
),
controller: _favSearchCtr.scrollController,
itemCount: loadingState.response.length,
itemBuilder: ((context, index) {
if (index == loadingState.response.length - 1) {
_favSearchCtr.onLoadMore();
}
return FollowItem(
item: loadingState.response[index],
);
}),
),
SearchType.history => CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: _favSearchCtr.scrollController,
slivers: [
SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom + 80,
),
controller: _favSearchCtr.scrollController,
itemCount: loadingState.response.length,
itemBuilder: ((context, index) {
if (index == loadingState.response.length - 1) {
_favSearchCtr.onLoadMore();
}
return FollowItem(
item: loadingState.response[index],
);
}),
)
: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: _favSearchCtr.scrollController,
slivers: [
SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom + 80,
),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.2,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response.length - 1) {
_favSearchCtr.onLoadMore();
}
return HistoryItem(
videoItem: loadingState.response[index],
ctr: _favSearchCtr,
onChoose: null,
);
},
childCount: loadingState.response.length,
),
),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.2,
),
],
)
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response.length - 1) {
_favSearchCtr.onLoadMore();
}
return HistoryItem(
videoItem: loadingState.response[index],
ctr: _favSearchCtr,
onChoose: null,
);
},
childCount: loadingState.response.length,
),
),
),
],
),
}
: errorWidget(
callback: _favSearchCtr.onReload,
),