Skip to content

Commit 0cf15d5

Browse files
authored
Merge pull request #910 from AppFlowy-IO/feat/hide_card_cell
chore: hide cell
2 parents 0035115 + 0228303 commit 0cf15d5

File tree

12 files changed

+70
-30
lines changed

12 files changed

+70
-30
lines changed

frontend/app_flowy/lib/plugins/board/presentation/board_page.dart

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ class BoardContent extends StatelessWidget {
6969
dataController: context.read<BoardBloc>().boardController,
7070
headerBuilder: _buildHeader,
7171
footBuilder: _buildFooter,
72-
cardBuilder: (_, data) => _buildCard(context, data),
72+
cardBuilder: (_, column, columnItem) => _buildCard(
73+
context,
74+
column,
75+
columnItem,
76+
),
7377
columnConstraints: const BoxConstraints.tightFor(width: 240),
7478
config: AFBoardConfig(
7579
columnBackgroundColor: HexColor.fromHex('#F7F8FC'),
@@ -129,12 +133,16 @@ class BoardContent extends StatelessWidget {
129133
});
130134
}
131135

132-
Widget _buildCard(BuildContext context, AFColumnItem item) {
133-
final rowPB = (item as BoardColumnItem).row;
136+
Widget _buildCard(
137+
BuildContext context,
138+
AFBoardColumnData column,
139+
AFColumnItem columnItem,
140+
) {
141+
final rowPB = (columnItem as BoardColumnItem).row;
134142
final rowCache = context.read<BoardBloc>().getRowCache(rowPB.blockId);
135143

136144
/// Return placeholder widget if the rowCache is null.
137-
if (rowCache == null) return SizedBox(key: ObjectKey(item));
145+
if (rowCache == null) return SizedBox(key: ObjectKey(columnItem));
138146

139147
final fieldCache = context.read<BoardBloc>().fieldCache;
140148
final gridId = context.read<BoardBloc>().gridId;
@@ -151,11 +159,12 @@ class BoardContent extends StatelessWidget {
151159
);
152160

153161
return AppFlowyColumnItemCard(
154-
key: ObjectKey(item),
162+
key: ObjectKey(columnItem),
155163
margin: config.cardPadding,
156164
decoration: _makeBoxDecoration(context),
157165
child: BoardCard(
158166
gridId: gridId,
167+
groupId: column.id,
159168
isEditing: isEditing,
160169
cellBuilder: cellBuilder,
161170
dataController: cardController,

frontend/app_flowy/lib/plugins/board/presentation/card/board_checkbox_cell.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import 'package:flutter/material.dart';
66
import 'package:flutter_bloc/flutter_bloc.dart';
77

88
class BoardCheckboxCell extends StatefulWidget {
9+
final String groupId;
910
final GridCellControllerBuilder cellControllerBuilder;
1011

1112
const BoardCheckboxCell({
13+
required this.groupId,
1214
required this.cellControllerBuilder,
1315
Key? key,
1416
}) : super(key: key);

frontend/app_flowy/lib/plugins/board/presentation/card/board_date_cell.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
88
import 'define.dart';
99

1010
class BoardDateCell extends StatefulWidget {
11+
final String groupId;
1112
final GridCellControllerBuilder cellControllerBuilder;
1213

1314
const BoardDateCell({
15+
required this.groupId,
1416
required this.cellControllerBuilder,
1517
Key? key,
1618
}) : super(key: key);

frontend/app_flowy/lib/plugins/board/presentation/card/board_number_cell.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
77
import 'define.dart';
88

99
class BoardNumberCell extends StatefulWidget {
10+
final String groupId;
1011
final GridCellControllerBuilder cellControllerBuilder;
1112

1213
const BoardNumberCell({
14+
required this.groupId,
1315
required this.cellControllerBuilder,
1416
Key? key,
1517
}) : super(key: key);

frontend/app_flowy/lib/plugins/board/presentation/card/board_select_option_cell.dart

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
77
import 'define.dart';
88

99
class BoardSelectOptionCell extends StatefulWidget {
10+
final String groupId;
1011
final GridCellControllerBuilder cellControllerBuilder;
1112

1213
const BoardSelectOptionCell({
14+
required this.groupId,
1315
required this.cellControllerBuilder,
1416
Key? key,
1517
}) : super(key: key);
@@ -36,23 +38,29 @@ class _BoardSelectOptionCellState extends State<BoardSelectOptionCell> {
3638
value: _cellBloc,
3739
child: BlocBuilder<BoardSelectOptionCellBloc, BoardSelectOptionCellState>(
3840
builder: (context, state) {
39-
final children = state.selectedOptions
40-
.map(
41-
(option) => SelectOptionTag.fromOption(
42-
context: context,
43-
option: option,
41+
if (state.selectedOptions
42+
.where((element) => element.id == widget.groupId)
43+
.isNotEmpty) {
44+
return const SizedBox();
45+
} else {
46+
final children = state.selectedOptions
47+
.map(
48+
(option) => SelectOptionTag.fromOption(
49+
context: context,
50+
option: option,
51+
),
52+
)
53+
.toList();
54+
return Padding(
55+
padding: EdgeInsets.only(top: BoardSizes.cardCellVPadding),
56+
child: Align(
57+
alignment: Alignment.centerLeft,
58+
child: AbsorbPointer(
59+
child: Wrap(children: children, spacing: 4, runSpacing: 2),
4460
),
45-
)
46-
.toList();
47-
return Padding(
48-
padding: EdgeInsets.only(top: BoardSizes.cardCellVPadding),
49-
child: Align(
50-
alignment: Alignment.centerLeft,
51-
child: AbsorbPointer(
52-
child: Wrap(children: children, spacing: 4, runSpacing: 2),
5361
),
54-
),
55-
);
62+
);
63+
}
5664
},
5765
),
5866
);

frontend/app_flowy/lib/plugins/board/presentation/card/board_text_cell.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import 'package:flutter_bloc/flutter_bloc.dart';
77
import 'define.dart';
88

99
class BoardTextCell extends StatefulWidget {
10+
final String groupId;
1011
final GridCellControllerBuilder cellControllerBuilder;
11-
const BoardTextCell({required this.cellControllerBuilder, Key? key})
12-
: super(key: key);
12+
const BoardTextCell({
13+
required this.groupId,
14+
required this.cellControllerBuilder,
15+
Key? key,
16+
}) : super(key: key);
1317

1418
@override
1519
State<BoardTextCell> createState() => _BoardTextCellState();

frontend/app_flowy/lib/plugins/board/presentation/card/board_url_cell.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
77
import 'define.dart';
88

99
class BoardUrlCell extends StatefulWidget {
10+
final String groupId;
1011
final GridCellControllerBuilder cellControllerBuilder;
1112

1213
const BoardUrlCell({
14+
required this.groupId,
1315
required this.cellControllerBuilder,
1416
Key? key,
1517
}) : super(key: key);

frontend/app_flowy/lib/plugins/board/presentation/card/card.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ typedef OnEndEditing = void Function(String rowId);
1414

1515
class BoardCard extends StatefulWidget {
1616
final String gridId;
17+
final String groupId;
1718
final bool isEditing;
1819
final CardDataController dataController;
1920
final BoardCellBuilder cellBuilder;
@@ -22,6 +23,7 @@ class BoardCard extends StatefulWidget {
2223

2324
const BoardCard({
2425
required this.gridId,
26+
required this.groupId,
2527
required this.isEditing,
2628
required this.dataController,
2729
required this.cellBuilder,
@@ -71,7 +73,7 @@ class _BoardCardState extends State<BoardCard> {
7173
List<Widget> _makeCells(BuildContext context, GridCellMap cellMap) {
7274
return cellMap.values.map(
7375
(cellId) {
74-
final child = widget.cellBuilder.buildCell(cellId);
76+
final child = widget.cellBuilder.buildCell(widget.groupId, cellId);
7577
return Padding(
7678
padding: const EdgeInsets.symmetric(horizontal: 6),
7779
child: child,

frontend/app_flowy/lib/plugins/board/presentation/card/card_cell_builder.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BoardCellBuilder {
1919

2020
BoardCellBuilder(this.delegate);
2121

22-
Widget buildCell(GridCellIdentifier cellId) {
22+
Widget buildCell(String groupId, GridCellIdentifier cellId) {
2323
final cellControllerBuilder = GridCellControllerBuilder(
2424
delegate: delegate,
2525
cellId: cellId,
@@ -30,36 +30,43 @@ class BoardCellBuilder {
3030
switch (cellId.fieldType) {
3131
case FieldType.Checkbox:
3232
return BoardCheckboxCell(
33+
groupId: groupId,
3334
cellControllerBuilder: cellControllerBuilder,
3435
key: key,
3536
);
3637
case FieldType.DateTime:
3738
return BoardDateCell(
39+
groupId: groupId,
3840
cellControllerBuilder: cellControllerBuilder,
3941
key: key,
4042
);
4143
case FieldType.SingleSelect:
4244
return BoardSelectOptionCell(
45+
groupId: groupId,
4346
cellControllerBuilder: cellControllerBuilder,
4447
key: key,
4548
);
4649
case FieldType.MultiSelect:
4750
return BoardSelectOptionCell(
51+
groupId: groupId,
4852
cellControllerBuilder: cellControllerBuilder,
4953
key: key,
5054
);
5155
case FieldType.Number:
5256
return BoardNumberCell(
57+
groupId: groupId,
5358
cellControllerBuilder: cellControllerBuilder,
5459
key: key,
5560
);
5661
case FieldType.RichText:
5762
return BoardTextCell(
63+
groupId: groupId,
5864
cellControllerBuilder: cellControllerBuilder,
5965
key: key,
6066
);
6167
case FieldType.URL:
6268
return BoardUrlCell(
69+
groupId: groupId,
6370
cellControllerBuilder: cellControllerBuilder,
6471
key: key,
6572
);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ class _MultiBoardListExampleState extends State<MultiBoardListExample> {
9494
margin: config.columnItemPadding,
9595
);
9696
},
97-
cardBuilder: (context, item) {
97+
cardBuilder: (context, column, columnItem) {
9898
return AppFlowyColumnItemCard(
99-
key: ObjectKey(item),
100-
child: _buildCard(item),
99+
key: ObjectKey(columnItem),
100+
child: _buildCard(columnItem),
101101
);
102102
},
103103
columnConstraints: const BoxConstraints.tightFor(width: 240),

0 commit comments

Comments
 (0)