Revert "[DO NOT REVIEW][TEST][NUI] key focus default algorithm test"
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Navigation / Page.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI.Components
22 {
23     /// <summary>
24     /// PageAppearingEventArgs is a class to record <see cref="Page.Appearing"/> event arguments which will be sent to user.
25     /// </summary>
26     /// <since_tizen> 9 </since_tizen>
27     public class PageAppearingEventArgs : EventArgs
28     {
29     }
30
31     /// <summary>
32     /// PageDisappearingEventArgs is a class to record <see cref="Page.Disappearing"/> event arguments which will be sent to user.
33     /// </summary>
34     /// <since_tizen> 9 </since_tizen>
35     public class PageDisappearingEventArgs : EventArgs
36     {
37     }
38
39     /// <summary>
40     /// PageAppearedEventArgs is a class to record <see cref="Page.Appeared"/> event arguments which will be sent to user.
41     /// </summary>
42     /// <since_tizen> 9 </since_tizen>
43     public class PageAppearedEventArgs : EventArgs
44     {
45     }
46
47     /// <summary>
48     /// PageDisappearedEventArgs is a class to record <see cref="Page.Disappeared"/> event arguments which will be sent to user.
49     /// </summary>
50     /// <since_tizen> 9 </since_tizen>
51     public class PageDisappearedEventArgs : EventArgs
52     {
53     }
54
55     /// <summary>
56     /// The Page class is a class which is an element of navigation.
57     /// </summary>
58     /// <since_tizen> 9 </since_tizen>
59     public abstract class Page : Control
60     {
61         /// <summary>
62         /// AppearingTransitionProperty
63         /// </summary>
64         [EditorBrowsable(EditorBrowsableState.Never)]
65         public static readonly BindableProperty AppearingTransitionProperty = BindableProperty.Create(nameof(AppearingTransition), typeof(TransitionBase), typeof(Page), null, propertyChanged: (bindable, oldValue, newValue) =>
66         {
67             var instance = (Page)bindable;
68             if (newValue != null)
69             {
70                 instance.InternalAppearingTransition = newValue as TransitionBase;
71             }
72         },
73         defaultValueCreator: (bindable) =>
74         {
75             var instance = (Page)bindable;
76             return instance.InternalAppearingTransition;
77         });
78
79         /// <summary>
80         /// DisappearingTransitionProperty
81         /// </summary>
82         [EditorBrowsable(EditorBrowsableState.Never)]
83         public static readonly BindableProperty DisappearingTransitionProperty = BindableProperty.Create(nameof(DisappearingTransition), typeof(TransitionBase), typeof(Page), null, propertyChanged: (bindable, oldValue, newValue) =>
84         {
85             var instance = (Page)bindable;
86             if (newValue != null)
87             {
88                 instance.InternalDisappearingTransition = newValue as TransitionBase;
89             }
90         },
91         defaultValueCreator: (bindable) =>
92         {
93             var instance = (Page)bindable;
94             return instance.InternalDisappearingTransition;
95         });
96
97         private Navigator navigator = null;
98
99         // Default transition is Fade.
100         private TransitionBase appearingTransition = null;
101
102         private TransitionBase disappearingTransition = null;
103
104         /// <summary>
105         /// Creates a new instance of a Page.
106         /// </summary>
107         /// <since_tizen> 9 </since_tizen>
108         public Page() : base()
109         {
110         }
111
112         /// <summary>
113         /// Navigator which has pushed the Page into its stack.
114         /// If this Page has not been pushed into any Navigator, then Navigator is null.
115         /// </summary>
116         /// <since_tizen> 9 </since_tizen>
117         public Navigator Navigator
118         {
119             get
120             {
121                 return navigator;
122             }
123             internal set
124             {
125                 if (navigator == value)
126                 {
127                     return;
128                 }
129
130                 navigator = value;
131             }
132         }
133
134         /// <summary>
135         /// Transition properties for the transition of Views in this page during this page is pushed to Navigator.
136         /// </summary>
137         [EditorBrowsable(EditorBrowsableState.Never)]
138         public TransitionBase AppearingTransition
139         {
140             get
141             {
142                 return GetValue(AppearingTransitionProperty) as TransitionBase;
143             }
144             set
145             {
146                 SetValue(AppearingTransitionProperty, value);
147                 NotifyPropertyChanged();
148             }
149         }
150         private TransitionBase InternalAppearingTransition
151         {
152             set
153             {
154                 appearingTransition = value;
155             }
156             get
157             {
158                 return appearingTransition;
159             }
160         }
161
162         /// <summary>
163         /// Transition properties for the transition of Views in this page during this page is popped from Navigator.
164         /// </summary>
165         [EditorBrowsable(EditorBrowsableState.Never)]
166         public TransitionBase DisappearingTransition
167         {
168             get
169             {
170                 return GetValue(DisappearingTransitionProperty) as TransitionBase;
171             }
172             set
173             {
174                 SetValue(DisappearingTransitionProperty, value);
175                 NotifyPropertyChanged();
176             }
177         }
178         private TransitionBase InternalDisappearingTransition
179         {
180             set
181             {
182                 disappearingTransition = value;
183             }
184             get
185             {
186                 return disappearingTransition;
187             }
188         }
189
190         /// <summary>
191         /// Appearing event is invoked right before the page appears.
192         /// </summary>
193         /// <since_tizen> 9 </since_tizen>
194         public event EventHandler<PageAppearingEventArgs> Appearing;
195
196         /// <summary>
197         /// Disappearing event is invoked right before the page disappears.
198         /// </summary>
199         /// <since_tizen> 9 </since_tizen>
200         public event EventHandler<PageDisappearingEventArgs> Disappearing;
201
202         /// <summary>
203         /// Appeared event is invoked right after the page appears.
204         /// </summary>
205         /// <since_tizen> 9 </since_tizen>
206         public event EventHandler<PageAppearedEventArgs> Appeared;
207
208         /// <summary>
209         /// Disappeared event is invoked right after the page disappears.
210         /// </summary>
211         /// <since_tizen> 9 </since_tizen>
212         public event EventHandler<PageDisappearedEventArgs> Disappeared;
213
214         internal void InvokeAppearing()
215         {
216             Appearing?.Invoke(this, new PageAppearingEventArgs());
217         }
218
219         internal void InvokeDisappearing()
220         {
221             Disappearing?.Invoke(this, new PageDisappearingEventArgs());
222         }
223
224         internal void InvokeAppeared()
225         {
226             Appeared?.Invoke(this, new PageAppearedEventArgs());
227         }
228
229         internal void InvokeDisappeared()
230         {
231             Disappeared?.Invoke(this, new PageDisappearedEventArgs());
232         }
233     }
234 }