mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
@@ -1,20 +1,18 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/skeleton/dynamic_card.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/sliver_layout_builder.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart' hide SliverLayoutBuilder;
|
||||
import 'package:flutter/rendering.dart' show SliverConstraints;
|
||||
import 'package:waterfall_flow/waterfall_flow.dart'
|
||||
show SliverWaterfallFlowDelegate;
|
||||
|
||||
mixin DynMixin {
|
||||
late double maxWidth;
|
||||
|
||||
late final dynGridDelegate =
|
||||
SliverWaterfallFlowDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
crossAxisSpacing: 4,
|
||||
afterCalc: (value) => maxWidth = value,
|
||||
);
|
||||
|
||||
Widget buildPage(Widget child) {
|
||||
@@ -26,7 +24,6 @@ mixin DynMixin {
|
||||
final maxWidth = constraints.crossAxisExtent;
|
||||
final cardWidth = Grid.smallCardWidth * 2;
|
||||
final flag = cardWidth < maxWidth;
|
||||
this.maxWidth = flag ? cardWidth : maxWidth;
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: flag ? (maxWidth - cardWidth) / 2 : 0,
|
||||
@@ -76,7 +73,6 @@ class SliverWaterfallFlowDelegateWithMaxCrossAxisExtent
|
||||
super.collectGarbage,
|
||||
super.viewportBuilder,
|
||||
super.closeToTrailing,
|
||||
this.afterCalc,
|
||||
}) : assert(maxCrossAxisExtent >= 0);
|
||||
|
||||
/// The maximum extent of tiles in the cross axis.
|
||||
@@ -95,8 +91,6 @@ class SliverWaterfallFlowDelegateWithMaxCrossAxisExtent
|
||||
int? crossAxisCount;
|
||||
double? crossAxisExtent;
|
||||
|
||||
final ValueChanged<double>? afterCalc;
|
||||
|
||||
@override
|
||||
int getCrossAxisCount(SliverConstraints constraints) {
|
||||
final crossAxisExtent = constraints.crossAxisExtent;
|
||||
@@ -106,10 +100,6 @@ class SliverWaterfallFlowDelegateWithMaxCrossAxisExtent
|
||||
this.crossAxisExtent = crossAxisExtent;
|
||||
crossAxisCount = (crossAxisExtent / (maxCrossAxisExtent + crossAxisSpacing))
|
||||
.ceil();
|
||||
afterCalc?.call(
|
||||
(crossAxisExtent - ((crossAxisCount! - 1) * crossAxisSpacing)) /
|
||||
crossAxisCount!,
|
||||
);
|
||||
return crossAxisCount!;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user