예제 #1
0
        public void Activate()
        {
            themeLoader = new ThemeLoader();

            var mainPage = new ContentPage()
            {
                ThemeChangeSensitive = true,
                AppBar = new AppBar()
                {
                    AutoNavigationContent = false,
                    Title = "NUI theme sample",
                    //Actions = new View[] { closeButton },
                },
                Content = new ScrollableBase()
                {
                    Layout = new LinearLayout()
                    {
                        LinearOrientation = LinearLayout.Orientation.Vertical,
                        CellPadding       = new Size2D(20, 20)
                    },
                    WidthResizePolicy  = ResizePolicyType.FillToParent,
                    HeightResizePolicy = ResizePolicyType.FillToParent,
                    Padding            = new Extents(30, 30, 20, 20)
                }
            };

            string[] ids = (string[])themeLoader.QueryIds();
            if (ids != null && ids.Contains("org.tizen.default-dark-theme") || ids.Contains("org.tizen.default-light-theme"))
            {
                var title = $"Current theme: {(themeLoader.CurrentTheme.Id == "org.tizen.default-dark-theme" ? "Dark" : "Light")}";

                mainPage.Content.Add(CreateClickableItem("Theme change", title, delegate(View view)
                {
                    TextLabel text = view.Children[1] as TextLabel;

                    if (themeLoader.CurrentTheme.Id == "org.tizen.default-dark-theme")
                    {
                        var theme = themeLoader.LoadTheme("org.tizen.default-light-theme");
                        Tizen.Log.Info("test", $"Id: {theme.Id}, Version: {theme.Version}");
                        themeLoader.CurrentTheme = theme;
                        text.Text = "Current theme: Light";
                    }
                    else
                    {
                        var theme = themeLoader.LoadTheme("org.tizen.default-dark-theme");
                        Tizen.Log.Info("test", $"Id: {theme.Id}, Version: {theme.Version}");
                        themeLoader.CurrentTheme = theme;
                        text.Text = "Current theme: Dark";
                    }
                }));

                mainPage.Content.Add(CreateItem("Switch", CreateSwitchExample()));
            }
            else
            {
                mainPage.AppBar.Title = "No proper theme is found!";
            }

            NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(mainPage);
        }