Skip to content

Commit 6070b5b

Browse files
committed
fix(ReactTextView): Add support for 'padding' property
Fixes microsoft#410
1 parent 1b92c6f commit 6070b5b

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,29 @@ public override void OnCollectExtraUpdates(UIViewOperationQueue uiViewOperationQ
121121

122122
if (_inline != null)
123123
{
124+
var _paddings = new Thickness()
125+
{
126+
Left = float.IsNaN(GetPadding(CSSSpacingType.Left)) ?
127+
float.IsNaN(GetPadding(CSSSpacingType.Horizontal)) ?
128+
float.IsNaN(GetPadding(CSSSpacingType.All)) ? 0 :
129+
GetPadding(CSSSpacingType.All) :
130+
GetPadding(CSSSpacingType.Horizontal) :
131+
GetPadding(CSSSpacingType.Left),
132+
Top = float.IsNaN(GetPadding(CSSSpacingType.Top)) ?
133+
float.IsNaN(GetPadding(CSSSpacingType.Vertical)) ?
134+
float.IsNaN(GetPadding(CSSSpacingType.All)) ? 0 :
135+
GetPadding(CSSSpacingType.All) :
136+
GetPadding(CSSSpacingType.Vertical) :
137+
GetPadding(CSSSpacingType.Top),
138+
};
139+
124140
var args = Tuple.Create(
125141
_inline,
126142
_textAlignment,
127143
_lineHeight,
128144
_numberOfLines,
129-
_letterSpacing);
145+
_letterSpacing,
146+
_paddings);
130147

131148
uiViewOperationQueue.EnqueueUpdateExtraData(ReactTag, args);
132149
}
@@ -394,7 +411,7 @@ private static MeasureOutput MeasureText(CSSNode node, float width, float height
394411
textBlock.CharacterSpacing = textNode._letterSpacing;
395412
textBlock.LineHeight = textNode._lineHeight;
396413
textBlock.MaxLines = textNode._numberOfLines;
397-
textBlock.TextAlignment = (TextAlignment)textNode._textAlignment;
414+
textBlock.TextAlignment = textNode._textAlignment;
398415

399416
textBlock.Inlines.Add(ReactTextShadowNodeInlineVisitor.Apply(node));
400417

ReactWindows/ReactNative/Views/Text/ReactTextViewManager.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override ReactTextShadowNode CreateShadowNodeInstance()
4040
/// <param name="extraData">The aggregated virtual node changes.</param>
4141
public override void UpdateExtraData(TextBlock root, object extraData)
4242
{
43-
var textUpdate = (Tuple<Inline, TextAlignment, double, int, int>)extraData;
43+
var textUpdate = (Tuple<Inline, TextAlignment, double, int, int, Thickness>)extraData;
4444
var inline = textUpdate.Item1;
4545

4646
root.Inlines.Clear();
@@ -49,7 +49,8 @@ public override void UpdateExtraData(TextBlock root, object extraData)
4949
root.TextAlignment = textUpdate.Item2;
5050
root.LineHeight = textUpdate.Item3;
5151
root.MaxLines = textUpdate.Item4;
52-
root.CharacterSpacing = textUpdate.Item5;
52+
root.CharacterSpacing = textUpdate.Item5;
53+
root.Padding = textUpdate.Item6;
5354
}
5455

5556
/// <summary>

0 commit comments

Comments
 (0)