Fixing theme issues 67/301667/4 accepted/tizen/unified/20231128.175127
authortarunkumarmahay1999 <tarun.mahay@samsung.com>
Tue, 21 Nov 2023 09:45:30 +0000 (15:15 +0530)
committertarunkumarmahay1999 <tarun.mahay@samsung.com>
Wed, 22 Nov 2023 10:00:51 +0000 (15:30 +0530)
Change-Id: Ie729e4d03ecbfe9d71d8304a0478de0ecd6692d8
Signed-off-by: tarunkumarmahay1999 <tarun.mahay@samsung.com>
12 files changed:
VolumeApp/Common/AppCommon.cs
VolumeApp/Common/ThemeColor.cs [new file with mode: 0644]
VolumeApp/Common/ThemeUtility.cs [deleted file]
VolumeApp/Core/ViewManager.cs
VolumeApp/Views/MainView.cs
VolumeApp/VolumeApp.cs
VolumeApp/VolumeApp.csproj
VolumeApp/res/Images/dark/button_outline.png [deleted file]
VolumeApp/res/Images/light/button_outline.png [deleted file]
VolumeApp/res/themes/dark.xaml [deleted file]
VolumeApp/res/themes/light.xaml [deleted file]
packaging/org.tizen.volume-nui-1.0.0.tpk

