diff options
-rw-r--r-- | .nuspec/Xamarin.Forms.Platform.Tizen.nuspec | 4 | ||||
-rw-r--r-- | Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Image.cs | 30 | ||||
-rw-r--r-- | Xamarin.Forms.Core/Xamarin.Forms.Core.csproj | 3 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs | 19 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs | 3 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Forms.cs | 5 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Native/Label.cs | 7 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Native/ListView.cs | 35 | ||||
-rwxr-xr-x[-rw-r--r--] | Xamarin.Forms.Platform.Tizen/Native/Span.cs | 4 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs | 45 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs | 29 | ||||
-rwxr-xr-x[-rw-r--r--] | Xamarin.Forms.Platform.Tizen/ResourcePath.cs | 17 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs | 2 | ||||
-rw-r--r-- | packaging/xamarin-forms-tizen.spec | 3 |
14 files changed, 127 insertions, 79 deletions
diff --git a/.nuspec/Xamarin.Forms.Platform.Tizen.nuspec b/.nuspec/Xamarin.Forms.Platform.Tizen.nuspec index 3bcf80be..0632d890 100644 --- a/.nuspec/Xamarin.Forms.Platform.Tizen.nuspec +++ b/.nuspec/Xamarin.Forms.Platform.Tizen.nuspec @@ -15,7 +15,7 @@ </dependencies> </metadata> <files> - <file src="../Xamarin.Forms.Platform.Tizen/bin/$Configuration$/Xamarin.Forms.Platform.Tizen.dll" target="lib/netcoreapp1.0"/> - <file src="../Xamarin.Forms.Platform.Tizen/bin/$Configuration$/Xamarin.Forms.Platform.Tizen.*pdb" target="lib/netcoreapp1.0"/> + <file src="../Xamarin.Forms.Platform.Tizen/bin/$Configuration$/Xamarin.Forms.Platform.Tizen.dll" target="lib/netstandard1.6"/> + <file src="../Xamarin.Forms.Platform.Tizen/bin/$Configuration$/Xamarin.Forms.Platform.Tizen.*pdb" target="lib/netstandard1.6"/> </files> </package> diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Image.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Image.cs new file mode 100644 index 00000000..2c86fd04 --- /dev/null +++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Image.cs @@ -0,0 +1,30 @@ +namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific +{ + using FormsElement = Forms.Image; + + public static class Image + { + public static readonly BindableProperty BlendColorProperty = BindableProperty.Create("BlendColor", typeof(Color), typeof(FormsElement), Color.Default); + + public static Color GetBlendColor(BindableObject element) + { + return (Color)element.GetValue(BlendColorProperty); + } + + public static void SetBlendColor(BindableObject element, Color color) + { + element.SetValue(BlendColorProperty, color); + } + + public static Color GetBlendColor(this IPlatformElementConfiguration<Tizen, FormsElement> config) + { + return GetBlendColor(config.Element); + } + + public static IPlatformElementConfiguration<Tizen, FormsElement> SetBlendColor(this IPlatformElementConfiguration<Tizen, FormsElement> config, Color color) + { + SetBlendColor(config.Element, color); + return config; + } + } +} diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj index eef2d8f7..26445cae 100644 --- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj +++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -99,6 +99,7 @@ <Compile Include="PlatformConfiguration\iOSSpecific\StatusBarHiddenMode.cs" /> <Compile Include="PlatformConfiguration\iOSSpecific\UIStatusBarAnimation.cs" /> <Compile Include="PlatformConfiguration\iOSSpecific\VisualElement.cs" /> + <Compile Include="PlatformConfiguration\TizenSpecific\Image.cs" /> <Compile Include="PlatformConfiguration\TizenSpecific\ProgressBar.cs" /> <Compile Include="PlatformConfiguration\TizenSpecific\Button.cs" /> <Compile Include="PlatformConfiguration\TizenSpecific\ButtonStyle.cs" /> diff --git a/Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs b/Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs index 449b6f33..94899011 100644 --- a/Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs @@ -9,6 +9,8 @@ namespace Xamarin.Forms.Platform.Tizen const string _heightProperty = "Height"; readonly Dictionary<Cell, Dictionary<string, EvasObject>> _realizedNativeViews = new Dictionary<Cell, Dictionary<string, EvasObject>>(); + Native.ListView.ItemContext _currentItem; + protected CellRenderer(string style) { Class = new GenItemClass(style) @@ -109,15 +111,22 @@ namespace Xamarin.Forms.Platform.Tizen OnUnrealizedCell(cell); } + internal Native.ListView.ItemContext GetCurrentItem() + { + return _currentItem; + } + string GetText(object data, string part) { - var span = OnGetText((data as Native.ListView.ItemContext).Cell, part); + _currentItem = data as Native.ListView.ItemContext; + var span = OnGetText(_currentItem.Cell, part); return span != null ? ToNative(span).GetMarkupText() : null; } EvasObject GetContent(object data, string part) { - var cell = (data as Native.ListView.ItemContext).Cell; + _currentItem = data as Native.ListView.ItemContext; + var cell = _currentItem.Cell; EvasObject nativeView = OnGetContent(cell, part); UpdateRealizedView(cell, part, nativeView); return nativeView; @@ -125,7 +134,8 @@ namespace Xamarin.Forms.Platform.Tizen EvasObject ReusableContent(object data, string part, EvasObject old) { - var cell = (data as Native.ListView.ItemContext).Cell; + _currentItem = data as Native.ListView.ItemContext; + var cell = _currentItem.Cell; EvasObject nativeView = OnReusableContent(cell, part, old); UpdateRealizedView(cell, part, nativeView); return nativeView; @@ -148,7 +158,8 @@ namespace Xamarin.Forms.Platform.Tizen void ItemDeleted(object data) { - var cell = (data as Native.ListView.ItemContext).Cell; + _currentItem = data as Native.ListView.ItemContext; + var cell = _currentItem.Cell; _realizedNativeViews.Remove(cell); OnDeleted(cell); } diff --git a/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs b/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs index 63287786..bb17ec82 100644 --- a/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs @@ -38,11 +38,12 @@ namespace Xamarin.Forms.Platform.Tizen // It is a condition for reusable the cell if (listView != null && listView.HasUnevenRows == false && - !(listView.ItemTemplate is DataTemplateSelector)) + !(listView.ItemTemplate is DataTemplateSelector) && !GetCurrentItem().IsGroupItem) { return CreateReusableContent(viewCell); } + Platform.GetRenderer(viewCell.View)?.Dispose(); var renderer = Platform.GetOrCreateRenderer(viewCell.View); int height = (int)viewCell.RenderHeight; height = height > 0 ? height : FindCellContentHeight(viewCell); diff --git a/Xamarin.Forms.Platform.Tizen/Forms.cs b/Xamarin.Forms.Platform.Tizen/Forms.cs index 453bab82..a12d9513 100644 --- a/Xamarin.Forms.Platform.Tizen/Forms.cs +++ b/Xamarin.Forms.Platform.Tizen/Forms.cs @@ -123,10 +123,8 @@ namespace Xamarin.Forms.Platform.Tizen Elementary.ThemeOverlay(); } - //TO-DO: Need to change to Tizen. - Device.OS = TargetPlatform.Other; + Device.OS = TargetPlatform.Tizen; -#if !NET45 // In .NETCore, AppDomain feature is not supported. // The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually. // The assembly of the executing application and referenced assemblies of it are added into the list here. @@ -147,7 +145,6 @@ namespace Xamarin.Forms.Platform.Tizen } } } -#endif Device.PlatformServices = new TizenPlatformServices(); ; if (Device.info != null) diff --git a/Xamarin.Forms.Platform.Tizen/Native/Label.cs b/Xamarin.Forms.Platform.Tizen/Native/Label.cs index c07cce82..9d52cde2 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Label.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Label.cs @@ -1,4 +1,4 @@ -using System; +using System; using ElmSharp; using ELabel = ElmSharp.Label; using EColor = ElmSharp.Color; @@ -300,6 +300,11 @@ namespace Xamarin.Forms.Platform.Tizen.Native rawSize.Height += verticalPadding; formattedSize.Height += verticalPadding; + // This is the EFL team's guide. + // For wrap to work properly, the label must be 1 pixel larger than the size of the formatted text. + rawSize.Width += 1; + formattedSize.Width += 1; + if (rawSize.Width > availableWidth) { return new ESize() diff --git a/Xamarin.Forms.Platform.Tizen/Native/ListView.cs b/Xamarin.Forms.Platform.Tizen/Native/ListView.cs index f5047b3d..fbee7d48 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/ListView.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/ListView.cs @@ -85,32 +85,10 @@ namespace Xamarin.Forms.Platform.Tizen.Native GenItemClass _headerFooterItemClass = null; /// <summary> - /// Indicates if the list view has uneven rows. - /// </summary> - bool _hasUnevenRows = false; - - /// <summary> - /// Indicates if grouping in the list view is enabled. - /// </summary> - bool _isGroupingEnabled = false; - - /// <summary> /// Gets or sets a value indicating whether this instance has grouping enabled. /// </summary> /// <value><c>true</c> if this instance has grouping enabled.</value> - public bool IsGroupingEnabled - { - get - { - return _isGroupingEnabled; - } - - set - { - _isGroupingEnabled = value; - UpdateHomogeneousMode(); - } - } + public bool IsGroupingEnabled { get; set; } /// <summary> /// Constructor of ListView native control. @@ -146,8 +124,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// <param name="hasUnevenRows">If <c>true</c>, the list will allow uneven sizes for its rows.</param> public void SetHasUnevenRows(bool hasUnevenRows) { - _hasUnevenRows = hasUnevenRows; - UpdateHomogeneousMode(); + Homogeneous = !hasUnevenRows; UpdateRealizedItems(); } @@ -622,13 +599,5 @@ namespace Xamarin.Forms.Platform.Tizen.Native } return _headerFooterItemClass; } - - /// <summary> - /// Updates the homogeneous mode of the list view. - /// </summary> - void UpdateHomogeneousMode() - { - Homogeneous = !_hasUnevenRows && !_isGroupingEnabled; - } } } diff --git a/Xamarin.Forms.Platform.Tizen/Native/Span.cs b/Xamarin.Forms.Platform.Tizen/Native/Span.cs index 0e3f0000..c92fefcf 100644..100755 --- a/Xamarin.Forms.Platform.Tizen/Native/Span.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Span.cs @@ -144,7 +144,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// <summary> /// This method return text decorated with markup if FormattedText is set or plain text otherwise. /// </summary> - internal string GetDecoratedText() + public string GetDecoratedText() { if (FormattedText != null) { @@ -275,7 +275,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native .Replace("\n", "<br>"); } - internal string GetStyle() + public string GetStyle() { StringBuilder sb = new StringBuilder(); diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs index ca06a669..09353b2a 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs @@ -1,15 +1,15 @@ +using System.ComponentModel; using System.Threading; using System.Threading.Tasks; +using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Image; + namespace Xamarin.Forms.Platform.Tizen { public class ImageRenderer : ViewRenderer<Image, Native.Image> { public ImageRenderer() { - RegisterPropertyHandler(Image.SourceProperty, UpdateSource); - RegisterPropertyHandler(Image.AspectProperty, UpdateAspect); - RegisterPropertyHandler(Image.IsOpaqueProperty, UpdateIsOpaque); } protected override void OnElementChanged(ElementChangedEventArgs<Image> e) @@ -20,9 +20,35 @@ namespace Xamarin.Forms.Platform.Tizen SetNativeControl(image); } + if (e.NewElement != null) + { + UpdateAll(); + } + base.OnElementChanged(e); } + protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + { + base.OnElementPropertyChanged(sender, e); + if (e.PropertyName == Image.SourceProperty.PropertyName) + { + UpdateSource(); + } + else if (e.PropertyName == Image.AspectProperty.PropertyName) + { + UpdateAspect(); + } + else if (e.PropertyName == Image.IsOpaqueProperty.PropertyName) + { + UpdateIsOpaque(); + } + else if (e.PropertyName == Specific.BlendColorProperty.PropertyName) + { + UpdateBlendColor(); + } + } + async void UpdateSource() { ImageSource source = Element.Source; @@ -49,6 +75,19 @@ namespace Xamarin.Forms.Platform.Tizen { Control.IsOpaque = Element.IsOpaque; } + + void UpdateBlendColor() + { + Control.Color = Specific.GetBlendColor(Element).ToNative(); + } + + void UpdateAll() + { + UpdateSource(); + UpdateAspect(); + UpdateIsOpaque(); + UpdateBlendColor(); + } } public interface IImageSourceHandler : IRegisterable diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs index 5a4744fc..d21d3d76 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/LabelRenderer.cs @@ -90,14 +90,27 @@ namespace Xamarin.Forms.Platform.Tizen void UpdateLineBreakMode() { - if (Element.LineBreakMode == LineBreakMode.CharacterWrap) - Control.LineBreakMode = Native.LineBreakMode.CharacterWrap; - else if (Element.LineBreakMode == LineBreakMode.WordWrap) - Control.LineBreakMode = Native.LineBreakMode.WordWrap; - else if (Element.LineBreakMode == LineBreakMode.NoWrap) - Control.LineBreakMode = Native.LineBreakMode.NoWrap; - else - Control.LineBreakMode = Native.LineBreakMode.MixedWrap; + Control.LineBreakMode = ConvertToNativeLineBreakMode(Element.LineBreakMode); + } + + Native.LineBreakMode ConvertToNativeLineBreakMode(LineBreakMode mode) + { + switch (mode) + { + case LineBreakMode.CharacterWrap: + return Native.LineBreakMode.CharacterWrap; + case LineBreakMode.HeadTruncation: + return Native.LineBreakMode.HeadTruncation; + case LineBreakMode.MiddleTruncation: + return Native.LineBreakMode.MiddleTruncation; + case LineBreakMode.NoWrap: + return Native.LineBreakMode.NoWrap; + case LineBreakMode.TailTruncation: + return Native.LineBreakMode.TailTruncation; + case LineBreakMode.WordWrap: + default: + return Native.LineBreakMode.WordWrap; + } } } } diff --git a/Xamarin.Forms.Platform.Tizen/ResourcePath.cs b/Xamarin.Forms.Platform.Tizen/ResourcePath.cs index d2387793..b3678727 100644..100755 --- a/Xamarin.Forms.Platform.Tizen/ResourcePath.cs +++ b/Xamarin.Forms.Platform.Tizen/ResourcePath.cs @@ -1,13 +1,10 @@ using System.IO; -#if NET45 -using System.Reflection; -#endif using AppFW = Tizen.Applications; namespace Xamarin.Forms.Platform.Tizen { - internal static class ResourcePath + public static class ResourcePath { public static string GetPath(string res) { @@ -26,18 +23,6 @@ namespace Xamarin.Forms.Platform.Tizen } } -#if NET45 - string exedir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - // ind resource in "exepath/../res/" - { - string resPath = exedir + "/../res/" + res; - if (File.Exists(resPath)) - { - return resPath; - } - } -#endif - return res; } } diff --git a/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs b/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs index db7ee1de..bb7183a9 100644 --- a/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs +++ b/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs @@ -192,7 +192,6 @@ namespace Xamarin.Forms.Platform.Tizen #endregion -#if !NET45 // In .NETCore, AppDomain is not supported. The list of the assemblies should be generated manually. internal class AppDomain { @@ -226,7 +225,6 @@ namespace Xamarin.Forms.Platform.Tizen return _assemblies.ToArray(); } } -#endif } } diff --git a/packaging/xamarin-forms-tizen.spec b/packaging/xamarin-forms-tizen.spec index ca3fca42..80983d6d 100644 --- a/packaging/xamarin-forms-tizen.spec +++ b/packaging/xamarin-forms-tizen.spec @@ -1,5 +1,4 @@ %define XF_VERSION 2.3.3.175 -## %define XF_PRETAG pre3 # Increase this XF_TIZEN_VERSION when any public APIs of Xamarin.Forms.Platform.Tizen are changed. %define XF_TIZEN_VERSION b02 @@ -19,7 +18,7 @@ Source1: %{name}.manifest # let's override Mono provided portion %define __mono_requires %{_builddir}/%name-%version/packaging/custom-find-requires -ExcludeArch: aarch64 %ix86 +ExcludeArch: aarch64 BuildRequires: mono-compiler BuildRequires: mono-devel |