<RelativeLayout x:Name="AppListGrid"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0}"
- RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}">
+ RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
+ HorizontalOptions="Start">
<StackLayout x:Name="AppUpperList"
IsVisible="False"
}
/// <summary>
- /// Identifies the ItemTemplate bindable property
- /// </summary>
- public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create("ItemTemplate", typeof(DataTemplate), typeof(AppListView), default(DataTemplate));
-
- /// <summary>
- /// Gets or sets template of list items
- /// </summary>
- public DataTemplate ItemTemplate
- {
- get { return (DataTemplate)GetValue(ItemTemplateProperty); }
- set { SetValue(ItemTemplateProperty, value); }
- }
-
- /// <summary>
/// A count of items in list
/// </summary>
private int AppCount;
/// </summary>
public ICommand OnChangeFocusChainingCommand { get; set; }
+ public EventHandler<ScrolledEventArgs> ScrollPositionChanged;
+
/// <summary>
/// A constructor
/// Adds PropertyChanged event handler
AppCount = 0;
AppUpperList.Children.Clear();
AppLowerList.Children.Clear();
- if (ItemTemplate == null || ItemsSource == null)
+
+ foreach (var item in ItemsSource)
{
- return;
- }
+ var viewCell = new AppItemCell();
+ viewCell.BindingContext = item;
+ viewCell.OnClickedCommand = new Command(() =>
+ {
+ item.DoAction();
+ });
+ var index = AppCount / 2;
+ viewCell.OnFocusedCommand = new Command(() =>
+ {
+ ScrollToIndex(index);
+ });
+
+ if (AppCount % 2 == 0)
+ {
+ Device.BeginInvokeOnMainThread(() => AppUpperList.Children.Add(viewCell));
+ }
+ else
+ {
+ Device.BeginInvokeOnMainThread(() => AppLowerList.Children.Add(viewCell));
+ }
+ AppCount = AppCount + 1;
+
+ }
foreach (var item in ItemsSource)
{
var viewCell = new AppItemCell();
if (AppCount % 2 == 0)
{
- AppUpperList.Children.Add(viewCell);
+ Device.BeginInvokeOnMainThread(() => AppUpperList.Children.Add(viewCell));
}
else
{
- AppLowerList.Children.Add(viewCell);
+ Device.BeginInvokeOnMainThread(() => AppLowerList.Children.Add(viewCell));
}
AppCount = AppCount + 1;
+
}
if (AppCount > 0)
var lowerDistance = Math.Abs(ScrollX - lowerScrollX);
var upperDistance = Math.Abs(ScrollX - upperScrollX);
- if (lowerDistance > upperDistance)
- {
- await Task.Delay(1);
- await ScrollToAsync(upperScrollX, 0, true);
- }
- else
- {
- await Task.Delay(1);
- await ScrollToAsync(lowerScrollX, 0, true);
- }
+ var scrollPositionX = lowerDistance > upperDistance ? upperScrollX : lowerScrollX;
+ ScrollPositionChanged?.Invoke(this, new ScrolledEventArgs(scrollPositionX, 0));
+
+ await Task.Delay(1);
+ await ScrollToAsync(scrollPositionX, 0, true);
}
}
/// <summary>
/// The drop down list of sort options
/// </summary>
- private DropdownList SortButton;
+ public DropdownList SortList { get; private set; }
/// <summary>
/// The Option button object
/// </summary>
- private Button OptionButton;
+ public Button OptionButton { get; private set; }
/// <summary>
/// Identifies the PinAppCommand bindable property
}
/// <summary>
- /// Gets Sort DropdownList
- /// </summary>
- /// <returns>Returns Sort DropdownList</returns>
- public DropdownList GetSortDropdownList()
- {
- return SortButton;
- }
-
- /// <summary>
/// Creates Option Button
/// </summary>
private void CreateOptionButton()
{
List<string> SortList = new List<string> { "NEWEST", "A - Z", "Z - A" };
- SortButton = new DropdownList();
- SortButton.ItemsSource = SortList;
- SortButton.SelectedItem = SortList[0];
+ this.SortList = new DropdownList();
+ this.SortList.ItemsSource = SortList;
+ this.SortList.SelectedItem = SortList[0];
- SortButton.Expanded += (s, e) =>
+ this.SortList.Expanded += (s, e) =>
{
- ChangeBackKeyInfoCommand?.Execute(SortButton.IsExpanded);
+ ChangeBackKeyInfoCommand?.Execute(this.SortList.IsExpanded);
};
- SortButton.Collapsed += (s, e) =>
+ this.SortList.Collapsed += (s, e) =>
{
- ChangeBackKeyInfoCommand?.Execute(SortButton.IsExpanded);
+ ChangeBackKeyInfoCommand?.Execute(this.SortList.IsExpanded);
};
- SortButton.ItemSelected += (s, e) =>
+ this.SortList.ItemSelected += (s, e) =>
{
if (SortList.Contains(e.SelectedItem.ToString()))
{
}
};
- this.Children.Add(SortButton,
+ this.Children.Add(this.SortList,
heightConstraint: Constraint.Constant(SizeUtils.GetHeightSize(80)),
widthConstraint: Constraint.Constant(SizeUtils.GetWidthSize(300)),
yConstraint: Constraint.Constant(SizeUtils.GetHeightSize(662)),
</StackLayout>
</Grid>
- <Controls:AppListView x:Name="AppList"
+ <Controls:AppListView x:Name="AppList"
Grid.Row="1"
Grid.RowSpan="4"
- ItemsSource="{Binding InstalledAppList}">
- <Controls:AppListView.ItemTemplate>
- <DataTemplate>
- <Controls:AppItemCell/>
- </DataTemplate>
- </Controls:AppListView.ItemTemplate>
- </Controls:AppListView>
+ ItemsSource="{Binding InstalledAppList}"/>
- <BoxView x:Name="PageDimBox"
+
+ <BoxView x:Name="PageDimBox"
Color="Black"
Grid.Row="0"
Grid.RowSpan="7"
namespace TVApps.Views
{
+ using System;
using Tizen = Xamarin.Forms.PlatformConfiguration.Tizen;
/// <summary>
/// A custom view for displaying main page of TV Apps
AppList.InitializeFocus();
});
+ AppList.ScrollPositionChanged += OnScrollPositionChanged;
+
FooterNormal.ChangeBackKeyInfoCommand = new Command<bool>((isShowingPopup) =>
{
if (isShowingPopup)
});
}
+ private void OnScrollPositionChanged(object sender, ScrolledEventArgs e)
+ {
+ SetFocusChainingWithCurrentStatus(CurrentStatus, e.ScrollX);
+ }
+
/// <summary>
/// A method for customizing behavior immediately prior to the Page becoming visible
/// Sets focus chain and Moves focus to first App icon
}
}
- SetFocusChainingWithCurrentStatus(CurrentStatus);
+ SetFocusChainingWithCurrentStatus(CurrentStatus, 0);
}
/// <summary>
/// <summary>
/// A method for setting focus chain list with FooterNormalStatus
/// </summary>
- private void SetFocusChainingUpAndDownForDefaultMode()
+ private void SetFocusChainingUpAndDownForDefaultMode(double scrollX)
{
- List<View> lowerList = AppList.GetAppsLowerList().ToList();
- DropdownList sortList = FooterNormal.GetSortDropdownList();
-
- foreach (var item in lowerList)
+ var FocusableList = AppList.GetAppsLowerList().ToList().FindAll((item) =>
+ {
+ return scrollX <= item.X && (scrollX + 1920) >= item.X + item.Width;
+ });
+ DebuggingUtils.Dbg("FOCUSTEST" + FocusableList.Count + " // ");
+ foreach (var item in FocusableList)
{
Button button = item.FindByName<Button>("ButtonFocusArea");
- button?.On<Tizen>()?.SetNextFocusDownView(sortList);
+ button?.On<Tizen>()?.SetNextFocusDownView(FooterNormal.SortList);
+ }
+
+ if (FocusableList.Count == 7)
+ {
+ Button button = FocusableList.Last().FindByName<Button>("ButtonFocusArea");
+ button?.On<Tizen>()?.SetNextFocusDownView(FooterNormal.OptionButton);
}
}
/// <summary>
/// A method for setting focus chain list with FooterDeleteStatus
/// </summary>
- private void SetFocusChainingUpAndDownForDeleteMode()
+ private void SetFocusChainingUpAndDownForDeleteMode(double scrollX)
{
List<View> lowerList = AppList.GetAppsLowerList().ToList();
Button cancelButton = FooterDelete.GetCancelButton();
/// <summary>
/// A method for setting focus chain list with FooterPinStatus
/// </summary>
- private void SetFocusChainingUpAndDownForPinMode()
+ private void SetFocusChainingUpAndDownForPinMode(double scrollX)
{
List<View> lowerList = AppList.GetAppsLowerList().ToList();
Button doneButton = FooterPin.GetDoneButton();
/// A method for changing focus chain list by Status
/// </summary>
/// <param name="status">The TVApps Application status</param>
- private void SetFocusChainingWithCurrentStatus(AppsStatus status)
+ private void SetFocusChainingWithCurrentStatus(AppsStatus status, double scrollX)
{
switch (status)
{
case AppsStatus.Pin:
- SetFocusChainingUpAndDownForPinMode();
+ SetFocusChainingUpAndDownForPinMode(scrollX);
break;
case AppsStatus.Delete:
- SetFocusChainingUpAndDownForDeleteMode();
+ SetFocusChainingUpAndDownForDeleteMode(scrollX);
break;
default:
- SetFocusChainingUpAndDownForDefaultMode();
+ SetFocusChainingUpAndDownForDefaultMode(scrollX);
break;
}
}
return true;
}
- DropdownList sortList = FooterNormal.GetSortDropdownList();
+ DropdownList sortList = FooterNormal.SortList;
if (sortList.IsExpanded)
{
sub.OnStateChanged(currentState);
}
+ OnPropertyChanged("CurrentState");
}
}