index 91ac297e01be724514eced9a1ba969f83cf5293e..ebf1679bf3fdf215fd7a68c024c34aa834ad2322 100644 (file)
@@ -21,9 +21,11 @@ namespace VolumeApp.Common
     {
         public static Vector4 mainViewCornerRadius = new Vector4(12.0f, 12.0f, 12.0f, 12.0f);
         public static Extents mainViewPadding = new Extents(20, 20, 20, 20).SpToPx();
-        public static Shadow mainViewLightBoxShadow = new Shadow(0.0f, new Color(0, 0, 0, 0.16f), new Vector2(0, 2));
-        public static Shadow mainViewDarkBoxShadow = new Shadow(0.0f, new Color(1.0f, 1.0f, 1.0f, 0.5f), new Vector2(0, 2));
+        public static Shadow mainViewLightBoxShadow = new Shadow(8.0f, new Color(0, 0, 0, 0.16f));
+        public static Shadow mainViewDarkBoxShadow = new Shadow(8.0f, new Color(1.0f, 1.0f, 1.0f, 0.5f));
         public static int mainViewWidth = 104.SpToPx();
+        public static int textLabelPixelSize = 24.SpToPx();
+        public static int borderLineWidth = 2.SpToPx();
 
         public static Vector4 sliderCornerRadius = new Vector4(8, 8, 8, 8);
         public static Size2D sliderThumbSizeNormal = new Size2D(24, 24).SpToPx();
diff --git a/VolumeApp/Common/ThemeColor.cs b/VolumeApp/Common/ThemeColor.cs
new file mode 100644 (file)
index 0000000..7ad55bf
--- /dev/null
@@ -0,0 +1,23 @@
+using Tizen.NUI;
+
+namespace VolumeApp.Common
+{
+    public static class ThemeColor
+    {
+        private static bool IsLightTheme => ThemeManager.PlatformThemeId == ThemeManager.DefaultLightThemeName;
+
+        public static Shadow PopupBoxShadow => IsLightTheme? AppCommon.mainViewLightBoxShadow : AppCommon.mainViewDarkBoxShadow;
+
+        public static Color AppBackgroundColor => IsLightTheme ? new Color("#FAFAFA") : new Color("#16131A");
+
+        public static Color AlertDialogTextLabelColor => IsLightTheme ? new Color("#090E21") : new Color("#FDFDFD");
+
+        public static Color IncreaseTextLabelColor => IsLightTheme ? new Color("#FDFDFD") : new Color("#16131A");
+
+        public static string SliderThumbURL => IsLightTheme ? "*Resource*/Images/light/thumb_light.png" : "*Resource*/Images/dark/thumb_dark.png";
+
+        public static Color CancelTextColor => IsLightTheme ? new Color("#FF6200") : new Color("#FF8A00");
+
+        public static Color BorderLineColor => IsLightTheme ? new Color("#FF6200") : new Color("#FF8A00");
+    }
+}
diff --git a/VolumeApp/Common/ThemeUtility.cs b/VolumeApp/Common/ThemeUtility.cs
deleted file mode 100644 (file)
index 65ab1b8..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using Tizen.NUI;
-using System.IO;
-using System;
-using Tizen.NUI.Xaml;
-
-namespace VolumeApp.Common
-{
-    class ThemeUtility
-    {
-        private Theme theme;
-
-        private static ThemeUtility instance = null;
-        private ThemeUtility()
-        {
-            ThemeManager.ThemeChanged += OnThemeChanged;
-        }
-
-        public static ThemeUtility GetInstance()
-        {
-            if(instance == null)
-            {
-                instance = new ThemeUtility();
-            }
-            return instance;
-        }
-
-
-        public void UpdateTheme(string platformThemeId)
-        {
-            if (platformThemeId == null)
-            {
-                Tizen.Log.Error(Resources.LogTag, "Platform theme id is null");
-                return;
-            }
-            if (platformThemeId.Equals(Resources.LightPlatformThemeId))
-            {
-                SetTheme(Resources.GetThemePath() + "light.xaml");
-            }
-            else if (platformThemeId.Equals(Resources.DarkPlatformThemeId))
-            {
-                SetTheme(Resources.GetThemePath() + "dark.xaml");
-            }
-        }
-
-        public void Clear()
-        {
-            ThemeManager.ThemeChanged -= OnThemeChanged;
-            theme.Clear();
-            instance = null;
-        }
-        private void SetTheme(string path)
-        {
-            try
-            {
-                theme = new Theme(path);
-                ThemeManager.ApplyTheme(theme);
-            }
-            catch (ArgumentNullException e)
-            {
-                Tizen.Log.Error(Resources.LogTag, "ArgumentNullException: " + e.ParamName);
-            }
-            catch (IOException e)
-            {
-                Tizen.Log.Error(Resources.LogTag, "IOException: " + e.Message);
-            }
-            catch (XamlParseException e)
-            {
-                Tizen.Log.Error(Resources.LogTag, "XamlParseException: " + e.Message);
-                if (e.XmlInfo != null)
-                {
-                    Tizen.Log.Error(Resources.LogTag, "XamlParseException, LineNo." + e.XmlInfo.LineNumber + " Pos: " + e.XmlInfo.LinePosition + " HasInfo: " + e.XmlInfo.HasLineInfo().ToString());
-                }
-            }
-        }
-        private void OnThemeChanged(object sender, ThemeChangedEventArgs e)
-        {
-            if (e.IsPlatformThemeChanged)
-            {
-                Tizen.Log.Info(Resources.LogTag, "Theme Changed: " + e.ThemeId);
-                UpdateTheme(ThemeManager.PlatformThemeId);
-            }
-        }
-    }
-}
index 555d5652fdf9f1bfdf094d58021a9be9d79e8769..6b6040d78c0f8a6805e64e38748dce96df4e5f94 100644 (file)
@@ -28,8 +28,6 @@ namespace VolumeApp.Core
         {
             window = Window.Instance;
 
-            ThemeUtility.GetInstance().UpdateTheme(ThemeManager.PlatformThemeId);
-
             mainView = new MainView();
             window.Add(mainView);
 
@@ -173,8 +171,6 @@ namespace VolumeApp.Core
 
                 window.Remove(mainView);
                 mainView?.Dispose();
-
-                ThemeUtility.GetInstance().Clear();
             }
             base.Dispose(type);
         }
