Skip to content

Commit

Permalink
chore: Addressing Shadows PR remaining comments (#696)
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Uno.Toolkit.Skia.WinUI/Controls/Shadows/ShadowContainer.cs
  • Loading branch information
eriklimakc authored and pictos committed Aug 20, 2023
1 parent c30ea9d commit 13c7320
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

#if IS_WINUI
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Markup;
#else
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Markup;
#endif

namespace Uno.Toolkit.Samples.Converters
Expand All @@ -24,13 +26,7 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
return value;
}

hex = hex.Replace("#", string.Empty);
byte a = (byte)(System.Convert.ToUInt32(hex.Substring(0, 2), 16));
byte r = (byte)(System.Convert.ToUInt32(hex.Substring(2, 2), 16));
byte g = (byte)(System.Convert.ToUInt32(hex.Substring(4, 2), 16));
byte b = (byte)(System.Convert.ToUInt32(hex.Substring(6, 2), 16));

return Color.FromArgb(a, r, g, b);
return XamlBindingHelper.ConvertValue(typeof(Color), hex);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;

namespace Uno.Toolkit.UI;
Expand All @@ -8,6 +9,7 @@ public class ShadowCollection : ObservableCollection<Shadow>
public bool HasInnerShadow() => this.Any(s => s.IsInner);

public string ToKey(double width, double height, Windows.UI.Color? contentBackground)
=> $"w{width},h{height}" + (contentBackground.HasValue ? $",cb{contentBackground.Value}:" : ":") +
=> string.Create(CultureInfo.InvariantCulture, $"w{width},h{height}") +
(contentBackground.HasValue ? $",cb{contentBackground.Value}:" : ":") +
string.Join("/", this.Select(x => x.ToKey()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class ShadowContainer : ContentControl
nameof(Shadows),
typeof(ShadowCollection),
typeof(ShadowContainer),
new(new ShadowCollection(), OnShadowsChanged));
new(null, OnShadowsChanged));

/// <summary>
/// The collection of shadows that will be displayed under your control.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public ShadowContainer()
#if HAS_UNO_WINUI && !NET6_0_OR_GREATER
throw new NotSupportedException("ShadowContainer doesn't support Xamarin + WinUI considering moving to .NET6 or greater.");
#else
Shadows = new();

DefaultStyleKey = typeof(ShadowContainer);

_cornerRadius = new CornerRadius(0);
Expand Down

0 comments on commit 13c7320

Please sign in to comment.