+++ /dev/null
-/*
- * 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.
- * 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.
- *
- */
-#if PROFILE_TV
-using System.Collections.Generic;
-
-namespace Tizen.NUI
-{
- internal partial class DefaultThemeCreator
- {
- public Theme Create()
- {
- Tizen.Log.Info("NUI", $"PROFILE_TV DefaultThemeCreator.Create()");
-
- Theme theme = new Theme()
- {
- Id = DefaultId,
- Version = DefaultVersion,
- };
- return theme;
- }
- }
-}
-#endif
* limitations under the License.
*
*/
-
-#if !PROFILE_TV
-#define ExternalThemeEnabled
-#endif
-
using System;
using System.Collections.Generic;
using System.ComponentModel;
static ThemeManager()
{
-#if ExternalThemeEnabled
+ if (InitialThemeDisabled) return;
+
ExternalThemeManager.Initialize();
AddPackageTheme(DefaultThemeCreator.Instance);
-#endif
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static string PlatformThemeId
{
- get => platformTheme?.Id ?? (platformThemeEnabled ? baseTheme.Id : null);
+ get => platformTheme?.Id ?? (platformThemeEnabled ? baseTheme?.Id : null);
}
/// <summary>
/// </summary>
internal static Theme BaseTheme
{
- get => baseTheme;
+ get
+ {
+ if (baseTheme == null)
+ {
+ baseTheme = new Theme();
+ UpdateThemeForInitialize();
+ }
+ return baseTheme;
+ }
set
{
baseTheme = value;
internal static bool ApplicationThemeChangeSensitive { get; set; } = false;
+#if PROFILE_TV
+ internal const bool InitialThemeDisabled = true;
+#else
+ internal const bool InitialThemeDisabled = false;
+#endif
+
/// <summary>
/// Apply custom theme to the NUI.
/// This will change the appearance of the existing components with property <seealso cref="View.ThemeChangeSensitive"/> on.
/// <param name="version">The external theme version.</param>
internal static void ApplyExternalPlatformTheme(string id, string version)
{
-#if ExternalThemeEnabled
- Debug.Assert(baseTheme != null);
+ if (InitialThemeDisabled) return;
// If the given theme is invalid, do nothing.
if (string.IsNullOrEmpty(id))
}
// If no platform theme has been applied and the base theme can cover the given one, do nothing.
- if (platformTheme == null && baseTheme.HasSameIdAndVersion(id, version))
+ if (platformTheme == null && baseTheme != null && baseTheme.HasSameIdAndVersion(id, version))
{
Tizen.Log.Info("NUI", "The base theme can cover platform theme: Skip loading.");
return;
UpdateThemeForUpdate();
NotifyThemeChanged(true);
}
-#endif
}
internal static void AddPackageTheme(IThemeCreator themeCreator)
{
-#if PROFILE_TV
- // for tv profile, set empty theme and just return here!
- userTheme = null;
- baseTheme = themeCreator.Create();
- return;
-#endif
- if (packages.Contains(themeCreator))
+ if (InitialThemeDisabled || packages.Contains(themeCreator))
{
return;
}
- Tizen.Log.Info("NUI", $"AddPackageTheme({themeCreator.GetType().Assembly.GetName().Name})");
+ Tizen.Log.Debug("NUI", $"AddPackageTheme({themeCreator.GetType().Assembly.GetName().Name})");
packages.Add(themeCreator);
// Base theme
else baseTheme.MergeWithoutClone(packageBaseTheme);
baseTheme.PackageCount++;
-#if ExternalThemeEnabled
if (platformThemeEnabled)
{
Tizen.Log.Info("NUI", $"Platform theme is enabled");
}
UpdateThemeForUpdate();
}
-#endif
UpdateThemeForInitialize();
}
internal static void Preload()
{
-#if ExternalThemeEnabled
- Debug.Assert(baseTheme != null);
+ if (InitialThemeDisabled) return;
if (string.IsNullOrEmpty(ExternalThemeManager.CurrentThemeId)) return;
LoadPlatformTheme(ExternalThemeManager.CurrentThemeId);
-#endif
}
// TODO Please make it private after removing Tizen.NUI.Components.StyleManager.
}
themeForInitialize = new Theme();
- themeForInitialize.Merge(baseTheme);
+
+ if (baseTheme != null) themeForInitialize.Merge(baseTheme);
if (userTheme == null)
{
private static void NotifyThemeChanged(bool platformThemeUpdated = false)
{
- Debug.Assert(baseTheme != null);
-
var platformThemeId = PlatformThemeId;
var userThemeId = userTheme?.Id;
ThemeChangedInternal.Invoke(null, new ThemeChangedEventArgs(userThemeId, platformThemeId, platformThemeUpdated));