}
NUIApplication.GetDefaultWindow().GetDefaultNavigator().EnableBackNavigation = true;
};
-
- NUIApplication.GetDefaultWindow().KeyEvent += GadgetNavigation_KeyEvent;
}
public static void SetFullScreenMode(bool fullScreen)
public static void NavigateTo(string menuPath)
{
- semaphore.Wait();
-
- var info = GadgetManager.Instance.GetGadgetInfoFromPath(menuPath);
- if (info == null)
+ try
{
- Logger.Warn($"could not find gadget for menupath: {menuPath}");
- semaphore.Release();
- return;
- }
+ semaphore.Wait();
- if (gadgetPages.Values.Select(x => x.ClassName).Contains(info.ClassName))
- {
- Logger.Verbose($"Already navigated to menupath: {menuPath}");
- semaphore.Release();
- return;
- }
+ var info = GadgetManager.Instance.GetGadgetInfoFromPath(menuPath);
+ if (info == null)
+ {
+ Logger.Warn($"could not find gadget for menupath: {menuPath}");
+ return;
+ }
- try
- {
- var gadget = NUIGadgetManager.Add(info.Pkg.ResourceType, info.ClassName) as MenuGadget;
+ if (gadgetPages.Values.Select(x => x.ClassName).Contains(info.ClassName))
+ {
+ Logger.Verbose($"Already navigated to menupath: {menuPath}");
+ return;
+ }
+ var gadget = NUIGadgetManager.Add(info.Pkg.ResourceType, info.ClassName) as MenuGadget;
var title = gadget.ProvideTitle();
var content = gadget.MainView;
+ if (info.IsFullScreenMode)
+ {
+ SetFullScreenMode(true);
+
+ var contentPage = new ContentPage
+ {
+ CornerRadius = 0.SpToPx(),
+ Content = content,
+ ThemeChangeSensitive = true,
+ };
+
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().PushWithTransition(contentPage);
+ gadgetPages.Add(contentPage, gadget);
+ return;
+ }
+
// TODO: remove style customization with scalable unit, when merged to TizenFX
var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar") as AppBarStyle;
appBarStyle.TitleTextLabel.PixelSize = 24f.SpToPx();
- var backButton = new Views.BackButton();
+ var backButton = new BackButton();
+ backButton.Margin = new Extents(0, 8, 0, 0).SpToPx();
backButton.Clicked += (s, e) => NavigateBack();
var moreItems = new List<View>();
moreItems.Add(moreButton);
}
- if (info.IsFullScreenMode)
- {
- SetFullScreenMode(true);
-
- var contentPage = new ContentPage
- {
- CornerRadius = 0.SpToPx(),
- Content = content,
- ThemeChangeSensitive = true,
- };
-
- NUIApplication.GetDefaultWindow().GetDefaultNavigator().PushWithTransition(contentPage);
- gadgetPages.Add(contentPage, gadget);
- }
- else
+ var page = new BaseContentPage
{
- backButton.Margin = new Extents(0, 8, 0, 0).SpToPx();
-
- var page = new BaseContentPage
+ // TODO: CornerRadius depends on SettingViewBorder.CornerRadius - SettingViewBorder.BorderLineThickness, which is defined at SettingView project.
+ CornerRadius = (26.0f - 6.0f).SpToPx(),
+ ClippingMode = ClippingModeType.ClipChildren,
+ AppBar = new AppBar(appBarStyle)
{
- // TODO: CornerRadius depends on SettingViewBorder.CornerRadius - SettingViewBorder.BorderLineThickness, which is defined at SettingView project.
- CornerRadius = (26.0f - 6.0f).SpToPx(),
- ClippingMode = ClippingModeType.ClipChildren,
- AppBar = new AppBar(appBarStyle)
- {
- Size = new Size(-1, 64).SpToPx(),
- Title = title,
- NavigationContent = backButton,
- ThemeChangeSensitive = true,
- },
- Content = content,
+ Size = new Size(-1, 64).SpToPx(),
+ Title = title,
+ NavigationContent = backButton,
ThemeChangeSensitive = true,
- };
-
- page.AppBar.Actions = moreItems;
+ Actions = moreItems,
+ },
+ Content = content,
+ ThemeChangeSensitive = true,
+ };
- NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(page);
- gadgetPages.Add(page, gadget);
- }
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(page);
+ gadgetPages.Add(page, gadget);
}
- catch (System.Exception e) // TODO: add separate catch blocks for specific exceptions?
+ catch (Exception e)
{
Logger.Error($"could not create gadget for menu path: {menuPath} => {e}");
}
-
- semaphore.Release();
+ finally
+ {
+ semaphore.Release();
+ }
}
private static Button GetMoreButton(IEnumerable<MoreMenuItem> moreMenu)
return moreButton;
}
-
- private static void GadgetNavigation_KeyEvent(object sender, Window.KeyEventArgs e)
- {
- if (NUIApplication.GetDefaultWindow().GetDefaultNavigator().ChildCount == 1)
- {
- return;
- }
-
- if (e.Key.State == Key.StateType.Down && e.Key.KeyPressedName == "XF86Back")
- {
- NUIApplication.GetDefaultWindow().GetDefaultNavigator().EnableBackNavigation = false;
- }
- else if (e.Key.State == Key.StateType.Up && e.Key.KeyPressedName == "XF86Back")
- {
- NavigateBack();
- }
- else
- {
- NUIApplication.GetDefaultWindow().GetDefaultNavigator().EnableBackNavigation = true;
- }
- }
}
}