mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-22 10:06:23 +08:00
@@ -1,10 +1,21 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
mixin GridMixin<T extends StatefulWidget> on State<T> {
|
||||
late final gridDelegate = Grid.videoCardHDelegate(context);
|
||||
|
||||
Widget get gridSkeleton => SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (_, _) => const VideoCardHSkeleton(),
|
||||
itemCount: 10,
|
||||
);
|
||||
}
|
||||
|
||||
class Grid {
|
||||
static final double smallCardWidth = Pref.smallCardWidth;
|
||||
|
||||
|
||||
@@ -10,11 +10,12 @@ import 'package:waterfall_flow/waterfall_flow.dart'
|
||||
mixin DynMixin {
|
||||
late double maxWidth;
|
||||
|
||||
late final gridDelegate = SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
crossAxisSpacing: 4,
|
||||
callback: (value) => maxWidth = value,
|
||||
);
|
||||
late final dynGridDelegate =
|
||||
SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
crossAxisSpacing: 4,
|
||||
callback: (value) => maxWidth = value,
|
||||
);
|
||||
|
||||
late final skeDelegate = SliverGridDelegateWithExtentAndRatio(
|
||||
crossAxisSpacing: 4,
|
||||
@@ -25,27 +26,25 @@ mixin DynMixin {
|
||||
);
|
||||
|
||||
Widget get dynSkeleton {
|
||||
if (!GlobalData().dynamicsWaterfallFlow) {
|
||||
return SliverCrossAxisGroup(
|
||||
slivers: [
|
||||
const SliverFillRemaining(),
|
||||
SliverConstrainedCrossAxis(
|
||||
maxExtent: Grid.smallCardWidth * 2,
|
||||
sliver: SliverList.builder(
|
||||
itemBuilder: (_, _) => const DynamicCardSkeleton(),
|
||||
itemCount: 10,
|
||||
),
|
||||
),
|
||||
const SliverFillRemaining(),
|
||||
],
|
||||
if (GlobalData().dynamicsWaterfallFlow) {
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: skeDelegate,
|
||||
itemBuilder: (_, _) => const DynamicCardSkeleton(),
|
||||
itemCount: 10,
|
||||
);
|
||||
}
|
||||
return SliverGrid(
|
||||
gridDelegate: skeDelegate,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, _) => const DynamicCardSkeleton(),
|
||||
childCount: 10,
|
||||
),
|
||||
return SliverCrossAxisGroup(
|
||||
slivers: [
|
||||
const SliverFillRemaining(),
|
||||
SliverConstrainedCrossAxis(
|
||||
maxExtent: Grid.smallCardWidth * 2,
|
||||
sliver: SliverList.builder(
|
||||
itemBuilder: (_, _) => const DynamicCardSkeleton(),
|
||||
itemCount: 10,
|
||||
),
|
||||
),
|
||||
const SliverFillRemaining(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user