Add SubPanelThumbnailButton XAML for Recent apps subpanel
authorgs86.lee <gs86.lee@DO-GS86-LEE04>
Fri, 24 Feb 2017 07:27:18 +0000 (16:27 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:44 +0000 (18:34 +0900)
Change-Id: I47a70dccf61f2683ce2da1b65ad48af9b04b793f

TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml [new file with mode: 0644]
TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs [new file with mode: 0644]

diff --git a/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml b/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml
new file mode 100644 (file)
index 0000000..ec7daf2
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
+          xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+          x:Class="TVHome.Controls.SubPanelThumbnailButton">
+  <RelativeLayout Opacity="0.3">
+    <BoxView x:Name = "ButtonBox"
+             RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+             RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.94}"
+             Color="Blue" />
+    <Image x:Name="ButtonImage"
+           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.94}"
+           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.94}"
+           Source="{Binding CurrentStateDescription.IconPath}" />
+    <Image x:Name="ButtonIcon"
+           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonImage, Property=Height, Factor=0.4}"
+           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonImage, Property=Width, Factor=0.4}"
+           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonImage, Property=Height, Factor=0.6}"
+           RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonImage, Property=Width, Factor=0.6}"
+           Source="AppIcon.png" />
+    <Label x:Name="ButtonTitle"
+           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.2}"
+           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.94}"
+           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8}"
+           Opacity="0"
+           LineBreakMode="TailTruncation"
+           HorizontalTextAlignment="Center"
+           Text="{Binding CurrentStateDescription.Label}" />
+    <Button x:Name = "ButtonFocusArea"
+            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.94}"
+            Focused="OnFocused"
+            Unfocused="OnUnfocused"
+            Clicked="OnClicked"
+            Opacity="0" />
+  </RelativeLayout>
+</ViewCell>
\ No newline at end of file
diff --git a/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs b/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs
new file mode 100644 (file)
index 0000000..ddb83a0
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Windows.Input;
+using TVHome.Utils;
+using Xamarin.Forms;
+
+namespace TVHome.Controls
+{
+    /// <summary>
+    /// Custom Control for Thumbnail Button in Sub Panel
+    /// </summary>
+    public partial class SubPanelThumbnailButton : ViewCell
+    {
+        public BindableProperty OnFocusedCommandProperty = BindableProperty.Create("OnFocusedCommand", typeof(ICommand), typeof(SubPanelButton));
+
+        public ICommand OnFocusedCommand
+        {
+            get { return (ICommand)GetValue(OnFocusedCommandProperty); }
+            set { SetValue(OnFocusedCommandProperty, value); }
+        }
+
+        public BindableProperty OnClickedCommandProperty = BindableProperty.Create("OnClickedCommand", typeof(ICommand), typeof(SubPanelButton));
+
+        public ICommand OnClickedCommand
+        {
+            get { return (ICommand)GetValue(OnClickedCommandProperty); }
+            set { SetValue(OnClickedCommandProperty, value); }
+        }
+
+        public SubPanelThumbnailButton()
+        {
+            InitializeComponent();
+        }
+
+        private async void OnFocused(object sender, FocusEventArgs e)
+        {
+            if (OnFocusedCommand != null)
+            {
+                OnFocusedCommand.Execute("");
+            }
+
+            ButtonTitle.FadeTo(0.99, 300);
+            await View.FadeTo(0.6, 300);
+        }
+
+        private async void OnUnfocused(object sender, FocusEventArgs e)
+        {
+            ButtonTitle.FadeTo(0, 300);
+            await View.FadeTo(0.3, 300);
+        }
+
+        private async void OnClicked(object sender, EventArgs e)
+        {
+            if (OnClickedCommand != null)
+            {
+                OnClickedCommand.Execute("");
+            }
+
+            await View.FadeTo(0.9, 300);
+        }
+    }
+}
\ No newline at end of file