From a5aaec7b58f3d575633f90b7a9d9f19e40ccb3e0 Mon Sep 17 00:00:00 2001 From: orz12 Date: Wed, 7 Feb 2024 20:03:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=A8=E6=80=81=E7=80=91=E5=B8=83?= =?UTF-8?q?=E6=B5=81=E6=A8=AA=E5=B1=8F=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/dynamics/view.dart | 33 +++++++++++++++++++++++++-------- pubspec.lock | 2 +- pubspec.yaml | 2 ++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index 575c8767..685adbf4 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; import 'package:pilipala/common/skeleton/dynamic_card.dart'; import 'package:pilipala/common/widgets/http_error.dart'; import 'package:pilipala/common/widgets/no_data.dart'; @@ -14,6 +15,8 @@ import 'package:pilipala/pages/main/index.dart'; import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/storage.dart'; +import '../../common/constants.dart'; +import '../../utils/grid.dart'; import 'controller.dart'; import 'widgets/dynamic_panel.dart'; import 'widgets/up_panel.dart'; @@ -269,14 +272,28 @@ class _DynamicsPageState extends State return const NoData(); } } else { - return SliverList( - delegate: SliverChildBuilderDelegate( - (context, index) { - return DynamicPanel(item: list[index]); - }, - childCount: list.length, - ), - ); + return SliverWaterfallFlow.extent( + maxCrossAxisExtent: Grid.maxRowWidth * 2, + //cacheExtent: 0.0, + crossAxisSpacing: StyleString.safeSpace, + mainAxisSpacing: StyleString.safeSpace, + + /// follow max child trailing layout offset and layout with full cross axis extend + /// last child as loadmore item/no more item in [GridView] and [WaterfallFlow] + /// with full cross axis extend + // LastChildLayoutType.fullCrossAxisExtend, + + /// as foot at trailing and layout with full cross axis extend + /// show no more item at trailing when children are not full of viewport + /// if children is full of viewport, it's the same as fullCrossAxisExtend + // LastChildLayoutType.foot, + lastChildLayoutTypeBuilder: (index) => + index == list.length + ? LastChildLayoutType.foot + : LastChildLayoutType.none, + children: [ + for (var i in list) DynamicPanel(item: i), + ]); } }, ); diff --git a/pubspec.lock b/pubspec.lock index 2639cebc..1f081d1f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1597,7 +1597,7 @@ packages: source: hosted version: "1.1.0" waterfall_flow: - dependency: transitive + dependency: "direct main" description: name: waterfall_flow sha256: "11538b0d890458e55e6248b177732495d20893cfc7e85d7e8dbf4fdce61c9f10" diff --git a/pubspec.yaml b/pubspec.yaml index 16df4ad7..7a70a4af 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -140,6 +140,8 @@ dependencies: catcher_2: ^1.1.0 logger: ^2.0.2+1 path: 1.8.3 + #瀑布流 + waterfall_flow: ^3.0.3 dev_dependencies: flutter_test: