int widgetWidth = window.Size.Width;
int widgetHeight = window.Size.Height;
+ Navigator navigator = window.GetDefaultNavigator();
+
Bundle bundle = new Bundle();
bundle.AddItem(" ", " ");
String encodedBundle = bundle.Encode();
// Add Widget of "secondPage@NUISettingsReset" in advance to avoid loading pending.
AddWidget(out secondPageWidgetView, "secondPage@NUISettingsReset", encodedBundle, widgetWidth, widgetHeight, 0.0f);
- Navigator navigator = window.GetDefaultNavigator();
+ // Add Widget of "thirdPage@NUISettingsReset" in advance to avoid loading pending.
+ AddWidget(out thirdPageWidgetView, "thirdPage@NUISettingsReset", encodedBundle, widgetWidth, widgetHeight, 0.0f);
- var button = new Button()
+ // Add Widget of "fourthPage@NUISettingsReset" in advance to avoid loading pending.
+ AddWidget(out fourthPageWidgetView, "fourthPage@NUISettingsReset", encodedBundle, widgetWidth, widgetHeight, 0.0f);
+
+ var content = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ CellPadding = new Size2D(0, 20),
+ },
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ var secondPageButton = new Button()
{
Text = "Click to Second Page",
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = LayoutParamPolicies.MatchParent,
};
- button.Clicked += (o, e) =>
+ secondPageButton.Clicked += (o, e) =>
{
- var page = new ContentPage();
- page.Content = secondPageWidgetView;
+ var page = new ContentPage()
+ {
+ Content = secondPageWidgetView,
+ };
navigator.Push(page);
};
+ content.Add(secondPageButton);
+
+ var thirdPageButton = new Button()
+ {
+ Text = "Click to Third Page",
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+ thirdPageButton.Clicked += (o, e) =>
+ {
+ var page = new ContentPage()
+ {
+ Content = thirdPageWidgetView,
+ };
+ navigator.Push(page);
+ };
+ content.Add(thirdPageButton);
+
+ var fourthPageButton = new Button()
+ {
+ Text = "Click to Fourth Page",
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+ fourthPageButton.Clicked += (o, e) =>
+ {
+ var page = new DialogPage()
+ {
+ Content = fourthPageWidgetView,
+ EnableScrim = false, // fourthPageWidgetView's DialogPage.Scrim is used, so this DialogPage.Scrim should not be used.
+ };
+ navigator.Push(page);
+ };
+ content.Add(fourthPageButton);
// Push the first page.
- PushContentPage("First Page", button);
+ PushContentPage("First Page", content);
}
void AddWidget(out WidgetView widgetView, string widgetID, string contentInfo, int width, int height, float updatePeriod)
Window window = GetDefaultWindow();
Navigator navigator = window.GetDefaultNavigator();
- window.KeyEvent += OnKeyEvent;
- window.TouchEvent += OnTouchEvent;
-
var page = new ContentPage()
{
AppBar = new AppBar()
namespace WidgetTemplate
{
- class SecondPage : Widget
+ class SecondPage : ContentPage
+ {
+ public SecondPage(Window window) : base()
+ {
+ if (window == null)
+ {
+ throw new ArgumentNullException(nameof(window), "window should not be null.");
+ }
+
+ var appBar = new AppBar()
+ {
+ Title = "Second Page",
+ };
+
+ AppBar = appBar;
+
+ var button = new Button()
+ {
+ Text = "Click to Third Page",
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+ button.Clicked += (o, e) =>
+ {
+ window.GetDefaultNavigator().Push(new ThirdPage(window));
+ };
+
+ Content = button;
+ }
+ }
+
+ class SecondPageWidget : Widget
{
protected override void OnCreate(string contentInfo, Window window)
{
window.BackgroundColor = Color.Transparent;
- // Update Widget Content by sending message to add the third page in advance.
- Bundle nextBundle = new Bundle();
- nextBundle.AddItem("WIDGET_ID", "thirdPage@NUISettingsReset");
- nextBundle.AddItem("WIDGET_ACTION", "ADD");
- nextBundle.AddItem("WIDGET_WIDTH", window.Size.Width.ToString());
- nextBundle.AddItem("WIDGET_HEIGHT", window.Size.Height.ToString());
- String encodedBundle = nextBundle.Encode();
- SetContentInfo(encodedBundle);
+ var secondPage = new SecondPage(window);
var appBar = new AppBar()
{
- Title = "Second Page",
+ Title = secondPage.AppBar.Title,
AutoNavigationContent = false,
};
+ // Since this is Widget, bundle with "POP" message should be sent to make the main app pops this.
var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
var navigationContent = new Button(((AppBarStyle)appBarStyle).BackButton);
navigationContent.Clicked += (o, e) =>
{
- // Update Widget Content by sending message to pop the second page.
- Bundle nextBundle2 = new Bundle();
- nextBundle2.AddItem("WIDGET_ACTION", "POP");
- String encodedBundle2 = nextBundle2.Encode();
- SetContentInfo(encodedBundle2);
+ // Update Widget Content by sending message to pop the current page.
+ Bundle nextBundle = new Bundle();
+ nextBundle.AddItem("WIDGET_ACTION", "POP");
+ String encodedBundle = nextBundle.Encode();
+ SetContentInfo(encodedBundle);
};
+ appBar.AutoNavigationContent = false;
appBar.NavigationContent = navigationContent;
- var page = new ContentPage()
- {
- AppBar = appBar,
- };
-
- var button = new Button()
- {
- Text = "Click to Third Page",
- WidthSpecification = LayoutParamPolicies.MatchParent,
- HeightSpecification = LayoutParamPolicies.MatchParent,
- };
- button.Clicked += (o, e) =>
- {
- // Update Widget Content by sending message to push the third page.
- Bundle nextBundle2 = new Bundle();
- nextBundle2.AddItem("WIDGET_ID", "thirdPage@NUISettingsReset");
- nextBundle2.AddItem("WIDGET_PAGE", "CONTENT_PAGE");
- nextBundle2.AddItem("WIDGET_ACTION", "PUSH");
- String encodedBundle2 = nextBundle2.Encode();
- SetContentInfo(encodedBundle2);
- };
+ secondPage.AppBar = appBar;
- page.Content = button;
- window.Add(page);
+ window.GetDefaultNavigator().Push(secondPage);
}
protected override void OnPause()
}
}
- class ThirdPage : Widget
+ class ThirdPage : ContentPage
+ {
+ public ThirdPage(Window window) : base()
+ {
+ if (window == null)
+ {
+ throw new ArgumentNullException(nameof(window), "window should not be null.");
+ }
+
+ var appBar = new AppBar()
+ {
+ Title = "Third Page",
+ };
+ AppBar = appBar;
+
+ var button = new Button()
+ {
+ Text = "Click to Fourth Page",
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+ button.Clicked += (o, e) =>
+ {
+ window.GetDefaultNavigator().Push(new FourthPage(window));
+ };
+
+ Content = button;
+ }
+ }
+
+ class ThirdPageWidget : Widget
{
protected override void OnCreate(string contentInfo, Window window)
{
window.BackgroundColor = Color.Transparent;
- // Update Widget Content by sending message to add the fourth page in advance.
- Bundle nextBundle = new Bundle();
- nextBundle.AddItem("WIDGET_ID", "fourthPage@NUISettingsReset");
- nextBundle.AddItem("WIDGET_WIDTH", window.Size.Width.ToString());
- nextBundle.AddItem("WIDGET_HEIGHT", window.Size.Height.ToString());
- nextBundle.AddItem("WIDGET_ACTION", "ADD");
- String encodedBundle = nextBundle.Encode();
- SetContentInfo(encodedBundle);
+ var thirdPage = new ThirdPage(window);
var appBar = new AppBar()
{
- Title = "Third Page",
+ Title = thirdPage.AppBar.Title,
AutoNavigationContent = false,
};
+ // Since this is Widget, bundle with "POP" message should be sent to make the main app pops this.
var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
var navigationContent = new Button(((AppBarStyle)appBarStyle).BackButton);
navigationContent.Clicked += (o, e) =>
{
- // Update Widget Content by sending message to pop the third page.
- Bundle nextBundle2 = new Bundle();
- nextBundle2.AddItem("WIDGET_ACTION", "POP");
- String encodedBundle2 = nextBundle2.Encode();
- SetContentInfo(encodedBundle2);
+ // Update Widget Content by sending message to pop the current page.
+ Bundle nextBundle = new Bundle();
+ nextBundle.AddItem("WIDGET_ACTION", "POP");
+ String encodedBundle = nextBundle.Encode();
+ SetContentInfo(encodedBundle);
};
+ appBar.AutoNavigationContent = false;
appBar.NavigationContent = navigationContent;
- var page = new ContentPage()
- {
- AppBar = appBar,
- };
+ thirdPage.AppBar = appBar;
- var button = new Button()
- {
- Text = "Click to Fourth Page",
- WidthSpecification = LayoutParamPolicies.MatchParent,
- HeightSpecification = LayoutParamPolicies.MatchParent,
- };
- button.Clicked += (o, e) =>
- {
- // Update Widget Content by sending message to push the fourth page.
- Bundle nextBundle2 = new Bundle();
- nextBundle2.AddItem("WIDGET_ID", "fourthPage@NUISettingsReset");
- nextBundle2.AddItem("WIDGET_PAGE", "DIALOG_PAGE");
- nextBundle2.AddItem("WIDGET_ACTION", "PUSH");
- String encodedBundle2 = nextBundle2.Encode();
- SetContentInfo(encodedBundle2);
- };
-
- page.Content = button;
- window.Add(page);
+ window.GetDefaultNavigator().Push(thirdPage);
}
protected override void OnPause()
}
}
- class FourthPage : Widget
+ class FourthPage : DialogPage
+ {
+ public FourthPage(Window window) : base()
+ {
+ if (window == null)
+ {
+ throw new ArgumentNullException(nameof(window), "window should not be null.");
+ }
+
+ var button = new Button()
+ {
+ Text = "OK",
+ };
+ button.Clicked += (o, e) =>
+ {
+ window.GetDefaultNavigator().Pop();
+ };
+
+ var dialog = new AlertDialog()
+ {
+ Title = "Fourth Page",
+ Message = "Message",
+ Actions = new View[] { button },
+ };
+
+ Content = dialog;
+ }
+ }
+
+ class WidgetDialogPage : DialogPage
+ {
+ public WidgetDialogPage(Window window) : base()
+ {
+ if (window == null)
+ {
+ throw new ArgumentNullException(nameof(window), "window should not be null.");
+ }
+
+ // Default Scrim calls navigator.Pop() when the Scrim is touched.
+ // To pop widget page when the Scrim is touched, bundle with "POP" message should be sent to make the main app pops this.
+ Scrim = CreateScrim(window);
+ }
+
+ public EventHandler<TouchEventArgs> ScrimTouchEvent;
+
+ private View CreateScrim(Window window)
+ {
+ if (window == null)
+ {
+ throw new ArgumentNullException(nameof(window), "window should not be null.");
+ }
+
+ var scrimStyle = ThemeManager.GetStyle("Tizen.NUI.Components.DialogPage.Scrim");
+ var scrim = new VisualView(scrimStyle);
+ scrim.Size = window.Size;
+ scrim.TouchEvent += (object source, TouchEventArgs e) =>
+ {
+ if ((EnableDismissOnScrim == true) && (e.Touch.GetState(0) == PointStateType.Up))
+ {
+ // Default Scrim calls navigator.Pop() when the Scrim is touched.
+ // To pop widget page when the Scrim is touched, bundle with "POP" message should be sent to make the main app pops this.
+ ScrimTouchEvent?.Invoke(source, e);
+ }
+ return true;
+ };
+
+ return scrim;
+ }
+ }
+
+ class FourthPageWidget : Widget
{
protected override void OnCreate(string contentInfo, Window window)
{
window.BackgroundColor = Color.Transparent;
+ var fourthPage = new WidgetDialogPage(window);
+
var button = new Button()
{
Text = "OK",
};
button.Clicked += (o, e) =>
{
- // Update Widget Content by sending message to pop the fourth page.
- Bundle nextBundle2 = new Bundle();
- nextBundle2.AddItem("WIDGET_ACTION", "POP");
- String encodedBundle2 = nextBundle2.Encode();
- SetContentInfo(encodedBundle2);
+ // Update Widget Content by sending message to pop the current page.
+ Bundle nextBundle = new Bundle();
+ nextBundle.AddItem("WIDGET_ACTION", "POP");
+ String encodedBundle = nextBundle.Encode();
+ SetContentInfo(encodedBundle);
};
var dialog = new AlertDialog()
Actions = new View[] { button },
};
- window.Add(dialog);
+ fourthPage.Content = dialog;
+
+ // Default Scrim calls navigator.Pop() when the Scrim is touched.
+ // To pop widget page when the Scrim is touched, bundle with "POP" message should be sent to make the main app pops this.
+ fourthPage.ScrimTouchEvent += (o, e) =>
+ {
+ // Update Widget Content by sending message to pop the current page.
+ Bundle nextBundle = new Bundle();
+ nextBundle.AddItem("WIDGET_ACTION", "POP");
+ String encodedBundle = nextBundle.Encode();
+ SetContentInfo(encodedBundle);
+ };
+
+ window.GetDefaultNavigator().Push(fourthPage);
}
protected override void OnPause()
static void Main(string[] args)
{
Dictionary<System.Type, string> widgetSet = new Dictionary<Type, string>();
- widgetSet.Add(typeof(SecondPage), "secondPage@NUISettingsReset");
- widgetSet.Add(typeof(ThirdPage), "thirdPage@NUISettingsReset");
- widgetSet.Add(typeof(FourthPage), "fourthPage@NUISettingsReset");
+ widgetSet.Add(typeof(SecondPageWidget), "secondPage@NUISettingsReset");
+ widgetSet.Add(typeof(ThirdPageWidget), "thirdPage@NUISettingsReset");
+ widgetSet.Add(typeof(FourthPageWidget), "fourthPage@NUISettingsReset");
var app = new Program(widgetSet);
app.Run(args);
}