fix: Swiper

This commit is contained in:
xkeyC 2024-03-31 15:05:06 +08:00
parent 494ae6468d
commit c32de21fa1
4 changed files with 10 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -135,3 +135,9 @@ Future<Uint8List?> widgetToPngImage(GlobalKey repaintBoundaryKey,
double roundDoubleTo(double value, double precision) =>
(value * precision).round() / precision;
int getMinNumber(List<int> list) {
if (list.isEmpty) return 0;
list.sort((a, b) => a.compareTo(b));
return list.first;
}

View File

@ -356,7 +356,8 @@ class HomeUI extends HookConsumerWidget {
child: makeLoading(context),
)
: Swiper(
itemCount: homeState.rssVideoItems?.length ?? 0,
itemCount: getMinNumber(
[homeState.rssVideoItems?.length ?? 0, 6]),
itemBuilder: (context, index) {
final item = homeState.rssVideoItems![index];
return GestureDetector(
@ -712,7 +713,8 @@ class HomeUI extends HookConsumerWidget {
width: width,
height: 62,
child: Swiper(
itemCount: homeState.countdownFestivalListData!.length,
itemCount: getMinNumber(
[homeState.countdownFestivalListData!.length, 6]),
autoplay: true,
autoplayDelay: 5000,
itemBuilder: (context, index) {