Skip to content

Commit d505314

Browse files
authored
chore: allow groups to take minimal vertical space if possible (#1736)
1 parent 2e91dfb commit d505314

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

frontend/app_flowy/packages/appflowy_board/example/lib/multi_board_list_example.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class _MultiBoardListExampleState extends State<MultiBoardListExample> {
6161
Widget build(BuildContext context) {
6262
final config = AppFlowyBoardConfig(
6363
groupBackgroundColor: HexColor.fromHex('#F7F8FC'),
64+
stretchGroupHeight: false,
6465
);
6566
return AppFlowyBoard(
6667
controller: controller,

frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class AppFlowyBoardConfig {
2727
final EdgeInsets headerPadding;
2828
final EdgeInsets cardPadding;
2929
final Color groupBackgroundColor;
30+
final bool stretchGroupHeight;
3031

3132
const AppFlowyBoardConfig({
3233
this.cornerRadius = 6.0,
@@ -36,6 +37,7 @@ class AppFlowyBoardConfig {
3637
this.headerPadding = const EdgeInsets.symmetric(horizontal: 16),
3738
this.cardPadding = const EdgeInsets.symmetric(horizontal: 3, vertical: 4),
3839
this.groupBackgroundColor = Colors.transparent,
40+
this.stretchGroupHeight = true,
3941
});
4042
}
4143

@@ -274,6 +276,7 @@ class _AppFlowyBoardContentState extends State<_AppFlowyBoardContent> {
274276
dragStateStorage: widget.boardState,
275277
dragTargetKeys: widget.boardState,
276278
reorderFlexAction: reorderFlexAction,
279+
stretchGroupHeight: widget.config.stretchGroupHeight,
277280
);
278281

279282
return ConstrainedBox(

frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_group/group.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class AppFlowyBoardGroup extends StatefulWidget {
8888

8989
final Color backgroundColor;
9090

91+
final bool stretchGroupHeight;
92+
9193
final DraggingStateStorage? dragStateStorage;
9294

9395
final ReorderDragTargeKeys? dragTargetKeys;
@@ -112,6 +114,7 @@ class AppFlowyBoardGroup extends StatefulWidget {
112114
this.itemMargin = EdgeInsets.zero,
113115
this.cornerRadius = 0.0,
114116
this.backgroundColor = Colors.transparent,
117+
this.stretchGroupHeight = true,
115118
}) : config = const ReorderFlexConfig(),
116119
super(key: key);
117120

@@ -172,7 +175,8 @@ class _AppFlowyBoardGroupState extends State<AppFlowyBoardGroup> {
172175
children: children,
173176
);
174177

175-
reorderFlex = Expanded(
178+
reorderFlex = Flexible(
179+
fit: widget.stretchGroupHeight ? FlexFit.tight : FlexFit.loose,
176180
child: Padding(padding: widget.itemMargin, child: reorderFlex),
177181
);
178182

@@ -183,7 +187,9 @@ class _AppFlowyBoardGroupState extends State<AppFlowyBoardGroup> {
183187
color: widget.backgroundColor,
184188
borderRadius: BorderRadius.circular(widget.cornerRadius),
185189
),
186-
child: Column(
190+
child: Flex(
191+
direction: Axis.vertical,
192+
mainAxisSize: MainAxisSize.min,
187193
children: [
188194
if (header != null) header,
189195
reorderFlex,

0 commit comments

Comments
 (0)