chore: insert cell content when creating card

This commit is contained in:
appflowy
2022-08-14 11:05:55 +08:00
parent f0914cd6f1
commit 43eaa2748d
18 changed files with 286 additions and 118 deletions

View File

@ -52,8 +52,8 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
_startListening();
await _loadGrid(emit);
},
createRow: () async {
final result = await _dataController.createRow();
createRow: (groupId) async {
final result = await _dataController.createBoardCard(groupId);
result.fold(
(rowPB) {
emit(state.copyWith(editingRow: some(rowPB)));
@ -153,7 +153,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
@freezed
class BoardEvent with _$BoardEvent {
const factory BoardEvent.initial() = InitialGrid;
const factory BoardEvent.createRow() = _CreateRow;
const factory BoardEvent.createRow(String groupId) = _CreateRow;
const factory BoardEvent.endEditRow(String rowId) = _EndEditRow;
const factory BoardEvent.didReceiveGroups(List<GroupPB> groups) =
_DidReceiveGroup;

View File

@ -21,7 +21,7 @@ typedef OnError = void Function(FlowyError);
class BoardDataController {
final String gridId;
final GridService _gridFFIService;
final GridFFIService _gridFFIService;
final GridFieldCache fieldCache;
// key: the block id
@ -45,7 +45,7 @@ class BoardDataController {
BoardDataController({required ViewPB view})
: gridId = view.id,
_blocks = LinkedHashMap.new(),
_gridFFIService = GridService(gridId: view.id),
_gridFFIService = GridFFIService(gridId: view.id),
fieldCache = GridFieldCache(gridId: view.id);
void addListener({
@ -88,8 +88,8 @@ class BoardDataController {
);
}
Future<Either<RowPB, FlowyError>> createRow() {
return _gridFFIService.createRow();
Future<Either<RowPB, FlowyError>> createBoardCard(String groupId) {
return _gridFFIService.createBoardCard(groupId);
}
Future<void> dispose() async {

View File

@ -88,7 +88,7 @@ class BoardContent extends StatelessWidget {
height: 50,
margin: config.columnItemPadding,
onAddButtonClick: () {
context.read<BoardBloc>().add(const BoardEvent.createRow());
context.read<BoardBloc>().add(BoardEvent.createRow(columnData.id));
});
}