{
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();
--- /dev/null
+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");
+ }
+}
+++ /dev/null
-/*
- * 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);
- }
- }
- }
-}
{
window = Window.Instance;
- ThemeUtility.GetInstance().UpdateTheme(ThemeManager.PlatformThemeId);
-
mainView = new MainView();
window.Add(mainView);
window.Remove(mainView);
mainView?.Dispose();
-
- ThemeUtility.GetInstance().Clear();
}
base.Dispose(type);
}
public event Action SafeVolumeLevelPopupRemoved;
public MainView()
{
- StyleName = "MainViewBackground";
-
WidthSpecification = AppCommon.mainViewWidth;
HeightSpecification = (ScreenSizeUtils.IsPortrait ? ScreenSizeUtils.Width : ScreenSizeUtils.Height) / 2;
slider = new Slider()
{
- StyleName = "Slider",
ThemeChangeSensitive = true,
WidthSpecification = AppCommon.sliderWidth,
Direction = Slider.DirectionType.Vertical,
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;
}
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;
{
cancelButton.SizeWidth = (safeVolumeLevelPopup.WidthSpecification / 2) - 40.SpToPx();
increaseButton.SizeWidth = (safeVolumeLevelPopup.WidthSpecification / 2) - 40.SpToPx();
-
}
+ UpdateAlertPopupTheme();
Window.Instance.Add(safeVolumeLevelPopup);
Window.Instance.Raise();
SafeVolumeLevelPopupAdded?.Invoke();
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)
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)
}
AudioManager.VolumeController.Changed -= OnAudioVolumeChanged;
+ ThemeManager.ThemeChanged -= OnThemeChanged;
}
base.Dispose(type);
}
}
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;
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Tizen.NET.Sdk/1.1.9">
<PropertyGroup>
<OutputType>Exe</OutputType>
<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>
+++ /dev/null
-<?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
+++ /dev/null
-<?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