add icon to more menu items
authorYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Wed, 24 Jan 2024 08:05:53 +0000 (09:05 +0100)
committerYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Tue, 30 Jan 2024 11:26:16 +0000 (12:26 +0100)
SettingCore/GadgetNavigation.cs
SettingCore/MoreMenuItem.cs

index 264aaa2da36c574953e68b017dcf005cd6cfe41e..4a8768c952401403200d27ef861d3e59236d6378 100644 (file)
@@ -265,12 +265,48 @@ namespace SettingCore
                         TextColor = IsLightTheme ? new Color("#090E21") : new Color("#FDFDFD"),
                     };
 
+                    if (!String.IsNullOrEmpty(moreMenuItem.IconPath))
+                    {
+                        item.Layout = new FlexLayout()
+                        {
+                            Justification = FlexLayout.FlexJustification.SpaceBetween,
+                            Direction = FlexLayout.FlexDirection.Row,
+                            ItemsAlignment = FlexLayout.AlignmentType.Center
+                        };
+   
+                        // remove buttons icon
+                        item.Remove(item.Children[0]);
+
+                        var iconVisual = new ImageVisual
+                        {
+                            URL = System.IO.Path.Combine(Tizen.Applications.Application.Current.DirectoryInfo.Resource, moreMenuItem.IconPath),
+                            FittingMode = FittingModeType.ScaleToFill,
+                        };
+                        var itemIcon = new ImageView
+                        {
+                            ResourceUrl = System.IO.Path.Combine(Tizen.Applications.Application.Current.DirectoryInfo.Resource, moreMenuItem.IconPath),
+                            Size = new Size(32, 32).SpToPx(),
+                        };
+
+                        item.Add(itemIcon);
+                    }
+
                     if (moreMenuItem.Action is null)
                     {
                         item.TextColor = IsLightTheme ? new Color("#83868F") : new Color("#666666");
                     }
                     else
                     {
+                        item.TouchEvent += (s, e) =>
+                        {
+                            var state = e.Touch.GetState(0);
+                            if (state == PointStateType.Down)
+                            {
+                                item.TextColor = IsLightTheme ? new Color("#FF6200") : new Color("#FF8A00");
+                            }
+                            return false;
+                        };
+
                         item.Clicked += (s, e) =>
                         {
                             moreMenuItem.Action?.Invoke();
index ac940b9c3657012a8d2938e7f8906c1d0c409282..afa147256c77a6bcac9c2aadeab3fcd3dc904ed0 100644 (file)
@@ -5,6 +5,7 @@ namespace SettingCore
     public class MoreMenuItem
     {
         public string Text { get; set; }
+        public string IconPath { get; set; }
         public Action Action { get; set; }
     }
 }