--- /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.
+ *
+ */
+using System.ComponentModel;
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI.Components
+{
+ /// <summary>
+ /// The ContentPage class is a class which is a formatted full screen page.
+ /// ContentPage contains title app bar and content.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class ContentPage : Page
+ {
+ private AppBar appBar = null;
+ private View content = null;
+
+ /// <summary>
+ /// Creates a new instance of a ContentPage.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ContentPage() : base()
+ {
+ // AppBar and Content are located vertically.
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ };
+
+ // ContentPage fills to parent by default.
+ WidthResizePolicy = ResizePolicyType.FillToParent;
+ HeightResizePolicy = ResizePolicyType.FillToParent;
+ }
+
+ /// <summary>
+ /// Dispose ContentPage and all children on it.
+ /// </summary>
+ /// <param name="type">Dispose type.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ if (type == DisposeTypes.Explicit)
+ {
+ if (appBar != null)
+ {
+ Utility.Dispose(appBar);
+ }
+
+ if (content != null)
+ {
+ Utility.Dispose(content);
+ }
+ }
+
+ base.Dispose(type);
+ }
+
+ /// <summary>
+ /// AppBar of ContentPage. AppBar is added to Children automatically.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public AppBar AppBar
+ {
+ get
+ {
+ return appBar;
+ }
+ set
+ {
+ if (appBar == value)
+ {
+ return;
+ }
+
+ if (appBar != null)
+ {
+ Remove(appBar);
+ }
+
+ appBar = value;
+ if (appBar == null)
+ {
+ return;
+ }
+
+ appBar.Weight = 0.0f;
+
+ ResetContent();
+ }
+ }
+
+ /// <summary>
+ /// Content of ContentPage. Content is added to Children automatically.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public View Content
+ {
+ get
+ {
+ return content;
+ }
+ set
+ {
+ if (content == value)
+ {
+ return;
+ }
+
+ if (content != null)
+ {
+ Remove(content);
+ }
+
+ content = value;
+ if (content == null)
+ {
+ return;
+ }
+
+ content.Weight = 1.0f;
+
+ ResetContent();
+ }
+ }
+
+ private void ResetContent()
+ {
+ // To keep the order of AppBar and Content, the existing contents are
+ // removed and added again.
+ if ((appBar != null) && Children.Contains(appBar))
+ {
+ Remove(appBar);
+ }
+
+ if ((content != null) && Children.Contains(content))
+ {
+ Remove(content);
+ }
+
+ if (appBar != null)
+ {
+ Add(appBar);
+ }
+
+ if (content != null)
+ {
+ Add(content);
+ }
+ }
+ }
+}
NavigationPages.Add(page);
Add(page);
+ page.Navigator = this;
//Invoke Page events
page.InvokeAppearing();
NavigationPages.Insert(index, page);
Add(page);
+ page.Navigator = this;
}
/// <summary>
throw new ArgumentNullException(nameof(page), "page should not be null.");
}
+ page.Navigator = null;
NavigationPages.Remove(page);
base.Remove(page);
}
var dialog = new Dialog(content);
SetDialogScrim(dialog);
- var dialogPage = new Page(dialog);
+ // FIXME: Needs to use DialogPage.
+ var dialogPage = new ContentPage()
+ {
+ Content = dialog,
+ };
defaultNavigator.Push(dialogPage);
}
var dialog = new AlertDialog(titleContent, content, actionContent);
SetDialogScrim(dialog);
- var dialogPage = new Page(dialog);
+ // FIXME: Needs to use DialogPage.
+ var dialogPage = new ContentPage()
+ {
+ Content = dialog,
+ };
defaultNavigator.Push(dialogPage);
}
var dialog = new AlertDialog(title, message, positiveButtonText, positiveButtonClickedHandler, negativeButtonText, negativeButtonClickedHandler);
SetDialogScrim(dialog);
- var dialogPage = new Page(dialog);
+ // FIXME: Needs to use DialogPage.
+ var dialogPage = new ContentPage()
+ {
+ Content = dialog,
+ };
defaultNavigator.Push(dialogPage);
}
*/
using System;
using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
namespace Tizen.NUI.Components
{
/// The Page class is a class which is an element of navigation.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class Page : Control
+ public abstract class Page : Control
{
- private AppBar appBar = null;
- private View content = null;
+ private Navigator navigator = null;
/// <summary>
/// Creates a new instance of a Page.
/// </summary>
- /// <param name="content">The content to set to Content of Page.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public Page(View content = null) : this(null, content)
+ public Page() : base()
{
}
/// <summary>
- /// Creates a new instance of a Page.
- /// </summary>
- /// <param name="appBar">The content to set to AppBar of Page.</param>
- /// <param name="content">The content to set to Content of Page.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Page(AppBar appBar, View content = null) : base()
- {
- //AppBar and Content are located vertically.
- var linearLayout = new LinearLayout();
- linearLayout.LinearOrientation = LinearLayout.Orientation.Vertical;
- Layout = linearLayout;
-
- //Page fills to parent by default.
- WidthResizePolicy = ResizePolicyType.FillToParent;
- HeightResizePolicy = ResizePolicyType.FillToParent;
-
- if (appBar)
- {
- AppBar = appBar;
- }
-
- if (content)
- {
- Content = content;
- }
- }
-
- /// <summary>
- /// Dispose Page and all children on it.
- /// </summary>
- /// <param name="type">Dispose type.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- if (appBar != null)
- {
- Utility.Dispose(appBar);
- }
-
- if (content != null)
- {
- Utility.Dispose(content);
- }
- }
-
- base.Dispose(type);
- }
-
- /// <summary>
- /// AppBar of Page. AppBar is added to Children automatically.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public AppBar AppBar
- {
- get
- {
- return appBar;
- }
- set
- {
- if (appBar == value)
- {
- return;
- }
-
- if (appBar != null)
- {
- Remove(appBar);
- }
-
- appBar = value;
- if (appBar == null)
- {
- return;
- }
-
- appBar.Weight = 0.0f;
-
- ResetContent();
- }
- }
-
- /// <summary>
- /// Content of Page. Content is added to Children automatically.
+ /// Navigator which has pushed the Page into its stack.
+ /// If this Page has not been pushed into any Navigator, then Navigator is null.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public View Content
+ public Navigator Navigator
{
get
{
- return content;
+ return navigator;
}
- set
+ internal set
{
- if (content == value)
- {
- return;
- }
-
- if (content != null)
- {
- Remove(content);
- }
-
- content = value;
- if (content == null)
+ if (navigator == value)
{
return;
}
- content.Weight = 1.0f;
-
- ResetContent();
- }
- }
-
- private void ResetContent()
- {
- //To keep the order of AppBar and Content, the existing contents are
- //removed and added again.
- if ((appBar != null) && Children.Contains(appBar))
- {
- Remove(appBar);
- }
-
- if ((content != null) && Children.Contains(content))
- {
- Remove(content);
- }
-
- if (appBar != null)
- {
- Add(appBar);
- }
-
- if (content != null)
- {
- Add(content);
+ navigator = value;
}
}
"No", (object sender2, ClickedEventArgs e2) => { window.GetDefaultNavigator().Pop(); });
};
- window.GetDefaultNavigator().Push(new Page(button));
+ var dialogPage = new ContentPage()
+ {
+ Content = button,
+ };
+ window.GetDefaultNavigator().Push(dialogPage);
}
public void Deactivate()
{
public class AppBarSample : IExample
{
- private Page firstPage, secondPage;
+ private ContentPage firstPage, secondPage;
private AppBar firstAppBar, secondAppBar;
private Button firstActionButton, secondActionButton;
private Button firstButton, secondButton;
CreateSecondPage();
};
- firstPage = new Page(firstAppBar, firstButton);
+ firstPage = new ContentPage()
+ {
+ AppBar = firstAppBar,
+ Content = firstButton,
+ };
NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(firstPage);
}
NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
};
- secondPage = new Page(secondAppBar, secondButton);
+ secondPage = new ContentPage()
+ {
+ AppBar = secondAppBar,
+ Content = secondButton,
+ };
NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(secondPage);
}
Navigator.ShowDialog(textLabel);
};
- window.GetDefaultNavigator().Push(new Page(button));
+ var dialogPage = new ContentPage()
+ {
+ Content = button,
+ };
+ window.GetDefaultNavigator().Push(dialogPage);
}
public void Deactivate()
public class NavigatorSample : IExample
{
private Navigator navigator;
- private Page firstPage, secondPage;
+ private ContentPage firstPage, secondPage;
private Button firstButton, secondButton;
public void Activate()
CreateSecondPage();
};
- firstPage = new Page(firstButton);
+ firstPage = new ContentPage()
+ {
+ Content = firstButton,
+ };
firstPage.Appearing += (object sender, PageAppearingEventArgs e) =>
{
global::System.Console.WriteLine("First Page is appearing!");
navigator.Pop();
};
- secondPage = new Page(secondButton);
+ secondPage = new ContentPage()
+ {
+ Content = secondButton,
+ };
secondPage.Appearing += (object sender, PageAppearingEventArgs e) =>
{
global::System.Console.WriteLine("Second Page is appearing!");