using System.Threading.Tasks;
using System.Windows.Input;
using System.Collections.Generic;
+using System.Linq;
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using TVApps.Controls;
+using Tizen.Xamarin.Forms.Extension;
namespace TVApps.Views
{
+ using Tizen = Xamarin.Forms.PlatformConfiguration.Tizen;
/// <summary>
/// A custom view for displaying main page of TV Apps
/// </summary>
public partial class MainPage : ContentPage
{
+ private DropdownList sortList;
+ private Button doneButton;
+ private Button cancelButton;
+
/// <summary>
/// SubPanel icon's transition height value when it focused.
/// </summary>
PageDimBox.IsVisible = false;
await Task.Delay(1);
AppList.InitializeFocus();
+
+ List<View> upperList = AppList.GetAppsUpperList().ToList();
+ List<View> lowerList = AppList.GetAppsLowerList().ToList();
+
+ int upperCount = upperList.Count;
+ int lowerCount = lowerList.Count;
+
+ Button prevButton;
+ Button button;
+ Button nextButton;
+
+ for (int i = 1; i < upperCount-1; i++)
+ {
+ prevButton = upperList[i-1].FindByName<Button>("ButtonFocusArea");
+ button = upperList[i].FindByName<Button>("ButtonFocusArea");
+ nextButton = upperList[i + 1].FindByName<Button>("ButtonFocusArea");
+
+ SetFocusChainingLeftAndRight(prevButton, button);
+ SetFocusChainingLeftAndRight(button, nextButton);
+
+ if (i == 1)
+ {
+ prevButton?.On<Tizen>()?.SetNextFocusDownView(
+ lowerList[i - 1].FindByName<Button>("ButtonFocusArea"));
+ }
+
+ button?.On<Tizen>()?.SetNextFocusDownView(
+ lowerList[i].FindByName<Button>("ButtonFocusArea"));
+
+ if (i == upperCount-2)
+ {
+ button?.On<Tizen>()?.SetNextFocusDownView(lowerList[i].FindByName<Button>("ButtonFocusArea"));
+
+ nextButton?.On<Tizen>()?.SetNextFocusRightView(nextButton);
+ nextButton?.On<Tizen>()?.SetNextFocusDownView(
+ lowerList[lowerCount - 1].FindByName<Button>("ButtonFocusArea"));
+ }
+ }
+
+ for (int i = 1; i < lowerCount - 1; i++)
+ {
+ prevButton = lowerList[i - 1].FindByName<Button>("ButtonFocusArea");
+ button = lowerList[i].FindByName<Button>("ButtonFocusArea");
+ nextButton = lowerList[i + 1].FindByName<Button>("ButtonFocusArea");
+
+ SetFocusChainingLeftAndRight(prevButton, button);
+ SetFocusChainingLeftAndRight(button, nextButton);
+
+ if (i == 1)
+ {
+ prevButton?.On<Tizen>()?.SetNextFocusUpView(
+ upperList[i - 1].FindByName<Button>("ButtonFocusArea"));
+ }
+
+ button?.On<Tizen>()?.SetNextFocusUpView(
+ upperList[i].FindByName<Button>("ButtonFocusArea"));
+
+ if (i == lowerCount-2)
+ {
+ nextButton?.On<Tizen>()?.SetNextFocusUpView(upperList[i+1].FindByName<Button>("ButtonFocusArea"));
+
+ if (upperCount > lowerCount)
+ {
+ nextButton?.On<Tizen>()?.SetNextFocusRightView(upperList[upperCount-1].FindByName<Button>("ButtonFocusArea"));
+ }
+ else
+ {
+ nextButton?.On<Tizen>()?.SetNextFocusRightView(nextButton);
+ }
+ }
+ }
+
+ SetFocusChainingUpAndDownForDefaultMode();
+ }
+
+ private void SetFocusChainingLeftAndRight(Button left, Button right)
+ {
+ left?.On<Tizen>()?.SetNextFocusRightView(right);
+ right?.On<Tizen>()?.SetNextFocusLeftView(left);
+ }
+
+ private void SetFocusChainingUpAndDownForDefaultMode()
+ {
+ List<View> lowerList = AppList.GetAppsLowerList().ToList();
+ sortList = FooterNormal.GetSortDropdownList();
+
+ foreach (var item in lowerList)
+ {
+ Button button = item.FindByName<Button>("ButtonFocusArea");
+ button?.On<Tizen>()?.SetNextFocusDownView(sortList);
+ }
+ }
+
+ private void SetFocusChainingUpAndDownForDeleteMode()
+ {
+ List<View> lowerList = AppList.GetAppsLowerList().ToList();
+ cancelButton = FooterDelete.GetCancelButton();
+
+ foreach (var item in lowerList)
+ {
+ Button button = item.FindByName<Button>("ButtonFocusArea");
+ button?.On<Tizen>()?.SetNextFocusDownView(cancelButton);
+ }
+ }
+
+ private void SetFocusChainingUpAndDownForPinMode()
+ {
+ List<View> lowerList = AppList.GetAppsLowerList().ToList();
+ doneButton = FooterPin.GetDoneButton();
+
+ foreach (var item in lowerList)
+ {
+ Button button = item.FindByName<Button>("ButtonFocusArea");
+ button?.On<Tizen>()?.SetNextFocusDownView(doneButton);
+ }
}
/// <summary>
FooterDelete.IsVisible = false;
BackKeyInfo.Text = "Quit";
AppList.InitializeFocus();
+ SetFocusChainingUpAndDownForDefaultMode();
break;
case AppsStatus.Pin:
FooterNormal.IsVisible = false;
FooterPin.IsVisible = true;
FooterDelete.IsVisible = false;
+ SetFocusChainingUpAndDownForPinMode();
BackKeyInfo.Text = "Back";
break;
case AppsStatus.Delete:
FooterNormal.IsVisible = false;
FooterPin.IsVisible = false;
FooterDelete.IsVisible = true;
+ SetFocusChainingUpAndDownForDeleteMode();
BackKeyInfo.Text = "Back";
break;
case AppsStatus.LongPress: