Skip to content

Commit

Permalink
feat: refactor logic for converting color string to Color in backgrou…
Browse files Browse the repository at this point in the history
…nd_color_mixin.dart (#538)
  • Loading branch information
LucasXu0 authored Oct 13, 2023
1 parent 7317eb9 commit 56c269e
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart';

/// If you want to customize the logic of how to convert a color string to a
/// [Color], you can set this variable.
typedef BlockComponentBackgroundColorDecorator = Color? Function(
Node node,
String colorString,
);
BlockComponentBackgroundColorDecorator? blockComponentBackgroundColorDecorator;

mixin BlockComponentBackgroundColorMixin {
Node get node;

Expand All @@ -10,6 +18,12 @@ mixin BlockComponentBackgroundColorMixin {
if (colorString == null) {
return Colors.transparent;
}
return colorString.tryToColor() ?? Colors.transparent;

return blockComponentBackgroundColorDecorator?.call(
node,
colorString,
) ??
colorString.tryToColor() ??
Colors.transparent;
}
}

0 comments on commit 56c269e

Please sign in to comment.