[Tizen]Add Material Style Renderers (#6204)
This commit is contained in:
Родитель
3b6462ba1f
Коммит
6b17b4570f
|
@ -28,7 +28,7 @@
|
||||||
</group>
|
</group>
|
||||||
<group targetFramework="tizen40">
|
<group targetFramework="tizen40">
|
||||||
<dependency id="Tizen.NET" version="4.0.0"/>
|
<dependency id="Tizen.NET" version="4.0.0"/>
|
||||||
<dependency id="Tizen.NET.MaterialComponents" version="0.9.5-preview"/>
|
<dependency id="Tizen.NET.MaterialComponents" version="0.9.7-preview"/>
|
||||||
</group>
|
</group>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<PackageReference Include="Tizen.NET" Version="4.0.0">
|
<PackageReference Include="Tizen.NET" Version="4.0.0">
|
||||||
<ExcludeAssets>Runtime</ExcludeAssets>
|
<ExcludeAssets>Runtime</ExcludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Tizen.NET.MaterialComponents" Version="0.9.5-preview" />
|
<PackageReference Include="Tizen.NET.MaterialComponents" Version="0.9.7-preview" />
|
||||||
<PackageReference Include="Tizen.NET.Sdk" Version="1.0.1" />
|
<PackageReference Include="Tizen.NET.Sdk" Version="1.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,8 @@
|
||||||
|
|
||||||
<Label Text="Image" Margin="0,0,0,-10" />
|
<Label Text="Image" Margin="0,0,0,-10" />
|
||||||
<StackLayout Orientation="Horizontal">
|
<StackLayout Orientation="Horizontal">
|
||||||
<Button Image="bank" Text="Enabled" HorizontalOptions="FillAndExpand" />
|
<Button Image="bank.png" Text="Enabled" HorizontalOptions="FillAndExpand" />
|
||||||
<Button Image="bank" Text="Disabled" IsEnabled="false" HorizontalOptions="FillAndExpand" />
|
<Button Image="bank.png" Text="Disabled" IsEnabled="false" HorizontalOptions="FillAndExpand" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
|
||||||
<Label Text="Custom Background" Margin="0,0,0,-10" />
|
<Label Text="Custom Background" Margin="0,0,0,-10" />
|
||||||
|
@ -101,8 +101,8 @@
|
||||||
|
|
||||||
<Label Text="Custom Text & Image" Margin="0,0,0,-10" />
|
<Label Text="Custom Text & Image" Margin="0,0,0,-10" />
|
||||||
<StackLayout Orientation="Horizontal">
|
<StackLayout Orientation="Horizontal">
|
||||||
<Button Image="bank" Text="Enabled" TextColor="{StaticResource LightRedColor}" HorizontalOptions="FillAndExpand" />
|
<Button Image="bank.png" Text="Enabled" TextColor="{StaticResource LightRedColor}" HorizontalOptions="FillAndExpand" />
|
||||||
<Button Image="bank" Text="Disabled" TextColor="{StaticResource LightRedColor}" IsEnabled="false" HorizontalOptions="FillAndExpand" />
|
<Button Image="bank.png" Text="Disabled" TextColor="{StaticResource LightRedColor}" IsEnabled="false" HorizontalOptions="FillAndExpand" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
|
||||||
<Label Text="Custom Background & Border" Margin="0,0,0,-10" />
|
<Label Text="Custom Background & Border" Margin="0,0,0,-10" />
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Platform.Tizen;
|
||||||
|
using Xamarin.Forms.Material.Tizen;
|
||||||
|
using Tizen.NET.MaterialComponents;
|
||||||
|
using TForms = Xamarin.Forms.Platform.Tizen.Forms;
|
||||||
|
|
||||||
|
[assembly: ExportRenderer(typeof(ActivityIndicator), typeof(MaterialActivityIndicatorRenderer), new[] { typeof(VisualMarker.MaterialVisual) })]
|
||||||
|
namespace Xamarin.Forms.Material.Tizen
|
||||||
|
{
|
||||||
|
public class MaterialActivityIndicatorRenderer : ActivityIndicatorRenderer
|
||||||
|
{
|
||||||
|
protected override void OnElementChanged(ElementChangedEventArgs<ActivityIndicator> e)
|
||||||
|
{
|
||||||
|
if (Control == null)
|
||||||
|
{
|
||||||
|
SetNativeControl(new MActivityIndicator(TForms.NativeParent));
|
||||||
|
}
|
||||||
|
|
||||||
|
base.OnElementChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Platform.Tizen;
|
||||||
|
using Xamarin.Forms.Platform.Tizen.Native;
|
||||||
|
using Xamarin.Forms.Material.Tizen;
|
||||||
|
using TForms = Xamarin.Forms.Platform.Tizen.Forms;
|
||||||
|
using XFButton = Xamarin.Forms.Button;
|
||||||
|
using EButton = ElmSharp.Button;
|
||||||
|
|
||||||
|
[assembly: ExportRenderer(typeof(XFButton), typeof(MaterialButtonRenderer), new[] { typeof(VisualMarker.MaterialVisual) })]
|
||||||
|
namespace Xamarin.Forms.Material.Tizen
|
||||||
|
{
|
||||||
|
public class MaterialButtonRenderer : ButtonRenderer
|
||||||
|
{
|
||||||
|
protected override EButton CreateNativeControl()
|
||||||
|
{
|
||||||
|
return new MaterialButton(TForms.NativeParent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Platform.Tizen;
|
||||||
|
using Xamarin.Forms.Platform.Tizen.Native;
|
||||||
|
using Xamarin.Forms.Material.Tizen;
|
||||||
|
using TForms = Xamarin.Forms.Platform.Tizen.Forms;
|
||||||
|
using XFEntry = Xamarin.Forms.Entry;
|
||||||
|
|
||||||
|
[assembly: ExportRenderer(typeof(XFEntry), typeof(MaterialEntryRenderer), new[] { typeof(VisualMarker.MaterialVisual) })]
|
||||||
|
namespace Xamarin.Forms.Material.Tizen
|
||||||
|
{
|
||||||
|
public class MaterialEntryRenderer : EntryRenderer
|
||||||
|
{
|
||||||
|
protected override ElmSharp.Entry CreateNativeControl()
|
||||||
|
{
|
||||||
|
return new MaterialEntry(TForms.NativeParent)
|
||||||
|
{
|
||||||
|
IsSingleLine = true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateTextColor()
|
||||||
|
{
|
||||||
|
if(Control is MaterialEntry me)
|
||||||
|
{
|
||||||
|
me.TextColor = Element.TextColor.ToNative();
|
||||||
|
me.TextFocusedColor = Element.TextColor.ToNative();
|
||||||
|
me.UnderlineColor = Element.TextColor.ToNative();
|
||||||
|
me.UnderlineFocusedColor = Element.TextColor.ToNative();
|
||||||
|
me.CursorColor = Element.TextColor.ToNative();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Platform.Tizen;
|
using Xamarin.Forms.Platform.Tizen;
|
||||||
|
using Xamarin.Forms.Platform.Tizen.Native;
|
||||||
using Xamarin.Forms.Material.Tizen;
|
using Xamarin.Forms.Material.Tizen;
|
||||||
using Xamarin.Forms.Material.Tizen.Native;
|
|
||||||
using Tizen.NET.MaterialComponents;
|
using Tizen.NET.MaterialComponents;
|
||||||
using TForms = Xamarin.Forms.Platform.Tizen.Forms;
|
using TForms = Xamarin.Forms.Platform.Tizen.Forms;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace Xamarin.Forms.Material.Tizen
|
||||||
{
|
{
|
||||||
if (Control == null)
|
if (Control == null)
|
||||||
{
|
{
|
||||||
SetNativeControl(new MCanvas(TForms.NativeParent));
|
SetNativeControl(new MaterialCanvas(TForms.NativeParent));
|
||||||
}
|
}
|
||||||
base.OnElementChanged(e);
|
base.OnElementChanged(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,18 +9,30 @@
|
||||||
<AssemblyName>Xamarin.Forms.Material</AssemblyName>
|
<AssemblyName>Xamarin.Forms.Material</AssemblyName>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<PackageId>Xamarin.Forms.Material.Tizen</PackageId>
|
<PackageId>Xamarin.Forms.Material.Tizen</PackageId>
|
||||||
<DefineConstants>__TIZEN__</DefineConstants>
|
<DefineConstants>__TIZEN__;__MATERIAL__</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\Xamarin.Forms.Material.Android\MaterialColors.cs">
|
<Compile Include="..\Xamarin.Forms.Material.Android\MaterialColors.cs">
|
||||||
<Link>MaterialColors.cs</Link>
|
<Link>MaterialColors.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\Xamarin.Forms.Platform.Tizen\Native\Canvas.cs">
|
||||||
|
<Link>Native\Canvas.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\Xamarin.Forms.Platform.Tizen\Native\Button.cs">
|
||||||
|
<Link>Native\Button.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\Xamarin.Forms.Platform.Tizen\Native\Box.cs">
|
||||||
|
<Link>Native\Box.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\Xamarin.Forms.Platform.Tizen\Native\Entry.cs">
|
||||||
|
<Link>Native\Entry.cs</Link>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Tizen.NET" Version="4.0.0" />
|
<PackageReference Include="Tizen.NET" Version="4.0.0" />
|
||||||
<PackageReference Include="Tizen.NET.MaterialComponents" Version="0.9.5-preview" />
|
<PackageReference Include="Tizen.NET.MaterialComponents" Version="0.9.7-preview" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Xamarin.Forms.Internals;
|
using Xamarin.Forms.Internals;
|
||||||
using ElmSharp;
|
using ElmSharp;
|
||||||
|
using EEntry = ElmSharp.Entry;
|
||||||
|
|
||||||
namespace Xamarin.Forms.Platform.Tizen
|
namespace Xamarin.Forms.Platform.Tizen
|
||||||
{
|
{
|
||||||
|
@ -63,18 +64,18 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
return isSpellCheckEnabled && isTextPredictionEnabled ? InputHints.AutoComplete : InputHints.None;
|
return isSpellCheckEnabled && isTextPredictionEnabled ? InputHints.AutoComplete : InputHints.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateKeyboard(this Native.Entry control, Keyboard keyboard, bool isSpellCheckEnabled, bool isTextPredictionEnabled)
|
public static void UpdateKeyboard(this Native.IEntry control, Keyboard keyboard, bool isSpellCheckEnabled, bool isTextPredictionEnabled)
|
||||||
{
|
{
|
||||||
control.Keyboard = keyboard.ToNative();
|
control.Keyboard = keyboard.ToNative();
|
||||||
if (keyboard is CustomKeyboard customKeyboard)
|
if (keyboard is CustomKeyboard customKeyboard)
|
||||||
{
|
{
|
||||||
control.AutoCapital = customKeyboard.Flags.ToAutoCapital();
|
(control as EEntry).AutoCapital = customKeyboard.Flags.ToAutoCapital();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
control.AutoCapital = AutoCapital.None;
|
(control as EEntry).AutoCapital = AutoCapital.None;
|
||||||
}
|
}
|
||||||
control.InputHint = keyboard.ToInputHints(isSpellCheckEnabled, isTextPredictionEnabled);
|
(control as EEntry).InputHint = keyboard.ToInputHints(isSpellCheckEnabled, isTextPredictionEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,8 +2,20 @@ using System;
|
||||||
using ElmSharp;
|
using ElmSharp;
|
||||||
using EBox = ElmSharp.Box;
|
using EBox = ElmSharp.Box;
|
||||||
|
|
||||||
|
#if __MATERIAL__
|
||||||
|
using Tizen.NET.MaterialComponents;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Xamarin.Forms.Platform.Tizen.Native
|
namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
{
|
{
|
||||||
|
#if __MATERIAL__
|
||||||
|
public class MaterialBox : MCard
|
||||||
|
{
|
||||||
|
public MaterialBox(EvasObject parent) : base(parent)
|
||||||
|
{
|
||||||
|
SetLayoutCallback(() => { NotifyOnLayout(); });
|
||||||
|
}
|
||||||
|
#else
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extends the ElmSharp.Box class with functionality useful to Xamarin.Forms renderer.
|
/// Extends the ElmSharp.Box class with functionality useful to Xamarin.Forms renderer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -13,19 +25,16 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class Box : EBox
|
public class Box : EBox
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The last processed geometry of the Box which was reported from the native layer.
|
|
||||||
/// </summary>
|
|
||||||
Rect _previousGeometry;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.Box"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parent">The parent EvasObject.</param>
|
|
||||||
public Box(EvasObject parent) : base(parent)
|
public Box(EvasObject parent) : base(parent)
|
||||||
{
|
{
|
||||||
SetLayoutCallback(() => { NotifyOnLayout(); });
|
SetLayoutCallback(() => { NotifyOnLayout(); });
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last processed geometry of the Box which was reported from the native layer.
|
||||||
|
/// </summary>
|
||||||
|
Rect _previousGeometry;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Notifies that the layout has been updated.
|
/// Notifies that the layout has been updated.
|
||||||
|
|
|
@ -1,18 +1,37 @@
|
||||||
using System;
|
using System;
|
||||||
using ElmSharp;
|
using ElmSharp;
|
||||||
using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
|
|
||||||
using EButton = ElmSharp.Button;
|
|
||||||
using EColor = ElmSharp.Color;
|
using EColor = ElmSharp.Color;
|
||||||
using ESize = ElmSharp.Size;
|
using ESize = ElmSharp.Size;
|
||||||
|
using TSButtonStyle = Xamarin.Forms.PlatformConfiguration.TizenSpecific.ButtonStyle;
|
||||||
|
using EButton = ElmSharp.Button;
|
||||||
|
|
||||||
|
#if __MATERIAL__
|
||||||
|
using Tizen.NET.MaterialComponents;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Xamarin.Forms.Platform.Tizen.Native
|
namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
{
|
{
|
||||||
|
#if __MATERIAL__
|
||||||
|
public class MaterialButton : MButton, IMeasurable, IBatchable, IButton
|
||||||
|
{
|
||||||
|
public MaterialButton(EvasObject parent) : base(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#else
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extends the EButton control, providing basic formatting features,
|
/// Extends the EButton control, providing basic formatting features,
|
||||||
/// i.e. font color, size, additional image.
|
/// i.e. font color, size, additional image.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Button : EButton, IMeasurable, IBatchable
|
public class Button : EButton, IMeasurable, IBatchable, IButton
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.Button"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">Parent evas object.</param>
|
||||||
|
public Button(EvasObject parent) : base(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds the formatted text of the button.
|
/// Holds the formatted text of the button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -23,14 +42,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Image _image;
|
Image _image;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.Button"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parent">Parent evas object.</param>
|
|
||||||
public Button(EvasObject parent) : base(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the button's text.
|
/// Gets or sets the button's text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -182,7 +193,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual ESize Measure(int availableWidth, int availableHeight)
|
public virtual ESize Measure(int availableWidth, int availableHeight)
|
||||||
{
|
{
|
||||||
if (Style == ButtonStyle.Circle)
|
if (Style == TSButtonStyle.Circle)
|
||||||
{
|
{
|
||||||
return new ESize(MinimumWidth, MinimumHeight);
|
return new ESize(MinimumWidth, MinimumHeight);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +287,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
if (Style != style)
|
if (Style != style)
|
||||||
{
|
{
|
||||||
Style = style;
|
Style = style;
|
||||||
if (Style == ButtonStyle.Default)
|
if (Style == TSButtonStyle.Default)
|
||||||
_span.HorizontalTextAlignment = TextAlignment.Auto;
|
_span.HorizontalTextAlignment = TextAlignment.Auto;
|
||||||
else
|
else
|
||||||
_span.HorizontalTextAlignment = TextAlignment.Center;
|
_span.HorizontalTextAlignment = TextAlignment.Center;
|
||||||
|
|
|
@ -2,8 +2,21 @@
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using ElmSharp;
|
using ElmSharp;
|
||||||
|
|
||||||
|
#if __MATERIAL__
|
||||||
|
using Tizen.NET.MaterialComponents;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Xamarin.Forms.Platform.Tizen.Native
|
namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
{
|
{
|
||||||
|
#if __MATERIAL__
|
||||||
|
public class MaterialCanvas : MaterialBox, IContainable<EvasObject>
|
||||||
|
{
|
||||||
|
public MaterialCanvas(EvasObject parent) : base(parent)
|
||||||
|
{
|
||||||
|
Initilize();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A Canvas provides a class which can be a container for other controls.
|
/// A Canvas provides a class which can be a container for other controls.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -13,17 +26,50 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class Canvas : Box, IContainable<EvasObject>
|
public class Canvas : Box, IContainable<EvasObject>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The list of Views.
|
|
||||||
/// </summary>
|
|
||||||
readonly ObservableCollection<EvasObject> _children = new ObservableCollection<EvasObject>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.Canvas"/> class.
|
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.Canvas"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Canvas doesn't support replacing its children, this will be ignored.</remarks>
|
/// <remarks>Canvas doesn't support replacing its children, this will be ignored.</remarks>
|
||||||
/// <param name="parent">Parent of this instance.</param>
|
/// <param name="parent">Parent of this instance.</param>
|
||||||
public Canvas(EvasObject parent) : base(parent)
|
public Canvas(EvasObject parent) : base(parent)
|
||||||
|
{
|
||||||
|
Initilize();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The list of Views.
|
||||||
|
/// </summary>
|
||||||
|
readonly ObservableCollection<EvasObject> _children = new ObservableCollection<EvasObject>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets list of native elements that are placed in the canvas.
|
||||||
|
/// </summary>
|
||||||
|
public new IList<EvasObject> Children
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides destruction for native element and contained elements.
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnUnrealize()
|
||||||
|
{
|
||||||
|
foreach (var child in _children)
|
||||||
|
{
|
||||||
|
child.Unrealize();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.OnUnrealize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the the class
|
||||||
|
/// </summary>
|
||||||
|
void Initilize()
|
||||||
{
|
{
|
||||||
_children.CollectionChanged += (o, e) =>
|
_children.CollectionChanged += (o, e) =>
|
||||||
{
|
{
|
||||||
|
@ -56,30 +102,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets list of native elements that are placed in the canvas.
|
|
||||||
/// </summary>
|
|
||||||
public new IList<EvasObject> Children
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provides destruction for native element and contained elements.
|
|
||||||
/// </summary>
|
|
||||||
protected override void OnUnrealize()
|
|
||||||
{
|
|
||||||
foreach (var child in _children)
|
|
||||||
{
|
|
||||||
child.Unrealize();
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnUnrealize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a new child to a container.
|
/// Adds a new child to a container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -4,14 +4,39 @@ using EEntry = ElmSharp.Entry;
|
||||||
using EColor = ElmSharp.Color;
|
using EColor = ElmSharp.Color;
|
||||||
using ESize = ElmSharp.Size;
|
using ESize = ElmSharp.Size;
|
||||||
|
|
||||||
|
#if __MATERIAL__
|
||||||
|
using Tizen.NET.MaterialComponents;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Xamarin.Forms.Platform.Tizen.Native
|
namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
{
|
{
|
||||||
|
#if __MATERIAL__
|
||||||
|
public class MaterialEntry : MTextField, IMeasurable, IBatchable, IEntry
|
||||||
|
{
|
||||||
|
const int TextFieldMinimumHeight = 115;
|
||||||
|
|
||||||
|
public MaterialEntry(EvasObject parent) : base(parent)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extends the Entry control, providing basic formatting features,
|
/// Extends the Entry control, providing basic formatting features,
|
||||||
/// i.e. font color, size, placeholder.
|
/// i.e. font color, size, placeholder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Entry : EEntry, IMeasurable, IBatchable
|
public class Entry : EEntry, IMeasurable, IBatchable, IEntry
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.MaterialEntry"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">Parent evas object.</param>
|
||||||
|
public Entry(EvasObject parent) : base(parent)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const int VariationNormal = 0;
|
const int VariationNormal = 0;
|
||||||
const int VariationSignedAndDecimal = 3;
|
const int VariationSignedAndDecimal = 3;
|
||||||
|
|
||||||
|
@ -36,26 +61,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Keyboard _keyboard;
|
Keyboard _keyboard;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.Entry"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parent">Parent evas object.</param>
|
|
||||||
public Entry(EvasObject parent) : base(parent)
|
|
||||||
{
|
|
||||||
Scrollable = true;
|
|
||||||
|
|
||||||
ChangedByUser += (s, e) =>
|
|
||||||
{
|
|
||||||
_changedByUserCallbackDepth++;
|
|
||||||
|
|
||||||
Text = GetInternalText();
|
|
||||||
|
|
||||||
_changedByUserCallbackDepth--;
|
|
||||||
};
|
|
||||||
|
|
||||||
ApplyKeyboard(Keyboard.Normal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when the text has changed.
|
/// Occurs when the text has changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -92,7 +97,11 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// Gets or sets the color of the text.
|
/// Gets or sets the color of the text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The color of the text.</value>
|
/// <value>The color of the text.</value>
|
||||||
|
#if __MATERIAL__
|
||||||
|
public new EColor TextColor
|
||||||
|
#else
|
||||||
public EColor TextColor
|
public EColor TextColor
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -314,8 +323,8 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// there's text in the entry, use it instead
|
// there's text in the entry, use it instead
|
||||||
rawSize = Native.TextHelper.GetRawTextBlockSize(this);
|
rawSize = TextHelper.GetRawTextBlockSize(this);
|
||||||
formattedSize = Native.TextHelper.GetFormattedTextBlockSize(this);
|
formattedSize = TextHelper.GetFormattedTextBlockSize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore the original size
|
// restore the original size
|
||||||
|
@ -328,21 +337,31 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
formattedSize.Height += verticalPadding;
|
formattedSize.Height += verticalPadding;
|
||||||
formattedSize.Width += horizontalPadding;
|
formattedSize.Width += horizontalPadding;
|
||||||
|
|
||||||
|
ESize size;
|
||||||
|
|
||||||
// if the raw text width is larger than available width, we use the available width,
|
// if the raw text width is larger than available width, we use the available width,
|
||||||
// while height is set to the smallest height value
|
// while height is set to the smallest height value
|
||||||
if (rawSize.Width > availableWidth)
|
if (rawSize.Width > availableWidth)
|
||||||
{
|
{
|
||||||
return new ESize
|
size.Width = availableWidth;
|
||||||
{
|
size.Height = Math.Min(formattedSize.Height, Math.Max(rawSize.Height, availableHeight));
|
||||||
Width = availableWidth,
|
|
||||||
Height = Math.Min(formattedSize.Height, Math.Max(rawSize.Height, availableHeight)),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// width is fine, return the formatted text size
|
// width is fine, return the formatted text size
|
||||||
return formattedSize;
|
size = formattedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __MATERIAL__
|
||||||
|
// for adapting material style,
|
||||||
|
// the height of the entry should be bigger than minimun size defined by Tizen.NET.Material.Components
|
||||||
|
if (size.Height < TextFieldMinimumHeight)
|
||||||
|
{
|
||||||
|
size.Height = TextFieldMinimumHeight;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return size;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnTextChanged(string oldValue, string newValue)
|
protected virtual void OnTextChanged(string oldValue, string newValue)
|
||||||
|
@ -350,6 +369,22 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
TextChanged?.Invoke(this, new TextChangedEventArgs(oldValue, newValue));
|
TextChanged?.Invoke(this, new TextChangedEventArgs(oldValue, newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Initialize()
|
||||||
|
{
|
||||||
|
Scrollable = true;
|
||||||
|
|
||||||
|
ChangedByUser += (s, e) =>
|
||||||
|
{
|
||||||
|
_changedByUserCallbackDepth++;
|
||||||
|
|
||||||
|
Text = GetInternalText();
|
||||||
|
|
||||||
|
_changedByUserCallbackDepth--;
|
||||||
|
};
|
||||||
|
|
||||||
|
ApplyKeyboard(Keyboard.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
void IBatchable.OnBatchCommitted()
|
void IBatchable.OnBatchCommitted()
|
||||||
{
|
{
|
||||||
ApplyTextAndStyle();
|
ApplyTextAndStyle();
|
||||||
|
@ -386,7 +421,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// <returns>The internal text representation.</returns>
|
/// <returns>The internal text representation.</returns>
|
||||||
string GetInternalText()
|
string GetInternalText()
|
||||||
{
|
{
|
||||||
return Entry.ConvertMarkupToUtf8(base.Text);
|
return EEntry.ConvertMarkupToUtf8(base.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -439,7 +474,11 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// <param name="markupText">Markup text to be used as a placeholder.</param>
|
/// <param name="markupText">Markup text to be used as a placeholder.</param>
|
||||||
protected virtual void SetInternalPlaceholderAndStyle(string markupText)
|
protected virtual void SetInternalPlaceholderAndStyle(string markupText)
|
||||||
{
|
{
|
||||||
|
#if __MATERIAL__
|
||||||
|
base.Label = markupText;
|
||||||
|
#else
|
||||||
SetPartText("elm.guide", markupText ?? "");
|
SetPartText("elm.guide", markupText ?? "");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
using EColor = ElmSharp.Color;
|
||||||
|
using ESize = ElmSharp.Size;
|
||||||
|
|
||||||
|
namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
|
{
|
||||||
|
public interface IButton
|
||||||
|
{
|
||||||
|
string Text { get; set; }
|
||||||
|
|
||||||
|
double FontSize { get; set; }
|
||||||
|
|
||||||
|
FontAttributes FontAttributes { get; set; }
|
||||||
|
|
||||||
|
string FontFamily { get; set; }
|
||||||
|
|
||||||
|
EColor TextColor { get; set; }
|
||||||
|
|
||||||
|
Image Image { get; set; }
|
||||||
|
|
||||||
|
ESize Measure(int availableWidth, int availableHeight);
|
||||||
|
|
||||||
|
void UpdateStyle(string style);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using EColor = ElmSharp.Color;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
|
{
|
||||||
|
public interface IEntry
|
||||||
|
{
|
||||||
|
double FontSize { get; set; }
|
||||||
|
|
||||||
|
FontAttributes FontAttributes { get; set; }
|
||||||
|
|
||||||
|
string FontFamily { get; set; }
|
||||||
|
|
||||||
|
EColor TextColor { get; set; }
|
||||||
|
|
||||||
|
TextAlignment HorizontalTextAlignment { get; set; }
|
||||||
|
|
||||||
|
string Placeholder { get; set; }
|
||||||
|
|
||||||
|
EColor PlaceholderColor { get; set; }
|
||||||
|
|
||||||
|
string FontWeight { get; set; }
|
||||||
|
|
||||||
|
Keyboard Keyboard { get; set; }
|
||||||
|
|
||||||
|
event EventHandler<TextChangedEventArgs> TextChanged;
|
||||||
|
}
|
||||||
|
}
|
|
@ -233,7 +233,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
|
|
||||||
if (LineHeight != -1.0d)
|
if (LineHeight != -1.0d)
|
||||||
{
|
{
|
||||||
_formattingString.Append($"linerelsize={(int)(LineHeight*100)}%");
|
_formattingString.Append($"linerelsize={(int)(LineHeight * 100)}%");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (LineBreakMode)
|
switch (LineBreakMode)
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Text Helper contains functions that assist in working with text-able objects.
|
/// The Text Helper contains functions that assist in working with text-able objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static class TextHelper
|
public static class TextHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the size of raw text block.
|
/// Gets the size of raw text block.
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Xamarin.Forms.Platform.Tizen.Native;
|
||||||
|
using EButton = ElmSharp.Button;
|
||||||
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement;
|
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement;
|
||||||
|
|
||||||
namespace Xamarin.Forms.Platform.Tizen
|
namespace Xamarin.Forms.Platform.Tizen
|
||||||
{
|
{
|
||||||
public class ButtonRenderer : ViewRenderer<Button, Native.Button>
|
public class ButtonRenderer : ViewRenderer<Button, EButton>
|
||||||
{
|
{
|
||||||
public ButtonRenderer()
|
public ButtonRenderer()
|
||||||
{
|
{
|
||||||
|
@ -22,10 +24,7 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
{
|
{
|
||||||
if (Control == null)
|
if (Control == null)
|
||||||
{
|
{
|
||||||
if (Device.Idiom == TargetIdiom.Watch)
|
SetNativeControl(CreateNativeControl());
|
||||||
SetNativeControl(new Native.Watch.WatchButton(Forms.NativeParent));
|
|
||||||
else
|
|
||||||
SetNativeControl(new Native.Button(Forms.NativeParent));
|
|
||||||
|
|
||||||
Control.Clicked += OnButtonClicked;
|
Control.Clicked += OnButtonClicked;
|
||||||
Control.Pressed += OnButtonPressed;
|
Control.Pressed += OnButtonPressed;
|
||||||
|
@ -34,9 +33,27 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
base.OnElementChanged(e);
|
base.OnElementChanged(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual EButton CreateNativeControl()
|
||||||
|
{
|
||||||
|
if (Device.Idiom == TargetIdiom.Watch)
|
||||||
|
return new Native.Watch.WatchButton(Forms.NativeParent);
|
||||||
|
else
|
||||||
|
return new Native.Button(Forms.NativeParent);
|
||||||
|
}
|
||||||
|
|
||||||
protected override Size MinimumSize()
|
protected override Size MinimumSize()
|
||||||
{
|
{
|
||||||
return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
|
Size measured;
|
||||||
|
if(Control is IMeasurable im)
|
||||||
|
{
|
||||||
|
measured = im.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
measured = base.MinimumSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
return measured;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateThemeStyle()
|
protected override void UpdateThemeStyle()
|
||||||
|
@ -44,7 +61,7 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
var style = Specific.GetStyle(Element);
|
var style = Specific.GetStyle(Element);
|
||||||
if (!string.IsNullOrEmpty(style))
|
if (!string.IsNullOrEmpty(style))
|
||||||
{
|
{
|
||||||
Control.UpdateStyle(style);
|
(Control as IButton)?.UpdateStyle(style);
|
||||||
((IVisualElementController)Element).NativeSizeChanged();
|
((IVisualElementController)Element).NativeSizeChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,39 +97,55 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
|
|
||||||
void UpdateText()
|
void UpdateText()
|
||||||
{
|
{
|
||||||
Control.Text = Element.Text ?? "";
|
(Control as IButton).Text = Element.Text ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFontSize()
|
void UpdateFontSize()
|
||||||
{
|
{
|
||||||
Control.FontSize = Element.FontSize;
|
//(Control as IButton).FontSize = Element.FontSize;
|
||||||
|
if (Control is IButton ib)
|
||||||
|
{
|
||||||
|
ib.FontSize = Element.FontSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFontAttributes()
|
void UpdateFontAttributes()
|
||||||
{
|
{
|
||||||
Control.FontAttributes = Element.FontAttributes;
|
if (Control is IButton ib)
|
||||||
|
{
|
||||||
|
ib.FontAttributes = Element.FontAttributes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFontFamily()
|
void UpdateFontFamily()
|
||||||
{
|
{
|
||||||
Control.FontFamily = Element.FontFamily;
|
if (Control is IButton ib)
|
||||||
|
{
|
||||||
|
ib.FontFamily = Element.FontFamily;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTextColor()
|
void UpdateTextColor()
|
||||||
{
|
{
|
||||||
Control.TextColor = Element.TextColor.ToNative();
|
if (Control is IButton ib)
|
||||||
|
{
|
||||||
|
ib.TextColor = Element.TextColor.ToNative();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateBitmap()
|
void UpdateBitmap()
|
||||||
{
|
{
|
||||||
if (!Element.ImageSource.IsNullOrEmpty())
|
if (Control is IButton ib)
|
||||||
{
|
{
|
||||||
Control.Image = new Native.Image(Control);
|
if (Element.ImageSource != null)
|
||||||
_ = Control.Image.LoadFromImageSourceAsync(Element.ImageSource);
|
{
|
||||||
}
|
ib.Image = new Native.Image(Control);
|
||||||
else
|
var task = ib.Image.LoadFromImageSourceAsync(Element.ImageSource);
|
||||||
{
|
}
|
||||||
Control.Image = null;
|
else
|
||||||
|
{
|
||||||
|
ib.Image = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
|
using IEntry = Xamarin.Forms.Platform.Tizen.Native.IEntry;
|
||||||
|
using EEntry = ElmSharp.Entry;
|
||||||
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Entry;
|
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Entry;
|
||||||
|
|
||||||
namespace Xamarin.Forms.Platform.Tizen
|
namespace Xamarin.Forms.Platform.Tizen
|
||||||
{
|
{
|
||||||
public class EntryRenderer : ViewRenderer<Entry, Native.Entry>
|
public class EntryRenderer : ViewRenderer<Entry, EEntry>
|
||||||
{
|
{
|
||||||
public EntryRenderer()
|
public EntryRenderer()
|
||||||
{
|
{
|
||||||
|
@ -30,30 +32,45 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
{
|
{
|
||||||
if (Control == null)
|
if (Control == null)
|
||||||
{
|
{
|
||||||
var entry = new Native.EditfieldEntry(Forms.NativeParent)
|
var entry = CreateNativeControl();
|
||||||
{
|
|
||||||
IsSingleLine = true,
|
|
||||||
};
|
|
||||||
entry.SetVerticalTextAlignment("elm.text", 0.5);
|
entry.SetVerticalTextAlignment("elm.text", 0.5);
|
||||||
entry.SetVerticalTextAlignment("elm.guide", 0.5);
|
entry.SetVerticalTextAlignment("elm.guide", 0.5);
|
||||||
entry.TextChanged += OnTextChanged;
|
|
||||||
entry.Activated += OnCompleted;
|
entry.Activated += OnCompleted;
|
||||||
entry.CursorChanged += OnCursorChanged;
|
entry.CursorChanged += OnCursorChanged;
|
||||||
|
|
||||||
|
if (entry is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.TextChanged += OnTextChanged;
|
||||||
|
}
|
||||||
entry.PrependMarkUpFilter(MaxLengthFilter);
|
entry.PrependMarkUpFilter(MaxLengthFilter);
|
||||||
SetNativeControl(entry);
|
SetNativeControl(entry);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
base.OnElementChanged(e);
|
base.OnElementChanged(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual EEntry CreateNativeControl()
|
||||||
|
{
|
||||||
|
return new Native.EditfieldEntry(Forms.NativeParent)
|
||||||
|
{
|
||||||
|
IsSingleLine = true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
if (null != Control)
|
if (null != Control)
|
||||||
{
|
{
|
||||||
Control.TextChanged -= OnTextChanged;
|
|
||||||
Control.Activated -= OnCompleted;
|
Control.Activated -= OnCompleted;
|
||||||
Control.CursorChanged -= OnCursorChanged;
|
Control.CursorChanged -= OnCursorChanged;
|
||||||
|
|
||||||
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.TextChanged -= OnTextChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +79,17 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
|
|
||||||
protected override Size MinimumSize()
|
protected override Size MinimumSize()
|
||||||
{
|
{
|
||||||
return (Control as Native.IMeasurable).Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
|
Size measured;
|
||||||
|
if (Control is Native.IMeasurable im)
|
||||||
|
{
|
||||||
|
measured = im.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
measured = base.MinimumSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
return measured;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTextChanged(object sender, EventArgs e)
|
void OnTextChanged(object sender, EventArgs e)
|
||||||
|
@ -92,36 +119,52 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTextColor()
|
protected virtual void UpdateTextColor()
|
||||||
{
|
{
|
||||||
Control.TextColor = Element.TextColor.ToNative();
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.TextColor = Element.TextColor.ToNative();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFontSize()
|
void UpdateFontSize()
|
||||||
{
|
{
|
||||||
Control.FontSize = Element.FontSize;
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.FontSize = Element.FontSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFontFamily()
|
void UpdateFontFamily()
|
||||||
{
|
{
|
||||||
Control.FontFamily = Element.FontFamily;
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.FontFamily = Element.FontFamily;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFontAttributes()
|
void UpdateFontAttributes()
|
||||||
{
|
{
|
||||||
Control.FontAttributes = Element.FontAttributes;
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.FontAttributes = Element.FontAttributes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateHorizontalTextAlignment()
|
void UpdateHorizontalTextAlignment()
|
||||||
{
|
{
|
||||||
Control.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative();
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateKeyboard(bool initialize)
|
void UpdateKeyboard(bool initialize)
|
||||||
{
|
{
|
||||||
if (initialize && Element.Keyboard == Keyboard.Default)
|
if (initialize && Element.Keyboard == Keyboard.Default)
|
||||||
return;
|
return;
|
||||||
Control.UpdateKeyboard(Element.Keyboard, Element.IsSpellCheckEnabled, Element.IsTextPredictionEnabled);
|
|
||||||
|
(Control as IEntry)?.UpdateKeyboard(Element.Keyboard, Element.IsSpellCheckEnabled, Element.IsTextPredictionEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateIsSpellCheckEnabled()
|
void UpdateIsSpellCheckEnabled()
|
||||||
|
@ -131,17 +174,26 @@ namespace Xamarin.Forms.Platform.Tizen
|
||||||
|
|
||||||
void UpdatePlaceholder()
|
void UpdatePlaceholder()
|
||||||
{
|
{
|
||||||
Control.Placeholder = Element.Placeholder;
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.Placeholder = Element.Placeholder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePlaceholderColor()
|
void UpdatePlaceholderColor()
|
||||||
{
|
{
|
||||||
Control.PlaceholderColor = Element.PlaceholderColor.ToNative();
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.PlaceholderColor = Element.PlaceholderColor.ToNative();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFontWeight()
|
void UpdateFontWeight()
|
||||||
{
|
{
|
||||||
Control.FontWeight = Specific.GetFontWeight(Element);
|
if (Control is IEntry ie)
|
||||||
|
{
|
||||||
|
ie.FontWeight = Specific.GetFontWeight(Element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateMaxLength()
|
void UpdateMaxLength()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче