Add No Contents to display layout in Recent list
authorHyerim Kim <rimi.kim@samsung.com>
Wed, 22 Mar 2017 09:40:32 +0000 (18:40 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:49 +0000 (18:34 +0900)
Change-Id: I4370af33f34a29aa5b413c7bbbf9e18d5f53582b
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
TVHome/TVHome/ViewModels/MainPageViewModel.cs
TVHome/TVHome/Views/MainPage.xaml
TVHome/TVHome/Views/SubThumbnailPanel.xaml [changed mode: 0644->0755]
TVHome/TVHome/Views/SubThumbnailPanel.xaml.cs [changed mode: 0644->0755]

index 9cc8933..bcbb686 100755 (executable)
@@ -20,6 +20,7 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Windows.Input;
 using System.Threading.Tasks;
+using System.Linq;
 using LibTVRefCommonPortable.DataModels;
 using LibTVRefCommonPortable.Utils;
 using Xamarin.Forms;
@@ -57,6 +58,8 @@ namespace TVHome.ViewModels
         public HomeStatus CurrentStatus { get; private set; }
         public HomeMenuItem SelectedMenuName { get; private set; }
 
+        public bool IsShowNoRecentContents { get; set;}
+
         public event PropertyChangedEventHandler PropertyChanged;
 
         public MainPageViewModel()
@@ -207,10 +210,16 @@ namespace TVHome.ViewModels
         private async void MakeRecentButtons()
         {
             RecentList = await TVHomeImpl.GetInstance.RecentShortcutControllerInstance.GetList();
-            if (RecentList != null)
+            if (RecentList.Count<ShortcutInfo>() > 0)
             {
+                IsShowNoRecentContents = false;
                 OnPropertyChanged("RecentList");
             }
+            else
+            {
+                IsShowNoRecentContents = true;
+            }
+            OnPropertyChanged("IsShowNoRecentContents");
         }
 
         public void OnPropertyChanged(string name)
index 146bf96..4cba2b0 100755 (executable)
                             RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
                             RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.89}"
                             OnFocusedCommand="{Binding SubPanelFocusedCommand}"
-                            ItemsSource="{Binding RecentList}" >
-                <Views:SubThumbnailPanel.ItemTemplate>
-                    <DataTemplate>
-                        <Controls:SubPanelThumbnailButton/>
-                    </DataTemplate>
-                </Views:SubThumbnailPanel.ItemTemplate>
+                            ItemsSource="{Binding RecentList}"
+                            ShowNoContentsInfo="{Binding IsShowNoRecentContents}">
             </Views:SubThumbnailPanel>
 
             <Views:SubPanel x:Name="AppsSubPanel"
old mode 100644 (file)
new mode 100755 (executable)
index 3faff6d..a11e9e0
@@ -3,12 +3,46 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:Views="clr-namespace:TVHome.Views"
              x:Class="TVHome.Views.SubThumbnailPanel">
+  <RelativeLayout x:Name="ThumbnailParent"
+                  RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+                  RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
+                  RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
+                  RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}" >
     <ScrollView x:Name="PanelScrollView"
                 Orientation="Horizontal"
-                HorizontalOptions="Center">
-        <StackLayout x:Name="PanelButtonStack"
-                     Orientation="Horizontal"
-                     Padding="96,18,96,18">
-        </StackLayout>
+                HorizontalOptions="Center"
+                IsVisible="true"
+                RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+                RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
+                RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
+                RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}" >
+      <StackLayout x:Name="PanelButtonStack"
+                  Orientation="Horizontal"
+                  Padding="96,18,96,18"
+                  IsVisible="true">
+      </StackLayout>
     </ScrollView>
