2 * Copyright(c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
19 using System.ComponentModel;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Binding;
22 using System.Windows.Input;
24 namespace Tizen.NUI.Components
27 /// PageAppearingEventArgs is a class to record page appearing event arguments which will be sent to user.
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public class PageAppearingEventArgs : EventArgs
35 /// PageDisappearingEventArgs is a class to record page disappearing event arguments which will be sent to user.
37 [EditorBrowsable(EditorBrowsableState.Never)]
38 public class PageDisappearingEventArgs : EventArgs
43 /// The Page class is a class which is an element of navigation.
45 [EditorBrowsable(EditorBrowsableState.Never)]
46 public class Page : Control
48 private AppBar _appBar = null;
49 private View _content = null;
52 /// Creates a new instance of a Page.
54 /// <param name="content">The content to set to Content of Page.</param>
55 [EditorBrowsable(EditorBrowsableState.Never)]
56 public Page(View content = null) : this(null, content)
61 /// Creates a new instance of a Page.
63 /// <param name="appBar">The content to set to AppBar of Page.</param>
64 /// <param name="content">The content to set to Content of Page.</param>
65 [EditorBrowsable(EditorBrowsableState.Never)]
66 public Page(AppBar appBar, View content = null) : base()
68 //AppBar and Content are located verically.
69 var linearLayout = new LinearLayout();
70 linearLayout.LinearOrientation = LinearLayout.Orientation.Vertical;
71 Layout = linearLayout;
73 //Page fills to parent by default.
74 WidthResizePolicy = ResizePolicyType.FillToParent;
75 HeightResizePolicy = ResizePolicyType.FillToParent;
89 /// Dispose Page and all children on it.
91 /// <param name="type">Dispose type.</param>
92 [EditorBrowsable(EditorBrowsableState.Never)]
93 protected override void Dispose(DisposeTypes type)
100 if (type == DisposeTypes.Explicit)
104 Utility.Dispose(_appBar);
107 if (_content != null)
109 Utility.Dispose(_content);
117 /// AppBar of Page. AppBar is added to Children automatically.
119 [EditorBrowsable(EditorBrowsableState.Never)]
128 if (_appBar == value)
144 _appBar.Weight = 0.0f;
151 /// Content of Page. Content is added to Children automatically.
153 [EditorBrowsable(EditorBrowsableState.Never)]
162 if (_content == value)
167 if (_content != null)
173 if (_content == null)
178 _content.Weight = 1.0f;
184 private void ResetContent()
186 //To keep the order of AppBar and Content, the existing contents are
187 //removed and added again.
188 if ((_appBar != null) && Children.Contains(_appBar))
193 if ((_content != null) && Children.Contains(_content))
203 if (_content != null)
210 /// An event for the page appearing signal which can be used to subscribe or unsubscribe the event handler provided by the user.
212 [EditorBrowsable(EditorBrowsableState.Never)]
213 public event EventHandler<PageAppearingEventArgs> Appearing;
216 /// An event for the page disappearing signal which can be used to subscribe or unsubscribe the event handler provided by the user.
218 [EditorBrowsable(EditorBrowsableState.Never)]
219 public event EventHandler<PageDisappearingEventArgs> Disappearing;
221 internal void InvokeAppearing()
223 Appearing?.Invoke(this, new PageAppearingEventArgs());
226 internal void InvokeDisappearing()
228 Disappearing?.Invoke(this, new PageDisappearingEventArgs());