using System.ComponentModel;
using System.Windows.Input;
using System.Threading.Tasks;
+using System.Linq;
using LibTVRefCommonPortable.DataModels;
using LibTVRefCommonPortable.Utils;
using Xamarin.Forms;
public HomeStatus CurrentStatus { get; private set; }
public HomeMenuItem SelectedMenuName { get; private set; }
+ public bool IsShowNoRecentContents { get; set;}
+
public event PropertyChangedEventHandler PropertyChanged;
public MainPageViewModel()
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)
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"
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
/// </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();
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;
}
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(() =>
{
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()