Skip to content

Commit

Permalink
feat: Checkbox unresponsive in custom Theme example in editor example…
Browse files Browse the repository at this point in the history
… app (#543)

* feat: checkbox unresponsive custom theme example

* fix: resolve feedback

* fix: change inkwell to gesture detector

---------

Co-authored-by: Johan Sutrisno <johan@zero-one-group.com>
  • Loading branch information
johansutrisno and johanzeroone authored Nov 5, 2023
1 parent 4b1a3d5 commit 5c4f4ab
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions example/lib/pages/customize_theme_for_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _CustomizeThemeForEditorState extends State<CustomizeThemeForEditor> {
child: AppFlowyEditor(
editorState: editorState,
editorStyle: customizeEditorStyle(),
blockComponentBuilders: customBuilder(),
blockComponentBuilders: customBuilder(editorState),
header: Image.asset(
'assets/images/header.png',
height: 200,
Expand All @@ -74,7 +74,9 @@ class _CustomizeThemeForEditorState extends State<CustomizeThemeForEditor> {
}

/// custom the block style
Map<String, BlockComponentBuilder> customBuilder() {
Map<String, BlockComponentBuilder> customBuilder(
EditorState editorState,
) {
final configuration = BlockComponentConfiguration(
padding: (node) {
if (HeadingBlockKeys.type == node.type) {
Expand Down Expand Up @@ -102,10 +104,16 @@ class _CustomizeThemeForEditorState extends State<CustomizeThemeForEditor> {
configuration: configuration,
iconBuilder: (context, node) {
final checked = node.attributes[TodoListBlockKeys.checked] as bool;
return Icon(
checked ? Icons.check_box : Icons.check_box_outline_blank,
size: 20,
color: Colors.white,
return GestureDetector(
onTap: () => editorState.apply(
editorState.transaction
..updateNode(node, {TodoListBlockKeys.checked: !checked}),
),
child: Icon(
checked ? Icons.check_box : Icons.check_box_outline_blank,
size: 20,
color: Colors.white,
),
);
},
),
Expand Down

0 comments on commit 5c4f4ab

Please sign in to comment.