From 56fdc99990ac8b0ade8305b16869e1cc778fc864 Mon Sep 17 00:00:00 2001 From: appflowy Date: Wed, 7 Sep 2022 16:38:34 +0800 Subject: [PATCH] feat: enable select checkbox directly --- .../board/application/card/board_checkbox_cell_bloc.dart | 4 ++++ .../board/presentation/card/board_checkbox_cell.dart | 3 +++ .../plugins/grid/application/cell/checkbox_cell_bloc.dart | 6 +----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/app_flowy/lib/plugins/board/application/card/board_checkbox_cell_bloc.dart b/frontend/app_flowy/lib/plugins/board/application/card/board_checkbox_cell_bloc.dart index 3834db112c..c8a0d87f9c 100644 --- a/frontend/app_flowy/lib/plugins/board/application/card/board_checkbox_cell_bloc.dart +++ b/frontend/app_flowy/lib/plugins/board/application/card/board_checkbox_cell_bloc.dart @@ -21,6 +21,9 @@ class BoardCheckboxCellBloc didReceiveCellUpdate: (cellData) { emit(state.copyWith(isSelected: _isSelected(cellData))); }, + select: () async { + cellController.saveCellData(!state.isSelected ? "Yes" : "No"); + }, ); }, ); @@ -50,6 +53,7 @@ class BoardCheckboxCellBloc @freezed class BoardCheckboxCellEvent with _$BoardCheckboxCellEvent { const factory BoardCheckboxCellEvent.initial() = _InitialCell; + const factory BoardCheckboxCellEvent.select() = _Selected; const factory BoardCheckboxCellEvent.didReceiveCellUpdate( String cellContent) = _DidReceiveCellUpdate; } diff --git a/frontend/app_flowy/lib/plugins/board/presentation/card/board_checkbox_cell.dart b/frontend/app_flowy/lib/plugins/board/presentation/card/board_checkbox_cell.dart index f832d3749d..6b94d3399b 100644 --- a/frontend/app_flowy/lib/plugins/board/presentation/card/board_checkbox_cell.dart +++ b/frontend/app_flowy/lib/plugins/board/presentation/card/board_checkbox_cell.dart @@ -48,6 +48,9 @@ class _BoardCheckboxCellState extends State { iconPadding: EdgeInsets.zero, icon: icon, width: 20, + onPressed: () => context + .read() + .add(const BoardCheckboxCellEvent.select()), ), ); }, diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/checkbox_cell_bloc.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/checkbox_cell_bloc.dart index f5e7a451e2..5f7aee108e 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/cell/checkbox_cell_bloc.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/checkbox_cell_bloc.dart @@ -20,7 +20,7 @@ class CheckboxCellBloc extends Bloc { _startListening(); }, select: () async { - _updateCellData(); + cellController.saveCellData(!state.isSelected ? "Yes" : "No"); }, didReceiveCellUpdate: (cellData) { emit(state.copyWith(isSelected: _isSelected(cellData))); @@ -49,10 +49,6 @@ class CheckboxCellBloc extends Bloc { } })); } - - void _updateCellData() { - cellController.saveCellData(!state.isSelected ? "Yes" : "No"); - } } @freezed