index 0377b775450904a599b20e65bbf6fb6de1994888..b72761d10b2ff280a06110654b1441b958d562f2 100644 (file)
@@ -41,8 +41,6 @@ namespace VolumeApp.Views
         public event Action SafeVolumeLevelPopupRemoved;
         public MainView()
         {
-            StyleName = "MainViewBackground";
-
             WidthSpecification = AppCommon.mainViewWidth;
             HeightSpecification = (ScreenSizeUtils.IsPortrait ? ScreenSizeUtils.Width : ScreenSizeUtils.Height) / 2;
 
@@ -66,7 +64,6 @@ namespace VolumeApp.Views
 
             slider = new Slider()
             {
-                StyleName = "Slider",
                 ThemeChangeSensitive = true,
                 WidthSpecification = AppCommon.sliderWidth,
                 Direction = Slider.DirectionType.Vertical,
@@ -88,11 +85,12 @@ namespace VolumeApp.Views
             RelativeLayout.SetHorizontalAlignment(slider, RelativeLayout.Alignment.Center);
             RelativeLayout.SetFillVertical(slider, true);
 
+            UpdateTheme();
+
             slider.SlidingStarted += OnSlidingStarted;
             slider.ValueChanged += OnSliderValueChanged;
             slider.SlidingFinished += OnSlidingFinished;
-
-            UpdateTheme(ThemeManager.PlatformThemeId);
+            ThemeManager.ThemeChanged += OnThemeChanged;
             AudioManager.VolumeController.Changed += OnAudioVolumeChanged;
         }
 
@@ -220,28 +218,44 @@ namespace VolumeApp.Views
 
         private void AddSafeLevelVolumePopup()
         {
-            cancelButton = new Button("CancelButton")
+            if(cancelButton == null)
             {
-                Name = "CancelButton",
-                ThemeChangeSensitive = true,
-                Size2D = AppCommon.buttonSize,
-            };
-            increaseButton = new Button()
+                cancelButton = new Button()
+                {
+                    Name = "CancelButton",
+                    ThemeChangeSensitive = true,
+                    Size2D = AppCommon.buttonSize,
+                    BorderlineWidth = AppCommon.borderLineWidth,
+                    Text = "Cancel",
+                    BackgroundColor = Color.Transparent,
+                };
+                cancelButton.TextLabel.FontFamily = "BreezeSans";
+                cancelButton.TextLabel.PixelSize = AppCommon.textLabelPixelSize;
+            }
+            if(increaseButton == null)
             {
-                Size2D = AppCommon.buttonSize,
-                Text = "Increase",
-                CornerRadius = AppCommon.buttonCornerRadius,
-            };
+                increaseButton = new Button()
+                {
+                    Size2D = AppCommon.buttonSize,
+                    Text = "Increase",
+                    CornerRadius = AppCommon.buttonCornerRadius,
+                };
+            }
             if (safeVolumeLevelPopup == null)
             {
                 safeVolumeLevelPopup = new AlertDialog()
                 {
                     WidthSpecification = (int)((ScreenSizeUtils.IsPortrait ? ScreenSizeUtils.Height : ScreenSizeUtils.Width) * 0.36f),
-                    StyleName = "AlertDialogBackground",
                     Title = "Increase media volume",
                     Message = "Listening at a high volume for a long time may damage your hearing. The volume will be increased above safe levels.",
                     Actions = new List<Button>() { cancelButton, increaseButton, },
                 };
+                var title = safeVolumeLevelPopup.TitleContent as TextLabel;
+                title.FontFamily = "BreezeSans";
+                title.PixelSize = AppCommon.textLabelPixelSize;
+                var message = safeVolumeLevelPopup.Content as TextLabel;
+                message.FontFamily = "BreezeSans";
+                message.PixelSize = AppCommon.textLabelPixelSize;
             }
             safeVolumeLevelPopup.Content.WidthSpecification = LayoutParamPolicies.MatchParent;
             safeVolumeLevelPopup.ActionContent.WidthSpecification = LayoutParamPolicies.MatchParent;
@@ -249,8 +263,8 @@ namespace VolumeApp.Views
             {
                 cancelButton.SizeWidth = (safeVolumeLevelPopup.WidthSpecification / 2) - 40.SpToPx();
                 increaseButton.SizeWidth = (safeVolumeLevelPopup.WidthSpecification / 2) - 40.SpToPx();
-
             }
+            UpdateAlertPopupTheme();
             Window.Instance.Add(safeVolumeLevelPopup);
             Window.Instance.Raise();
             SafeVolumeLevelPopupAdded?.Invoke();
@@ -259,6 +273,39 @@ namespace VolumeApp.Views
             increaseButton.Clicked += OnIncreaseButtonClicked;
         }
 
