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 /// Navigator which has pushed the Page into its stack.
118 /// If this Page has not been pushed into any Navigator, then Navigator is null.
120 /// <since_tizen> 9 </since_tizen>
121 public Navigator Navigator
129 if (navigator == value)
139 /// Transition properties for the transition of Views in this page during this page is pushed to Navigator.
141 [EditorBrowsable(EditorBrowsableState.Never)]
142 public TransitionBase AppearingTransition
146 return GetValue(AppearingTransitionProperty) as TransitionBase;
150 SetValue(AppearingTransitionProperty, value);
151 NotifyPropertyChanged();
154 private TransitionBase InternalAppearingTransition
158 appearingTransition = value;
162 return appearingTransition;
167 /// Transition properties for the transition of Views in this page during this page is popped from Navigator.
169 [EditorBrowsable(EditorBrowsableState.Never)]
170 public TransitionBase DisappearingTransition
174 return GetValue(DisappearingTransitionProperty) as TransitionBase;
178 SetValue(DisappearingTransitionProperty, value);
179 NotifyPropertyChanged();
182 private TransitionBase InternalDisappearingTransition
186 disappearingTransition = value;
190 return disappearingTransition;
195 /// Appearing event is invoked right before the page appears.
197 /// <since_tizen> 9 </since_tizen>
198 public event EventHandler<PageAppearingEventArgs> Appearing;
201 /// Disappearing event is invoked right before the page disappears.
203 /// <since_tizen> 9 </since_tizen>
204 public event EventHandler<PageDisappearingEventArgs> Disappearing;
207 /// Appeared event is invoked right after the page appears.
209 /// <since_tizen> 9 </since_tizen>
210 public event EventHandler<PageAppearedEventArgs> Appeared;
213 /// Disappeared event is invoked right after the page disappears.
215 /// <since_tizen> 9 </since_tizen>
216 public event EventHandler<PageDisappearedEventArgs> Disappeared;
218 internal void InvokeAppearing()
220 Appearing?.Invoke(this, new PageAppearingEventArgs());
223 internal void InvokeDisappearing()
225 Disappearing?.Invoke(this, new PageDisappearingEventArgs());
228 internal void InvokeAppeared()
230 Appeared?.Invoke(this, new PageAppearedEventArgs());
233 internal void InvokeDisappeared()
235 Disappeared?.Invoke(this, new PageDisappearedEventArgs());
239 /// works only when DefaultAlgorithm is enabled.
240 /// to save the currently focused View when disappeared.
242 [EditorBrowsable(EditorBrowsableState.Never)]
243 protected internal virtual void SaveKeyFocus()
245 if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
247 if (this is DialogPage)
249 FocusManager.Instance.ResetFocusFinderRootView();
252 var currentFocusedView = FocusManager.Instance.GetCurrentFocusView();
253 if (currentFocusedView)
255 var findChild = FindDescendantByID(currentFocusedView.ID);
258 LastFocusedView = findChild;
262 LastFocusedView = null;
267 /// works only when DefaultAlgorithm is enabled.
268 /// to set key focused View when showing.
270 [EditorBrowsable(EditorBrowsableState.Never)]
271 protected internal virtual void RestoreKeyFocus()
273 if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
277 FocusManager.Instance.SetCurrentFocusView(LastFocusedView);
281 var temp = new Tizen.NUI.BaseComponents.View()
283 Size = new Size(0.1f, 0.1f, 0.0f),
284 Position = new Position(0, 0, 0),
288 temp.LowerToBottom();
289 FocusManager.Instance.SetCurrentFocusView(temp);
290 var focused = FocusManager.Instance.GetNearestFocusableActor(this, temp, Tizen.NUI.BaseComponents.View.FocusDirection.Down);
293 FocusManager.Instance.SetCurrentFocusView(focused);
297 FocusManager.Instance.ClearFocus();
303 if (this is DialogPage)
305 FocusManager.Instance.SetFocusFinderRootView(this);