From 3fa7211d38b369f7a262cbeeaa4dc566ba35a8fe Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Thu, 4 Mar 2021 17:05:31 +0900 Subject: [PATCH] Support TranslatablePlaceholderTextFocused to TextField PlaceholderTextFoused can set the SID value by this patch Signed-off-by: Bowon Ryu --- .../public/BaseComponents/Style/TextFieldStyle.cs | 26 ------------- .../src/public/BaseComponents/TextField.cs | 44 ++++++++++++++++++++++ .../BaseComponents/TextFieldBindableProperty.cs | 27 +++++++++++++ .../public/BaseComponents/TextFieldSelectorData.cs | 3 ++ 4 files changed, 74 insertions(+), 26 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs index 16696e1..95b190a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs @@ -27,19 +27,6 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public class TextFieldStyle : ViewStyle { - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty TranslatablePlaceholderTextSelectorProperty = BindableProperty.Create("TranslatablePlaceholderTextSelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textFieldStyle = (TextFieldStyle)bindable; - textFieldStyle.translatablePlaceholderTextSelector = ((Selector)newValue)?.Clone(); - }, - defaultValueCreator: (bindable) => - { - var textFieldStyle = (TextFieldStyle)bindable; - return textFieldStyle.translatablePlaceholderTextSelector; - }); - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { @@ -491,7 +478,6 @@ namespace Tizen.NUI.BaseComponents private bool? enableSelection; private bool? ellipsis; private bool? matchSystemLanguageDirection; - private Selector translatablePlaceholderTextSelector; private Selector fontFamilySelector; private Selector textColorSelector; private Selector pointSizeSelector; @@ -510,18 +496,6 @@ namespace Tizen.NUI.BaseComponents /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public Selector TranslatablePlaceholderText - { - get - { - Selector tmp = (Selector)GetValue(TranslatablePlaceholderTextSelectorProperty); - return (null != tmp) ? tmp : translatablePlaceholderTextSelector = new Selector(); - } - set => SetValue(TranslatablePlaceholderTextSelectorProperty, value); - } - - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] public string PlaceholderText { get => (string)GetValue(PlaceholderTextProperty); diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index c0495bd..1501cdb 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -32,6 +32,7 @@ namespace Tizen.NUI.BaseComponents { private string textFieldTextSid = null; private string textFieldPlaceHolderTextSid = null; + private string textFieldPlaceHolderTextFocusedSid = null; private bool systemlangTextFlag = false; private InputMethodContext inputMethodCotext = null; private TextFieldSelectorData selectorData; @@ -179,6 +180,45 @@ namespace Tizen.NUI.BaseComponents } /// + /// The TranslatablePlaceholderTextFocused property.
+ /// The text can set the SID value.
+ ///
+ /// + /// ResourceManager about multilingual is null. + /// + /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public string TranslatablePlaceholderTextFocused + { + get + { + return (string)GetValue(TranslatablePlaceholderTextFocusedProperty); + } + set + { + SetValue(TranslatablePlaceholderTextFocusedProperty, value); + selectorData?.TranslatablePlaceholderTextFocused?.Reset(this); + } + } + private string translatablePlaceholderTextFocused + { + get + { + return textFieldPlaceHolderTextFocusedSid; + } + set + { + if (NUIApplication.MultilingualResourceManager == null) + { + throw new ArgumentNullException(null, "ResourceManager about multilingual is null"); + } + textFieldPlaceHolderTextFocusedSid = value; + PlaceholderTextFocused = SetTranslatable(textFieldPlaceHolderTextFocusedSid); + NotifyPropertyChanged(); + } + } + + /// /// The Text property. /// /// 3 @@ -1511,6 +1551,10 @@ namespace Tizen.NUI.BaseComponents { PlaceholderText = NUIApplication.MultilingualResourceManager?.GetString(textFieldPlaceHolderTextSid, new CultureInfo(e.Value.Replace("_", "-"))); } + if (textFieldPlaceHolderTextFocusedSid != null) + { + PlaceholderTextFocused = NUIApplication.MultilingualResourceManager?.GetString(textFieldPlaceHolderTextFocusedSid, new CultureInfo(e.Value.Replace("_", "-"))); + } } private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs index 9c58900..cd08a01 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs @@ -60,6 +60,23 @@ namespace Tizen.NUI.BaseComponents var textField = (TextField)bindable; return textField.translatablePlaceholderText; }); + /// + /// TranslatablePlaceholderTextFocused property + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty TranslatablePlaceholderTextFocusedProperty = BindableProperty.Create(nameof(TranslatablePlaceholderTextFocused), typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + if (newValue != null) + { + textField.translatablePlaceholderTextFocused = (string)newValue; + } + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.translatablePlaceholderTextFocused; + }); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(TextField), string.Empty, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => @@ -1011,6 +1028,16 @@ namespace Tizen.NUI.BaseComponents var textField = (TextField)bindable; return textField.GetSelector(textField.selectorData?.TranslatablePlaceholderText, TextField.TranslatablePlaceholderTextProperty); }); + internal static readonly BindableProperty TranslatablePlaceholderTextFocusedSelectorProperty = BindableProperty.Create("TranslatablePlaceholderTextFocusedSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.EnsureSelectorData().EnsureTranslatablePlaceholderTextFocused().Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.GetSelector(textField.selectorData?.TranslatablePlaceholderTextFocused, TextField.TranslatablePlaceholderTextFocusedProperty); + }); internal static readonly BindableProperty TextSelectorProperty = BindableProperty.Create("TextSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => { var textField = (TextField)bindable; diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs b/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs index 6cc9984..1a73502 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs @@ -29,6 +29,7 @@ namespace Tizen.NUI.BaseComponents public TriggerableSelector PointSize { get; private set; } public TriggerableSelector PixelSize { get; private set; } public TriggerableSelector TranslatablePlaceholderText { get; private set; } + public TriggerableSelector TranslatablePlaceholderTextFocused { get; private set; } public TriggerableSelector PlaceholderTextColor { get; private set; } public TriggerableSelector PrimaryCursorColor { get; private set; } @@ -39,6 +40,7 @@ namespace Tizen.NUI.BaseComponents public TriggerableSelector EnsurePointSize() => PointSize ?? (PointSize = new TriggerableSelector(TextField.PointSizeProperty)); public TriggerableSelector EnsurePixelSize() => PixelSize ?? (PixelSize = new TriggerableSelector(TextField.PixelSizeProperty)); public TriggerableSelector EnsureTranslatablePlaceholderText() => TranslatablePlaceholderText ?? (TranslatablePlaceholderText = new TriggerableSelector(TextField.TranslatablePlaceholderTextProperty)); + public TriggerableSelector EnsureTranslatablePlaceholderTextFocused() => TranslatablePlaceholderTextFocused ?? (TranslatablePlaceholderTextFocused = new TriggerableSelector(TextField.TranslatablePlaceholderTextFocusedProperty)); public TriggerableSelector EnsurePlaceholderTextColor() => PlaceholderTextColor ?? (PlaceholderTextColor = new TriggerableSelector(TextField.PlaceholderTextColorProperty)); public TriggerableSelector EnsurePrimaryCursorColor() => PrimaryCursorColor ?? (PrimaryCursorColor = new TriggerableSelector(TextField.PrimaryCursorColorProperty)); @@ -51,6 +53,7 @@ namespace Tizen.NUI.BaseComponents PointSize?.Reset(view); PixelSize?.Reset(view); TranslatablePlaceholderText?.Reset(view); + TranslatablePlaceholderTextFocused?.Reset(view); PlaceholderTextColor?.Reset(view); PrimaryCursorColor?.Reset(view); } -- 2.7.4