update main menu component
authorYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Thu, 25 Jan 2024 12:48:12 +0000 (13:48 +0100)
committerYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Tue, 30 Jan 2024 07:29:56 +0000 (08:29 +0100)
SettingCore/Views/MainMenuItem.cs

index 379d92518fdb004f40672d9899ba56193a8a058a..1820e45a816c53ed728ba263e453675cef3b710a 100644 (file)
@@ -1,5 +1,6 @@
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
 
 namespace SettingCore.Views
 {
@@ -8,26 +9,26 @@ namespace SettingCore.Views
         private readonly ThemeColor BackgroundColors = new ThemeColor(Color.Transparent, Color.Transparent, new Color("#FF6400").WithAlpha(0.16f), Color.White.WithAlpha(0.16f));
         private readonly ThemeColor TextColors = new ThemeColor(new Color("#090E21"), new Color("#FDFDFD"), new Color("#FF6200"), new Color("#FF8A00"));
         private readonly ThemeColor IconColors = new ThemeColor(Color.White, Color.Black, Color.White, Color.Black);
-        private readonly ThemeColor IconBackgroundColors;
 
         private readonly ImageView icon;
+        private readonly View iconBackground;
         private readonly ImageVisual iconVisual;
         private readonly TextLabel titleTextLabel;
 
-        public MainMenuItem(string iconPath, Color iconBackgroungColor, string title) : base()
-        {
-            IconBackgroundColors = new ThemeColor(iconBackgroungColor, iconBackgroungColor, iconBackgroungColor, iconBackgroungColor);
+        public string MenuPath { get; private set; }
 
+        public MainMenuItem(string iconPath, Color iconBackgroungColor, string title, string menuPath) : base()
+        {
             Layout = new LinearLayout
             {
                 LinearOrientation = LinearLayout.Orientation.Horizontal,
                 VerticalAlignment = VerticalAlignment.Center,
             };
 
-            var iconBackground = new View
+            iconBackground = new View
             {
                 CornerRadius = 5.SpToPx(),
-                BackgroundColor = IconBackgroundColors.Normal,
+                BackgroundColor = iconBackgroungColor,
                 Size = new Size(32, 32).SpToPx(),
                 Margin = new Extents(16, 16, 16, 16).SpToPx(),
             };
@@ -60,9 +61,22 @@ namespace SettingCore.Views
 
             AccessibilityRole = Role.MenuItem;
 
+            MenuPath = menuPath;
+            Clicked += (s, e) =>
+            {
+                Logger.Debug($"navigating to menupath {MenuPath}, title: {title}");
+                GadgetNavigation.NavigateTo(MenuPath);
+            };
+
             ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
         }
 
+        public void UpdateItem(string title, Color iconBackgroungColor)
+        {
+            titleTextLabel.Text = title;
+            iconBackground.BackgroundColor = iconBackgroungColor;
+        }        
+        
         public override void OnChangeSelected(bool selected)
         {
             if (selected)