From 3aec6579c8e969b1d5cda7d5277717370aa0d1fa Mon Sep 17 00:00:00 2001 From: Johan Sutrisno Date: Wed, 18 Oct 2023 22:06:55 +0700 Subject: [PATCH 1/3] feat: checkbox unresponsive custom theme example --- .../lib/pages/customize_theme_for_editor.dart | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/example/lib/pages/customize_theme_for_editor.dart b/example/lib/pages/customize_theme_for_editor.dart index a79fd3fbc..6e003bc1b 100644 --- a/example/lib/pages/customize_theme_for_editor.dart +++ b/example/lib/pages/customize_theme_for_editor.dart @@ -102,10 +102,20 @@ class _CustomizeThemeForEditorState extends State { 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 InkWell( + onTap: () async { + final state = await editorState; + final transaction = state.transaction + ..updateNode(node, { + TodoListBlockKeys.checked: !checked, + }); + state.apply(transaction); + }, + child: Icon( + checked ? Icons.check_box : Icons.check_box_outline_blank, + size: 20, + color: Colors.white, + ), ); }, ), From 4b5e94d3735a9b90277f4e551a0e0a545995f1ab Mon Sep 17 00:00:00 2001 From: Johan Sutrisno Date: Thu, 2 Nov 2023 15:13:48 +0700 Subject: [PATCH 2/3] fix: resolve feedback --- .../lib/pages/customize_theme_for_editor.dart | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/example/lib/pages/customize_theme_for_editor.dart b/example/lib/pages/customize_theme_for_editor.dart index 6e003bc1b..a8ffec4ca 100644 --- a/example/lib/pages/customize_theme_for_editor.dart +++ b/example/lib/pages/customize_theme_for_editor.dart @@ -63,7 +63,7 @@ class _CustomizeThemeForEditorState extends State { child: AppFlowyEditor( editorState: editorState, editorStyle: customizeEditorStyle(), - blockComponentBuilders: customBuilder(), + blockComponentBuilders: customBuilder(editorState), header: Image.asset( 'assets/images/header.png', height: 200, @@ -74,7 +74,9 @@ class _CustomizeThemeForEditorState extends State { } /// custom the block style - Map customBuilder() { + Map customBuilder( + EditorState editorState, + ) { final configuration = BlockComponentConfiguration( padding: (node) { if (HeadingBlockKeys.type == node.type) { @@ -103,14 +105,10 @@ class _CustomizeThemeForEditorState extends State { iconBuilder: (context, node) { final checked = node.attributes[TodoListBlockKeys.checked] as bool; return InkWell( - onTap: () async { - final state = await editorState; - final transaction = state.transaction - ..updateNode(node, { - TodoListBlockKeys.checked: !checked, - }); - state.apply(transaction); - }, + onTap: () => editorState.apply( + editorState.transaction + ..updateNode(node, {TodoListBlockKeys.checked: !checked}), + ), child: Icon( checked ? Icons.check_box : Icons.check_box_outline_blank, size: 20, From f72e4012cca631e786db59f0e1f7118d44a16cce Mon Sep 17 00:00:00 2001 From: Johan Sutrisno Date: Thu, 2 Nov 2023 21:51:28 +0700 Subject: [PATCH 3/3] fix: change inkwell to gesture detector --- example/lib/pages/customize_theme_for_editor.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lib/pages/customize_theme_for_editor.dart b/example/lib/pages/customize_theme_for_editor.dart index a8ffec4ca..dacc06b0e 100644 --- a/example/lib/pages/customize_theme_for_editor.dart +++ b/example/lib/pages/customize_theme_for_editor.dart @@ -104,7 +104,7 @@ class _CustomizeThemeForEditorState extends State { configuration: configuration, iconBuilder: (context, node) { final checked = node.attributes[TodoListBlockKeys.checked] as bool; - return InkWell( + return GestureDetector( onTap: () => editorState.apply( editorState.transaction ..updateNode(node, {TodoListBlockKeys.checked: !checked}),