-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavigationApp.cs
More file actions
62 lines (58 loc) · 2.06 KB
/
Copy pathNavigationApp.cs
File metadata and controls
62 lines (58 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using UniMob.UI;
using UniMob.UI.Widgets;
using UnityEngine;
namespace Samples.Navigation
{
public class NavigationApp : UniMobUIApp
{
protected override Widget Build(BuildContext context)
{
return new Navigator("main", new Dictionary<string, Func<Route>>
{
["main"] = BuildMainRoute,
["detail"] = BuildDetailRoute,
});
}
private Route BuildMainRoute()
{
return new PageRouteBuilder(
new RouteSettings("name", RouteModalType.Fullscreen),
transitionDuration: 0.2f,
reverseTransitionDuration: 0.2f,
pageBuilder: (context, animation, secondaryAnimation) => new MainWidget
{
ShowDetail = () => Navigator.PushNamed(context, "detail"),
},
transitionsBuilder: BuildSlideTransitions
);
}
private Route BuildDetailRoute()
{
return new PageRouteBuilder(
new RouteSettings("detail", RouteModalType.Fullscreen),
transitionDuration: 0.2f,
reverseTransitionDuration: 0.2f,
pageBuilder: (context, animation, secondaryAnimation) => new DetailWidget
{
Close = () => Navigator.Pop(context),
},
transitionsBuilder: BuildSlideTransitions
);
}
private Widget BuildSlideTransitions(BuildContext context, AnimationController animation,
AnimationController secondaryAnimation, Widget child)
{
return new CompositeTransition
{
Position = secondaryAnimation.Drive(new Vector2Tween(Vector2.left, Vector2.zero)),
Child = new CompositeTransition
{
Position = animation.Drive(new Vector2Tween(Vector2.right, Vector2.zero)),
Child = child,
}
};
}
}
}