зеркало из https://github.com/DeGsoft/maui-linux.git
[Core] LabelHandler Preview (#13764)
* LabelHandler with a subset of the properties (Text and TextColor) * Init LabelHandler * Fixed build errors * Updated TexColor property * Removed not implemented Label properties * Updated Button.Impl.cs * Updated FormsHandlers * Fix up default text color handling * Fix rebase errors and sample app * Clean up unused stuff * Fix interface structure * Fix stubs Co-authored-by: E.Z. Hart <hartez@gmail.com> Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
This commit is contained in:
Родитель
4ca457d330
Коммит
505fc4b41b
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xamarin.Platform.Handlers;
|
||||
|
@ -10,15 +10,11 @@ namespace Xamarin.Forms
|
|||
// This is used to register the handler version against the xplat code so that the handler version will be used
|
||||
// when running a full Xamarin.Forms application. This lets us test the handler code inside the Control Gallery
|
||||
// And other scenarios
|
||||
|
||||
public static void InitHandlers()
|
||||
{
|
||||
//Xamarin.Platform.Registrar.Handlers.Register(typeof(Slider), typeof(Xamarin.Platform.Handlers.SliderHandler));
|
||||
//Xamarin.Platform.Registrar.Handlers.Register(typeof(Button), typeof(Xamarin.Platform.Handlers.ButtonHandler));
|
||||
//RegistrarHandlers.Handlers.Register<Xamarin.Forms.StackLayout, Xamarin.Platform.Handlers.LayoutHandler>();
|
||||
|
||||
Platform.Registrar.Handlers.Register(typeof(Label), typeof(LabelHandler));
|
||||
Xamarin.Platform.Registrar.Handlers.Register<VerticalStackLayout, LayoutHandler>();
|
||||
Xamarin.Platform.Registrar.Handlers.Register<HorizontalStackLayout, LayoutHandler>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +1,22 @@
|
|||
using System;
|
||||
using Xamarin.Platform;
|
||||
using Xamarin.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public partial class Button : IButton
|
||||
{
|
||||
public TextAlignment HorizontalTextAlignment => throw new NotImplementedException();
|
||||
|
||||
public TextAlignment VerticalTextAlignment => throw new NotImplementedException();
|
||||
|
||||
void IButton.Clicked()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
(this as IButtonController).SendClicked();
|
||||
}
|
||||
|
||||
void IButton.Pressed()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
(this as IButtonController).SendPressed();
|
||||
}
|
||||
|
||||
void IButton.Released()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
(this as IButtonController).SendReleased();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using Xamarin.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public partial class Label : ILabel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using Xamarin.Platform;
|
||||
using Xamarin.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ using Xamarin.Forms.Internals;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[ContentProperty("Text")]
|
||||
public class Label : View, IFontElement, ITextElement, ITextAlignmentElement, ILineHeightElement, IElementConfiguration<Label>, IDecorableTextElement, IPaddingElement
|
||||
public partial class Label : View, IFontElement, ITextElement, ITextAlignmentElement, ILineHeightElement, IElementConfiguration<Label>, IDecorableTextElement, IPaddingElement
|
||||
{
|
||||
public static readonly BindableProperty HorizontalTextAlignmentProperty = TextAlignmentElement.HorizontalTextAlignmentProperty;
|
||||
|
||||
|
|
|
@ -33,7 +33,15 @@ namespace Sample
|
|||
|
||||
public virtual void Arrange(Rectangle bounds)
|
||||
{
|
||||
if (IsArrangeValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Frame = this.ComputeFrame(bounds);
|
||||
IsArrangeValid = true;
|
||||
|
||||
Handler?.SetFrame(Frame);
|
||||
}
|
||||
|
||||
public virtual void InvalidateMeasure()
|
||||
|
|
|
@ -3,26 +3,21 @@ using Xamarin.Platform;
|
|||
|
||||
namespace Sample
|
||||
{
|
||||
public class Label : Xamarin.Forms.View, ILabel
|
||||
public class Label : View, ILabel
|
||||
{
|
||||
public Label()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public Color TextColor { get; set; }
|
||||
|
||||
public Font Font { get; set; }
|
||||
public FontAttributes FontAttributes => throw new System.NotImplementedException();
|
||||
|
||||
public string FontFamily { get; set; }
|
||||
public string FontFamily => throw new System.NotImplementedException();
|
||||
|
||||
public double FontSize { get; set; }
|
||||
|
||||
public FontAttributes FontAttributes { get; set; }
|
||||
|
||||
public TextTransform TextTransform { get; set; }
|
||||
|
||||
public TextAlignment HorizontalTextAlignment { get; set; }
|
||||
|
||||
public TextAlignment VerticalTextAlignment { get; set; }
|
||||
|
||||
public double CharacterSpacing { get; set; }
|
||||
public double FontSize => throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,4 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Platform;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Platform.Handlers;
|
||||
using RegistrarHandlers = Xamarin.Platform.Registrar;
|
||||
|
||||
|
@ -18,23 +15,19 @@ namespace Sample
|
|||
|
||||
HasInit = true;
|
||||
|
||||
//RegistrarHandlers.Handlers.Register<Layout, LayoutHandler>();
|
||||
|
||||
RegistrarHandlers.Handlers.Register<Button, ButtonHandler>();
|
||||
RegistrarHandlers.Handlers.Register<Label, LabelHandler>();
|
||||
RegistrarHandlers.Handlers.Register<Slider, SliderHandler>();
|
||||
RegistrarHandlers.Handlers.Register<VerticalStackLayout, LayoutHandler>();
|
||||
RegistrarHandlers.Handlers.Register<HorizontalStackLayout, LayoutHandler>();
|
||||
RegistrarHandlers.Handlers.Register<Xamarin.Forms.FlexLayout, LayoutHandler>();
|
||||
RegistrarHandlers.Handlers.Register<FlexLayout, LayoutHandler>();
|
||||
RegistrarHandlers.Handlers.Register<Xamarin.Forms.StackLayout, LayoutHandler>();
|
||||
//RegistrarHandlers.Handlers.Register<Entry, EntryHandler>();
|
||||
RegistrarHandlers.Handlers.Register<Label, LabelHandler>();
|
||||
}
|
||||
|
||||
|
||||
void RegisterLegacyRendererAgainstFormsControl()
|
||||
{
|
||||
#if MONOANDROID && !NET6_0
|
||||
|
||||
// register renderer with old registrar so it can get shimmed
|
||||
// This will move to some extension method
|
||||
Xamarin.Forms.Internals.Registrar.Registered.Register(
|
||||
|
@ -44,8 +37,7 @@ namespace Sample
|
|||
// This registers the shim against the handler registrar
|
||||
// So when the handler.registrar returns the RendererToHandlerShim
|
||||
// Which will then forward the request to the old registrar
|
||||
Registrar.Handlers.Register<Xamarin.Forms.Button, RendererToHandlerShim>();
|
||||
|
||||
RegistrarHandlers.Handlers.Register<Xamarin.Forms.Button, RendererToHandlerShim>();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace Xamarin.Platform
|
||||
{
|
||||
public interface IButton : IText
|
||||
public interface IButton : IView, IText
|
||||
{
|
||||
void Pressed();
|
||||
void Released();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Xamarin.Platform
|
||||
{
|
||||
public interface IFont : IView
|
||||
public interface IFont
|
||||
{
|
||||
FontAttributes FontAttributes { get; }
|
||||
string FontFamily { get; }
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.Platform
|
||||
{
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.Platform
|
||||
{
|
||||
public interface ILabel : IText
|
||||
public interface ILabel : IView, IText
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.Platform
|
||||
{
|
||||
public interface IPadding
|
||||
{
|
||||
Thickness Padding { get; }
|
||||
}
|
||||
}
|
|
@ -2,16 +2,10 @@
|
|||
|
||||
namespace Xamarin.Platform
|
||||
{
|
||||
public interface IText : IFont, ITextAlignment
|
||||
public interface IText : IFont
|
||||
{
|
||||
string Text { get; }
|
||||
|
||||
Color TextColor { get; }
|
||||
|
||||
Font Font { get; }
|
||||
|
||||
TextTransform TextTransform { get; }
|
||||
|
||||
double CharacterSpacing { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using Android.Widget;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.Platform.Handlers
|
||||
{
|
||||
public partial class LabelHandler : AbstractViewHandler<ILabel, TextView>
|
||||
{
|
||||
static Color DefaultTextColor { get; set; }
|
||||
|
||||
protected override TextView CreateNativeView() => new TextView(Context);
|
||||
|
||||
protected override void SetupDefaults(TextView nativeView)
|
||||
{
|
||||
if (nativeView.TextColors == null)
|
||||
{
|
||||
DefaultTextColor = Color.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefaultTextColor = Color.FromUint((uint)nativeView.TextColors.DefaultColor);
|
||||
}
|
||||
}
|
||||
|
||||
public static void MapText(LabelHandler handler, ILabel label)
|
||||
{
|
||||
ViewHandler.CheckParameters(handler, label);
|
||||
|
||||
handler.TypedNativeView?.UpdateText(label);
|
||||
}
|
||||
|
||||
public static void MapTextColor(LabelHandler handler, ILabel label)
|
||||
{
|
||||
ViewHandler.CheckParameters(handler, label);
|
||||
|
||||
handler.TypedNativeView?.UpdateTextColor(label, DefaultTextColor);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace Xamarin.Platform.Handlers
|
||||
{
|
||||
public partial class LabelHandler : AbstractViewHandler<ILabel, object>
|
||||
{
|
||||
protected override object CreateNativeView() => throw new NotImplementedException();
|
||||
|
||||
public static void MapText(IViewHandler handler, ILabel label) { }
|
||||
public static void MapTextColor(IViewHandler handler, ILabel label) { }
|
||||
}
|
||||
}
|
|
@ -1,19 +1,6 @@
|
|||
using System;
|
||||
#if __IOS__
|
||||
using NativeView = UIKit.UILabel;
|
||||
#elif __MACOS__
|
||||
using NativeView = AppKit.NSTextField;
|
||||
#elif MONOANDROID
|
||||
using NativeView = Android.Widget.TextView;
|
||||
#elif NETCOREAPP
|
||||
using NativeView = System.Windows.Controls.TextBlock;
|
||||
#elif NETSTANDARD
|
||||
using NativeView = System.Object;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Platform.Handlers
|
||||
namespace Xamarin.Platform.Handlers
|
||||
{
|
||||
public class LabelHandler : AbstractViewHandler<ILabel, NativeView>
|
||||
public partial class LabelHandler
|
||||
{
|
||||
public static PropertyMapper<ILabel, LabelHandler> LabelMapper = new PropertyMapper<ILabel, LabelHandler>(ViewHandler.ViewMapper)
|
||||
{
|
||||
|
@ -21,20 +8,6 @@ namespace Xamarin.Platform.Handlers
|
|||
[nameof(ILabel.Text)] = MapText,
|
||||
};
|
||||
|
||||
public static void MapTextColor(LabelHandler handler, ILabel Label)
|
||||
{
|
||||
}
|
||||
|
||||
public static void MapText(LabelHandler handler, ILabel label)
|
||||
{
|
||||
handler.TypedNativeView?.UpdateText(label);
|
||||
}
|
||||
#if MONOANDROID
|
||||
protected override NativeView CreateNativeView() => new NativeView(this.Context);
|
||||
#else
|
||||
protected override NativeView CreateNativeView() => new NativeView();
|
||||
#endif
|
||||
|
||||
public LabelHandler() : base(LabelMapper)
|
||||
{
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
using UIKit;
|
||||
|
||||
namespace Xamarin.Platform.Handlers
|
||||
{
|
||||
public partial class LabelHandler : AbstractViewHandler<ILabel, UILabel>
|
||||
{
|
||||
protected override UILabel CreateNativeView() => new UILabel();
|
||||
|
||||
public static void MapText(LabelHandler handler, ILabel label)
|
||||
{
|
||||
ViewHandler.CheckParameters(handler, label);
|
||||
|
||||
handler.TypedNativeView?.UpdateText(label);
|
||||
}
|
||||
|
||||
public static void MapTextColor(LabelHandler handler, ILabel label)
|
||||
{
|
||||
ViewHandler.CheckParameters(handler, label);
|
||||
|
||||
handler.TypedNativeView?.UpdateTextColor(label);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
using Android.Content.Res;
|
||||
using Android.Graphics;
|
||||
using Android.OS;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Java.Net;
|
||||
|
||||
namespace Xamarin.Platform.Handlers
|
||||
{
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Android.Content.Res;
|
||||
using Android.Content.Res;
|
||||
using AndroidX.AppCompat.Widget;
|
||||
using Xamarin.Forms;
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@ namespace Xamarin.Platform
|
|||
return new ColorStateList(States, new[] { color.ToNative().ToArgb(), disabled });
|
||||
}
|
||||
|
||||
public static Color ToColor(this uint color)
|
||||
{
|
||||
return Color.FromUint(color);
|
||||
}
|
||||
|
||||
public static Color ToColor(this AColor color)
|
||||
{
|
||||
return Color.FromUint((uint)color.ToArgb());
|
||||
|
|
|
@ -4,7 +4,23 @@ namespace Xamarin.Platform
|
|||
{
|
||||
public static class LabelExtensions
|
||||
{
|
||||
public static void UpdateText(this TextView textView, ILabel label) =>
|
||||
public static void UpdateText(this TextView textView, ILabel label)
|
||||
{
|
||||
textView.Text = label.Text;
|
||||
}
|
||||
|
||||
public static void UpdateTextColor(this TextView textView, ILabel label, Forms.Color defaultColor)
|
||||
{
|
||||
Forms.Color textColor = label.TextColor;
|
||||
|
||||
if (textColor.IsDefault)
|
||||
{
|
||||
textView.SetTextColor(defaultColor.ToNative());
|
||||
}
|
||||
else
|
||||
{
|
||||
textView.SetTextColor(textColor.ToNative());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,5 +6,10 @@
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public static void UpdateTextColor(this object nothing, ILabel label)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
using UIKit;
|
||||
|
||||
namespace Xamarin.Platform
|
||||
{
|
||||
public static class LabelExtensions
|
||||
{
|
||||
public static void UpdateText(this UILabel label, string text)
|
||||
=> label.Text = text;
|
||||
public static void UpdateText(this UILabel nativeLabel, ILabel label)
|
||||
{
|
||||
nativeLabel.Text = label.Text;
|
||||
}
|
||||
|
||||
public static void UpdateText(this UILabel label, NSAttributedString text)
|
||||
=> label.AttributedText = text;
|
||||
public static void UpdateTextColor(this UILabel nativeLabel, ILabel label)
|
||||
{
|
||||
var textColor = label.TextColor;
|
||||
|
||||
public static void UpdateText(this UILabel label, ILabel text)
|
||||
=> label.UpdateText(text.Text);
|
||||
if (textColor.IsDefault)
|
||||
{
|
||||
// Default value of color documented to be black in iOS docs
|
||||
nativeLabel.TextColor = textColor.ToNative(ColorExtensions.LabelColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
nativeLabel.TextColor = textColor.ToNative(textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System.Threading.Tasks;
|
||||
using Android.Widget;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.Platform.Handlers.DeviceTests
|
||||
{
|
||||
public partial class LabelHandlerTests
|
||||
{
|
||||
TextView GetNativeLabel(LabelHandler labelHandler) =>
|
||||
(TextView)labelHandler.View;
|
||||
|
||||
string GetNativeText(LabelHandler labelHandler) =>
|
||||
GetNativeLabel(labelHandler).Text;
|
||||
|
||||
Color GetNativeTextColor(LabelHandler labelHandler) =>
|
||||
((uint)GetNativeLabel(labelHandler).CurrentTextColor).ToColor();
|
||||
|
||||
Task ValidateNativeBackgroundColor(ILabel label, Color color)
|
||||
{
|
||||
return InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
GetNativeLabel(CreateHandler(label)).AssertContainsColor(color);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Platform.Handlers.DeviceTests.Stubs;
|
||||
using Xunit;
|
||||
|
||||
namespace Xamarin.Platform.Handlers.DeviceTests
|
||||
{
|
||||
public partial class LabelHandlerTests : HandlerTestBase<LabelHandler>
|
||||
{
|
||||
[Fact]
|
||||
public async Task BackgroundColorInitializesCorrectly()
|
||||
{
|
||||
var label = new LabelStub()
|
||||
{
|
||||
BackgroundColor = Color.Blue,
|
||||
Text = "Test"
|
||||
};
|
||||
|
||||
await ValidateNativeBackgroundColor(label, Color.Blue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TextInitializesCorrectly()
|
||||
{
|
||||
var label = new LabelStub()
|
||||
{
|
||||
Text = "Test"
|
||||
};
|
||||
|
||||
await ValidatePropertyInitValue(label, () => label.Text, GetNativeText, label.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TextColorInitializesCorrectly()
|
||||
{
|
||||
var label = new LabelStub()
|
||||
{
|
||||
Text = "Test",
|
||||
TextColor = Color.Red
|
||||
};
|
||||
|
||||
await ValidatePropertyInitValue(label, () => label.TextColor, GetNativeTextColor, label.TextColor);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System.Threading.Tasks;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.Platform.Handlers.DeviceTests
|
||||
{
|
||||
public partial class LabelHandlerTests
|
||||
{
|
||||
UILabel GetNativeLabel(LabelHandler labelHandler) =>
|
||||
(UILabel)labelHandler.View;
|
||||
|
||||
string GetNativeText(LabelHandler labelHandler) =>
|
||||
GetNativeLabel(labelHandler).Text;
|
||||
|
||||
Color GetNativeTextColor(LabelHandler labelHandler) =>
|
||||
GetNativeLabel(labelHandler).TextColor.ToColor();
|
||||
|
||||
Task ValidateNativeBackgroundColor(ILabel label, Color color)
|
||||
{
|
||||
return InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
GetNativeLabel(CreateHandler(label)).AssertContainsColor(color);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +1,26 @@
|
|||
using System.Threading.Tasks;
|
||||
using Android.Widget;
|
||||
using Xamarin.Forms;
|
||||
using Xunit;
|
||||
|
||||
namespace Xamarin.Platform.Handlers.DeviceTests
|
||||
{
|
||||
public partial class SliderHandlerTests
|
||||
{
|
||||
SeekBar GetSlider(SliderHandler sliderHandler) =>
|
||||
((SeekBar)sliderHandler.View);
|
||||
SeekBar GetNativeSlider(SliderHandler sliderHandler) =>
|
||||
(SeekBar)sliderHandler.View;
|
||||
|
||||
double GetNativeProgress(SliderHandler sliderHandler) =>
|
||||
GetSlider(sliderHandler).Progress;
|
||||
GetNativeSlider(sliderHandler).Progress;
|
||||
|
||||
double GetNativeMaximum(SliderHandler sliderHandler) =>
|
||||
GetSlider(sliderHandler).Max;
|
||||
|
||||
GetNativeSlider(sliderHandler).Max;
|
||||
|
||||
Task ValidateNativeThumbColor(ISlider slider, Color color)
|
||||
{
|
||||
return InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
GetSlider(CreateHandler(slider)).AssertContainsColor(color);
|
||||
GetNativeSlider(CreateHandler(slider)).AssertContainsColor(color);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Platform.Handlers.DeviceTests.Stubs;
|
||||
using Xunit;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xunit;
|
||||
|
@ -8,19 +7,18 @@ namespace Xamarin.Platform.Handlers.DeviceTests
|
|||
{
|
||||
public partial class SliderHandlerTests
|
||||
{
|
||||
UISlider GetSlider(SliderHandler sliderHandler) =>
|
||||
((UISlider)sliderHandler.View);
|
||||
UISlider GetNativeSlider(SliderHandler sliderHandler) =>
|
||||
(UISlider)sliderHandler.View;
|
||||
|
||||
double GetNativeProgress(SliderHandler sliderHandler) =>
|
||||
GetSlider(sliderHandler).Value;
|
||||
GetNativeSlider(sliderHandler).Value;
|
||||
|
||||
double GetNativeMaximum(SliderHandler sliderHandler) =>
|
||||
GetSlider(sliderHandler).MaxValue;
|
||||
|
||||
GetNativeSlider(sliderHandler).MaxValue;
|
||||
|
||||
async Task ValidateNativeThumbColor(ISlider slider, Color color)
|
||||
{
|
||||
var expected = await GetValueAsync(slider, handler => GetSlider(handler).ThumbTintColor.ToColor());
|
||||
var expected = await GetValueAsync(slider, handler => GetNativeSlider(handler).ThumbTintColor.ToColor());
|
||||
Assert.Equal(expected, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.Platform.Handlers.DeviceTests.Stubs
|
||||
{
|
||||
public partial class LabelStub : StubBase, ILabel
|
||||
{
|
||||
public string Text { get; set; }
|
||||
|
||||
public Color TextColor { get; set; }
|
||||
|
||||
public FontAttributes FontAttributes => throw new System.NotImplementedException();
|
||||
|
||||
public string FontFamily => throw new System.NotImplementedException();
|
||||
|
||||
public double FontSize => throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Platform;
|
||||
using Xamarin.Platform.Handlers;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.Platform.Handlers.DeviceTests.Stubs
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ using Android.Util;
|
|||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
|
||||
using Xamarin.Platform;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
{
|
||||
|
@ -181,6 +182,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
Control.UpdateFlowDirection(Element);
|
||||
}
|
||||
|
||||
[PortHandler]
|
||||
void UpdateColor()
|
||||
{
|
||||
Color c = Element.TextColor;
|
||||
|
|
|
@ -6,6 +6,7 @@ using Foundation;
|
|||
using System.Collections.Generic;
|
||||
using CoreGraphics;
|
||||
using System.Diagnostics;
|
||||
using Xamarin.Platform;
|
||||
|
||||
#if __MOBILE__
|
||||
using UIKit;
|
||||
|
@ -556,6 +557,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
UpdateLayout();
|
||||
}
|
||||
|
||||
[PortHandler]
|
||||
void UpdateTextColor()
|
||||
{
|
||||
if (IsTextFormatted)
|
||||
|
|
Загрузка…
Ссылка в новой задаче