2 * Copyright(c) 2021 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.ComponentModel;
19 using Tizen.NUI.Binding;
21 namespace Tizen.NUI.Components
24 /// PageAppearingEventArgs is a class to record <see cref="Page.Appearing"/> event arguments which will be sent to user.
26 /// <since_tizen> 9 </since_tizen>
27 public class PageAppearingEventArgs : EventArgs
32 /// PageDisappearingEventArgs is a class to record <see cref="Page.Disappearing"/> event arguments which will be sent to user.
34 /// <since_tizen> 9 </since_tizen>
35 public class PageDisappearingEventArgs : EventArgs
40 /// PageAppearedEventArgs is a class to record <see cref="Page.Appeared"/> event arguments which will be sent to user.
42 /// <since_tizen> 9 </since_tizen>
43 public class PageAppearedEventArgs : EventArgs
48 /// PageDisappearedEventArgs is a class to record <see cref="Page.Disappeared"/> event arguments which will be sent to user.
50 /// <since_tizen> 9 </since_tizen>
51 public class PageDisappearedEventArgs : EventArgs
56 /// The Page class is a class which is an element of navigation.
58 /// <since_tizen> 9 </since_tizen>
59 public abstract class Page : Control
62 /// AppearingTransitionProperty
64 [EditorBrowsable(EditorBrowsableState.Never)]
65 public static readonly BindableProperty AppearingTransitionProperty = BindableProperty.Create(nameof(AppearingTransition), typeof(TransitionBase), typeof(Page), null, propertyChanged: (bindable, oldValue, newValue) =>
67 var instance = (Page)bindable;
70 instance.InternalAppearingTransition = newValue as TransitionBase;
73 defaultValueCreator: (bindable) =>
75 var instance = (Page)bindable;
76 return instance.InternalAppearingTransition;
80 /// DisappearingTransitionProperty
82 [EditorBrowsable(EditorBrowsableState.Never)]
83 public static readonly BindableProperty DisappearingTransitionProperty = BindableProperty.Create(nameof(DisappearingTransition), typeof(TransitionBase), typeof(Page), null, propertyChanged: (bindable, oldValue, newValue) =>
85 var instance = (Page)bindable;
88 instance.InternalDisappearingTransition = newValue as TransitionBase;
91 defaultValueCreator: (bindable) =>
93 var instance = (Page)bindable;
94 return instance.InternalDisappearingTransition;
98 [EditorBrowsable(EditorBrowsableState.Never)]
99 protected internal BaseComponents.View LastFocusedView = null;
101 private Navigator navigator = null;
103 // Default transition is Fade.
104 private TransitionBase appearingTransition = null;
106 private TransitionBase disappearingTransition = null;
109 /// Creates a new instance of a Page.
111 /// <since_tizen> 9 </since_tizen>
112 public Page() : base()
117 /// Creates a new instance of a Page with style.
119 /// <param name="style">A style applied to the newly created Page.</param>
120 [EditorBrowsable(EditorBrowsableState.Never)]
121 public Page(ControlStyle style) : base(style)
126 /// Navigator which has pushed the Page into its stack.
127 /// If this Page has not been pushed into any Navigator, then Navigator is null.
129 /// <since_tizen> 9 </since_tizen>
130 public Navigator Navigator
138 if (navigator == value)
148 /// Transition properties for the transition of Views in this page during this page is pushed to Navigator.
150 [EditorBrowsable(EditorBrowsableState.Never)]
151 public TransitionBase AppearingTransition
155 return GetValue(AppearingTransitionProperty) as TransitionBase;
159 SetValue(AppearingTransitionProperty, value);
160 NotifyPropertyChanged();
163 private TransitionBase InternalAppearingTransition
167 appearingTransition = value;
171 return appearingTransition;
176 /// Transition properties for the transition of Views in this page during this page is popped from Navigator.
178 [EditorBrowsable(EditorBrowsableState.Never)]
179 public TransitionBase DisappearingTransition
183 return GetValue(DisappearingTransitionProperty) as TransitionBase;
187 SetValue(DisappearingTransitionProperty, value);
188 NotifyPropertyChanged();
191 private TransitionBase InternalDisappearingTransition
195 disappearingTransition = value;
199 return disappearingTransition;
204 /// Appearing event is invoked right before the page appears.
206 /// <since_tizen> 9 </since_tizen>
207 public event EventHandler<PageAppearingEventArgs> Appearing;
210 /// Disappearing event is invoked right before the page disappears.
212 /// <since_tizen> 9 </since_tizen>
213 public event EventHandler<PageDisappearingEventArgs> Disappearing;
216 /// Appeared event is invoked right after the page appears.
218 /// <since_tizen> 9 </since_tizen>
219 public event EventHandler<PageAppearedEventArgs> Appeared;
222 /// Disappeared event is invoked right after the page disappears.
224 /// <since_tizen> 9 </since_tizen>
225 public event EventHandler<PageDisappearedEventArgs> Disappeared;
227 internal void InvokeAppearing()
229 Appearing?.Invoke(this, new PageAppearingEventArgs());
232 internal void InvokeDisappearing()
234 Disappearing?.Invoke(this, new PageDisappearingEventArgs());
237 internal void InvokeAppeared()
239 Appeared?.Invoke(this, new PageAppearedEventArgs());
242 internal void InvokeDisappeared()
244 Disappeared?.Invoke(this, new PageDisappearedEventArgs());
248 /// works only when DefaultAlgorithm is enabled.
249 /// to save the currently focused View when disappeared.
251 [EditorBrowsable(EditorBrowsableState.Never)]
252 protected internal virtual void SaveKeyFocus()
254 if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
256 if (this is DialogPage)
258 FocusManager.Instance.ResetFocusFinderRootView();
261 var currentFocusedView = FocusManager.Instance.GetCurrentFocusView();
262 if (currentFocusedView)
264 var findChild = FindDescendantByID(currentFocusedView.ID);
267 LastFocusedView = findChild;
271 LastFocusedView = null;
276 /// works only when DefaultAlgorithm is enabled.
277 /// to set key focused View when showing.
279 [EditorBrowsable(EditorBrowsableState.Never)]
280 protected internal virtual void RestoreKeyFocus()
282 if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
286 FocusManager.Instance.SetCurrentFocusView(LastFocusedView);
290 var temp = new Tizen.NUI.BaseComponents.View()
292 Size = new Size(0.1f, 0.1f, 0.0f),
293 Position = new Position(0, 0, 0),
297 temp.LowerToBottom();
298 FocusManager.Instance.SetCurrentFocusView(temp);
299 var focused = FocusManager.Instance.GetNearestFocusableActor(this, temp, Tizen.NUI.BaseComponents.View.FocusDirection.Down);
302 FocusManager.Instance.SetCurrentFocusView(focused);
306 FocusManager.Instance.ClearFocus();
312 if (this is DialogPage)
314 FocusManager.Instance.SetFocusFinderRootView(this);