Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Checkbox unresponsive in custom Theme example in editor example app #543

Merged
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
Loading