2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class PageTransitionSample : IExample
9 private readonly string[,] Keywords = new string[3, 2]
12 {"green", "greenGrey"},
15 private readonly string totalGreyTag = "totalGrey";
17 private Navigator navigator;
18 private ContentPage mainPage;
19 private ContentPage redPage, greenPage, bluePage, totalPage;
21 private readonly Vector4 ColorGrey = new Vector4(0.82f, 0.80f, 0.78f, 1.0f);
22 private readonly Vector4 ColorBackground = new Vector4(0.99f, 0.94f, 0.83f, 1.0f);
24 private readonly Vector4[] TileColor = { new Color("#F5625D"), new Color("#7DFF83"), new Color("#7E72DF") };
26 private readonly Vector2 baseSize = new Vector2(480.0f, 800.0f);
27 private Vector2 contentSize;
29 private float magnification;
31 private float convertSize(float size)
33 return size * magnification;
37 public void Activate()
39 Window window = NUIApplication.GetDefaultWindow();
40 Vector2 windowSize = new Vector2((float)(window.Size.Width), (float)(window.Size.Height));
41 magnification = Math.Min(windowSize.X / baseSize.X, windowSize.Y / baseSize.Y);
42 contentSize = baseSize * magnification;
44 navigator = new Navigator()
46 WidthResizePolicy = ResizePolicyType.FillToParent,
47 HeightResizePolicy = ResizePolicyType.FillToParent,
48 Transition = new Transition()
50 TimePeriod = new TimePeriod(400),
51 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine),
54 window.Add(navigator);
56 View mainRoot = new View()
58 WidthResizePolicy = ResizePolicyType.FillToParent,
59 HeightResizePolicy = ResizePolicyType.FillToParent
62 View layoutView = new View()
64 PositionUsesPivotPoint = true,
65 PivotPoint = PivotPoint.BottomCenter,
66 ParentOrigin = ParentOrigin.BottomCenter,
67 Layout = new LinearLayout()
69 LinearAlignment = LinearLayout.Alignment.Center,
70 LinearOrientation = LinearLayout.Orientation.Horizontal,
71 CellPadding = new Size(convertSize(60), convertSize(60)),
73 Position = new Position(0, -convertSize(30))
75 mainRoot.Add(layoutView);
77 View redButton = CreateButton(TileColor[0], Keywords[0, 0], Keywords[0, 1], redPage);
78 View greenButton = CreateButton(TileColor[1], Keywords[1, 0], Keywords[1, 1], greenPage);
79 View blueButton = CreateButton(TileColor[2], Keywords[2, 0], Keywords[2, 1], bluePage);
81 layoutView.Add(redButton);
82 layoutView.Add(greenButton);
83 layoutView.Add(blueButton);
86 TransitionGroup transitionGroup = new TransitionGroup()
88 UseGroupTimePeriod = true,
89 UseGroupAlphaFunction = true,
90 StepTransition = true,
91 TimePeriod = new TimePeriod(500, 3000),
92 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOut),
94 SlideTransition slide = new SlideTransition()
96 TimePeriod = new TimePeriod(1000),
97 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
98 Direction = SlideTransitionDirection.Top
100 transitionGroup.AddTransition(slide);
101 FadeTransition fade = new FadeTransition()
104 TimePeriod = new TimePeriod(1000),
105 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default)
107 transitionGroup.AddTransition(fade);
108 ScaleTransition scale = new ScaleTransition()
110 ScaleFactor = new Vector2(0.3f, 0.3f),
111 TimePeriod = new TimePeriod(1000),
112 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default)
114 transitionGroup.AddTransition(scale);
116 mainPage = new ContentPage()
118 BackgroundColor = Color.Transparent,
120 DisappearingTransition = new ScaleTransition()
122 TimePeriod = new TimePeriod(500),
123 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
124 ScaleFactor = new Vector2(0.5f, 1.5f)
126 AppearingTransition = transitionGroup,
128 navigator.Push(mainPage);
130 View totalGreyView = new View()
132 Size = new Size(convertSize(50), convertSize(50)),
133 CornerRadius = convertSize(25),
134 BackgroundColor = ColorGrey,
135 TransitionOptions = new TransitionOptions()
137 TransitionTag = totalGreyTag,
141 totalGreyView.TouchEvent += (object sender, View.TouchEventArgs e) =>
143 if (e.Touch.GetState(0) == PointStateType.Down)
145 navigator.PushWithTransition(totalPage);
149 layoutView.Add(totalGreyView);
152 // ------------------------------------------------------
155 View totalPageRoot = new View()
157 WidthResizePolicy = ResizePolicyType.FillToParent,
158 SizeHeight = contentSize.Height,
161 View totalLayoutView = new View()
163 Layout = new GridLayout()
166 GridOrientation = GridLayout.Orientation.Vertical,
168 PositionUsesPivotPoint = true,
169 PivotPoint = PivotPoint.Center,
170 ParentOrigin = ParentOrigin.Center,
172 totalPageRoot.Add(totalLayoutView);
174 for (int i = 0; i < 3; ++i)
176 View sizeView = new View()
178 Size = new Size(contentSize.Width / 2.0f, contentSize.Height / 2.0f),
180 View smallView = CreatePageScene(TileColor[i], Keywords[i, 0], Keywords[i, 1]);
181 smallView.Scale = new Vector3(0.45f, 0.45f, 1.0f);
182 smallView.PositionUsesPivotPoint = true;
183 smallView.PivotPoint = PivotPoint.Center;
184 smallView.ParentOrigin = ParentOrigin.Center;
185 sizeView.Add(smallView);
186 totalLayoutView.Add(sizeView);
189 View sizeGreyView = new View()
191 Size = new Size(contentSize.Width / 2.0f, contentSize.Height / 2.0f),
194 View totalGreyReturnView = new View()
196 PositionUsesPivotPoint = true,
197 PivotPoint = PivotPoint.Center,
198 ParentOrigin = ParentOrigin.Center,
199 Size = new Size(convertSize(70), convertSize(70)),
200 CornerRadius = convertSize(20),
201 BackgroundColor = ColorGrey,
202 TransitionOptions = new TransitionOptions()
204 TransitionTag = totalGreyTag,
207 sizeGreyView.Add(totalGreyReturnView);
208 totalLayoutView.Add(sizeGreyView);
210 totalGreyReturnView.TouchEvent += (object sender, View.TouchEventArgs e) =>
212 if (e.Touch.GetState(0) == PointStateType.Down)
214 navigator.PopWithTransition();
219 totalPage = new ContentPage()
221 BackgroundColor = Color.Transparent,
222 Content = totalPageRoot,
223 AppearingTransition = new FadeTransition()
225 TimePeriod = new TimePeriod(500),
226 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
228 DisappearingTransition = new FadeTransition()
230 TimePeriod = new TimePeriod(500),
231 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
236 private View CreateButton(Color color, string colorTag, string greyTag, Page secondPage)
238 View colorView = new View()
240 Size = new Size(convertSize(50), convertSize(50)),
241 CornerRadius = 0.45f,
242 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
243 BackgroundColor = color,
244 Orientation = new Rotation(new Radian((float)Math.PI / 2.0f), Vector3.ZAxis),
245 TransitionOptions = new TransitionOptions()
247 TransitionTag = colorTag,
251 View greyView = new View()
253 PositionUsesPivotPoint = true,
254 PivotPoint = PivotPoint.Center,
255 ParentOrigin = ParentOrigin.Center,
256 Size = new Size(convertSize(40), convertSize(40)),
257 CornerRadius = 0.45f,
258 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
259 BackgroundColor = ColorGrey,
260 Orientation = new Rotation(new Radian(-(float)Math.PI / 2.0f), Vector3.ZAxis),
261 TransitionOptions = new TransitionOptions()
263 TransitionTag = greyTag,
267 secondPage = CreatePage(color, colorTag, greyTag);
269 greyView.TouchEvent += (object sender, View.TouchEventArgs e) =>
271 if (e.Touch.GetState(0) == PointStateType.Down)
273 navigator.PushWithTransition(secondPage);
277 colorView.Add(greyView);
281 private View CreatePageScene(Color color, string colorTag, string greyTag)
283 View pageBackground = new View()
285 SizeWidth = contentSize.Width,
286 SizeHeight = contentSize.Height,
289 View colorView = new View()
291 WidthResizePolicy = ResizePolicyType.FillToParent,
292 HeightResizePolicy = ResizePolicyType.FillToParent,
293 CornerRadius = 0.05f,
294 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
295 BackgroundColor = color,
296 TransitionOptions = new TransitionOptions()
298 TransitionTag = colorTag
302 View greyView = new View()
304 PositionUsesPivotPoint = true,
305 PivotPoint = PivotPoint.TopCenter,
306 ParentOrigin = ParentOrigin.TopCenter,
307 Position = new Position(0, convertSize(80)),
308 SizeWidth = contentSize.Width * 0.7f,
309 SizeHeight = contentSize.Height * 0.06f,
311 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
312 BackgroundColor = ColorGrey,
313 TransitionOptions = new TransitionOptions()
315 TransitionTag = greyTag
319 View whiteView = new View()
321 PositionUsesPivotPoint = true,
322 PivotPoint = PivotPoint.BottomCenter,
323 ParentOrigin = ParentOrigin.BottomCenter,
324 Position = new Position(0, -convertSize(60)),
325 SizeWidth = contentSize.Width * 0.75f,
326 SizeHeight = contentSize.Height * 0.7f,
328 CornerRadiusPolicy = VisualTransformPolicyType.Relative,
329 BackgroundColor = Color.AntiqueWhite,
331 pageBackground.Add(colorView);
332 pageBackground.Add(whiteView);
333 pageBackground.Add(greyView);
335 return pageBackground;
338 private Page CreatePage(Color color, string colorTag, string greyTag)
340 View pageRoot = new View()
342 WidthResizePolicy = ResizePolicyType.FillToParent,
343 HeightResizePolicy = ResizePolicyType.FillToParent
346 View pageBackground = CreatePageScene(color, colorTag, greyTag);
347 pageBackground.TouchEvent += (object sender, View.TouchEventArgs e) =>
349 if (e.Touch.GetState(0) == PointStateType.Down)
351 navigator.PopWithTransition();
355 pageRoot.Add(pageBackground);
357 TransitionGroup transitionGroup = new TransitionGroup();
358 FadeTransition slide = new FadeTransition()
360 TimePeriod = new TimePeriod(500),
361 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
363 transitionGroup.AddTransition(slide);
365 Page page = new ContentPage()
367 BackgroundColor = Color.Transparent,
370 AppearingTransition = transitionGroup,
371 DisappearingTransition = new SlideTransition()
373 TimePeriod = new TimePeriod(500),
374 AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
375 Direction = SlideTransitionDirection.Left
381 public void Deactivate()