+    <RelativeLayout x:Name="NoContentInfo"
+                    HorizontalOptions="Center"
+                    IsVisible="false"
+                    WidthRequest="648"
+                    HeightRequest="108"
+                    RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent ,Property=Height, Factor=0}"
+                    RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent ,Property=Width, Factor=0.33125}" >
+      <BoxView x:Name="BackgroundBox"
+              RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=NoContentInfo ,Property=Height, Factor=1}"
+              RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=NoContentInfo ,Property=Width, Factor=1}"
+              RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=NoContentInfo ,Property=Height, Factor=0}"
+              RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=NoContentInfo ,Property=Width, Factor=0}" />
+      <Label x:Name="Text"
+            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=BackgroundBox ,Property=Height, Factor=0.444444}"
+            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=BackgroundBox ,Property=Width, Factor=0.42284}"
+            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=BackgroundBox ,Property=Height, Factor=0.3056}"
+            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=BackgroundBox ,Property=Width, Factor=0.28858}"
+            Text="No Content to display"
+            HorizontalTextAlignment="Center"
+            FontSize="56"
+            TextColor="White" />
+    </RelativeLayout>
+  </RelativeLayout>
 </Views:Panel>
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 4b880cb..2f8cf92
@@ -31,6 +31,12 @@ namespace TVHome.Views
     /// </summary>
     public partial class SubThumbnailPanel : Panel
     {
+        public static readonly BindableProperty ShowNoContentsInfoProperty = BindableProperty.Create("ShowNoContentsInfo", typeof(bool), typeof(SubThumbnailPanel), default(bool));
+        public bool ShowNoContentsInfo
+        {
+            get { return (bool)GetValue(ShowNoContentsInfoProperty); }
+            set { SetValue(ShowNoContentsInfoProperty, value); }
+        }
         public SubThumbnailPanel()
         {
             InitializeComponent();
@@ -40,7 +46,22 @@ namespace TVHome.Views
 
         private void OnItemsSourcePropertyChanged(object sender, PropertyChangedEventArgs e)
         {
-            if (e.PropertyName != "ItemsSource")
+            if (e.PropertyName == "ShowNoContentsInfo")
+            {
+                if (ShowNoContentsInfo)
+                {
+                    PanelScrollView.IsVisible = false;
+                    NoContentInfo.IsVisible = true;
+                    HidePanel();
+                    return;
+                }
+                else
+                {
+                    PanelScrollView.IsVisible = true;
+                    NoContentInfo.IsVisible = false;
+                }
+            }
+            else if (e.PropertyName != "ItemsSource")
             {
                 return;
             }
@@ -48,7 +69,7 @@ namespace TVHome.Views
             PanelButtonStack.Children.Clear();
             foreach (ShortcutInfo item in ItemsSource)
             {
-                var button = ItemTemplate.CreateContent() as PanelButton;
+                PanelButton button = new SubPanelThumbnailButton();
                 button.View.BindingContext = item;
                 button.OnFocusedCommand = new Command(() =>
                 {
@@ -66,33 +87,49 @@ namespace TVHome.Views
 
         public override async void HidePanel()
         {
-            isFocused = false;
-            foreach (var item in PanelButtonStack.Children)
+            if (NoContentInfo.IsVisible)
             {
-                item.IsEnabled = false;
+#pragma warning disable CS4014
+                this.TranslateTo(0, 1, 0);
+#pragma warning restore CS4014
+                await this.FadeTo(0, 0);
             }
+            else
+            {
+                isFocused = false;
+                foreach (var item in PanelButtonStack.Children)
+                {
+                    item.IsEnabled = false;
+                }
 
 #pragma warning disable CS4014
-            PanelScrollView.ScrollToAsync(0, 0, true);
-            this.TranslateTo(0, 1, 0);
+                PanelScrollView.ScrollToAsync(0, 0, true);
+                this.TranslateTo(0, 1, 0);
 #pragma warning restore CS4014
-            await this.FadeTo(0, 0);
-            IsVisible = false;
+                await this.FadeTo(0, 0);
+            }
         }
 
         public override async void ShowPanel()
         {
-            IsVisible = true;
-            isFocused = false;
-            foreach (var item in PanelButtonStack.Children)
+            if (NoContentInfo.IsVisible)
             {
-                item.IsEnabled = true;
+                NoContentInfo.IsEnabled = false;
+                await this.FadeTo(0.8, 0);
             }
+            else
+            {
+                isFocused = false;
+                foreach (var item in PanelButtonStack.Children)
+                {
+                    item.IsEnabled = true;
+                }
 
 #pragma warning disable CS4014
-            this.TranslateTo(0, 0, 0);
+                this.TranslateTo(0, 0, 0);
 #pragma warning restore CS4014
-            await this.FadeTo(0.3, 0);
+                await this.FadeTo(0.3, 0);
+            }
         }
 
         public override async void FocusPanel()