[Tizen] fix picker focus issue in TV profile (#7770)
authorshmin <shmin.dev@gmail.com>
Thu, 3 Oct 2019 21:50:52 +0000 (06:50 +0900)
committerRui Marinho <me@ruimarinho.net>
Thu, 3 Oct 2019 21:50:52 +0000 (22:50 +0100)
Xamarin.Forms.Platform.Tizen/Native/EditfieldEntry.cs
Xamarin.Forms.Platform.Tizen/Renderers/PickerRenderer.cs

index cce50d0..7b239e1 100644 (file)
@@ -9,6 +9,9 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                public event EventHandler TextBlockFocused;
                public event EventHandler TextBlockUnfocused;
 
+               public event EventHandler LayoutFocused;
+               public event EventHandler LayoutUnfocused;
+
                public bool IsTextBlockFocused => _isTexstBlockFocused;
 
                ELayout _editfieldLayout;
@@ -91,14 +94,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                        return _editfieldLayout;
                }
 
-               protected ELayout EditfieldLayout
-               {
-                       get
-                       {
-                               return _editfieldLayout;
-                       }
-               }
-
                protected virtual ELayout CreateEditFieldLayout(EvasObject parent)
                {
                        var layout = new ELayout(parent);
@@ -108,11 +103,13 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                        {
                                SetFocusOnTextBlock(false);
                                layout.SignalEmit("elm,state,unfocused", "");
+                               LayoutUnfocused?.Invoke(this, EventArgs.Empty);
                        };
                        layout.Focused += (s, e) =>
                        {
                                AllowFocus(false);
                                layout.SignalEmit("elm,state,focused", "");
+                               LayoutFocused?.Invoke(this, EventArgs.Empty);
                        };
 
                        layout.KeyDown += (s, e) =>
index 9f04445..abfc0c2 100644 (file)
@@ -30,6 +30,11 @@ namespace Xamarin.Forms.Platform.Tizen
                                if (Control != null)
                                {
                                        Control.TextBlockFocused -= OnTextBlockFocused;
+                                       if (Device.Idiom == TargetIdiom.TV)
+                                       {
+                                               Control.LayoutFocused -= OnLayoutFocused;
+                                               Control.LayoutUnfocused -= OnLayoutUnfocused;
+                                       }
                                        CleanView();
                                }
                        }
@@ -46,7 +51,15 @@ namespace Xamarin.Forms.Platform.Tizen
                                        InputPanelShowByOnDemand = true,
                                };
                                entry.SetVerticalTextAlignment("elm.text", 0.5);
+                               entry.HorizontalTextAlignment = Native.TextAlignment.Center;
                                entry.TextBlockFocused += OnTextBlockFocused;
+
+                               if (Device.Idiom == TargetIdiom.TV)
+                               {
+                                       entry.LayoutFocused += OnLayoutFocused;
+                                       entry.LayoutUnfocused += OnLayoutUnfocused;
+                               }
+
                                SetNativeControl(entry);
                        }
                        base.OnElementChanged(e);
@@ -88,6 +101,16 @@ namespace Xamarin.Forms.Platform.Tizen
                        Control.PlaceholderColor = Element.TitleColor.ToNative();
                }
 
+               void OnLayoutFocused(object sender, EventArgs e)
+               {
+                       Control.FontSize = Control.FontSize * 1.5;
+               }
+
+               void OnLayoutUnfocused(object sender, EventArgs e)
+               {
+                       Control.FontSize = Control.FontSize / 1.5;
+               }
+
                void OnTextBlockFocused(object sender, EventArgs e)
                {
                        // For EFL Entry, the event will occur even if it is currently disabled.