mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-21 03:15:14 +08:00
@@ -54,82 +54,85 @@ class _RcmdPageState extends CommonPageState<RcmdPage, RcmdController>
|
||||
Widget _buildBody(LoadingState<List<dynamic>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => _buildSkeleton(),
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||
mainAxisSpacing: StyleString.cardSpace,
|
||||
crossAxisSpacing: StyleString.cardSpace,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth,
|
||||
childAspectRatio: StyleString.aspectRatio,
|
||||
mainAxisExtent: MediaQuery.textScalerOf(context).scale(90),
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index == response.length - 1) {
|
||||
controller.onLoadMore();
|
||||
}
|
||||
if (controller.lastRefreshAt != null) {
|
||||
if (controller.lastRefreshAt == index) {
|
||||
return GestureDetector(
|
||||
onTap: () => controller
|
||||
..animateToTop()
|
||||
..onRefresh(),
|
||||
child: Card(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Text(
|
||||
'上次看到这里\n点击刷新',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurfaceVariant,
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||
mainAxisSpacing: StyleString.cardSpace,
|
||||
crossAxisSpacing: StyleString.cardSpace,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth,
|
||||
childAspectRatio: StyleString.aspectRatio,
|
||||
mainAxisExtent: MediaQuery.textScalerOf(context).scale(90),
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index == response.length - 1) {
|
||||
controller.onLoadMore();
|
||||
}
|
||||
if (controller.lastRefreshAt != null) {
|
||||
if (controller.lastRefreshAt == index) {
|
||||
return GestureDetector(
|
||||
onTap: () => controller
|
||||
..animateToTop()
|
||||
..onRefresh(),
|
||||
child: Card(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
),
|
||||
child: Text(
|
||||
'上次看到这里\n点击刷新',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
int actualIndex = controller.lastRefreshAt == null
|
||||
? index
|
||||
: index > controller.lastRefreshAt!
|
||||
? index - 1
|
||||
: index;
|
||||
return VideoCardV(
|
||||
videoItem: response[actualIndex],
|
||||
onRemove: () {
|
||||
if (controller.lastRefreshAt != null &&
|
||||
actualIndex < controller.lastRefreshAt!) {
|
||||
controller.lastRefreshAt =
|
||||
controller.lastRefreshAt! - 1;
|
||||
}
|
||||
controller.loadingState
|
||||
..value.data!.removeAt(actualIndex)
|
||||
..refresh();
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return VideoCardV(
|
||||
videoItem: response[index],
|
||||
onRemove: () {
|
||||
controller.loadingState
|
||||
..value.data!.removeAt(index)
|
||||
..refresh();
|
||||
},
|
||||
);
|
||||
}
|
||||
int actualIndex = controller.lastRefreshAt == null
|
||||
? index
|
||||
: index > controller.lastRefreshAt!
|
||||
? index - 1
|
||||
: index;
|
||||
return VideoCardV(
|
||||
videoItem: response[actualIndex],
|
||||
onRemove: () {
|
||||
if (controller.lastRefreshAt != null &&
|
||||
actualIndex < controller.lastRefreshAt!) {
|
||||
controller.lastRefreshAt =
|
||||
controller.lastRefreshAt! - 1;
|
||||
}
|
||||
controller.loadingState
|
||||
..value.data!.removeAt(actualIndex)
|
||||
..refresh();
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return VideoCardV(
|
||||
videoItem: response[index],
|
||||
onRemove: () {
|
||||
controller.loadingState
|
||||
..value.data!.removeAt(index)
|
||||
..refresh();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
childCount: controller.lastRefreshAt != null
|
||||
? response!.length + 1
|
||||
: response!.length,
|
||||
),
|
||||
)
|
||||
: HttpError(onReload: controller.onReload),
|
||||
},
|
||||
childCount: controller.lastRefreshAt != null
|
||||
? response!.length + 1
|
||||
: response!.length,
|
||||
),
|
||||
)
|
||||
: HttpError(onReload: controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: controller.onReload,
|
||||
),
|
||||
errMsg: errMsg,
|
||||
onReload: controller.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user