/*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
public string Id { get; set; }
/// <summary>
+ /// The string key to identify the Theme.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string Version { get; set; } = null;
+
+ /// <summary>
/// For Xaml use only.
/// The bulit-in theme id that will be used as base of this.
/// View styles with same key are merged.
if (string.IsNullOrEmpty(baseTheme)) return;
- var baseThemeInstance = ThemeManager.GetBuiltinTheme(baseTheme);
+ var baseThemeInstance = (Theme)ThemeManager.GetBuiltinTheme(baseTheme)?.Clone();
if (baseThemeInstance != null)
{
internal int Count => map.Count;
+ internal int PackageCount { get; set; } = 0;
+
/// <summary>
/// Get an enumerator of the theme.
/// </summary>
/// <param name="styleName">The string key to find a ViewStyle.</param>
/// <returns>Founded style instance.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
- public ViewStyle GetStyle(string styleName) => map.ContainsKey(styleName) ? map[styleName] : null;
+ public ViewStyle GetStyle(string styleName)
+ {
+ map.TryGetValue(styleName, out ViewStyle result);
+ return result;
+ }
/// <summary>
/// Gets a style of given view type.
if (theme == null)
throw new ArgumentNullException(nameof(theme));
- if (Id == null) Id = theme.Id;
+ if (Id == null)
+ {
+ Id = theme.Id;
+ }
+
+ if (Version == null)
+ {
+ Version = theme.Version;
+ }
foreach (var item in theme)
{
/// </summary>
internal void AddStyleWithoutClone(string styleName, ViewStyle value) => map[styleName] = value;
+ internal void ApplyExternalTheme(IExternalTheme externalTheme, HashSet<ExternalThemeKeyList> keyListSet)
+ {
+ Id = externalTheme.Id;
+ Version = externalTheme.Version;
+
+ if (keyListSet == null)
+ {
+ // Nothing to apply
+ return;
+ }
+
+ foreach (var keyList in keyListSet)
+ {
+ keyList?.ApplyKeyActions(externalTheme, this);
+ }
+ }
+
+ internal bool HasSameIdAndVersion(IExternalTheme externalTheme)
+ {
+ if (externalTheme == null)
+ {
+ return false;
+ }
+
+ return string.Equals(Id, externalTheme.Id, StringComparison.OrdinalIgnoreCase) && string.Equals(Version, externalTheme.Version, StringComparison.OrdinalIgnoreCase);
+ }
+
internal void SetChangedResources(IEnumerable<KeyValuePair<string, string>> changedResources)
{
this.changedResources = changedResources;