+        protected override void OnThemeChanged(object sender, ThemeChangedEventArgs e)
+        {
+            Tizen.Log.Debug(Resources.LogTag, "theme is: " + ThemeManager.PlatformThemeId);
+            UpdateTheme();
+        }
+
+        private void UpdateTheme()
+        {
+            UpdateSliderAndBackground();
+            if (safeVolumeLevelPopup == null)
+            {
+                return;
+            }
+            UpdateAlertPopupTheme();
+        }
+        private void UpdateSliderAndBackground()
+        {
+            BackgroundColor = ThemeColor.AppBackgroundColor;
+            slider.ThumbImageUrl = ThemeColor.SliderThumbURL;
+        }
+
+        private void UpdateAlertPopupTheme()
+        {
+            safeVolumeLevelPopup.BackgroundColor = ThemeColor.AppBackgroundColor;
+            safeVolumeLevelPopup.BoxShadow = ThemeColor.PopupBoxShadow;
+            (safeVolumeLevelPopup.TitleContent as TextLabel).TextColor = ThemeColor.AlertDialogTextLabelColor;
+            (safeVolumeLevelPopup.Content as TextLabel).TextColor = ThemeColor.AlertDialogTextLabelColor;
+            cancelButton.TextLabel.TextColor = ThemeColor.CancelTextColor;
+            cancelButton.BorderlineColor = ThemeColor.BorderLineColor;
+            increaseButton.BackgroundColor = ThemeColor.BorderLineColor;
+            increaseButton.TextLabel.TextColor = ThemeColor.IncreaseTextLabelColor;
+        }
+
         private void UpdateAlertPopUp()
         {
             if (IsAlertPopupShown() == true)
@@ -280,26 +327,6 @@ namespace VolumeApp.Views
             RemoveSafeVolumeLevelPopup();
         }
 
-        private void UpdateTheme(string theme)
-        {
-            if (theme == Resources.LightPlatformThemeId)
-            {
-                BoxShadow = AppCommon.mainViewLightBoxShadow;
-            }
-            else
-            {
-                BoxShadow = AppCommon.mainViewDarkBoxShadow;
-            }
-        }
-
-        protected override void OnThemeChanged(object sender, ThemeChangedEventArgs e)
-        {
-            if (e.IsPlatformThemeChanged)
-            {
-                UpdateTheme(ThemeManager.PlatformThemeId);
-            }
-        }
-
         protected override void Dispose(DisposeTypes type)
         {
             if (Disposed)
@@ -333,6 +360,7 @@ namespace VolumeApp.Views
                 }
 
                 AudioManager.VolumeController.Changed -= OnAudioVolumeChanged;
+                ThemeManager.ThemeChanged -= OnThemeChanged;
             }
             base.Dispose(type);
         }
