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