* Clear global routes on unit tests and process global routes in the right place
* - route with current item in case shellSection is null
* inset ui test fix
* Fix ColorFilter for API 19
* add missing file
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
using System.Threading;
+using System.ComponentModel;
#if UITEST
void EmptyPageSafeArea()
{
var page = CreateContentPage();
- var topLabel = new Label() { Text = "Top Label", HeightRequest = 200, AutomationId = SafeAreaTopLabel, VerticalOptions = LayoutOptions.Start };
+ var topLabel = new Label() { Text = "Top Label", HeightRequest = 0, AutomationId = SafeAreaTopLabel, VerticalOptions = LayoutOptions.Start };
page.Content =
new StackLayout()
{
page.BackgroundColor = Color.Yellow;
- page.Appearing += (_, __) =>
+ PropertyChangedEventHandler propertyChangedEventHandler = null;
+ propertyChangedEventHandler = (sender, args) =>
{
- topLabel.HeightRequest = page.On<iOS>().SafeAreaInsets().Top;
+ if(args.PropertyName == PlatformConfiguration.iOSSpecific.Page.SafeAreaInsetsProperty.PropertyName)
+ {
+ if (page.On<iOS>().SafeAreaInsets().Top > 0)
+ {
+ page.PropertyChanged -= propertyChangedEventHandler;
+ topLabel.HeightRequest = page.On<iOS>().SafeAreaInsets().Top;
+ }
+ }
};
+ page.PropertyChanged += propertyChangedEventHandler;
+
Shell.SetTabBarIsVisible(page, false);
Shell.SetNavBarIsVisible(page, false);
CurrentItem = Items.Last();
public override void TearDown()
{
base.TearDown();
+ Routing.Clear();
}
{
shellSection.SetValueFromRenderer(ShellSection.CurrentItemProperty, shellContent);
}
-
- if (navigationRequest.Request.GlobalRoutes.Count > 0)
- {
- // TODO get rid of this hack and fix so if there's a stack the current page doesn't display
- Device.BeginInvokeOnMainThread(async () =>
- {
- await shellSection.GoToAsync(navigationRequest, queryData, false);
- });
- }
-
}
}
+
+ if (navigationRequest.Request.GlobalRoutes.Count > 0)
+ {
+ // TODO get rid of this hack and fix so if there's a stack the current page doesn't display
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await CurrentItem.CurrentItem.GoToAsync(navigationRequest, queryData, false);
+ });
+ }
}
else
{
aswitch.SetOnCheckedChangeListener(this);
SetNativeControl(aswitch);
_defaultTrackDrawable = aswitch.TrackDrawable;
- _defaultThumbColorFilter = Control.ThumbDrawable.ColorFilter;
+ _defaultThumbColorFilter = Control.ThumbDrawable.GetColorFilter();
}
else
UpdateEnabled(); // Normally set by SetNativeControl, but not when the Control is reused.
if (Element == null)
return;
- Color thumbColor = Element.ThumbColor;
- if (thumbColor.IsDefault)
- Control.ThumbDrawable.SetColorFilter(_defaultThumbColorFilter);
- else
- Control.ThumbDrawable.SetColorFilter(thumbColor.ToAndroid(), PorterDuff.Mode.SrcIn);
+ Control.ThumbDrawable.SetColorFilter(Element.ThumbColor, _defaultThumbColorFilter);
}
void HandleToggled(object sender, EventArgs e)
--- /dev/null
+using System;
+using ADrawable = Android.Graphics.Drawables.Drawable;
+using AColorFilter = Android.Graphics.ColorFilter;
+using ADrawableCompat = Android.Support.V4.Graphics.Drawable.DrawableCompat;
+using Android.Graphics;
+
+namespace Xamarin.Forms.Platform.Android
+{
+ internal static class DrawableExtensions
+ {
+ public static AColorFilter GetColorFilter(this ADrawable drawable)
+ {
+ if (drawable == null)
+ return null;
+
+ return ADrawableCompat.GetColorFilter(drawable);
+ }
+
+ public static void SetColorFilter(this ADrawable drawable, AColorFilter colorFilter)
+ {
+ if (drawable == null)
+ return;
+
+ if (colorFilter == null)
+ ADrawableCompat.ClearColorFilter(drawable);
+
+ drawable.SetColorFilter(colorFilter);
+ }
+
+ public static void SetColorFilter(this ADrawable drawable, Color color, AColorFilter defaultColorFilter)
+ {
+ if (drawable == null)
+ return;
+
+ if (color == Color.Default)
+ {
+ SetColorFilter(drawable, defaultColorFilter);
+ return;
+ }
+
+ drawable.SetColorFilter(color.ToAndroid(), PorterDuff.Mode.SrcIn);
+ }
+ }
+}
if (Build.VERSION.SdkInt > BuildVersionCodes.Kitkat)
{
- defaultthumbcolorfilter = seekBar.Thumb.ColorFilter;
+ defaultthumbcolorfilter = seekBar.Thumb.GetColorFilter();
defaultprogresstintmode = seekBar.ProgressTintMode;
defaultprogressbackgroundtintmode = seekBar.ProgressBackgroundTintMode;
defaultprogresstintlist = seekBar.ProgressTintList;
}
}
- private void UpdateThumbColor()
+ void UpdateThumbColor()
{
- if (Element != null)
- {
- if (Element.ThumbColor == Color.Default)
- {
- Control.Thumb.SetColorFilter(defaultthumbcolorfilter);
- }
- else
- {
- Control.Thumb.SetColorFilter(Element.ThumbColor.ToAndroid(), PorterDuff.Mode.SrcIn);
- }
-
- }
+ Control.Thumb.SetColorFilter(Element.ThumbColor, defaultthumbcolorfilter);
}
- private void UpdateThumbImage()
+ void UpdateThumbImage()
{
this.ApplyDrawableAsync(Slider.ThumbImageSourceProperty, Context, drawable =>
{
var aswitch = CreateNativeControl();
aswitch.SetOnCheckedChangeListener(this);
SetNativeControl(aswitch);
- _defaultTrackDrawable = Control.TrackDrawable;
- _defaultThumbColorFilter = Control.ThumbDrawable.ColorFilter;
+ _defaultTrackDrawable = Control.TrackDrawable;
+ _defaultThumbColorFilter = Control.ThumbDrawable.GetColorFilter();
}
else
{
if (Element == null)
return;
- Color thumbColor = Element.ThumbColor;
- if (thumbColor.IsDefault)
- Control.ThumbDrawable.SetColorFilter(_defaultThumbColorFilter);
- else
- Control.ThumbDrawable.SetColorFilter(thumbColor.ToAndroid(), PorterDuff.Mode.SrcIn);
+ Control.ThumbDrawable.SetColorFilter(Element.ThumbColor, _defaultThumbColorFilter);
}
void HandleToggled(object sender, EventArgs e)
<Compile Include="CollectionView\TemplatedItemViewHolder.cs" />
<Compile Include="CollectionView\TextViewHolder.cs" />
<Compile Include="Elevation.cs" />
+ <Compile Include="Extensions\DrawableExtensions.cs" />
<Compile Include="Extensions\EntryRendererExtensions.cs" />
<Compile Include="Extensions\FragmentManagerExtensions.cs" />
<Compile Include="Extensions\ScrollViewExtensions.cs" />