Text Sliding Animation
authorHeonjae Jang <heonjae.jang@samsung.com>
Mon, 1 May 2017 10:39:52 +0000 (19:39 +0900)
committerHeonjae Jang <heonjae.jang@samsung.com>
Mon, 1 May 2017 10:39:52 +0000 (19:39 +0900)
Change-Id: I58f9ea581485c607b6a5370d93b503d0a63e2361
Signed-off-by: Heonjae Jang <heonjae.jang@samsung.com>
TVMediaHub/TVMediaHub.Tizen/Views/MediaHubMainPage.xaml.cs
TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml
TVMediaHub/TVMediaHub.Tizen/Views/VideoItem.xaml.cs

index 3e7f09c..217a0d4 100755 (executable)
@@ -39,8 +39,8 @@ namespace TVMediaHub.Tizen.Views
         protected override void OnAppearing()
         {
             base.OnAppearing();
-
             CurrentPage = Children[StartTabIndex];
+            Focus();
         }
 
         protected override bool OnBackButtonPressed()
index 7f12ae0..1d934f6 100644 (file)
@@ -24,7 +24,7 @@
                     VerticalOptions="CenterAndExpand"
                     HorizontalOptions="CenterAndExpand"
                Source="{Binding ThumbnailPath}"/>
-        </Views:CustomImageControl>
+    </Views:CustomImageControl>
     <Utils:NinePatch x:Name="DimImage"
                      VerticalOptions="CenterAndExpand"
                      HorizontalOptions="CenterAndExpand"
                      Source="img_stroke2.9.png"
                      IsVisible="{Binding IsDeleteStatus}"
                      Opacity="0"/>
-    <Label x:Name="ContentTitle"
-           TextColor="White"
-           LineBreakMode="TailTruncation"
-           Text="{Binding ContentName}"/>
+    <RelativeLayout x:Name="TitleContainer">
+        <Label x:Name="ContentTitle"
+               TextColor="White"
+               LineBreakMode="NoWrap"
+               Text="{Binding ContentName}"/>
+    </RelativeLayout>
 </RelativeLayout>
index cc4f0b0..f94cb70 100644 (file)
@@ -46,6 +46,7 @@ namespace TVMediaHub.Tizen.Views
 
         private Rectangle PlayIconBounds;
 
+        private Rectangle TitleContainerBounds;
         private Rectangle ContentTitleBounds;
 
         public EventHandler OnFocusedEventHandler;
@@ -111,7 +112,7 @@ namespace TVMediaHub.Tizen.Views
 
             PlayIconBounds = new Rectangle(SizeUtils.GetWidthSize(208), SizeUtils.GetHeightSize(126), SizeUtils.GetWidthSize(80), SizeUtils.GetHeightSize(80));
 
-            ContentTitleBounds = new Rectangle(SizeUtils.GetWidthSize(94), SizeUtils.GetHeightSize(214), SizeUtils.GetWidthSize(284), SizeUtils.GetHeightSize(30));
+            TitleContainerBounds = new Rectangle(SizeUtils.GetWidthSize(94), SizeUtils.GetHeightSize(214), SizeUtils.GetWidthSize(284), SizeUtils.GetHeightSize(30));
 
             WidthRequest = SizeUtils.GetWidthSize(472);
             HeightRequest = SizeUtils.GetHeightSize(332);
@@ -154,7 +155,7 @@ namespace TVMediaHub.Tizen.Views
                 ImageArea.Layout(NormalBounds);
                 ContentImage.Layout(NormalContentImageBounds);
                 DimImage.Layout(NormalBounds);
-                ContentTitle.Layout(ContentTitleBounds);
+                TitleContainer.Layout(TitleContainerBounds);
                 PlayImage.Layout(PlayIconBounds);
                 CheckDimImage.Layout(NormalBounds);
                 CheckImage.Layout(NormalBounds);
@@ -169,6 +170,7 @@ namespace TVMediaHub.Tizen.Views
 
         public async void OnUnfocused(object sender, FocusEventArgs e)
         {
+            AnimationExtensions.AbortAnimation(this, "TextSliding");
             BgDimImage.Opacity = 0;
             Easing easing = new Easing(EasingFunction.EasyIn2);
 #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
@@ -189,6 +191,24 @@ namespace TVMediaHub.Tizen.Views
         public async void OnFocused(object sender, FocusEventArgs e)
         {
             Easing easing = new Easing(EasingFunction.EasyIn1);
+            this.Animate("TextSilding",
+                (v) => { },
+                length: 2000,
+                finished: (a, b) =>
+                {
+                    uint animationLength = (uint)(ContentTitle.Width * 12000 / 480);
+                    this.Animate("TextSliding",
+                        (v2) =>
+                        {
+                            ContentTitle.TranslationX = -ContentTitle.Width * v2;
+                        },
+                        length: animationLength,
+                        finished: (c, d) =>
+                         {
+                             ContentTitle.TranslationX = 0;
+                         });
+                });
+
             await Task.Delay(167);
             BgDimImage.Opacity = 0.99;
             OnFocusedEventHandler?.Invoke(sender, e);