diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell/selection_editor_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/cell/selection_editor_bloc.dart index 0b62945265..cb734c60d6 100644 --- a/frontend/app_flowy/lib/workspace/application/grid/cell/selection_editor_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/grid/cell/selection_editor_bloc.dart @@ -25,7 +25,8 @@ class SelectOptionEditorBloc extends Bloc emit) { + emit(state.copyWith(filter: optionName, options: _makeOptions(optionName, state.allOptions))); + } + + List _makeOptions(String filter, List allOptions) { + final List options = List.from(allOptions); + options.retainWhere((option) => option.name.contains(filter)); + return options; + } + void _startListening() { _onCellChangedFn = cellContext.startListening( onCellChanged: ((selectOptionContext) { @@ -109,20 +123,25 @@ class SelectOptionEditorEvent with _$SelectOptionEditorEvent { const factory SelectOptionEditorEvent.selectOption(String optionId) = _SelectOption; const factory SelectOptionEditorEvent.updateOption(SelectOption option) = _UpdateOption; const factory SelectOptionEditorEvent.deleteOption(SelectOption option) = _DeleteOption; + const factory SelectOptionEditorEvent.filterOption(String optionName) = _SelectOptionFilter; } @freezed class SelectOptionEditorState with _$SelectOptionEditorState { const factory SelectOptionEditorState({ required List options, + required List allOptions, required List selectedOptions, + required String filter, }) = _SelectOptionEditorState; factory SelectOptionEditorState.initial(GridSelectOptionCellContext context) { final data = context.getCellData(); return SelectOptionEditorState( options: data?.options ?? [], + allOptions: data?.options ?? [], selectedOptions: data?.selectOptions ?? [], + filter: "", ); } } diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/sizes.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/sizes.dart index 62577ee62c..c7ec279f19 100755 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/sizes.dart +++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/layout/sizes.dart @@ -9,8 +9,8 @@ class GridSize { static double get leadingHeaderPadding => 50 * scale; static double get trailHeaderPadding => 140 * scale; static double get headerContainerPadding => 0 * scale; - static double get cellHPadding => 8 * scale; - static double get cellVPadding => 8 * scale; + static double get cellHPadding => 10 * scale; + static double get cellVPadding => 10 * scale; static double get typeOptionItemHeight => 32 * scale; static double get typeOptionSeparatorHeight => 6 * scale; diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/selection_cell/selection_editor.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/selection_cell/selection_editor.dart index 4152e7b68f..9fe4a67034 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/selection_cell/selection_editor.dart +++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/selection_cell/selection_editor.dart @@ -144,6 +144,9 @@ class _TextField extends StatelessWidget { selectedOptionMap: optionMap, distanceToText: _editorPannelWidth * 0.7, tagController: _tagController, + newText: (text) { + context.read().add(SelectOptionEditorEvent.filterOption(text)); + }, onNewTag: (tagName) { context.read().add(SelectOptionEditorEvent.newOption(tagName)); }, diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/selection_cell/text_field.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/selection_cell/text_field.dart index 0bc33fc8d2..daabbf263d 100644 --- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/selection_cell/text_field.dart +++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/selection_cell/text_field.dart @@ -21,6 +21,7 @@ class SelectOptionTextField extends StatelessWidget { final double distanceToText; final Function(String) onNewTag; + final Function(String) newText; SelectOptionTextField({ required this.options, @@ -28,6 +29,7 @@ class SelectOptionTextField extends StatelessWidget { required this.distanceToText, required this.tagController, required this.onNewTag, + required this.newText, TextEditingController? controller, FocusNode? focusNode, Key? key, @@ -51,7 +53,12 @@ class SelectOptionTextField extends StatelessWidget { autofocus: true, controller: editController, focusNode: focusNode, - onChanged: onChanged, + onChanged: (text) { + if (onChanged != null) { + onChanged(text); + } + newText(text); + }, onSubmitted: (text) { if (onSubmitted != null) { onSubmitted(text);