Add runtime text shadow support
This commit is contained in:
@@ -31,6 +31,10 @@ class RuntimeNode {
|
||||
this.color,
|
||||
this.fontSize,
|
||||
this.textAlign = RuntimeTextAlignValue.center,
|
||||
this.textShadowColor,
|
||||
this.textShadowOffsetX,
|
||||
this.textShadowOffsetY,
|
||||
this.textShadowBlur,
|
||||
this.radius,
|
||||
this.strokeWidth,
|
||||
this.value,
|
||||
@@ -89,6 +93,10 @@ class RuntimeNode {
|
||||
final Color? color;
|
||||
final double? fontSize;
|
||||
final String textAlign;
|
||||
final Color? textShadowColor;
|
||||
final double? textShadowOffsetX;
|
||||
final double? textShadowOffsetY;
|
||||
final double? textShadowBlur;
|
||||
final double? radius;
|
||||
final double? strokeWidth;
|
||||
final double? value;
|
||||
@@ -232,6 +240,18 @@ class RuntimeNode {
|
||||
color: _colorProp(props, RuntimeProtocolField.color) ?? color,
|
||||
fontSize: _doubleProp(props, RuntimeProtocolField.fontSize) ?? fontSize,
|
||||
textAlign: nextTextAlign,
|
||||
textShadowColor:
|
||||
_colorProp(props, RuntimeProtocolField.textShadowColor) ??
|
||||
textShadowColor,
|
||||
textShadowOffsetX:
|
||||
_doubleProp(props, RuntimeProtocolField.textShadowOffsetX) ??
|
||||
textShadowOffsetX,
|
||||
textShadowOffsetY:
|
||||
_doubleProp(props, RuntimeProtocolField.textShadowOffsetY) ??
|
||||
textShadowOffsetY,
|
||||
textShadowBlur:
|
||||
_nonNegativeDoubleProp(props, RuntimeProtocolField.textShadowBlur) ??
|
||||
textShadowBlur,
|
||||
radius: _doubleProp(props, RuntimeProtocolField.radius) ?? radius,
|
||||
strokeWidth:
|
||||
_doubleProp(props, RuntimeProtocolField.strokeWidth) ?? strokeWidth,
|
||||
@@ -352,6 +372,19 @@ class RuntimeNode {
|
||||
color: _colorProp(map, RuntimeProtocolField.color),
|
||||
fontSize: _doubleProp(map, RuntimeProtocolField.fontSize),
|
||||
textAlign: textAlign,
|
||||
textShadowColor: _colorProp(map, RuntimeProtocolField.textShadowColor),
|
||||
textShadowOffsetX: _doubleProp(
|
||||
map,
|
||||
RuntimeProtocolField.textShadowOffsetX,
|
||||
),
|
||||
textShadowOffsetY: _doubleProp(
|
||||
map,
|
||||
RuntimeProtocolField.textShadowOffsetY,
|
||||
),
|
||||
textShadowBlur: _nonNegativeDoubleProp(
|
||||
map,
|
||||
RuntimeProtocolField.textShadowBlur,
|
||||
),
|
||||
radius: _doubleProp(map, RuntimeProtocolField.radius),
|
||||
strokeWidth: _doubleProp(map, RuntimeProtocolField.strokeWidth),
|
||||
value: _normalizedValueProp(map, RuntimeProtocolField.value),
|
||||
|
||||
@@ -161,6 +161,10 @@ class RuntimeProtocolField {
|
||||
static const color = 'color';
|
||||
static const fontSize = 'fontSize';
|
||||
static const textAlign = 'textAlign';
|
||||
static const textShadowColor = 'textShadowColor';
|
||||
static const textShadowOffsetX = 'textShadowOffsetX';
|
||||
static const textShadowOffsetY = 'textShadowOffsetY';
|
||||
static const textShadowBlur = 'textShadowBlur';
|
||||
static const radius = 'radius';
|
||||
static const strokeWidth = 'strokeWidth';
|
||||
static const value = 'value';
|
||||
@@ -244,6 +248,10 @@ class RuntimeProtocolSchema {
|
||||
RuntimeProtocolField.color,
|
||||
RuntimeProtocolField.fontSize,
|
||||
RuntimeProtocolField.textAlign,
|
||||
RuntimeProtocolField.textShadowColor,
|
||||
RuntimeProtocolField.textShadowOffsetX,
|
||||
RuntimeProtocolField.textShadowOffsetY,
|
||||
RuntimeProtocolField.textShadowBlur,
|
||||
RuntimeProtocolField.radius,
|
||||
RuntimeProtocolField.strokeWidth,
|
||||
RuntimeProtocolField.value,
|
||||
@@ -309,6 +317,10 @@ class RuntimeProtocolSchema {
|
||||
RuntimeProtocolField.color,
|
||||
RuntimeProtocolField.fontSize,
|
||||
RuntimeProtocolField.textAlign,
|
||||
RuntimeProtocolField.textShadowColor,
|
||||
RuntimeProtocolField.textShadowOffsetX,
|
||||
RuntimeProtocolField.textShadowOffsetY,
|
||||
RuntimeProtocolField.textShadowBlur,
|
||||
RuntimeProtocolField.radius,
|
||||
RuntimeProtocolField.strokeWidth,
|
||||
RuntimeProtocolField.value,
|
||||
|
||||
@@ -968,6 +968,7 @@ class RuntimeComponent extends PositionComponent
|
||||
fontWeight: node.type == RuntimeNodeType.button
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
shadows: _textShadows(node),
|
||||
);
|
||||
|
||||
final component = _textComponent;
|
||||
@@ -1033,6 +1034,23 @@ class RuntimeComponent extends PositionComponent
|
||||
return (node.text ?? '').contains('\n');
|
||||
}
|
||||
|
||||
List<Shadow>? _textShadows(RuntimeNode node) {
|
||||
final color = node.textShadowColor;
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
return [
|
||||
Shadow(
|
||||
color: composeRuntimeColorAlpha(color, renderAlpha),
|
||||
offset: Offset(
|
||||
node.textShadowOffsetX ?? 0,
|
||||
node.textShadowOffsetY ?? 0,
|
||||
),
|
||||
blurRadius: node.textShadowBlur ?? 0,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
Color _textColor(RuntimeNode node) {
|
||||
if (node.type == RuntimeNodeType.button) {
|
||||
return Colors.white;
|
||||
|
||||
Reference in New Issue
Block a user