OnPropertyChanged("IsDim");
}
- public void ShowOptions()
+ public void ShowOptions()
{
IsShowOptions = true;
OnPropertyChanged("IsShowOptions");
* limitations under the License.
*/
+using LibTVRefCommonPortable.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
{
public class HomeMenuAppShortcutInfo : ShortcutInfo
{
+ public string Status { get; set; }
+
public override void UpdateState()
{
SetCurrentState("default");
}
+
+ public void ChangeStatus(string status)
+ {
+ Status = status;
+ OnPropertyChanged("Status");
+ SetCurrentState(status);
+ }
}
}
{
break;
}
- if (i >= 4)
+ else if (i >= 4)
{
DebuggingUtils.Err("Can't open storage" + storagePath);
return new List<AppShortcutInfo>();
}
+
await Task.Delay(100);
DebuggingUtils.Dbg("[" + i + "/5] Waiting for Writting" + storagePath);
}
{
- "buildOptions": {
- "emitEntryPoint": true,
- "debugType": "portable",
- "platform": "AnyCPU",
- "preserveCompilationContext": true
- },
- "dependencies": {
- "ElmSharp": "1.1.0-beta-010",
- "Microsoft.NETCore.App": "1.1.0",
- "Tizen.Library": "1.0.0-pre2",
- "Xamarin.Forms": "2.3.3.193",
- "Xamarin.Forms.Platform.Tizen": "2.3.3.175-beta-007"
- },
- "runtimes": {
- "win": {},
- "linux": {}
- },
- "frameworks": {
- "netcoreapp1.0": {
- "imports": [
- "portable-net45+wp80+win81+wpa81",
- "netstandard1.6"
- ]
+ "buildOptions": {
+ "emitEntryPoint": true,
+ "debugType": "portable",
+ "platform": "AnyCPU",
+ "preserveCompilationContext": true
+ },
+ "dependencies": {
+ "ElmSharp": "1.1.0-beta-013",
+ "Microsoft.NETCore.App": "1.1.0",
+ "Tizen.Library": "1.0.0-pre2",
+ "Xamarin.Forms": "2.3.3.193",
+ "Xamarin.Forms.Platform.Tizen": "2.3.3.175-beta-007"
+ },
+ "runtimes": {
+ "win": {},
+ "linux": {}
+ },
+ "frameworks": {
+ "netcoreapp1.0": {
+ "imports": [
+ "portable-net45+wp80+win81+wpa81",
+ "netstandard1.6"
+ ]
+ }
}
- }
}
\ No newline at end of file
{
AppUninstalledListener += listener;
}
+
public static void SetPinAppRequestListener(EventHandler<TVAppsEventArgs> listener)
{
PinAppRequestListener += listener;
public void OnAppPinnedNotificationReceived(string appID)
{
}
+
+ public void OnHomeKeyPressed()
+ {
+ }
}
}
public void SetAppItemDim(string appId)
{
InstalledApps = new List<AppShortcutInfo>(InstalledApps);
- foreach(AppShortcutInfo app in InstalledApps)
+ foreach (AppShortcutInfo app in InstalledApps)
{
if (!app.AppID.Equals(appId))
{
public void UnsetAppItemDim(string appId)
{
InstalledApps = new List<AppShortcutInfo>(InstalledApps);
- foreach(AppShortcutInfo app in InstalledApps)
+ foreach (AppShortcutInfo app in InstalledApps)
{
if (!app.AppID.Equals(appId))
{
}
}
- public void HideLongPressOption(string appId)
+ public void HideLongPressOption(string appId)
{
InstalledApps = new List<AppShortcutInfo>(InstalledApps);
AppShortcutInfo longPressedApp = InstalledApps.Find(app => app.AppID.Equals(appId));
appsHolder.UpdatePinnedApps();
ChangeCurrentStatus(AppsStatus.Default);
- if(IsPinAppRequested)
+ if (IsPinAppRequested)
{
// TODO : check pinneed apps and a number of pinned apps
AppControlUtils.SendAppAddedNotificationToHome("org.tizen.settings");
DebuggingUtils.Dbg(" === Set LongPress AppID : " + appId);
// 1. ItemCell will be dimmed
- appsHolder.SetAppItemDim((string) appId);
+ appsHolder.SetAppItemDim((string)appId);
// 2. The selected icon on apps list will be moved
appsHolder.ShowLongPressOption((string)appId);
appsHolder.HideLongPressOption((string)appId);
// 3. ItemCell will be changed to normal
- appsHolder.UnsetAppItemDim((string) appId);
+ appsHolder.UnsetAppItemDim((string)appId);
});
await this.Navigation.PopAsync();
return true;
}
+
return true;
}
+
/*
protected override bool OnBackButtonPressed()
{
xmlns:Controls="clr-namespace:TVHome.Controls"
x:Class="TVHome.Controls.MainPanelButton">
<RelativeLayout Opacity="0.3">
- <BoxView x:Name = "ButtonBox"
- RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
- RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1.03}"
- RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
- RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
- Opacity="0"/>
+ <BoxView x:Name="ButtonBox"
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1.03}"
+ RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
+ Opacity="0" />
<Image x:Name="ButtonBgImage"
- RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=1}"
- RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=1.6857}"
- RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0}"
- RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=-0.343}"
- Source="img_tizen_home_menu_focused_bg.png"
- Opacity="0"
- Scale="0"/>
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=1}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=1.6857}"
+ RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0}"
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=-0.343}"
+ Source="img_tizen_home_menu_focused_bg.png"
+ Opacity="0"
+ Scale="0" />
+ <Image x:Name="ButtonBlurImage"
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=1}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=1.6857}"
+ RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0}"
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=-0.343}"
+ Source="home_icon_bg_01.png"
+ Scale="0.7"
+ Opacity="0" />
<Image x:Name="ButtonImage"
- RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.218}"
- RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
- RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.390}"
- RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
- Source="{Binding CurrentStateDescription.IconPath}" />
+ RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.218}"
+ RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
+ RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.390}"
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
+ Source="{Binding CurrentStateDescription.IconPath}" />
<Label x:Name="ButtonTitle"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.8739}"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0}"
LineBreakMode="TailTruncation"
HorizontalTextAlignment="Center"
Text="{Binding CurrentStateDescription.Label}" />
- <Button x:Name = "ButtonFocusArea"
+ <Button x:Name="ButtonFocusArea"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
Focused="OnFocused"
using System.Windows.Input;
using LibTVRefCommonPortable.Utils;
using Xamarin.Forms;
+using System.Threading.Tasks;
namespace TVHome.Controls
{
/// </summary>
public partial class MainPanelButton : PanelButton
{
+ public static readonly BindableProperty StatusProperty = BindableProperty.Create("Status", typeof(string), typeof(PanelButton), default(string));
+
+ public string Status
+ {
+ get { return (string)GetValue(StatusProperty); }
+ set { SetValue(StatusProperty, value); }
+ }
+
public MainPanelButton()
{
InitializeComponent();
+ PropertyChanged += MainPanelButton_PropertyChanged;
}
- public override async void OnFocused(object sender, FocusEventArgs e)
+ private async void MainPanelButton_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
- if (OnFocusedCommand != null)
+ if (e.PropertyName.CompareTo("Status") == 0)
{
- OnFocusedCommand.Execute("");
- }
+#pragma warning disable CS4014
+ switch (Status)
+ {
+ case "selected":
- if (ButtonTitle.Text.Equals("Apps"))
- {
- ButtonImage.Source = "ic_tizen_home_menu_apps_focused.png";
- }
- else if (ButtonTitle.Text.Equals("Recent"))
- {
- ButtonImage.Source = "ic_tizen_home_menu_recent_focused.png";
- }
- else
- {
- ButtonImage.Source = "ic_tizen_home_menu_settings_focused.png";
- }
+ ButtonBlurImage.Source = "home_icon_bg_01.png";
+ ButtonBgImage.FadeTo(0.875, 1);
+ await ButtonBlurImage.FadeTo(0.99, 1);
-#pragma warning disable CS4014
- ButtonTitle.FadeTo(0.8, 300);
- ButtonBgImage.FadeTo(0.99, 300);
- ButtonBgImage.ScaleTo(1.0, 300);
+ ButtonBlurImage.Source = "home_icon_bg_02.png";
+ ButtonBgImage.FadeTo(0.750, 1);
+ await ButtonBlurImage.FadeTo((1.0 - 0.01 * 2), 1);
+
+ ButtonBlurImage.Source = "home_icon_bg_03.png";
+ ButtonBgImage.FadeTo(0.625, 1);
+ await ButtonBlurImage.FadeTo((1.0 - 0.01 * 3), 1);
+
+ ButtonBlurImage.Source = "home_icon_bg_04.png";
+ ButtonBgImage.FadeTo(0.500, 1);
+ await ButtonBlurImage.FadeTo((1.0 - 0.01 * 4), 1);
+
+ ButtonBlurImage.Source = "home_icon_bg_05.png";
+ ButtonBgImage.FadeTo(0.375, 1);
+ await ButtonBlurImage.FadeTo((1.0 - 0.01 * 5), 1);
+
+ ButtonBlurImage.Source = "home_icon_bg_06.png";
+ ButtonBgImage.FadeTo(0.250, 1);
+ await ButtonBlurImage.FadeTo((1.0 - 0.01 * 6), 1);
+
+ ButtonBlurImage.Source = "home_icon_bg_07.png";
+ ButtonBgImage.FadeTo(0.125, 1);
+ await ButtonBlurImage.FadeTo((1.0 - 0.01 * 7), 1);
+
+ ButtonBlurImage.Source = "home_icon_bg_08.png";
+ ButtonBgImage.FadeTo(0.0, 1);
+ ButtonTitle.FadeTo(0.0, 1);
+ await ButtonBlurImage.FadeTo(0.0, 1);
+ break;
+ case "focused":
+ ButtonTitle.FadeTo(0.8, 100);
+ ButtonBgImage.FadeTo(0.99, 100);
+ ButtonBgImage.ScaleTo(1.0, 100);
+ await View.FadeTo(0.6, 100);
+ break;
+ default:
+ ButtonTitle.FadeTo(0, 100);
+ ButtonBgImage.FadeTo(0, 100);
+ ButtonBgImage.ScaleTo(0.01, 100);
+ await View.FadeTo(0.3, 100);
+ break;
+ }
#pragma warning restore CS4014
- await View.FadeTo(0.6, 300);
+ }
}
- public override async void OnUnfocused(object sender, FocusEventArgs e)
+ public override void OnFocused(object sender, FocusEventArgs e)
{
- if (ButtonTitle.Text.Equals("Apps"))
- {
- ButtonImage.Source = "ic_tizen_home_menu_apps_normal.png";
- }
- else if (ButtonTitle.Text.Equals("Recent"))
- {
- ButtonImage.Source = "ic_tizen_home_menu_recent_normal.png";
- }
- else
+ if (OnFocusedCommand != null)
{
- ButtonImage.Source = "ic_tizen_home_menu_settings_normal.png";
+ OnFocusedCommand.Execute("");
}
+ }
-#pragma warning disable CS4014
- ButtonTitle.FadeTo(0, 300);
- ButtonBgImage.FadeTo(0, 300);
- ButtonBgImage.ScaleTo(0.01, 300);
-#pragma warning restore CS4014
- await View.FadeTo(0.3, 300);
+ public override void OnUnfocused(object sender, FocusEventArgs e)
+ {
}
- public override async void OnClicked(object sender, EventArgs e)
+ public override void OnClicked(object sender, EventArgs e)
{
if (OnClickedCommand != null)
{
OnClickedCommand.Execute("");
}
-
- await View.FadeTo(0.9, 300);
}
}
}
{
public abstract class PanelButton : ViewCell
{
- public BindableProperty OnFocusedCommandProperty = BindableProperty.Create("OnFocusedCommand", typeof(ICommand), typeof(PanelButton));
- public ICommand OnFocusedCommand
- {
- get { return (ICommand)GetValue(OnFocusedCommandProperty); }
- set { SetValue(OnFocusedCommandProperty, value); }
- }
+ public ICommand OnFocusedCommand { get; set; }
- public BindableProperty OnClickedCommandProperty = BindableProperty.Create("OnClickedCommand", typeof(ICommand), typeof(PanelButton));
-
- public ICommand OnClickedCommand
- {
- get { return (ICommand)GetValue(OnClickedCommandProperty); }
- set { SetValue(OnClickedCommandProperty, value); }
- }
+ public ICommand OnClickedCommand { get; set; }
public abstract void OnFocused(object sender, FocusEventArgs e);
</Compile>\r
<Compile Include="TVHome.cs" />\r
<Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="ViewModels\IHomeViewModel.cs" />\r
<Compile Include="ViewModels\MainPageViewModel.cs" />\r
<Compile Include="Views\MainPage.xaml.cs">\r
<DependentUpon>MainPage.xaml</DependentUpon>\r
<Target Name="AfterBuild">\r
</Target>\r
-->\r
-</Project>\r
+</Project>
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TVHome.ViewModels
+{
+ interface IHomeViewModel
+ {
+ void OnPropertyChanged(string name);
+ void ChangeCurrentStatus(HomeStatus newStatus);
+ }
+}
namespace TVHome.ViewModels
{
- public class MainPageViewModel : INotifyPropertyChanged
+ public enum HomeStatus
+ {
+ Default = 0,
+ MainPanelFocused,
+ SubPanelFocused,
+ UnPin,
+ Move,
+ };
+ public enum HomeMenuItem
+ {
+ Recent = 0,
+ Apps,
+ Settings,
+ NotSelected,
+ };
+
+ public class MainPageViewModel : INotifyPropertyChanged, IHomeViewModel
{
public IEnumerable<ShortcutInfo> MainList { get; set; }
public IEnumerable<ShortcutInfo> RecentList { get; set; }
public IEnumerable<ShortcutInfo> AppList { get; set; }
public IEnumerable<ShortcutInfo> SettingsList { get; set; }
+ public Command MainPanelFocusedCommand { get; set; }
+ public Command SubPanelFocusedCommand { get; set; }
+ public Command SetMoveStatusCommand { get; set; }
+ public Command SetUnpinStatusCommand { get; set; }
+
+ public HomeStatus CurrentStatus { get; private set; }
+ public HomeMenuItem SelectedMenuName { get; private set; }
+
public event PropertyChangedEventHandler PropertyChanged;
- protected void OnPropertyChanged(string name)
+
+ public MainPageViewModel()
{
- PropertyChangedEventHandler handler = PropertyChanged;
- if (handler != null)
+ Init();
+ InitCommands();
+ MakeMainMenuItems();
+ MakeRecentButtons();
+
+ DebuggingUtils.Dbg("Reading Apps list");
+ TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetDefaultShortcuts();
+ OnPropertyChanged("AppList");
+ UpdateAppList(null, null);
+
+ //SettingsList = TVHomeImpl.GetInstance.AppShortcutControllerInstnace.ReadFromFile();
+ SettingsList = TVHomeImpl.GetInstance.SettingShortcutControllerInstance.GetList();
+ OnPropertyChanged("SettingsList");
+
+ TVHomeImpl.GetInstance.AppShortcutControllerInstance.AddFileSystemChangedListener(UpdateAppList);
+
+ App.SetAppPinnedNotificationListener((s, e) =>
{
- handler(this, new PropertyChangedEventArgs(name));
- }
+ // TODO : Make this for Move a pinned app/Show pinned apps(scroll to last)
+ if (e.arg.Length > 0)
+ {
+ DebuggingUtils.Dbg("Move, AppID : " + e.arg);
+ }
+ else
+ {
+ DebuggingUtils.Dbg("Show, Pinned Apps");
+ }
+ });
}
- public MainPageViewModel()
+ private void Init()
+ {
+ CurrentStatus = HomeStatus.Default;
+ SelectedMenuName = HomeMenuItem.NotSelected;
+ }
+
+ private void InitCommands()
+ {
+ MainPanelFocusedCommand = new Command<HomeMenuItem>((key) =>
+ {
+ DebuggingUtils.Dbg(key.ToString());
+ ChangeCurrentStatus(HomeStatus.MainPanelFocused);
+ ChangeSelectedPanelName(key);
+ });
+
+ SubPanelFocusedCommand = new Command(() =>
+ {
+ ChangeCurrentStatus(HomeStatus.SubPanelFocused);
+ });
+
+ SetMoveStatusCommand = new Command(() =>
+ {
+ ChangeCurrentStatus(HomeStatus.Move);
+ });
+
+ SetUnpinStatusCommand = new Command(() =>
+ {
+ ChangeCurrentStatus(HomeStatus.UnPin);
+ });
+ }
+
+ private void MakeMainMenuItems()
{
string[] AppName = { "Recent", "Apps", "Settings" };
// TODO : Revert this before release
//string[] AppControlID = { "org.tizen.settings", "org.tizen.apps", "org.tizen.settings" };
string[] AppControlID = { "org.tizen.settings", "org.tizen.example.TVApps.TizenTV", "org.tizen.settings" };
- string[] AppIconPath = { "ic_tizen_home_menu_recent_normal.png", "ic_tizen_home_menu_apps_normal.png", "ic_tizen_home_menu_settings_normal.png" };
+ string[] AppDefaultIconPath = { "ic_tizen_home_menu_recent_normal.png", "ic_tizen_home_menu_apps_normal.png", "ic_tizen_home_menu_settings_normal.png" };
+ string[] AppFocusedIconPath = { "ic_tizen_home_menu_recent_focused.png", "ic_tizen_home_menu_apps_focused.png", "ic_tizen_home_menu_settings_focused.png" };
+ string[] AppSelectedIconPath = { "ic_tizen_home_menu_recent_selected.png", "ic_tizen_home_menu_apps_selected.png", "ic_tizen_home_menu_settings_selected.png" };
+ string[] AppUnselectIconPath = { "ic_tizen_home_menu_recent_unselect.png", "ic_tizen_home_menu_apps_unselect.png", "ic_tizen_home_menu_settings_unselect.png" };
List<ShortcutInfo> TempList = new List<ShortcutInfo>();
for (int i = 0; i < 3; i++)
new StateDescription
{
Label = AppName[i],
- IconPath = AppIconPath[i],
+ IconPath = AppDefaultIconPath[i],
Action = new AppControlAction()
{
AppID = AppControlID[i]
}
}
},
- }
+ {
+ "focused",
+ new StateDescription
+ {
+ Label = AppName[i],
+ IconPath = AppFocusedIconPath[i],
+ Action = new AppControlAction()
+ {
+ AppID = AppControlID[i]
+ }
+ }
+ },
+ {
+ "selected",
+ new StateDescription
+ {
+ Label = AppName[i],
+ IconPath = AppSelectedIconPath[i],
+ Action = new AppControlAction()
+ {
+ AppID = AppControlID[i]
+ }
+ }
+ },
+ {
+ "unselect",
+ new StateDescription
+ {
+ Label = AppName[i],
+ IconPath = AppUnselectIconPath[i],
+ Action = new AppControlAction()
+ {
+ AppID = AppControlID[i]
+ }
+ }
+ },
+ },
};
shortcutInfo.UpdateState();
TempList.Add(shortcutInfo);
MainList = TempList;
OnPropertyChanged("MainList");
-
- MakeRecentButtons();
-
- DebuggingUtils.Dbg("Reading Apps list");
- AppList = TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetDefaultShortcuts();
- OnPropertyChanged("AppList");
- UpdateAppList(null, null);
-
- //SettingsList = TVHomeImpl.GetInstance.AppShortcutControllerInstnace.ReadFromFile();
- SettingsList = TVHomeImpl.GetInstance.SettingShortcutControllerInstance.GetList();
- OnPropertyChanged("SettingsList");
-
- TVHomeImpl.GetInstance.AppShortcutControllerInstance.AddFileSystemChangedListener(UpdateAppList);
-
- App.SetAppPinnedNotificationListener((s, e) =>
- {
- // TODO : Make this for Move a pinned app/Show pinned apps(scroll to last)
- if (e.arg.Length > 0)
- {
- DebuggingUtils.Dbg("Move, AppID : " + e.arg);
- }
- else
- {
- DebuggingUtils.Dbg("Show, Pinned Apps");
- }
- });
}
-
private async void UpdateAppList(object sender, EventArgs e)
{
AppList = await TVHomeImpl.GetInstance.AppShortcutControllerInstance.GetPinnedAppsWithDefaultShortcuts();
}
}
+ public void OnPropertyChanged(string name)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (handler != null)
+ {
+ handler(this, new PropertyChangedEventArgs(name));
+ }
+ }
+
+ public void ChangeCurrentStatus(HomeStatus newStatus)
+ {
+ if (CurrentStatus.CompareTo(newStatus) != 0)
+ {
+ CurrentStatus = newStatus;
+ if (CurrentStatus.CompareTo(HomeStatus.MainPanelFocused) == 0)
+ {
+ HomeMenuItem index = HomeMenuItem.Recent;
+ foreach (HomeMenuAppShortcutInfo item in MainList)
+ {
+ DebuggingUtils.Dbg(index.ToString());
+ if (index == SelectedMenuName)
+ {
+ DebuggingUtils.Dbg("To Focused");
+ item.ChangeStatus("focused");
+ }
+ else
+ {
+ DebuggingUtils.Dbg("To Default");
+ item.ChangeStatus("default");
+ }
+
+ index++;
+ }
+ }
+ else if (CurrentStatus.CompareTo(HomeStatus.SubPanelFocused) == 0)
+ {
+ HomeMenuItem index = HomeMenuItem.Recent;
+ foreach (HomeMenuAppShortcutInfo item in MainList)
+ {
+ DebuggingUtils.Dbg(index.ToString());
+ if (index == SelectedMenuName)
+ {
+ DebuggingUtils.Dbg("To be selected");
+ item.ChangeStatus("selected");
+ }
+ else
+ {
+ DebuggingUtils.Dbg("To be unselect");
+ item.ChangeStatus("unselect");
+ }
+
+ index++;
+ }
+ }
+
+ OnPropertyChanged("CurrentStatus");
+ }
+ }
+
+ public void ChangeSelectedPanelName(HomeMenuItem panelName)
+ {
+ if (SelectedMenuName.CompareTo(panelName) != 0)
+ {
+ SelectedMenuName = panelName;
+ HomeMenuItem index = HomeMenuItem.Recent;
+ foreach (HomeMenuAppShortcutInfo item in MainList)
+ {
+ DebuggingUtils.Dbg(index.ToString());
+ if (index == panelName)
+ {
+ DebuggingUtils.Dbg("To Focused");
+ item.ChangeStatus("focused");
+ }
+ else
+ {
+ DebuggingUtils.Dbg("To Default");
+ item.ChangeStatus("default");
+ }
+
+ index++;
+ }
+
+ OnPropertyChanged("SelectedMenuName");
+ }
+ }
}
}
xmlns:Views="clr-namespace:TVHome.Views"
xmlns:ViewModels="clr-namespace:TVHome.ViewModels"
xmlns:Controls="clr-namespace:TVHome.Controls"
- Appearing="OnAppearing">
+ Appearing="OnAppearing"
+ BackgroundImage="background.jpg"
+ CurrentStatus="{Binding CurrentStatus}"
+ SelectedMenuName="{Binding SelectedMenuName}">
<ContentPage.BindingContext>
<ViewModels:MainPageViewModel />
</ContentPage.BindingContext>
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.21875}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.6537}"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.390625}"
+ OnFocusedCommand="{Binding MainPanelFocusedCommand}"
ItemsSource="{Binding MainList}"/>
<Views:SubThumbnailPanel x:Name="RecentSubPanel"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.224}"
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>
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.2370}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8981}"
+ OnFocusedCommand="{Binding SubPanelFocusedCommand}"
ItemsSource="{Binding AppList}">
</Views:SubPanel>
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.2370}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.8981}"
+ OnFocusedCommand="{Binding SubPanelFocusedCommand}"
ItemsSource="{Binding SettingsList}">
<Views:SubPanel.ItemTemplate>
<DataTemplate>
-/*
+/*
* Copyright (c) 2017 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
using LibTVRefCommonPortable.Models;
using LibTVRefCommonPortable.Utils;
using Xamarin.Forms;
+using TVHome.ViewModels;
+using System.Linq;
namespace TVHome.Views
{
/// </summary>
public partial class MainPage : ContentPage
{
+ public static readonly BindableProperty CurrentStatusProperty = BindableProperty.Create("CurrentStatus", typeof(HomeStatus), typeof(MainPage), default(HomeStatus));
+ public HomeStatus CurrentStatus
+ {
+ get { return (HomeStatus)GetValue(CurrentStatusProperty); }
+ set { SetValue(CurrentStatusProperty, value); }
+ }
+
+ public static readonly BindableProperty SelectedMenuNameProperty = BindableProperty.Create("SelectedMenuName", typeof(HomeMenuItem), typeof(MainPage), default(HomeMenuItem));
+ public HomeMenuItem SelectedMenuName
+ {
+ get { return (HomeMenuItem)GetValue(SelectedMenuNameProperty); }
+ set { SetValue(SelectedMenuNameProperty, value); }
+ }
- private Dictionary<string, Panel> SubPanelDictionary;
- private Panel currentSubPanel;
- public ICommand ChangeSubPanelCommand;
+ private Dictionary<HomeMenuItem, Panel> SubPanelDictionary;
private async void PlayHideAnimation()
{
- currentSubPanel?.TranslateTo(0.0, 100, 150);
+ SubPanelDictionary[SelectedMenuName]?.TranslateTo(0.0, 100, 150);
await PageMainPanel.ScaleTo(0.0, 150);
}
private async void PlayShowAnimation()
{
- currentSubPanel?.TranslateTo(0.0, 0.0, 150);
+ SubPanelDictionary[SelectedMenuName]?.TranslateTo(0.0, 0.0, 150);
await PageMainPanel.ScaleTo(1.0, 150);
}
public MainPage()
{
InitializeComponent();
- SubPanelDictionary = new Dictionary<string, Panel>();
- SubPanelDictionary.Add("Recent", RecentSubPanel);
- SubPanelDictionary.Add("Apps", AppsSubPanel);
- SubPanelDictionary.Add("Settings", SettingsSubPanel);
+ SubPanelDictionary = new Dictionary<HomeMenuItem, Panel>();
+ SubPanelDictionary.Add(HomeMenuItem.Recent, RecentSubPanel);
+ SubPanelDictionary.Add(HomeMenuItem.Apps, AppsSubPanel);
+ SubPanelDictionary.Add(HomeMenuItem.Settings, SettingsSubPanel);
+ PropertyChanged += MainPage_PropertyChanged;
- App.SetHomeKeyListener((e, arg) => {
+ App.SetHomeKeyListener((e, arg) =>
+ {
DebuggingUtils.Dbg("FIRED!!");
if (IsVisible)
{
}
});
- PageMainPanel.OnFocusedCommand = new Command<string>((key) =>
+ AppsSubPanel.OnUnpinCommand = new Command<string>((appId) =>
{
- DebuggingUtils.Dbg("MainPage : " + key);
- foreach (KeyValuePair<string, Panel> aPair in SubPanelDictionary)
- {
- if (aPair.Key != key)
- aPair.Value.HidePanel();
- else
- {
- currentSubPanel = aPair.Value;
- currentSubPanel.ShowPanel();
- }
- }
+ UnpinAppShortcutInfo(appId);
});
+ }
- RecentSubPanel.OnFocusedCommand = new Command(() =>
+ private void MainPage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ DebuggingUtils.Dbg(e.PropertyName);
+ if (e.PropertyName.CompareTo("CurrentStatus") == 0)
{
- PageMainPanel.SelectPanel();
- });
+ SetCurrentStatus(CurrentStatus);
+ }
+ else if (e.PropertyName.CompareTo("SelectedMenuName") == 0)
+ {
+ SelectMenu(SelectedMenuName);
+ }
+ }
- AppsSubPanel.OnFocusedCommand = new Command(() =>
+ private void SetCurrentStatus(HomeStatus status)
+ {
+ switch (status)
{
- PageMainPanel.SelectPanel();
- });
+ case HomeStatus.Default:
+ break;
+ case HomeStatus.MainPanelFocused:
+ PageMainPanel.ShowPanel();
+ SelectMenu(SelectedMenuName);
+ break;
+ case HomeStatus.SubPanelFocused:
+ PageMainPanel.SelectPanel();
+ break;
+ case HomeStatus.Move:
+ break;
+ case HomeStatus.UnPin:
+ break;
+ }
+ }
- AppsSubPanel.OnUnpinCommand = new Command<string>((appId) =>
+ private void SelectMenu(HomeMenuItem panelName)
+ {
+ if (panelName == HomeMenuItem.NotSelected)
{
- UnpinAppShortcutInfo(appId);
- });
+ return;
+ }
+
+ IEnumerable<Panel> panels = from pair in SubPanelDictionary
+ where pair.Key != panelName
+ select pair.Value;
- SettingsSubPanel.OnFocusedCommand = new Command(() =>
+ foreach (Panel panel in panels)
{
- PageMainPanel.SelectPanel();
- });
+ panel.HidePanel();
+ }
+
+ SubPanelDictionary[panelName].ShowPanel();
}
private void OnAppearing(object sender, EventArgs e)
}
}
}
-}
+}
\ No newline at end of file
using LibTVRefCommonPortable.Utils;
using TVHome.ViewModels;
using Xamarin.Forms;
+using System.Threading.Tasks;
namespace TVHome.Views
{
return;
}
+ HomeMenuItem menuIndex = HomeMenuItem.Recent;
var index = 0;
PanelButtonGrid.Children.Clear();
foreach (ShortcutInfo item in ItemsSource)
{
var button = new MainPanelButton();
button.View.BindingContext = item;
+ button.SetBinding(MainPanelButton.StatusProperty, new Binding("BindingContext.Status", source: button.View));
+ HomeMenuItem ItemName = menuIndex;
button.OnFocusedCommand = new Command(() =>
{
FocusPanel();
- OnFocusedCommand.Execute(item.StateDescriptions["default"].Label);
+ OnFocusedCommand.Execute(ItemName);
});
button.OnClickedCommand = new Command(() =>
{
item.DoAction();
});
- PanelButtonGrid.Children.Add(button.View, index++, 0);
+ PanelButtonGrid.Children.Add(button.View, index, 0);
+
+ index++;
+ menuIndex++;
}
}
public override async void FocusPanel()
{
- await PanelButtonGrid.TranslateTo(0, 0);
+ await this.TranslateTo(0, 0, 300);
}
public override async void HidePanel()
{
- await PanelButtonGrid.ScaleTo(0, 0);
+ await this.ScaleTo(0, 0);
}
public async void SelectPanel()
{
- await PanelButtonGrid.TranslateTo(0, -78);
+ await Task.Delay(300);
+ await this.TranslateTo(0, -78, 300);
}
public override async void ShowPanel()
{
- await PanelButtonGrid.ScaleTo(1, 0);
+ await this.ScaleTo(1, 0);
}
}
}
\ No newline at end of file
get { return (ICommand)GetValue(OnUnpinCommandProperty); }
set { SetValue(OnUnpinCommandProperty, value); }
}
+
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(IEnumerable<ShortcutInfo>), typeof(MainPanel));
public IEnumerable<ShortcutInfo> ItemsSource
using TVHome.ViewModels;
using Xamarin.Forms;
using LibTVRefCommonPortable.Utils;
+using System.Threading.Tasks;
namespace TVHome.Views
{
button = new SubPanelReservedButton();
}
else
- {
+ {
button = new SubPanelButton();
- }
+ }
button.View.BindingContext = item;
button.OnFocusedCommand = new Command(() =>
item.FindByName<Image>("ButtonDimmedImage").Opacity = 0;
}
+ await Task.Delay(300);
#pragma warning disable CS4014
this.TranslateTo(0, -146, 300);
#pragma warning restore CS4014