From 066d00ec3c3a3c666a20b881f5b6ae91b254cebb Mon Sep 17 00:00:00 2001 From: huiyueun <35286162+huiyueun@users.noreply.github.com> Date: Fri, 25 Dec 2020 12:03:34 +0900 Subject: [PATCH] [NUI] Add ImageList property (#2449) Signed-off-by: huiyu.eun Co-authored-by: YeongJong Lee --- src/Tizen.NUI.Components/Controls/Loading.cs | 39 ++++++++++++++++++++++---- src/Tizen.NUI.Components/Style/LoadingStyle.cs | 34 ++++++++++++++++++++-- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/Loading.cs b/src/Tizen.NUI.Components/Controls/Loading.cs index 0674415..c61528a 100755 --- a/src/Tizen.NUI.Components/Controls/Loading.cs +++ b/src/Tizen.NUI.Components/Controls/Loading.cs @@ -29,7 +29,7 @@ namespace Tizen.NUI.Components /// 6 public class Loading : Control { - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. + /// The ImageArray bindable property. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ImageArrayProperty = BindableProperty.Create(nameof(ImageArray), typeof(string[]), typeof(Loading), null, propertyChanged: (bindable, oldValue, newValue) => { @@ -37,7 +37,7 @@ namespace Tizen.NUI.Components if (newValue != null) { instance.loadingStyle.Images = (string[])newValue; - instance.imageVisual.URLS = new List((string[])newValue); + instance.imageVisual.URLS = instance.loadingStyle.ImageList as List; } }, defaultValueCreator: (bindable) => @@ -45,7 +45,23 @@ namespace Tizen.NUI.Components var instance = (Loading)bindable; return instance.loadingStyle.Images; }); - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. + /// The ImageList bindable property. + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty ImageListProperty = BindableProperty.Create(nameof(ImageList), typeof(IList), typeof(Loading), null, propertyChanged: (bindable, oldValue, newValue) => + { + var instance = (Loading)bindable; + if (newValue != null) + { + var newValueList = newValue as List; + instance.loadingStyle.ImageList = newValueList; + instance.imageVisual.URLS = newValueList; + } + }, + defaultValueCreator: (bindable) => + { + return ((Loading)bindable).loadingStyle.ImageList; + }); + /// The Size bindable property. [EditorBrowsable(EditorBrowsableState.Never)] public new static readonly BindableProperty SizeProperty = BindableProperty.Create(nameof(Size), typeof(Size), typeof(Loading), new Size(0, 0), propertyChanged: (bindable, oldValue, newValue) => { @@ -62,7 +78,7 @@ namespace Tizen.NUI.Components var instance = (View)bindable; return instance.Size; }); - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. + /// The FrameRate bindable property. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty FrameRateProperty = BindableProperty.Create(nameof(FrameRate), typeof(int), typeof(Loading), (int)(1000 / 16.6f), propertyChanged: (bindable, oldValue, newValue) => { @@ -160,6 +176,18 @@ namespace Tizen.NUI.Components } /// + /// Gets loading image resource array. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IList ImageList + { + get + { + return GetValue(ImageListProperty) as List; + } + } + + /// /// Gets or sets loading size. /// /// 6 @@ -250,7 +278,8 @@ namespace Tizen.NUI.Components { if (null != loadingStyle.Images) { - imageVisual.URLS = new List(loadingStyle.Images); + loadingStyle.ImageList = new List(loadingStyle.Images); + imageVisual.URLS = loadingStyle.ImageList as List; } if (null != loadingStyle.FrameRate?.All && 0 != loadingStyle.FrameRate.All.Value) { diff --git a/src/Tizen.NUI.Components/Style/LoadingStyle.cs b/src/Tizen.NUI.Components/Style/LoadingStyle.cs index 9fd3e97..a24a54b 100755 --- a/src/Tizen.NUI.Components/Style/LoadingStyle.cs +++ b/src/Tizen.NUI.Components/Style/LoadingStyle.cs @@ -14,6 +14,7 @@ * limitations under the License. * */ +using System.Collections.Generic; using System.ComponentModel; using Tizen.NUI.BaseComponents; using Tizen.NUI.Binding; @@ -52,15 +53,34 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ImagesProperty = BindableProperty.Create(nameof(Images), typeof(string[]), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((LoadingStyle)bindable).images = (string[])((string[])newValue)?.Clone(); + ((LoadingStyle)bindable).images = new List((string[])newValue); }, defaultValueCreator: (bindable) => { + if (((LoadingStyle)bindable).images == null) + { + ((LoadingStyle)bindable).images = new List(); + } + return ((LoadingStyle)bindable).images?.ToArray(); + }); + + /// The Images bindable property. + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty ImageListProperty = BindableProperty.Create(nameof(ImageList), typeof(IList), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) => + { + ((LoadingStyle)bindable).images = newValue as List; + }, + defaultValueCreator: (bindable) => + { + if(((LoadingStyle)bindable).images == null) + { + ((LoadingStyle)bindable).images = new List(); + } return ((LoadingStyle)bindable).images; }); private Selector frameRate; - private string[] images; + private List images; static LoadingStyle() { } @@ -90,6 +110,16 @@ namespace Tizen.NUI.Components } /// + /// Gets loading image resources. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IList ImageList + { + get => GetValue(ImageListProperty) as List; + internal set => SetValue(ImageListProperty, value); + } + + /// /// Gets or sets loading image size. /// /// 8 -- 2.7.4