[NUI] integration from DevelNUI to master (#3309)
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / SwipeViewTest2 / SwipeViewTest2.xaml.cs
1 using Tizen.NUI;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
4
5 namespace NUITizenGallery
6 {
7     public partial class SwipeViewTest2Page : ContentPage
8     {
9         private PanGestureDetector panGestureDetector;
10         private Position init1Position;
11         private Position init2Position;
12
13         public SwipeViewTest2Page()
14         {
15             InitializeComponent();
16
17             panGestureDetector = new PanGestureDetector();
18             panGestureDetector.Attach(text1View);
19             panGestureDetector.Attach(text2View);
20             panGestureDetector.Detected += (obj, e) =>
21             {
22                 Vector2 velocity = e.PanGesture.Velocity;
23                 View view = e.View;
24                 if (view != null)
25                 {
26                     if (e.PanGesture.State == Gesture.StateType.Started)
27                     {
28                         init1Position = text1View.Position;
29                         init2Position = text2View.Position;
30                     }
31                     else if (e.PanGesture.State == Gesture.StateType.Finished || e.PanGesture.State == Gesture.StateType.Cancelled)
32                     {
33                         if(view.Position.X < - 110)
34                         {
35                             var button = new Button()
36                             {
37                                 Text = "Cancel",
38                             };
39
40                             button.Clicked += (object s, ClickedEventArgs a) =>
41                             {
42                                 Navigator?.Pop();
43                             };
44
45                             if (view == text1View)
46                             {
47                                 DialogPage.ShowAlertDialog("SwipeView", "SwipeItemView Invoked", button);
48                             }
49                             else if (view == text2View)
50                             {
51                                 DialogPage.ShowAlertDialog("SwipeView", "SwipeItemView Command Executed", button);
52                             }
53                         }
54
55                         text1View.Position = init1Position;
56                         text2View.Position = init2Position;
57                     }
58                     else
59                     {
60                         if (velocity.X < 0 && view.Position.X > -140)
61                         {
62                             view.Position += new Position(e.PanGesture.ScreenDisplacement.X, 0, 0);
63                         }
64                     }
65                 }
66             };
67
68         }
69
70     }
71 }