Skip to content

Commit

Permalink
feat: 动态瀑布流横屏支持
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Feb 7, 2024
1 parent 2f4753e commit a5aaec7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
33 changes: 25 additions & 8 deletions lib/pages/dynamics/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -269,14 +272,28 @@ class _DynamicsPageState extends State<DynamicsPage>
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),
]);
}
},
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ packages:
source: hosted
version: "1.1.0"
waterfall_flow:
dependency: transitive
dependency: "direct main"
description:
name: waterfall_flow
sha256: "11538b0d890458e55e6248b177732495d20893cfc7e85d7e8dbf4fdce61c9f10"
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a5aaec7

Please sign in to comment.