зеркало из https://github.com/DeGsoft/maui-linux.git
Clear global routes on unit tests and process global routes in the right place (#6781)
* 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
This commit is contained in:
Родитель
3113198179
Коммит
24fab93cb4
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
using System.Threading;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
#if UITEST
|
||||
|
@ -120,7 +121,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
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()
|
||||
{
|
||||
|
@ -143,11 +144,21 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
|
||||
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();
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace Xamarin.Forms.Core.UnitTests
|
|||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
Routing.Clear();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -421,18 +421,17 @@ namespace Xamarin.Forms
|
|||
{
|
||||
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
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
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.
|
||||
|
@ -140,11 +140,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
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)
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -73,7 +73,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
if (Build.VERSION.SdkInt > BuildVersionCodes.Kitkat)
|
||||
{
|
||||
defaultthumbcolorfilter = seekBar.Thumb.ColorFilter;
|
||||
defaultthumbcolorfilter = seekBar.Thumb.GetColorFilter();
|
||||
defaultprogresstintmode = seekBar.ProgressTintMode;
|
||||
defaultprogressbackgroundtintmode = seekBar.ProgressBackgroundTintMode;
|
||||
defaultprogresstintlist = seekBar.ProgressTintList;
|
||||
|
@ -178,23 +178,12 @@ namespace Xamarin.Forms.Platform.Android
|
|||
}
|
||||
}
|
||||
|
||||
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 =>
|
||||
{
|
||||
|
|
|
@ -83,8 +83,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
var aswitch = CreateNativeControl();
|
||||
aswitch.SetOnCheckedChangeListener(this);
|
||||
SetNativeControl(aswitch);
|
||||
_defaultTrackDrawable = Control.TrackDrawable;
|
||||
_defaultThumbColorFilter = Control.ThumbDrawable.ColorFilter;
|
||||
_defaultTrackDrawable = Control.TrackDrawable;
|
||||
_defaultThumbColorFilter = Control.ThumbDrawable.GetColorFilter();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -138,11 +138,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
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)
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
<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" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче