}
/// <summary>
- /// A method for changing the button's LayoutOptions according to parameter
+ /// A method for showing context popup
/// </summary>
- /// <param name="isMoveMode">A flag indicates whether the SubPanel is MoveMode or not</param>
- public override void ChangeLayoutOptions(bool isMoveMode)
+ public override void ShowContextPopup()
{
}
- /// <summary>
- /// A method for showing context popup
- /// </summary>
- public override void ShowContextPopup()
+ public override void ChangeShowOptionsMode(bool showOptions)
{
}
}
{
public bool isMoveMode;
public bool isFocused;
+ public bool isShowOptions;
+ public bool rightMoving;
+ public bool leftMoving;
/// <summary>
/// A Command will be executed the button is focused.
/// </summary>
/// </summary>
public ICommand OnClearAllCommand { get; set; }
+ public ICommand OnDefaultModeCommand { get; set; }
+
/// <summary>
/// Handles Button Focused event
/// </summary>
public abstract void ChangeMoveMode(bool isMoveMode, bool isDefault);
/// <summary>
- /// A method for changing the button's LayoutOptions according to parameter
- /// </summary>
- /// <param name="isMoveMode">A flag indicates whether the SubPanel is MoveMode or not</param>
- public abstract void ChangeLayoutOptions(bool isMoveMode);
-
- /// <summary>
/// A method for showing context popup
/// </summary>
public abstract void ShowContextPopup();
+
+ public abstract void ChangeShowOptionsMode(bool isShowOptions);
}
}
xmlns:Controls="clr-namespace:TVHome.Controls"
x:Class="TVHome.Controls.SubPanelAllAppsButton">
<RelativeLayout x:Name="ButtonBox"
- HorizontalOptions="Center">
+ HorizontalOptions="Center"
+ VerticalOptions="End">
<Image x:Name="ButtonImage"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.120879}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.095652}"
}
/// <summary>
- /// A method for changing the button's LayoutOptions according to parameter
+ /// A method for showing context popup
/// </summary>
- /// <param name="isMoveMode">A flag indicates whether the SubPanel is MoveMode or not</param>
- public override void ChangeLayoutOptions(bool isMoveMode)
+ public override void ShowContextPopup()
{
- if (isMoveMode)
- {
- View.VerticalOptions = LayoutOptions.End;
- }
- else
- {
- View.VerticalOptions = LayoutOptions.Start;
- }
-
- View.TranslateTo(0, 0, 0);
}
- /// <summary>
- /// A method for showing context popup
- /// </summary>
- public override void ShowContextPopup()
+ public override void ChangeShowOptionsMode(bool showOptions)
{
}
}
xmlns:Controls="clr-namespace:TVHome.Controls"
x:Class="TVHome.Controls.SubPanelButton">
<RelativeLayout x:Name="ButtonBox"
- HorizontalOptions="Center">
+ HorizontalOptions="Center"
+ VerticalOptions="End">
<Image x:Name="ButtonImage"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.120879}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.095652}"
public partial class SubPanelButton : PanelButton
{
/// <summary>
- /// A flag which enable showing a popup
- /// </summary>
- private bool isPopupShowing = false;
-
- /// <summary>
/// SubPanel icon's transition height value when it focused.
/// </summary>
private int selectTransitionHeight = SizeUtils.GetHeightSize(22);
{
if (isMoveMode && IsEnabled)
{
- OnMoveCommand.Execute(e);
+ OnMoveCommand?.Execute(e);
}
});
/// </summary>
public override void ShowContextPopup()
{
- if (isPopupShowing)
+ if (isShowOptions)
{
return;
}
if (ctxPopup.SelectedIndex == 0)
{
OnMoveFinishedCommand.Execute("");
- ctxPopup.Dismiss();
}
else if (ctxPopup.SelectedIndex == 1)
{
OnUnpinCommand.Execute("");
- ctxPopup.Dismiss();
}
+
+ popup.Dismiss();
};
popup.Dismissed += (sender, args) =>
{
- isPopupShowing = false;
+ var ctxPopup = sender as ContextPopup;
+ isShowOptions = false;
+
+ if (ctxPopup.SelectedIndex == -1)
+ {
+ OnDefaultModeCommand.Execute("");
+ }
};
- popup.Show(View);
- isPopupShowing = true;
+ popup.Show(View, View.Width / 2, View.Height - (moveTransitionHeight + selectTransitionHeight));
+ ButtonTitle.FadeTo(0, 300);
+ isShowOptions = true;
}
/// <param name="isDefault">A flag indicates whether this method is called by ChangeToDefaultMode method</param>
public override async void ChangeMoveMode(bool moveMode, bool isDefault)
{
+ isMoveMode = moveMode;
+
#pragma warning disable CS4014
if (moveMode)
{
ButtonTitle.FadeTo(0, 300);
- View.TranslateTo(0, -moveTransitionHeight, 300);
- ButtonImage.ScaleTo(1, 300);
- isMoveMode = true;
for (int i = 0; i < 2; i++)
{
}
else
{
- isMoveMode = false;
if (!isDefault)
{
View.TranslateTo(SizeUtils.GetWidthSize((int)View.TranslationX), 0, 300);
}
else
{
+ await View.TranslateTo(0, SizeUtils.GetHeightSize((int)View.TranslationY), 0);
View.TranslateTo(0, 0, 300);
}
OnFocused(null, null);
- LeftBtnImg.FadeTo(0, 300);
- await RightBtnImg.FadeTo(0, 300);
}
#pragma warning restore CS4014
}
- /// <summary>
- /// A method for changing the button's LayoutOptions according to parameter
- /// </summary>
- /// <param name="isMoveMode">A flag indicates whether the SubPanel is MoveMode or not</param>
- public override void ChangeLayoutOptions(bool isMoveMode)
+ public override async void ChangeShowOptionsMode(bool showOptions)
{
- if (isMoveMode)
+ if (showOptions)
{
- View.VerticalOptions = LayoutOptions.End;
+ View.TranslateTo(0, -moveTransitionHeight, 300);
+ ButtonImage.ScaleTo(1, 300);
}
else
{
- View.VerticalOptions = LayoutOptions.Start;
+ await View.TranslateTo(0, 0, 300);
}
-
- View.TranslateTo(0, 0, 0);
}
/// <summary>
#pragma warning disable CS4014
ButtonTitle.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetFontWeight(FontWeight.Medium);
- ButtonTitle.FadeTo(0.99, 300);
+ ButtonTitle.FadeTo(0.8, 300);
ButtonTitle.TranslateTo(0, selectTransitionHeight, 300);
#pragma warning restore CS4014
await ButtonImage.ScaleTo(1.3, 300);
{
isFocused = false;
- if (!isMoveMode)
+ if (!isMoveMode && !isShowOptions)
{
#pragma warning disable CS4014
ButtonTitle.On<Xamarin.Forms.PlatformConfiguration.Tizen>().SetFontWeight(FontWeight.Normal);
- ButtonTitle.FadeTo(0.5, 300);
+ ButtonTitle.FadeTo(0.6, 300);
ButtonTitle.TranslateTo(0, 0, 300);
#pragma warning restore CS4014
await ButtonImage.ScaleTo(1, 300);
xmlns:Controls="clr-namespace:TVHome.Controls"
x:Class="TVHome.Controls.SubPanelSettingButton">
<RelativeLayout x:Name="ButtonBox"
- HorizontalOptions="Center" >
+ HorizontalOptions="Center"
+ VerticalOptions="End">
<Image x:Name="ButtonImage"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Width, Factor=0.120879}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=ButtonBox, Property=Height, Factor=0.095652}"
}
/// <summary>
- /// A method for changing the button's LayoutOptions according to parameter
+ /// A method for showing Context popup
/// </summary>
- /// <param name="isMoveMode">A flag indicates whether the SubPanel is MoveMode or not</param>
- public override void ChangeLayoutOptions(bool isMoveMode)
+ public override void ShowContextPopup()
{
}
- /// <summary>
- /// A method for showing Context popup
- /// </summary>
- public override void ShowContextPopup()
+ public override void ChangeShowOptionsMode(bool showOptions)
{
}
}
}
/// <summary>
- /// A method for changing the button's LayoutOptions according to parameter
- /// </summary>
- /// <param name="isMoveMode">A flag indicates whether the SubPanel is MoveMode or not</param>
- public override void ChangeLayoutOptions(bool isMoveMode)
- {
- }
-
- /// <summary>
/// A method for showing Context popup
/// </summary>
public override void ShowContextPopup()
popup.Show(View);
isPopupShowing = true;
}
+
+ public override void ChangeShowOptionsMode(bool showOptions)
+ {
+ }
}
}
\ No newline at end of file
ToggleIconified();
});
- AppsSubPanel.OnMoveCommand = new Command<bool>((isMoveMode) =>
+ AppsSubPanel.OnShowOptionsCommand = new Command<bool>((isShowOptions) =>
{
var bounds = AppsSubPanel.Bounds;
- if (isMoveMode)
+ if (isShowOptions)
{
PageMainPanel.FadeTo(0, 300);
PageMainPanel.IsVisible = false;
}
else
{
- PageMainPanel.IsVisible = true;
PageMainPanel.FadeTo(1, 300);
bounds.Height -= 300;
bounds.Y += 300;
+ PageMainPanel.IsVisible = true;
}
- AppsSubPanel.LayoutTo(bounds, 300);
+ AppsSubPanel.LayoutTo(bounds, 0);
});
MessagingCenter.Subscribe<App, TVHomeStatus>(this, App.AppStatus, (sender, arg) =>
/// <returns>Always returns true</returns>
protected override bool OnBackButtonPressed()
{
- if (AppsSubPanel.isMoveMode)
+ if (AppsSubPanel.isMoveMode || AppsSubPanel.isShowOptions)
{
AppsSubPanel.ChangeToDefaultMode();
}
/// </summary>
public bool isMoveMode;
+ public bool isShowOptions;
+
/// <summary>
/// A method for handling panel focused event
/// </summary>
private List<View> ButtonViewList;
/// <summary>
- /// A Command will be executed the button is moved.
+ /// A Command will be executed the option menus are showed.
/// </summary>
- public ICommand OnMoveCommand { get; set; }
+ public ICommand OnShowOptionsCommand { get; set; }
/// <summary>
/// SubPanel icon's transition height value when it focused.
InitializeComponent();
isFocused = false;
isMoveMode = false;
+ isShowOptions = false;
ButtonList = new List<PanelButton>();
ButtonViewList = new List<View>();
MessagingCenter.Subscribe<App>(this, "MenuKeyPressed", (sender) =>
{
+ isShowOptions = true;
+
if (isFocused)
{
foreach (var item in ButtonList)
{
- if (item.isFocused)
+ if (item is SubPanelButton)
{
- item.ShowContextPopup();
+ if (item.isFocused)
+ {
+ OnShowOptionsCommand?.Execute(isShowOptions);
+ item.ShowContextPopup();
+ item.ChangeShowOptionsMode(isShowOptions);
+ ChangeIsEnabledProperty(item.View, false);
+ }
}
}
}
button = new SubPanelButton();
button.OnMoveCommand = new Command<string>((direction) =>
{
+ if (button.rightMoving || button.leftMoving)
+ {
+ return;
+ }
+
int index = ButtonViewList.IndexOf(button.View);
if (direction.Equals("Right"))
{
- MoveItemToRight(index);
+ button.rightMoving = true;
+ MoveItemToRight(index, button);
}
else if (direction.Equals("Left"))
{
- MoveItemToLeft(index);
+ button.leftMoving = true;
+ MoveItemToLeft(index, button);
}
});
button.OnMoveFinishedCommand = new Command(() =>
{
- // TODO : This is triggered by LongTap event.
isMoveMode = !isMoveMode;
+ isShowOptions = false;
- OnMoveCommand.Execute(isMoveMode);
-
- ChangeLayoutButtons(isMoveMode);
- ChangeIsEnabledProperty(button.View);
+ ChangeIsEnabledProperty(button.View, false);
button.ChangeMoveMode(isMoveMode, false);
if (!isMoveMode)
{
- foreach (var viewItem in ButtonViewList)
- {
- viewItem.TranslateTo(SizeUtils.GetWidthSize((int)viewItem.TranslationX), 0, 0);
- }
-
OnMoveVMCommand.Execute(ButtonViewList);
}
+
+ OnShowOptionsCommand.Execute(isMoveMode);
});
}
AppShortcutInfo shortcut = (AppShortcutInfo)button.View.BindingContext;
OnUnpinVMCommand.Execute(shortcut.AppID);
});
+ button.OnDefaultModeCommand = new Command(() =>
+ {
+ ChangeToDefaultMode();
+ });
PanelButtonStack.Children.Add(button.View);
ButtonViewList.Add(button.View);
/// A method is called when apps subpanel is changed to move mode and change item's IsEnabled property.
/// </summary>
/// <param name="selectedBtn">A selected button view to move</param>
- private void ChangeIsEnabledProperty(View selectedBtn)
+ private void ChangeIsEnabledProperty(View selectedBtn, bool isEnabled)
{
foreach (var item in PanelButtonStack.Children)
{
if (item != selectedBtn)
{
- item.IsEnabled = !isMoveMode;
+ item.IsEnabled = isEnabled;
}
}
}
/// <summary>
- /// A method for changing button's LayoutOptions in SubPanel according to parameter
- /// </summary>
- /// <param name="isMoveMode">A flag indicates whether the SubPanel is MoveMode or not</param>
- private void ChangeLayoutButtons(bool isMoveMode)
- {
- foreach (var item in ButtonList)
- {
- item.ChangeLayoutOptions(isMoveMode);
- }
- }
-
- /// <summary>
/// A method for hiding the panel
/// </summary>
public override async void HidePanel()
if (isMoveMode)
{
isMoveMode = !isMoveMode;
+ isShowOptions = false;
foreach (var item in ButtonList)
{
if (item.isMoveMode)
{
- ChangeIsEnabledProperty(item.View);
+ ChangeIsEnabledProperty(item.View, true);
item.ChangeMoveMode(isMoveMode, true);
}
else
}
}
- OnMoveCommand.Execute(isMoveMode);
- ChangeLayoutButtons(isMoveMode);
-
ButtonViewList.Clear();
foreach (var stackItem in PanelButtonStack.Children)
{
ButtonViewList.Add(stackItem);
}
+
+ OnShowOptionsCommand.Execute(isMoveMode);
+ }
+ else if (isShowOptions)
+ {
+ isShowOptions = !isShowOptions;
+
+ foreach (var item in ButtonList)
+ {
+ if (item.isFocused)
+ {
+ item.ChangeShowOptionsMode(isShowOptions);
+ ChangeIsEnabledProperty(item.View, true);
+ }
+ }
+
+ OnShowOptionsCommand?.Execute(isShowOptions);
}
}
/// A method for moving the selected item to right
/// </summary>
/// <param name="index">A index of item to be moved</param>
- private void MoveItemToRight(int index)
+ private void MoveItemToRight(int index, PanelButton button)
{
+ var btn = button as SubPanelButton;
View originItemView = ButtonViewList[index];
int nextIndex = index + 1;
if (nextIndex >= PanelButtonStack.Children.Count - 1)
animation.Add(0.5, 1, nextScaleUp);
animation.Add(0, 1, nextTranslate);
- animation.Commit(this, "MoveRightAnimation", 334);
+ animation.Commit(this, "MoveRightAnimation", 16, 334, null, (v, c)=> btn.rightMoving = false);
if (SizeUtils.GetWidthSize((int)(originItemView.X + translateX + 216)) - SizeUtils.GetWidthSize((int)PanelScrollView.ScrollX) > SizeUtils.GetWidthSize(1920))
{
/// A method for moving the selected item to left
/// </summary>
/// <param name="index">A index of item to be moved</param>
- private void MoveItemToLeft(int index)
+ private void MoveItemToLeft(int index, PanelButton button)
{
+ var btn = button as SubPanelButton;
View originItemView = ButtonViewList[index];
int prevIndex = index - 1;
animation.Add(0.5, 1, prevScaleUp);
animation.Add(0, 1, prevTranslate);
- animation.Commit(this, "MoveLeftAnimation", 334);
+ animation.Commit(this, "MoveLeftAnimation", 16, 334, null, (v,c)=> btn.leftMoving = false);
if (SizeUtils.GetWidthSize((int)(originItemView.X + translateX)) - SizeUtils.GetWidthSize((int)PanelScrollView.ScrollX) < 0)
{