Defer creating main view appbar.
authorPiotr Czaja <p.czaja@samsung.com>
Mon, 30 Oct 2023 15:24:45 +0000 (16:24 +0100)
committerPiotr Czaja/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <p.czaja@samsung.com>
Wed, 8 Nov 2023 13:11:03 +0000 (14:11 +0100)
Change-Id: I2d06711c4df6ec361587a20fce1990732e28b5bc

SettingView/SettingView.cs

index 86e9253ca2518897400c81a85ea84cca18d7e7a0..5cbe59c0afeadec4f919d1bca78fe11ac90b6ccc 100644 (file)
@@ -42,12 +42,7 @@ namespace SettingView
         {
             base.OnCreate();
 
-            mMainPage = new BaseContentPage()
-            {
-                CornerRadius = (SettingViewBorder.WindowCornerRadius - SettingViewBorder.WindowPadding).SpToPx(),
-                ThemeChangeSensitive = true,
-                AppBar = CreateAppBar(),
-            };
+            mMainPage = CreateMainPage();
 
             bool initilized = GadgetManager.Instance.Init();
             mMainPage.Content = initilized ? CreateContent() : GetTextNotice("Failed to initialize GadgetManager.\nPlease check error logs for more information.", Color.Red);
@@ -93,10 +88,21 @@ namespace SettingView
             GetDefaultWindow().AddAvailableOrientation(Window.WindowOrientation.PortraitInverse);
             GetDefaultWindow().AddAvailableOrientation(Window.WindowOrientation.LandscapeInverse);
 
-
             LogScalableInfo();
         }
 
+        private ContentPage CreateMainPage()
+        {
+            var mainPage = new BaseContentPage()
+            {
+                CornerRadius = (SettingViewBorder.WindowCornerRadius - SettingViewBorder.WindowPadding).SpToPx(),
+                ThemeChangeSensitive = true,
+            };
+
+            CreateAppBar(mainPage);
+            return mainPage;
+        }
+
         private void OnWindowOrientationChangedEvent(object sender, WindowOrientationChangedEventArgs e)
         {
             Window.WindowOrientation orientation = e.WindowOrientation;
@@ -201,22 +207,29 @@ namespace SettingView
             }
         }
 
-        private static AppBar CreateAppBar()
+        private static System.Threading.Tasks.Task CreateAppBar(BaseContentPage mainPage)
         {
-            // TODO: remove style customization with scalable unit, when merged to TizenFX
-            var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar") as AppBarStyle;
-            appBarStyle.TitleTextLabel.PixelSize = 24.SpToPx();
-
-            AppBar appBar = new AppBar(appBarStyle)
+            return System.Threading.Tasks.Task.Run(async () =>
             {
-                Size = new Size(-1, 64).SpToPx(),
-                Padding = new Extents(16, 16, 0, 0).SpToPx(),
-                Title = Resources.IDS_ST_OPT_SETTINGS,
-                AutoNavigationContent = false,
-                NavigationContent = new View(), // FIXME: must be set with empty View to hide default back button
-                ThemeChangeSensitive = true,
-            };
-            return appBar;
+                await Post(() =>
+                {
+                    // TODO: remove style customization with scalable unit, when merged to TizenFX
+                    var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar") as AppBarStyle;
+                    appBarStyle.TitleTextLabel.PixelSize = 24.SpToPx();
+
+                    AppBar appBar = new AppBar(appBarStyle)
+                    {
+                        Size = new Size(-1, 64).SpToPx(),
+                        Padding = new Extents(16, 16, 0, 0).SpToPx(),
+                        Title = Resources.IDS_ST_OPT_SETTINGS,
+                        AutoNavigationContent = false,
+                        NavigationContent = new View(), // FIXME: must be set with empty View to hide default back button
+                        ThemeChangeSensitive = true,
+                    };
+                    mainPage.AppBar = appBar;
+                    return true;
+                });
+            });
         }
 
         private static View CreateContent()