index 988d53f423568499263210784fe9cf87755daf67..2e048b2d18d33d006b807e4fb66246a7df065e78 100644 (file)
@@ -41,7 +41,7 @@ namespace VolumeApp
         }
         protected override void OnCreate()
         {
-            Tizen.Log.Debug(Resources.LogTag, "On Create called");
+            Tizen.Log.Debug(Resources.LogTag, "On Create called ");
             base.OnCreate();
 
             window = Window.Instance;
index 62c9bc3360800a64e58f5deca80bf569c6dee6b2..3c2c99b41d534167d1da937b9a14ee559bfc4e8e 100644 (file)
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Tizen.NET.Sdk/1.1.9">
 
        <PropertyGroup>
                <OutputType>Exe</OutputType>
@@ -14,7 +14,6 @@
 
     <ItemGroup>
         <PackageReference Include="Tizen.NET" Version="11.0.0.17848" />
-        <PackageReference Include="Tizen.NET.Sdk" Version="1.1.9" />
     </ItemGroup>
 
        <ItemGroup>
          <Folder Include="res\Images\dark\" />
        </ItemGroup>
 
-       <ItemGroup>
-         <None Update="res\themes\dark.xaml">
-           <Generator>MSBuild:Compile</Generator>
-         </None>
-         <None Update="res\themes\light.xaml">
-           <Generator>MSBuild:Compile</Generator>
-         </None>
-       </ItemGroup>
-
 </Project>
diff --git a/VolumeApp/res/Images/dark/button_outline.png b/VolumeApp/res/Images/dark/button_outline.png
deleted file mode 100644 (file)
index 38c2323..0000000
Binary files a/VolumeApp/res/Images/dark/button_outline.png and /dev/null differ
diff --git a/VolumeApp/res/Images/light/button_outline.png b/VolumeApp/res/Images/light/button_outline.png
deleted file mode 100644 (file)
index bbbabcc..0000000
Binary files a/VolumeApp/res/Images/light/button_outline.png and /dev/null differ
diff --git a/VolumeApp/res/themes/dark.xaml b/VolumeApp/res/themes/dark.xaml
deleted file mode 100644 (file)
index 75f559c..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Theme
-xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
-xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
-xmlns:c="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
-Id="DarkTheme">
-
-       <ViewStyle x:Key="MainViewBackground" BackgroundColor="#16131A" ThemeChangeSensitive="true" />
-    <c:AlertDialogStyle x:Key="AlertDialogBackground" ThemeChangeSensitive="true" BackgroundColor="#16131A">
-        <c:AlertDialogStyle.TitleTextLabel>
-            <TextLabelStyle TextColor="#FDFDFD" FontFamily="BreezeSans" PixelSize="24sp" />
-        </c:AlertDialogStyle.TitleTextLabel>
-        <c:AlertDialogStyle.MessageTextLabel>
-            <TextLabelStyle TextColor="#FDFDFD" FontFamily="BreezeSans" PixelSize="24sp" />
-        </c:AlertDialogStyle.MessageTextLabel>
-    </c:AlertDialogStyle>
-    <c:ButtonStyle x:Key="CancelButton" ThemeChangeSensitive="true" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
-        <c:ButtonStyle.BackgroundImage>*Resource*/Images/dark/button_outline.png</c:ButtonStyle.BackgroundImage>
-        <c:ButtonStyle.Text>
-            <TextLabelStyle TextColor="#FF8A00" FontFamily="BreezeSans" PixelSize="24sp" Text="Cancel" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-        </c:ButtonStyle.Text>
-    </c:ButtonStyle>
-    <c:SliderStyle x:Key="Slider" >
-        <c:SliderStyle.Thumb>
-            <ImageViewStyle>
-                <ImageViewStyle.ResourceUrl>
-                    <Selector x:TypeArguments="x:String" Normal="*Resource*/Images/dark/thumb_dark.png" Disabled="*Resource*/Images/dark/thumb_dark.png" />
-                </ImageViewStyle.ResourceUrl>
-            </ImageViewStyle>
-        </c:SliderStyle.Thumb>
-    </c:SliderStyle>
-</Theme>
\ No newline at end of file
diff --git a/VolumeApp/res/themes/light.xaml b/VolumeApp/res/themes/light.xaml
deleted file mode 100644 (file)
index 88a50ab..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<Theme
-xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
-xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
-xmlns:c="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
-Id="LightTheme">
-
-    <ViewStyle x:Key="MainViewBackground" BackgroundColor="#FAFAFA" ThemeChangeSensitive="true" />
-    <c:AlertDialogStyle x:Key="AlertDialogBackground" ThemeChangeSensitive="true" BackgroundColor="#FAFAFA">
-        <c:AlertDialogStyle.TitleTextLabel>
-            <TextLabelStyle TextColor="#090E21" FontFamily="BreezeSans" PixelSize="24sp" />
-        </c:AlertDialogStyle.TitleTextLabel>
-        <c:AlertDialogStyle.MessageTextLabel>
-            <TextLabelStyle TextColor="#090E21" FontFamily="BreezeSans" PixelSize="24sp" />
-        </c:AlertDialogStyle.MessageTextLabel>
-    </c:AlertDialogStyle>
-    <c:ButtonStyle x:Key="CancelButton" ThemeChangeSensitive="true" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
-        <c:ButtonStyle.BackgroundImage>*Resource*/Images/light/button_outline.png</c:ButtonStyle.BackgroundImage>
-        <c:ButtonStyle.Text>
-            <TextLabelStyle TextColor="#FF6200" FontFamily="BreezeSans" PixelSize="24sp" Text="Cancel" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-        </c:ButtonStyle.Text>
-    </c:ButtonStyle>
-    <c:SliderStyle x:Key="Slider" >
-        <c:SliderStyle.Thumb>
-            <ImageViewStyle>
-                <ImageViewStyle.ResourceUrl>
-                    <Selector x:TypeArguments="x:String" Normal="*Resource*/Images/light/thumb_light.png" Disabled="*Resource*/Images/light/thumb_light.png"/>
-                </ImageViewStyle.ResourceUrl>
-            </ImageViewStyle>
-        </c:SliderStyle.Thumb>
-    </c:SliderStyle>
-</Theme>
\ No newline at end of file
index 02b860a55f1a815ab85d634251f7f05d8681e1fe..db9726aa6b27104617de2070fd28ab73a92ab1f1 100644 (file)
Binary files a/packaging/org.tizen.volume-nui-1.0.0.tpk and b/packaging/org.tizen.volume-nui-1.0.0.tpk differ