{
static class AppConstants
{
+
+ private static bool IsLightTheme => ThemeManager.PlatformThemeId == LightPlatformThemeId;
+
public const string LogTag = "Notifications";
public const string LightPlatformThemeId = "org.tizen.default-light-theme";
public const string DarkPlatformThemeId = "org.tizen.default-dark-theme";
- public static Color LightBorderColor = new Color(0.9804f, 0.9804f, 0.9804f, 0.35f);
- public static Color DarkBorderColor = new Color(0.0863f, 0.0745f, 0.0980f, 0.50f);
+ public static Color BaseViewBackgroundColor => IsLightTheme ? new Color("#FAFAFA") : new Color("#16131A");
+ public static Color BorderBackgroundColor => IsLightTheme ? new Color("rgba(250, 250, 250, 0.35)") : new Color("rgba(22, 19, 25, 0.5)");
+ public static Color NotificationsTextColor => IsLightTheme ? new Color("#090E21") : new Color("#FDFDFD");
+ public static Color DisabledButtonTextColor => IsLightTheme ? new Color("#CACACA") : new Color("#666666");
+ public static Color NormalButtonTextColor => IsLightTheme ? new Color("#FF6200") : new Color("#FF8A00");
+ public static Color PressedButtonTextColor => IsLightTheme ? new Color("#FFA166") : new Color("#CC6E00");
+
+ public static string BackButtonIconUrl => Resources.GetImagePath() + (IsLightTheme ? "light" : "dark") + "/back.png";
+ public static string ClearBinIconUrl => Resources.GetImagePath() + (IsLightTheme ? "light" : "dark") + "/clear.png";
public static Size2D DefaultWindowSize = new Size2D(960, 540);
+ public static Size2D BackButtonSize = new Size2D(48, 48);
+ public static Size2D ClearBinSize = new Size2D(32, 32);
+ public static Size2D ClearAllButtonSize = new Size2D(150, 48);
public static Position2D DefaultWindowPosition = new Position2D(480, 170);
public const int BorderHeight = 52;
public const int HeaderHeight = 64;
public const int NotificationItemHeight = 80;
-
- public static Vector4 BorderCornerRadius = new Vector4(24, 24, 24, 24);
- public static Vector4 BaseViewCornerRadius = new Vector4(24, 24, 24, 24);
+ public const int BorderCornerRadius = 24;
+ public const int BaseViewCornerRadius = 24;
+ public const int TextPixelSize = 24;
public static Extents BaseViewPadding = new Extents(0, 0, 20, 20);
public static Extents HeaderPadding = new Extents(16, 16, 8, 8);
+++ /dev/null
-using System.Globalization;
-using System.Reflection;
-using System.Resources;
-
-namespace Notifications.Common
-{
- public class MultiResourceManager : ResourceManager
- {
- public MultiResourceManager(string baseName, Assembly assembly)
- : base(baseName, assembly)
- {
- }
-
- public override string GetString(string name)
- {
- return base.GetString(name)
- ?? TextResources.Resources.ResourceManager.GetString(name);
- }
-
- public override string GetString(string name, CultureInfo culture)
- {
- return base.GetString(name, culture)
- ?? TextResources.Resources.ResourceManager.GetString(name, culture);
- }
- }
-}
{
if (borderView != null)
{
- borderView.BackgroundColor = ThemeManager.PlatformThemeId == AppConstants.LightPlatformThemeId ? AppConstants.LightBorderColor : AppConstants.DarkBorderColor;
+ borderView.BackgroundColor = AppConstants.BorderBackgroundColor;
}
}
}
this.borderView = borderView;
ThemeManager.ThemeChanged += OnThemeChanged;
- borderView.BackgroundColor = ThemeManager.PlatformThemeId == AppConstants.LightPlatformThemeId ? AppConstants.LightBorderColor : AppConstants.DarkBorderColor;
+ borderView.BackgroundColor = AppConstants.BorderBackgroundColor;
}
public override void OnCreated(View borderView)
{
base.OnCreated(borderView);
}
-
+
public override bool CreateBottomBorderView(View bottomView)
{
if (bottomView == null)
}
base.OnResized(width, height);
- borderView.BackgroundColor = ThemeManager.PlatformThemeId == AppConstants.LightPlatformThemeId ? AppConstants.LightBorderColor : AppConstants.DarkBorderColor;
+ borderView.BackgroundColor = AppConstants.BorderBackgroundColor;
UpdateIcons();
}
using System;
using System.Collections.Generic;
using System.Globalization;
-using Tizen.Applications;
using Tizen.NUI;
using Notifications.Common;
-using Tizen.NUI.BaseComponents;
-
namespace Notifications
{
class Program : NUIApplication
}
catch (Exception e)
{
- Tizen.Log.Debug(AppConstants.LogTag, "Setting Language failed" + e.Message);
+ Tizen.Log.Error(AppConstants.LogTag, "Setting Language failed" + e.Message);
}
}
- MultilingualResourceManager = new MultiResourceManager("Notifications.TextResources.Resources", typeof(Resources).Assembly);
+ MultilingualResourceManager = TextResources.Resources.ResourceManager;
Tizen.System.SystemSettings.LocaleLanguageChanged += (s, e) => SetLanguage();
SetLanguage();
}
- protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
- {
- base.OnAppControlReceived(e);
- Tizen.Log.Info(AppConstants.LogTag, "AppControl Received");
- }
protected override void OnTerminate()
{
- Tizen.Log.Info(AppConstants.LogTag, "On App Terminate");
viewManager.Dispose();
base.OnTerminate();
}
</EmbeddedResource>
</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>
*/
using System;
-using System.IO;
using Tizen.Applications.NotificationEventListener;
using Tizen.NUI;
-using Tizen.NUI.Xaml;
using Notifications.Common;
using Notifications.ViewModels;
using Notifications.Views;
{
notificationsViewModel = new NotificationsViewModel();
notificationsViewModel.NotificationSelected += OnNotificationSelected;
- UpdateTheme(ThemeManager.PlatformThemeId);
+
baseView = new BaseView();
baseView.BindingContext = notificationsViewModel;
baseView.BackKeyPressed += OnBackKeyPressed;
+
Window.Instance.Add(baseView);
Window.Instance.Resized += OnWindowResized;
baseView.BindingContext = null;
baseView.BackKeyPressed -= OnBackKeyPressed;
baseView.Dispose();
+ baseView = null;
}
private void OnThemeChanged(object sender, ThemeChangedEventArgs e)
if (e.IsPlatformThemeChanged)
{
Tizen.Log.Info(AppConstants.LogTag, "Theme Changed: " + e.ThemeId);
- UpdateTheme(e.PlatformThemeId);
+ baseView.UpdateTheme();
}
}
baseView.BindingContext = notificationsViewModel;
baseView.UpdateContent();
}
-
- private void SetTheme(string path)
- {
- try
- {
- Theme theme = new Theme(path);
- ThemeManager.ApplyTheme(theme);
- }
- catch (ArgumentNullException e)
- {
- Tizen.Log.Error(AppConstants.LogTag, "ArgumentNullException: " + e.ParamName);
- }
- catch (IOException e)
- {
- Tizen.Log.Error(AppConstants.LogTag, "IOException: " + e.Message);
- }
- catch (XamlParseException e)
- {
- Tizen.Log.Error(AppConstants.LogTag, "XamlParseException: " + e.Message);
- if (e.XmlInfo != null)
- {
- Tizen.Log.Error(AppConstants.LogTag, "XamlParseException, LineNo." + e.XmlInfo.LineNumber + " Pos: " + e.XmlInfo.LinePosition + " HasInfo: " + e.XmlInfo.HasLineInfo().ToString());
- }
- }
- }
- private void UpdateTheme(string platformThemeId)
- {
- if (platformThemeId == null)
- {
- Tizen.Log.Error(AppConstants.LogTag, "Platform theme id is null");
- return;
- }
- if (platformThemeId.Equals(AppConstants.LightPlatformThemeId))
- {
- SetTheme(Resources.GetThemePath() + "light.xaml");
- }
- else if (platformThemeId.Equals(AppConstants.DarkPlatformThemeId))
- {
- SetTheme(Resources.GetThemePath() + "dark.xaml");
- }
- }
}
}
public BaseView() : base()
{
- StyleName = "BaseView";
+ ThemeChangeSensitive = true;
Size2D = Window.Instance.Size;
CornerRadius = AppConstants.BaseViewCornerRadius;
Layout = new LinearLayout()
{
AddNoNotificationsText();
}
+ UpdateTheme();
}
public void AddDetailContentView()
RemoveContent();
if (detailContentView == null)
{
- detailContentView = new Button()
+ ButtonStyle buttonStyle = new ButtonStyle()
+ {
+ BackgroundColor = Color.Transparent,
+ Text = new TextLabelStyle()
+ {
+ BackgroundColor = Color.Transparent,
+ MultiLine = true,
+ FontFamily = "BreezeSans",
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ },
+ Margin = AppConstants.DetailContentMargin.SpToPx(),
+ IsEnabled = true,
+ IsSelectable = false,
+ };
+ detailContentView = new Button(buttonStyle)
{
- StyleName = "DetailContentView",
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = LayoutParamPolicies.WrapContent,
- Margin = AppConstants.DetailContentMargin.SpToPx(),
};
detailContentView.SetBinding(Button.TextProperty, "DetailContent");
detailContentView.SetBinding(Control.CommandProperty, "AppLaunchCommand");
UpdateNotificationsViewItemTemplate();
}
+ public void UpdateTheme()
+ {
+ BackgroundColor = AppConstants.BaseViewBackgroundColor;
+ if (detailContentView != null)
+ {
+ detailContentView.TextColor = AppConstants.NotificationsTextColor;
+ }
+ backButton.Icon.ResourceUrl = AppConstants.BackButtonIconUrl;
+ titleText.TextColor = AppConstants.NotificationsTextColor;
+ if (noNotificationsText != null)
+ {
+ noNotificationsText.TextColor = AppConstants.NotificationsTextColor;
+ }
+ if (clearAllButton != null)
+ {
+ clearAllButton.TextColorSelector = new ColorSelector()
+ {
+ Normal = AppConstants.NormalButtonTextColor,
+ Pressed = AppConstants.PressedButtonTextColor,
+ Disabled = AppConstants.DisabledButtonTextColor,
+ };
+ }
+ }
+
public bool BackKeyEventEmitted()
{
if (detailContentView != null && detailContentView.GetParent() == this)
{
topView = new View()
{
+ ThemeChangeSensitive = true,
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = AppConstants.HeaderHeight.SpToPx(),
Layout = new RelativeLayout()
private void AddTopViewElements()
{
- backButton = new Button("BackButton");
+ ButtonStyle buttonStyle = new ButtonStyle()
+ {
+ BackgroundColor = Color.Transparent,
+ Size = AppConstants.BackButtonSize.SpToPx(),
+ Icon = new ImageViewStyle()
+ {
+ BackgroundColor = Color.Transparent,
+ Size = AppConstants.BackButtonSize.SpToPx(),
+ },
+ IsEnabled = true,
+ IsSelectable = false,
+ };
+ backButton = new Button(buttonStyle);
RelativeLayout.SetVerticalAlignment(backButton, RelativeLayout.Alignment.Center);
RelativeLayout.SetHorizontalAlignment(backButton, RelativeLayout.Alignment.Start);
backButton.SetBinding(Control.CommandProperty, "BackCommand");
titleText = new TextLabel()
{
- StyleName = "TitleText",
+ ThemeChangeSensitive = true,
TranslatableText = "IDS_ST_HEADER_NOTIFICATIONS",
HeightSpecification = LayoutParamPolicies.MatchParent,
VerticalAlignment = VerticalAlignment.Center,
+ PixelSize = AppConstants.TextPixelSize.SpToPx(),
+ FontFamily = "BreezeSans",
};
RelativeLayout.SetLeftTarget(titleText, backButton);
RelativeLayout.SetLeftRelativeOffset(titleText, 1.0f);
notificationsView.SizeWidth = Window.Instance.Size.Width;
notificationsView.ItemTemplate = new DataTemplate(() =>
{
- DefaultLinearItem item = new DefaultLinearItem();
- item.WidthSpecification = LayoutParamPolicies.MatchParent;
- item.HeightSpecification = AppConstants.NotificationItemHeight.SpToPx();
- item.Label.StyleName = "TitleText";
+ ItemLayout item = new ItemLayout();
item.Label.SetBinding(TextLabel.TextProperty, "Title");
- item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
- item.Label.VerticalAlignment = VerticalAlignment.Bottom;
- item.SubLabel.StyleName = "TitleText";
item.SubLabel.SetBinding(TextLabel.TextProperty, "SubTitle");
- item.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
- item.SubLabel.VerticalAlignment = VerticalAlignment.Top;
- item.Extra = new Button("ClearButton");
item.Extra.SetBinding(Control.CommandProperty, "ClearNotificationCommand");
return item;
});
{
if (clearAllButton == null)
{
- clearAllButton = new Button("ClearAllButton");
- clearAllButton.TextLabel.TranslatableText = "IDS_ST_BUTTON_CLEAR_ALL";
+ ButtonStyle buttonStyle = new ButtonStyle()
+ {
+ Size = AppConstants.ClearAllButtonSize.SpToPx(),
+ BackgroundColor = Color.Transparent,
+ Text = new TextLabelStyle()
+ {
+ BackgroundColor = Color.Transparent,
+ TranslatableText = "IDS_ST_BUTTON_CLEAR_ALL",
+ FontFamily = "BreezeSans",
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ },
+ };
+ clearAllButton = new Button(buttonStyle);
+
RelativeLayout.SetVerticalAlignment(clearAllButton, RelativeLayout.Alignment.Center);
RelativeLayout.SetHorizontalAlignment(clearAllButton, RelativeLayout.Alignment.End);
clearAllButton.SetBinding(Control.CommandProperty, "ClearAllNotificationsCommand");
{
noNotificationsText = new TextLabel()
{
- StyleName = "TitleText",
TranslatableText = "IDS_ST_BODY_NO_NOTIFICATIONS_MSG",
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = LayoutParamPolicies.MatchParent,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
+ FontFamily = "BreezeSans",
+ PixelSize = AppConstants.TextPixelSize.SpToPx(),
};
}
Add(noNotificationsText);
}
-
-
private bool isContentAvailable;
public bool IsContentAvailable
{
--- /dev/null
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using Notifications.Common;
+
+namespace Notifications.Views
+{
+ class ItemLayout : DefaultLinearItem
+ {
+ public ItemLayout() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = AppConstants.NotificationItemHeight.SpToPx();
+
+ Label.HorizontalAlignment = HorizontalAlignment.Begin;
+ Label.VerticalAlignment = VerticalAlignment.Bottom;
+ Label.FontFamily = "BreezeSans";
+ Label.PixelSize = AppConstants.TextPixelSize.SpToPx();
+
+ SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
+ SubLabel.VerticalAlignment = VerticalAlignment.Top;
+ SubLabel.FontFamily = "BreezeSans";
+ SubLabel.PixelSize = AppConstants.TextPixelSize.SpToPx();
+
+ ButtonStyle buttonStyle = new ButtonStyle()
+ {
+ Size = AppConstants.ClearBinSize.SpToPx(),
+ BackgroundColor = Color.Transparent,
+ Icon = new ImageViewStyle()
+ {
+ BackgroundColor = Color.Transparent,
+ Size = AppConstants.ClearBinSize.SpToPx(),
+ },
+ IsEnabled = true,
+ IsSelectable = false,
+ };
+ Extra = new Button(buttonStyle);
+
+ UpdateTheme();
+ ThemeManager.ThemeChanged += OnItemThemeChanged;
+ }
+
+ private void OnItemThemeChanged(object sender, ThemeChangedEventArgs e)
+ {
+ UpdateTheme();
+ }
+
+ private void UpdateTheme()
+ {
+ Label.TextColor = AppConstants.NotificationsTextColor;
+ SubLabel.TextColor = AppConstants.NotificationsTextColor;
+ ((Button)Extra).IconURL = AppConstants.ClearBinIconUrl;
+ }
+
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (Disposed)
+ {
+ return;
+ }
+ if (type == DisposeTypes.Explicit)
+ {
+ ThemeManager.ThemeChanged -= OnItemThemeChanged;
+ }
+ Tizen.Log.Info(AppConstants.LogTag, "Dispose ItemLayout");
+ base.Dispose(type);
+ }
+ }
+}
+++ /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="BaseView" ThemeChangeSensitive="true" BackgroundColor="#16131A" />
-
- <TextLabelStyle x:Key="TitleText" ThemeChangeSensitive="true" FontFamily="BreezeSans" TextColor="#FDFDFD" PixelSize="24sp" />
-
- <c:ButtonStyle x:Key="BackButton" ThemeChangeSensitive="true" Size="48sp, 48sp" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
- <c:ButtonStyle.Icon>
- <ImageViewStyle Size="48sp, 48sp">
- <ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/dark/back.png" />
- </ImageViewStyle.ResourceUrl>
- </ImageViewStyle>
- </c:ButtonStyle.Icon>
- </c:ButtonStyle>
-
- <c:ButtonStyle x:Key="ClearButton" ThemeChangeSensitive="true" Size="32sp, 32sp" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
- <c:ButtonStyle.Icon>
- <ImageViewStyle Size="32sp, 32sp">
- <ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/dark/clear.png" />
- </ImageViewStyle.ResourceUrl>
- </ImageViewStyle>
- </c:ButtonStyle.Icon>
- </c:ButtonStyle>
-
- <c:ButtonStyle x:Key="ClearAllButton" ThemeChangeSensitive="true" Size="150sp, 48sp" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
- <c:ButtonStyle.Text>
- <TextLabelStyle FontFamily="BreezeSans" TextColor="#FF8A00" VerticalAlignment="Center" HorizontalAlignment="Center"/>
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
-
- <c:ButtonStyle x:Key="DetailContentView" ThemeChangeSensitive="true" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
- <c:ButtonStyle.Text>
- <TextLabelStyle FontFamily="BreezeSans" TextColor="#FDFDFD" HorizontalAlignment="Begin" MultiLine="true" />
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
-
-</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="BaseView" ThemeChangeSensitive="true" BackgroundColor="#FAFAFA" />
-
- <TextLabelStyle x:Key="TitleText" ThemeChangeSensitive="true" FontFamily="BreezeSans" TextColor="#090E21" PixelSize="24sp" />
-
- <c:ButtonStyle x:Key="BackButton" ThemeChangeSensitive="true" Size="48sp, 48sp" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
- <c:ButtonStyle.Icon>
- <ImageViewStyle Size="48sp, 48sp">
- <ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/light/back.png" />
- </ImageViewStyle.ResourceUrl>
- </ImageViewStyle>
- </c:ButtonStyle.Icon>
- </c:ButtonStyle>
-
- <c:ButtonStyle x:Key="ClearButton" ThemeChangeSensitive="true" Size="32sp, 32sp" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
- <c:ButtonStyle.Icon>
- <ImageViewStyle Size="32sp, 32sp">
- <ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="*Resource*/images/light/clear.png" />
- </ImageViewStyle.ResourceUrl>
- </ImageViewStyle>
- </c:ButtonStyle.Icon>
- </c:ButtonStyle>
-
- <c:ButtonStyle x:Key="ClearAllButton" ThemeChangeSensitive="true" Size="150sp, 48sp" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
- <c:ButtonStyle.Text>
- <TextLabelStyle FontFamily="BreezeSans" TextColor="#FF6200" VerticalAlignment="Center" HorizontalAlignment="Center"/>
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
-
- <c:ButtonStyle x:Key="DetailContentView" ThemeChangeSensitive="true" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >
- <c:ButtonStyle.Text>
- <TextLabelStyle FontFamily="BreezeSans" TextColor="#090E21" HorizontalAlignment="Begin" MultiLine="true" />
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
-
-</Theme>
\ No newline at end of file