Support TranslatablePlaceholderTextFocused to TextField
authorBowon Ryu <bowon.ryu@samsung.com>
Thu, 4 Mar 2021 08:05:31 +0000 (17:05 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 17 Mar 2021 06:50:14 +0000 (15:50 +0900)
PlaceholderTextFoused can set the SID value by this patch

Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs
src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs

index 16696e1..95b190a 100755 (executable)
@@ -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<string>), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
-        {
-            var textFieldStyle = (TextFieldStyle)bindable;
-            textFieldStyle.translatablePlaceholderTextSelector = ((Selector<string>)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<string>), 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<string> translatablePlaceholderTextSelector;
         private Selector<string> fontFamilySelector;
         private Selector<Color> textColorSelector;
         private Selector<float?> 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<string> TranslatablePlaceholderText
-        {
-            get
-            {
-                Selector<string> tmp = (Selector<string>)GetValue(TranslatablePlaceholderTextSelectorProperty);
-                return (null != tmp) ? tmp : translatablePlaceholderTextSelector = new Selector<string>();
-            }
-            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);
index c0495bd..1501cdb 100755 (executable)
@@ -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
         }
 
         /// <summary>
+        /// The TranslatablePlaceholderTextFocused property.<br />
+        /// The text can set the SID value.<br />
+        /// </summary>
+        /// <exception cref='ArgumentNullException'>
+        /// ResourceManager about multilingual is null.
+        /// </exception>
+        /// 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();
+            }
+        }
+
+        /// <summary>
         /// The Text property.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -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)
index 9c58900..cd08a01 100755 (executable)
@@ -60,6 +60,23 @@ namespace Tizen.NUI.BaseComponents
             var textField = (TextField)bindable;
             return textField.translatablePlaceholderText;
         });
+        /// <summary>
+        /// TranslatablePlaceholderTextFocused property
+        /// </summary>
+        [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<string>(textField.selectorData?.TranslatablePlaceholderText, TextField.TranslatablePlaceholderTextProperty);
         });
+        internal static readonly BindableProperty TranslatablePlaceholderTextFocusedSelectorProperty = BindableProperty.Create("TranslatablePlaceholderTextFocusedSelector", typeof(Selector<string>), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var textField = (TextField)bindable;
+            textField.EnsureSelectorData().EnsureTranslatablePlaceholderTextFocused().Update(textField, (Selector<string>)newValue, true);
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var textField = (TextField)bindable;
+            return textField.GetSelector<string>(textField.selectorData?.TranslatablePlaceholderTextFocused, TextField.TranslatablePlaceholderTextFocusedProperty);
+        });
         internal static readonly BindableProperty TextSelectorProperty = BindableProperty.Create("TextSelector", typeof(Selector<string>), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var textField = (TextField)bindable;
index 6cc9984..1a73502 100755 (executable)
@@ -29,6 +29,7 @@ namespace Tizen.NUI.BaseComponents
         public TriggerableSelector<float?> PointSize { get; private set; }
         public TriggerableSelector<float?> PixelSize { get; private set; }
         public TriggerableSelector<string> TranslatablePlaceholderText { get; private set; }
+        public TriggerableSelector<string> TranslatablePlaceholderTextFocused { get; private set; }
         public TriggerableSelector<Vector4> PlaceholderTextColor { get; private set; }
         public TriggerableSelector<Vector4> PrimaryCursorColor { get; private set; }
 
@@ -39,6 +40,7 @@ namespace Tizen.NUI.BaseComponents
         public TriggerableSelector<float?> EnsurePointSize() => PointSize ?? (PointSize = new TriggerableSelector<float?>(TextField.PointSizeProperty));
         public TriggerableSelector<float?> EnsurePixelSize() => PixelSize ?? (PixelSize = new TriggerableSelector<float?>(TextField.PixelSizeProperty));
         public TriggerableSelector<string> EnsureTranslatablePlaceholderText() => TranslatablePlaceholderText ?? (TranslatablePlaceholderText = new TriggerableSelector<string>(TextField.TranslatablePlaceholderTextProperty));
+        public TriggerableSelector<string> EnsureTranslatablePlaceholderTextFocused() => TranslatablePlaceholderTextFocused ?? (TranslatablePlaceholderTextFocused = new TriggerableSelector<string>(TextField.TranslatablePlaceholderTextFocusedProperty));
         public TriggerableSelector<Vector4> EnsurePlaceholderTextColor() =>  PlaceholderTextColor ?? (PlaceholderTextColor = new TriggerableSelector<Vector4>(TextField.PlaceholderTextColorProperty));
         public TriggerableSelector<Vector4> EnsurePrimaryCursorColor() => PrimaryCursorColor ?? (PrimaryCursorColor = new TriggerableSelector<Vector4>(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);
         }