mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: hide cell
This commit is contained in:
parent
9188c1193e
commit
02283038d5
@ -69,7 +69,11 @@ class BoardContent extends StatelessWidget {
|
||||
dataController: context.read<BoardBloc>().boardController,
|
||||
headerBuilder: _buildHeader,
|
||||
footBuilder: _buildFooter,
|
||||
cardBuilder: (_, data) => _buildCard(context, data),
|
||||
cardBuilder: (_, column, columnItem) => _buildCard(
|
||||
context,
|
||||
column,
|
||||
columnItem,
|
||||
),
|
||||
columnConstraints: const BoxConstraints.tightFor(width: 240),
|
||||
config: AFBoardConfig(
|
||||
columnBackgroundColor: HexColor.fromHex('#F7F8FC'),
|
||||
@ -129,12 +133,16 @@ class BoardContent extends StatelessWidget {
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildCard(BuildContext context, AFColumnItem item) {
|
||||
final rowPB = (item as BoardColumnItem).row;
|
||||
Widget _buildCard(
|
||||
BuildContext context,
|
||||
AFBoardColumnData column,
|
||||
AFColumnItem columnItem,
|
||||
) {
|
||||
final rowPB = (columnItem as BoardColumnItem).row;
|
||||
final rowCache = context.read<BoardBloc>().getRowCache(rowPB.blockId);
|
||||
|
||||
/// Return placeholder widget if the rowCache is null.
|
||||
if (rowCache == null) return SizedBox(key: ObjectKey(item));
|
||||
if (rowCache == null) return SizedBox(key: ObjectKey(columnItem));
|
||||
|
||||
final fieldCache = context.read<BoardBloc>().fieldCache;
|
||||
final gridId = context.read<BoardBloc>().gridId;
|
||||
@ -151,11 +159,12 @@ class BoardContent extends StatelessWidget {
|
||||
);
|
||||
|
||||
return AppFlowyColumnItemCard(
|
||||
key: ObjectKey(item),
|
||||
key: ObjectKey(columnItem),
|
||||
margin: config.cardPadding,
|
||||
decoration: _makeBoxDecoration(context),
|
||||
child: BoardCard(
|
||||
gridId: gridId,
|
||||
groupId: column.id,
|
||||
isEditing: isEditing,
|
||||
cellBuilder: cellBuilder,
|
||||
dataController: cardController,
|
||||
|
@ -6,9 +6,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class BoardCheckboxCell extends StatefulWidget {
|
||||
final String groupId;
|
||||
final GridCellControllerBuilder cellControllerBuilder;
|
||||
|
||||
const BoardCheckboxCell({
|
||||
required this.groupId,
|
||||
required this.cellControllerBuilder,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
@ -8,9 +8,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'define.dart';
|
||||
|
||||
class BoardDateCell extends StatefulWidget {
|
||||
final String groupId;
|
||||
final GridCellControllerBuilder cellControllerBuilder;
|
||||
|
||||
const BoardDateCell({
|
||||
required this.groupId,
|
||||
required this.cellControllerBuilder,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
@ -7,9 +7,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'define.dart';
|
||||
|
||||
class BoardNumberCell extends StatefulWidget {
|
||||
final String groupId;
|
||||
final GridCellControllerBuilder cellControllerBuilder;
|
||||
|
||||
const BoardNumberCell({
|
||||
required this.groupId,
|
||||
required this.cellControllerBuilder,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
@ -7,9 +7,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'define.dart';
|
||||
|
||||
class BoardSelectOptionCell extends StatefulWidget {
|
||||
final String groupId;
|
||||
final GridCellControllerBuilder cellControllerBuilder;
|
||||
|
||||
const BoardSelectOptionCell({
|
||||
required this.groupId,
|
||||
required this.cellControllerBuilder,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
@ -36,23 +38,29 @@ class _BoardSelectOptionCellState extends State<BoardSelectOptionCell> {
|
||||
value: _cellBloc,
|
||||
child: BlocBuilder<BoardSelectOptionCellBloc, BoardSelectOptionCellState>(
|
||||
builder: (context, state) {
|
||||
final children = state.selectedOptions
|
||||
.map(
|
||||
(option) => SelectOptionTag.fromOption(
|
||||
context: context,
|
||||
option: option,
|
||||
if (state.selectedOptions
|
||||
.where((element) => element.id == widget.groupId)
|
||||
.isNotEmpty) {
|
||||
return const SizedBox();
|
||||
} else {
|
||||
final children = state.selectedOptions
|
||||
.map(
|
||||
(option) => SelectOptionTag.fromOption(
|
||||
context: context,
|
||||
option: option,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(top: BoardSizes.cardCellVPadding),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: AbsorbPointer(
|
||||
child: Wrap(children: children, spacing: 4, runSpacing: 2),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(top: BoardSizes.cardCellVPadding),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: AbsorbPointer(
|
||||
child: Wrap(children: children, spacing: 4, runSpacing: 2),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
@ -7,9 +7,13 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'define.dart';
|
||||
|
||||
class BoardTextCell extends StatefulWidget {
|
||||
final String groupId;
|
||||
final GridCellControllerBuilder cellControllerBuilder;
|
||||
const BoardTextCell({required this.cellControllerBuilder, Key? key})
|
||||
: super(key: key);
|
||||
const BoardTextCell({
|
||||
required this.groupId,
|
||||
required this.cellControllerBuilder,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<BoardTextCell> createState() => _BoardTextCellState();
|
||||
|
@ -7,9 +7,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'define.dart';
|
||||
|
||||
class BoardUrlCell extends StatefulWidget {
|
||||
final String groupId;
|
||||
final GridCellControllerBuilder cellControllerBuilder;
|
||||
|
||||
const BoardUrlCell({
|
||||
required this.groupId,
|
||||
required this.cellControllerBuilder,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
@ -14,6 +14,7 @@ typedef OnEndEditing = void Function(String rowId);
|
||||
|
||||
class BoardCard extends StatefulWidget {
|
||||
final String gridId;
|
||||
final String groupId;
|
||||
final bool isEditing;
|
||||
final CardDataController dataController;
|
||||
final BoardCellBuilder cellBuilder;
|
||||
@ -22,6 +23,7 @@ class BoardCard extends StatefulWidget {
|
||||
|
||||
const BoardCard({
|
||||
required this.gridId,
|
||||
required this.groupId,
|
||||
required this.isEditing,
|
||||
required this.dataController,
|
||||
required this.cellBuilder,
|
||||
@ -71,7 +73,7 @@ class _BoardCardState extends State<BoardCard> {
|
||||
List<Widget> _makeCells(BuildContext context, GridCellMap cellMap) {
|
||||
return cellMap.values.map(
|
||||
(cellId) {
|
||||
final child = widget.cellBuilder.buildCell(cellId);
|
||||
final child = widget.cellBuilder.buildCell(widget.groupId, cellId);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: child,
|
||||
|
@ -19,7 +19,7 @@ class BoardCellBuilder {
|
||||
|
||||
BoardCellBuilder(this.delegate);
|
||||
|
||||
Widget buildCell(GridCellIdentifier cellId) {
|
||||
Widget buildCell(String groupId, GridCellIdentifier cellId) {
|
||||
final cellControllerBuilder = GridCellControllerBuilder(
|
||||
delegate: delegate,
|
||||
cellId: cellId,
|
||||
@ -30,36 +30,43 @@ class BoardCellBuilder {
|
||||
switch (cellId.fieldType) {
|
||||
case FieldType.Checkbox:
|
||||
return BoardCheckboxCell(
|
||||
groupId: groupId,
|
||||
cellControllerBuilder: cellControllerBuilder,
|
||||
key: key,
|
||||
);
|
||||
case FieldType.DateTime:
|
||||
return BoardDateCell(
|
||||
groupId: groupId,
|
||||
cellControllerBuilder: cellControllerBuilder,
|
||||
key: key,
|
||||
);
|
||||
case FieldType.SingleSelect:
|
||||
return BoardSelectOptionCell(
|
||||
groupId: groupId,
|
||||
cellControllerBuilder: cellControllerBuilder,
|
||||
key: key,
|
||||
);
|
||||
case FieldType.MultiSelect:
|
||||
return BoardSelectOptionCell(
|
||||
groupId: groupId,
|
||||
cellControllerBuilder: cellControllerBuilder,
|
||||
key: key,
|
||||
);
|
||||
case FieldType.Number:
|
||||
return BoardNumberCell(
|
||||
groupId: groupId,
|
||||
cellControllerBuilder: cellControllerBuilder,
|
||||
key: key,
|
||||
);
|
||||
case FieldType.RichText:
|
||||
return BoardTextCell(
|
||||
groupId: groupId,
|
||||
cellControllerBuilder: cellControllerBuilder,
|
||||
key: key,
|
||||
);
|
||||
case FieldType.URL:
|
||||
return BoardUrlCell(
|
||||
groupId: groupId,
|
||||
cellControllerBuilder: cellControllerBuilder,
|
||||
key: key,
|
||||
);
|
||||
|
@ -94,10 +94,10 @@ class _MultiBoardListExampleState extends State<MultiBoardListExample> {
|
||||
margin: config.columnItemPadding,
|
||||
);
|
||||
},
|
||||
cardBuilder: (context, item) {
|
||||
cardBuilder: (context, column, columnItem) {
|
||||
return AppFlowyColumnItemCard(
|
||||
key: ObjectKey(item),
|
||||
child: _buildCard(item),
|
||||
key: ObjectKey(columnItem),
|
||||
child: _buildCard(columnItem),
|
||||
);
|
||||
},
|
||||
columnConstraints: const BoxConstraints.tightFor(width: 240),
|
||||
|
@ -32,8 +32,9 @@ class _SingleBoardListExampleState extends State<SingleBoardListExample> {
|
||||
Widget build(BuildContext context) {
|
||||
return AFBoard(
|
||||
dataController: boardData,
|
||||
cardBuilder: (context, item) {
|
||||
return _RowWidget(item: item as TextItem, key: ObjectKey(item));
|
||||
cardBuilder: (context, column, columnItem) {
|
||||
return _RowWidget(
|
||||
item: columnItem as TextItem, key: ObjectKey(columnItem));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ typedef OnColumnInserted = void Function(String listId, int insertedIndex);
|
||||
|
||||
typedef AFBoardColumnCardBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
AFBoardColumnData columnData,
|
||||
AFColumnItem item,
|
||||
);
|
||||
|
||||
@ -207,7 +208,7 @@ class _AFBoardColumnWidgetState extends State<AFBoardColumnWidget> {
|
||||
passthroughPhantomContext: item.phantomContext,
|
||||
);
|
||||
} else {
|
||||
return widget.cardBuilder(context, item);
|
||||
return widget.cardBuilder(context, widget.dataSource.columnData, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user