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;
97 [EditorBrowsable(EditorBrowsableState.Never)]
98 protected internal BaseComponents.View LastFocusedView = null;
100 private Navigator navigator = null;
102 // Default transition is Fade.
103 private TransitionBase appearingTransition = null;
105 private TransitionBase disappearingTransition = null;
108 /// Creates a new instance of a Page.
110 /// <since_tizen> 9 </since_tizen>
111 public Page() : base()
116 /// Navigator which has pushed the Page into its stack.
117 /// If this Page has not been pushed into any Navigator, then Navigator is null.
119 /// <since_tizen> 9 </since_tizen>
120 public Navigator Navigator
128 if (navigator == value)
138 /// Transition properties for the transition of Views in this page during this page is pushed to Navigator.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public TransitionBase AppearingTransition
145 return GetValue(AppearingTransitionProperty) as TransitionBase;
149 SetValue(AppearingTransitionProperty, value);
150 NotifyPropertyChanged();
153 private TransitionBase InternalAppearingTransition
157 appearingTransition = value;
161 return appearingTransition;
166 /// Transition properties for the transition of Views in this page during this page is popped from Navigator.
168 [EditorBrowsable(EditorBrowsableState.Never)]
169 public TransitionBase DisappearingTransition
173 return GetValue(DisappearingTransitionProperty) as TransitionBase;
177 SetValue(DisappearingTransitionProperty, value);
178 NotifyPropertyChanged();
181 private TransitionBase InternalDisappearingTransition
185 disappearingTransition = value;
189 return disappearingTransition;
194 /// Appearing event is invoked right before the page appears.
196 /// <since_tizen> 9 </since_tizen>
197 public event EventHandler<PageAppearingEventArgs> Appearing;
200 /// Disappearing event is invoked right before the page disappears.
202 /// <since_tizen> 9 </since_tizen>
203 public event EventHandler<PageDisappearingEventArgs> Disappearing;
206 /// Appeared event is invoked right after the page appears.
208 /// <since_tizen> 9 </since_tizen>
209 public event EventHandler<PageAppearedEventArgs> Appeared;
212 /// Disappeared event is invoked right after the page disappears.
214 /// <since_tizen> 9 </since_tizen>
215 public event EventHandler<PageDisappearedEventArgs> Disappeared;
217 internal void InvokeAppearing()
219 Appearing?.Invoke(this, new PageAppearingEventArgs());
222 internal void InvokeDisappearing()
224 Disappearing?.Invoke(this, new PageDisappearingEventArgs());
227 internal void InvokeAppeared()
229 Appeared?.Invoke(this, new PageAppearedEventArgs());
232 internal void InvokeDisappeared()
234 Disappeared?.Invoke(this, new PageDisappearedEventArgs());
238 /// works only when DefaultAlgorithm is enabled.
239 /// to save the currently focused View when disappeared.
241 [EditorBrowsable(EditorBrowsableState.Never)]
242 protected internal virtual void SaveKeyFocus()
244 if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
246 var currentFocusedView = FocusManager.Instance.GetCurrentFocusView();
247 if (currentFocusedView)
249 var findChild = FindDescendantByID(currentFocusedView.ID);
252 LastFocusedView = findChild;
256 LastFocusedView = null;
261 /// works only when DefaultAlgorithm is enabled.
262 /// to set key focused View when showing.
264 [EditorBrowsable(EditorBrowsableState.Never)]
265 protected internal virtual void RestoreKeyFocus()
267 if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
271 FocusManager.Instance.SetCurrentFocusView(LastFocusedView);
275 var temp = new Tizen.NUI.BaseComponents.View()
277 Size = new Size(0.1f, 0.1f, 0.0f),
278 Position = new Position(0, 0, 0),
282 temp.LowerToBottom();
283 FocusManager.Instance.SetCurrentFocusView(temp);
284 var focused = FocusManager.Instance.GetNearestFocusableActor(this, temp, Tizen.NUI.BaseComponents.View.FocusDirection.Down);
287 FocusManager.Instance.SetCurrentFocusView(focused);
291 FocusManager.Instance.ClearFocus();