Skip to content

Commit

Permalink
fix(Warnings): fix misc warnings throughout project (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
rozele committed Feb 10, 2017
1 parent 8a93885 commit 320c3c1
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,5 @@ private async Task<IFolder> GetAsyncStorageFolder(bool createIfNotExists)

return null;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private void OnImageStatusUpdate(Border view, ImageStatusEventData status)
/// </summary>
/// <param name="view">The image view instance.</param>
/// <param name="source">The source URI.</param>
private async void SetUriFromSingleSource(Border view, string source)
private void SetUriFromSingleSource(Border view, string source)
{
var imageBrush = (ImageBrush)view.Background;
var tag = view.GetTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void SetInjectedJavaScript(WebBrowser view, string injectedJavaScript)
/// <param name="view">A webview instance.</param>
/// <param name="source">A source for the webview (either static html or an uri).</param>
[ReactProp("source")]
public async void SetSource(WebBrowser view, JObject source)
public void SetSource(WebBrowser view, JObject source)
{
if (source != null)
{
Expand Down Expand Up @@ -169,7 +169,7 @@ public override void OnDropViewInstance(ThemedReactContext reactContext, WebBrow
}

/// <summary>
/// Creates a new view instance of type <see cref="WebView"/>.
/// Creates a new view instance of type <see cref="WebBrowser"/>.
/// </summary>
/// <param name="reactContext">The React context.</param>
/// <returns>The view instance.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void RunScript(string script, string sourceUrl)
if (sourceUrl == null)
throw new ArgumentNullException(nameof(sourceUrl));

string source = LoadScriptAsync(script).Result;
var source = LoadScriptAsync(script).Result;

try
{
Expand Down
11 changes: 11 additions & 0 deletions ReactWindows/ReactNative.Shared/UIManager/ColorHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@

namespace ReactNative.UIManager
{
/// <summary>
/// Helper class for parsing color values.
/// </summary>
public static class ColorHelpers
{
/// <summary>
/// Unsigned integer representation of transparent color.
/// </summary>
public const uint Transparent = 0x00FFFFFF;

/// <summary>
/// Parses a color from an unsigned integer.
/// </summary>
/// <param name="value">The unsigned integer color value.</param>
/// <returns>The parsed color value.</returns>
public static Color Parse(uint value)
{
var color = value;
Expand Down
188 changes: 177 additions & 11 deletions ReactWindows/ReactNative.Shared/UIManager/ReactShadowNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,40 @@ public MeasureFunction MeasureFunction
/// <param name="margin">The margin.</param>
public void SetMargin(int spacingType, float margin)
{
_yogaNode.SetMargin((YogaEdge)spacingType, margin);
var yogaEdge = (YogaEdge)spacingType;
switch (yogaEdge)
{
case YogaEdge.Left:
_yogaNode.MarginLeft = margin;
break;
case YogaEdge.Top:
_yogaNode.MarginTop = margin;
break;
case YogaEdge.Right:
_yogaNode.MarginRight = margin;
break;
case YogaEdge.Bottom:
_yogaNode.MarginBottom = margin;
break;
case YogaEdge.Start:
_yogaNode.MarginStart = margin;
break;
case YogaEdge.End:
_yogaNode.MarginEnd = margin;
break;
case YogaEdge.Horizontal:
_yogaNode.MarginHorizontal = margin;
break;
case YogaEdge.Vertical:
_yogaNode.MarginVertical = margin;
break;
case YogaEdge.All:
_yogaNode.Margin = margin;
break;
default:
throw new NotSupportedException(
Invariant($"Unsupported margin type '{yogaEdge}'."));
}
}

/// <summary>
Expand All @@ -529,7 +562,31 @@ public void SetMargin(int spacingType, float margin)
/// <returns>The padding.</returns>
public float GetPadding(int spacingType)
{
return _yogaNode.GetPadding((YogaEdge)spacingType).Value;
var yogaEdge = (YogaEdge)spacingType;
switch (yogaEdge)
{
case YogaEdge.Left:
return _yogaNode.PaddingLeft.Value;
case YogaEdge.Top:
return _yogaNode.PaddingTop.Value;
case YogaEdge.Right:
return _yogaNode.PaddingRight.Value;
case YogaEdge.Bottom:
return _yogaNode.PaddingBottom.Value;
case YogaEdge.Start:
return _yogaNode.PaddingStart.Value;
case YogaEdge.End:
return _yogaNode.PaddingEnd.Value;
case YogaEdge.Horizontal:
return _yogaNode.PaddingHorizontal.Value;
case YogaEdge.Vertical:
return _yogaNode.PaddingVertical.Value;
case YogaEdge.All:
return _yogaNode.Padding.Value;
default:
throw new NotSupportedException(
Invariant($"Unsupported padding type '{yogaEdge}'."));
}
}

/// <summary>
Expand Down Expand Up @@ -560,7 +617,27 @@ public void SetPadding(int spacingType, float padding)
/// <param name="spacingType">The spacing type.</param>
public float GetBorder(int spacingType)
{
return _yogaNode.GetBorder((YogaEdge)spacingType);
var yogaEdge = (YogaEdge)spacingType;
switch (yogaEdge)
{
case YogaEdge.Left:
return _yogaNode.BorderLeftWidth;
case YogaEdge.Top:
return _yogaNode.BorderTopWidth;
case YogaEdge.Right:
return _yogaNode.BorderRightWidth;
case YogaEdge.Bottom:
return _yogaNode.BorderBottomWidth;
case YogaEdge.Start:
return _yogaNode.BorderStartWidth;
case YogaEdge.End:
return _yogaNode.BorderEndWidth;
case YogaEdge.All:
return _yogaNode.BorderWidth;
default:
throw new NotSupportedException(
Invariant($"Unsupported border type '{yogaEdge}'."));
}
}

/// <summary>
Expand All @@ -570,7 +647,34 @@ public float GetBorder(int spacingType)
/// <param name="borderWidth">The border width.</param>
public void SetBorder(int spacingType, float borderWidth)
{
_yogaNode.SetBorder((YogaEdge)spacingType, borderWidth);
var yogaEdge = (YogaEdge)spacingType;
switch (yogaEdge)
{
case YogaEdge.Left:
_yogaNode.BorderLeftWidth = borderWidth;
break;
case YogaEdge.Top:
_yogaNode.BorderTopWidth = borderWidth;
break;
case YogaEdge.Right:
_yogaNode.BorderRightWidth = borderWidth;
break;
case YogaEdge.Bottom:
_yogaNode.BorderBottomWidth = borderWidth;
break;
case YogaEdge.Start:
_yogaNode.BorderStartWidth = borderWidth;
break;
case YogaEdge.End:
_yogaNode.BorderEndWidth = borderWidth;
break;
case YogaEdge.All:
_yogaNode.BorderWidth = borderWidth;
break;
default:
throw new NotSupportedException(
Invariant($"Unsupported border type '{yogaEdge}'."));
}
}

/// <summary>
Expand All @@ -580,7 +684,31 @@ public void SetBorder(int spacingType, float borderWidth)
/// <param name="position">The position.</param>
public void SetPosition(int spacingType, float position)
{
_yogaNode.SetPosition((YogaEdge)spacingType, position);
var yogaEdge = (YogaEdge)spacingType;
switch (yogaEdge)
{
case YogaEdge.Left:
_yogaNode.Left = position;
break;
case YogaEdge.Top:
_yogaNode.Top = position;
break;
case YogaEdge.Right:
_yogaNode.Right = position;
break;
case YogaEdge.Bottom:
_yogaNode.Bottom = position;
break;
case YogaEdge.Start:
_yogaNode.Start = position;
break;
case YogaEdge.End:
_yogaNode.End = position;
break;
default:
throw new NotSupportedException(
Invariant($"Unsupported position type '{yogaEdge}'."));
}
}

/// <summary>
Expand Down Expand Up @@ -1016,11 +1144,11 @@ private void UpdatePadding()
YogaConstants.IsUndefined(_padding.GetRaw(EdgeSpacing.Horizontal)) &&
YogaConstants.IsUndefined(_padding.GetRaw(EdgeSpacing.All)))
{
_yogaNode.SetPadding((YogaEdge)spacingType, _defaultPadding.GetRaw(spacingType));
SetPadding(_yogaNode, spacingType, _defaultPadding.GetRaw(spacingType));
}
else
{
_yogaNode.SetPadding((YogaEdge)spacingType, _padding.GetRaw(spacingType));
SetPadding(_yogaNode, spacingType, _padding.GetRaw(spacingType));
}
}
else if (spacingType == EdgeSpacing.Top || spacingType == EdgeSpacing.Bottom)
Expand All @@ -1029,25 +1157,63 @@ private void UpdatePadding()
YogaConstants.IsUndefined(_padding.GetRaw(EdgeSpacing.Vertical)) &&
YogaConstants.IsUndefined(_padding.GetRaw(EdgeSpacing.All)))
{
_yogaNode.SetPadding((YogaEdge)spacingType, _defaultPadding.GetRaw(spacingType));
SetPadding(_yogaNode, spacingType, _defaultPadding.GetRaw(spacingType));
}
else
{
_yogaNode.SetPadding((YogaEdge)spacingType, _padding.GetRaw(spacingType));
SetPadding(_yogaNode, spacingType, _padding.GetRaw(spacingType));
}
}
else
{
if (YogaConstants.IsUndefined(_padding.GetRaw(spacingType)))
{
_yogaNode.SetPadding((YogaEdge)spacingType, _defaultPadding.GetRaw(spacingType));
SetPadding(_yogaNode, spacingType, _defaultPadding.GetRaw(spacingType));
}
else
{
_yogaNode.SetPadding((YogaEdge)spacingType, _padding.GetRaw(spacingType));
SetPadding(_yogaNode, spacingType, _padding.GetRaw(spacingType));
}
}
}
}

private void SetPadding(YogaNode node, int spacingType, float padding)
{
var yogaEdge = (YogaEdge)spacingType;
switch (yogaEdge)
{
case YogaEdge.Left:
node.PaddingLeft = padding;
break;
case YogaEdge.Top:
node.PaddingTop = padding;
break;
case YogaEdge.Right:
node.PaddingRight = padding;
break;
case YogaEdge.Bottom:
node.PaddingBottom = padding;
break;
case YogaEdge.Start:
node.PaddingStart = padding;
break;
case YogaEdge.End:
node.PaddingEnd = padding;
break;
case YogaEdge.Horizontal:
node.PaddingHorizontal = padding;
break;
case YogaEdge.Vertical:
node.PaddingHorizontal = padding;
break;
case YogaEdge.All:
node.Padding = padding;
break;
default:
throw new NotSupportedException(
Invariant($"Unsupported padding type '{yogaEdge}'."));
}
}
}
}
3 changes: 3 additions & 0 deletions ReactWindows/ReactNative.Shared/UIManager/ViewProps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public static class ViewProps
EdgeSpacing.Bottom,
};

/// <summary>
/// Ordered list of position spacing types.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "IReadOnlyList is immutable.")]
public static readonly IReadOnlyList<int> PositionSpacingTypes =
new List<int>
Expand Down

0 comments on commit 320c3c1

Please sign in to comment.