2 * Copyright (c) 2017 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using LibTVRefCommonPortable.DataModels;
18 using LibTVRefCommonPortable.Utils;
20 using System.ComponentModel;
21 using System.Threading.Tasks;
22 using System.Windows.Input;
25 namespace TVApps.Controls
30 public partial class AppItemCell : ViewCell
32 public ICommand OnClickedCommand { get; set; }
34 public ICommand OnFocusedCommand { get; set; }
36 public static readonly BindableProperty IsPinnedProperty = BindableProperty.Create("IsPinned", typeof(bool), typeof(AppItemCell), default(bool));
39 get { return (bool)GetValue(IsPinnedProperty); }
40 set { SetValue(IsPinnedProperty, value); }
43 public static readonly BindableProperty IsCheckedProperty = BindableProperty.Create("IsChecked", typeof(bool), typeof(AppItemCell), default(bool));
46 get { return (bool)GetValue(IsCheckedProperty); }
47 set { SetValue(IsCheckedProperty, value); }
50 public static readonly BindableProperty IsShowOptionsProperty = BindableProperty.Create("IsShowOptions", typeof(bool), typeof(AppItemCell), default(bool));
51 public bool IsShowOptions
53 get { return (bool)GetValue(IsShowOptionsProperty); }
54 set { SetValue(IsShowOptionsProperty, value); }
57 public static readonly BindableProperty IsDimProperty = BindableProperty.Create("IsDim", typeof(bool), typeof(AppItemCell), default(bool));
60 get { return (bool)GetValue(IsDimProperty); }
61 set { SetValue(IsDimProperty, value); }
66 InitializeComponent();
67 PropertyChanged += AppItemCell_PropertyChanged;
68 ButtonTitle.PropertyChanged += ButtonTitle_PropertyChanged;
71 private void AppItemCell_PropertyChanged(object sender, PropertyChangedEventArgs e)
73 if (e.PropertyName.CompareTo("IsPinned") == 0)
77 PinnedIcon.FadeTo(0.99, 300);
81 PinnedIcon.FadeTo(0.0, 300);
86 else if (e.PropertyName.CompareTo("IsChecked") == 0)
90 CheckImage.FadeTo(0.99, 300);
91 DimImage.FadeTo(0.99, 300);
92 DimImage.TranslateTo(0.0, 2.0, 300);
93 DimImage.ScaleTo(1.32, 300);
97 // TODO : Change Animation (Add Pin Contents Item : Unselected)
98 CheckImage.FadeTo(0.0, 300);
99 DimImage.FadeTo(0.0, 300);
100 DimImage.TranslateTo(0.0, 0.0, 300);
101 DimImage.ScaleTo(0.0, 300);
106 else if (e.PropertyName.CompareTo("IsShowOptions") == 0)
109 // Set the icon status to default
110 ButtonImage.ScaleTo(1.0, 50);
111 ButtonImage.TranslateTo(0.0, 0.0, 50);
112 TextArea.TranslateTo(0.0, 0.0, 50);
116 ButtonImage.TranslateTo(0, -50, 100);
117 TextArea.TranslateTo(0, -50, 100);
118 TextArea.FadeTo(0.0, 100);
122 ButtonImage.TranslateTo(0, 0, 100);
123 TextArea.TranslateTo(0, 0, 100);
124 TextArea.FadeTo(0.99, 100);
127 else if (e.PropertyName.CompareTo("IsDim") == 0)
131 ItemDim.FadeTo(0.5, 100);
135 ItemDim.FadeTo(0.0, 100);
140 private void ButtonTitle_PropertyChanged(object sender, PropertyChangedEventArgs e)
142 if (e.PropertyName == "Width")
144 TextArea.ForceLayout();
148 private void OnClicked(object sender, EventArgs e)
150 OnClickedCommand?.Execute("");
153 private void OnFocused(object sender, EventArgs e)
155 OnFocusedCommand?.Execute("");
156 ButtonImage.ScaleTo(1.32, 300);
157 ButtonImage.TranslateTo(0.0, 2.0, 300);
158 TextArea.TranslateTo(0.0, 26.0, 300);
162 DimImage.ScaleTo(1.32, 300);
163 DimImage.TranslateTo(0.0, 2.0, 300);
164 CheckImage.TranslateTo(0.0, 2.0, 300);
168 private void OnUnFocused(object sender, EventArgs e)
170 ButtonImage.ScaleTo(1.0, 300);
171 ButtonImage.TranslateTo(0.0, 0.0, 300);
172 TextArea.TranslateTo(0.0, 0.0, 300);
176 DimImage.ScaleTo(1.0, 300);
177 DimImage.TranslateTo(0.0, 0.0, 300);
178 CheckImage.TranslateTo(0.0, 0.0, 300);