From: Hyerim Kim Date: Fri, 5 May 2017 02:38:48 +0000 (+0900) Subject: Implements context popup in AppsSubPanel X-Git-Tag: submit/tizen/20170808.015446~61 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f11b201e5f14fb0f7adeb31f949a63dacf18b7a6;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Implements context popup in AppsSubPanel Prevents continuous click event on Move mode Change-Id: I9671e0be790199fae926f198b48425de3e44c852 Signed-off-by: Hyerim Kim --- diff --git a/TVHome/TVHome/Controls/MainPanelButton.xaml.cs b/TVHome/TVHome/Controls/MainPanelButton.xaml.cs index 17eee40..4673323 100755 --- a/TVHome/TVHome/Controls/MainPanelButton.xaml.cs +++ b/TVHome/TVHome/Controls/MainPanelButton.xaml.cs @@ -146,17 +146,13 @@ namespace TVHome.Controls } /// - /// A method for changing the button's LayoutOptions according to parameter + /// A method for showing context popup /// - /// A flag indicates whether the SubPanel is MoveMode or not - public override void ChangeLayoutOptions(bool isMoveMode) + public override void ShowContextPopup() { } - /// - /// A method for showing context popup - /// - public override void ShowContextPopup() + public override void ChangeShowOptionsMode(bool showOptions) { } } diff --git a/TVHome/TVHome/Controls/PanelButton.cs b/TVHome/TVHome/Controls/PanelButton.cs index 84fa5b6..b2591c0 100755 --- a/TVHome/TVHome/Controls/PanelButton.cs +++ b/TVHome/TVHome/Controls/PanelButton.cs @@ -28,6 +28,9 @@ namespace TVHome.Controls { public bool isMoveMode; public bool isFocused; + public bool isShowOptions; + public bool rightMoving; + public bool leftMoving; /// /// A Command will be executed the button is focused. /// @@ -63,6 +66,8 @@ namespace TVHome.Controls /// public ICommand OnClearAllCommand { get; set; } + public ICommand OnDefaultModeCommand { get; set; } + /// /// Handles Button Focused event /// @@ -91,15 +96,11 @@ namespace TVHome.Controls /// A flag indicates whether this method is called by ChangeToDefaultMode method public abstract void ChangeMoveMode(bool isMoveMode, bool isDefault); - /// - /// A method for changing the button's LayoutOptions according to parameter - /// - /// A flag indicates whether the SubPanel is MoveMode or not - public abstract void ChangeLayoutOptions(bool isMoveMode); - /// /// A method for showing context popup /// public abstract void ShowContextPopup(); + + public abstract void ChangeShowOptionsMode(bool isShowOptions); } } diff --git a/TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml b/TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml index f12a969..706b656 100755 --- a/TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml +++ b/TVHome/TVHome/Controls/SubPanelAllAppsButton.xaml @@ -4,7 +4,8 @@ xmlns:Controls="clr-namespace:TVHome.Controls" x:Class="TVHome.Controls.SubPanelAllAppsButton"> + HorizontalOptions="Center" + VerticalOptions="End"> - /// A method for changing the button's LayoutOptions according to parameter + /// A method for showing context popup /// - /// A flag indicates whether the SubPanel is MoveMode or not - 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); } - /// - /// A method for showing context popup - /// - public override void ShowContextPopup() + public override void ChangeShowOptionsMode(bool showOptions) { } } diff --git a/TVHome/TVHome/Controls/SubPanelButton.xaml b/TVHome/TVHome/Controls/SubPanelButton.xaml index b3aff64..4f5aeb2 100755 --- a/TVHome/TVHome/Controls/SubPanelButton.xaml +++ b/TVHome/TVHome/Controls/SubPanelButton.xaml @@ -4,7 +4,8 @@ xmlns:Controls="clr-namespace:TVHome.Controls" x:Class="TVHome.Controls.SubPanelButton"> + HorizontalOptions="Center" + VerticalOptions="End"> public partial class SubPanelButton : PanelButton { - /// - /// A flag which enable showing a popup - /// - private bool isPopupShowing = false; - /// /// SubPanel icon's transition height value when it focused. /// @@ -58,7 +53,7 @@ namespace TVHome.Controls { if (isMoveMode && IsEnabled) { - OnMoveCommand.Execute(e); + OnMoveCommand?.Execute(e); } }); @@ -85,7 +80,7 @@ namespace TVHome.Controls /// public override void ShowContextPopup() { - if (isPopupShowing) + if (isShowOptions) { return; } @@ -106,22 +101,29 @@ namespace TVHome.Controls 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; } @@ -154,13 +156,12 @@ namespace TVHome.Controls /// A flag indicates whether this method is called by ChangeToDefaultMode method 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++) { @@ -172,39 +173,32 @@ namespace TVHome.Controls } 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 } - /// - /// A method for changing the button's LayoutOptions according to parameter - /// - /// A flag indicates whether the SubPanel is MoveMode or not - 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); } /// @@ -227,7 +221,7 @@ namespace TVHome.Controls #pragma warning disable CS4014 ButtonTitle.On().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); @@ -242,11 +236,11 @@ namespace TVHome.Controls { isFocused = false; - if (!isMoveMode) + if (!isMoveMode && !isShowOptions) { #pragma warning disable CS4014 ButtonTitle.On().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); diff --git a/TVHome/TVHome/Controls/SubPanelSettingButton.xaml b/TVHome/TVHome/Controls/SubPanelSettingButton.xaml index 27f7c73..8d11d0c 100755 --- a/TVHome/TVHome/Controls/SubPanelSettingButton.xaml +++ b/TVHome/TVHome/Controls/SubPanelSettingButton.xaml @@ -4,7 +4,8 @@ xmlns:Controls="clr-namespace:TVHome.Controls" x:Class="TVHome.Controls.SubPanelSettingButton"> + HorizontalOptions="Center" + VerticalOptions="End"> - /// A method for changing the button's LayoutOptions according to parameter + /// A method for showing Context popup /// - /// A flag indicates whether the SubPanel is MoveMode or not - public override void ChangeLayoutOptions(bool isMoveMode) + public override void ShowContextPopup() { } - /// - /// A method for showing Context popup - /// - public override void ShowContextPopup() + public override void ChangeShowOptionsMode(bool showOptions) { } } diff --git a/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs b/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs index b2a15ed..5488d3c 100755 --- a/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs +++ b/TVHome/TVHome/Controls/SubPanelThumbnailButton.xaml.cs @@ -184,14 +184,6 @@ namespace TVHome.Controls } - /// - /// A method for changing the button's LayoutOptions according to parameter - /// - /// A flag indicates whether the SubPanel is MoveMode or not - public override void ChangeLayoutOptions(bool isMoveMode) - { - } - /// /// A method for showing Context popup /// @@ -235,5 +227,9 @@ namespace TVHome.Controls popup.Show(View); isPopupShowing = true; } + + public override void ChangeShowOptionsMode(bool showOptions) + { + } } } \ No newline at end of file diff --git a/TVHome/TVHome/Views/MainPage.xaml.cs b/TVHome/TVHome/Views/MainPage.xaml.cs index 27d999a..682f44e 100755 --- a/TVHome/TVHome/Views/MainPage.xaml.cs +++ b/TVHome/TVHome/Views/MainPage.xaml.cs @@ -134,10 +134,10 @@ namespace TVHome.Views ToggleIconified(); }); - AppsSubPanel.OnMoveCommand = new Command((isMoveMode) => + AppsSubPanel.OnShowOptionsCommand = new Command((isShowOptions) => { var bounds = AppsSubPanel.Bounds; - if (isMoveMode) + if (isShowOptions) { PageMainPanel.FadeTo(0, 300); PageMainPanel.IsVisible = false; @@ -146,13 +146,13 @@ namespace TVHome.Views } 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(this, App.AppStatus, (sender, arg) => @@ -311,7 +311,7 @@ namespace TVHome.Views /// Always returns true protected override bool OnBackButtonPressed() { - if (AppsSubPanel.isMoveMode) + if (AppsSubPanel.isMoveMode || AppsSubPanel.isShowOptions) { AppsSubPanel.ChangeToDefaultMode(); } diff --git a/TVHome/TVHome/Views/Panel.cs b/TVHome/TVHome/Views/Panel.cs index d232db2..4451799 100755 --- a/TVHome/TVHome/Views/Panel.cs +++ b/TVHome/TVHome/Views/Panel.cs @@ -137,6 +137,8 @@ namespace TVHome.Views /// public bool isMoveMode; + public bool isShowOptions; + /// /// A method for handling panel focused event /// diff --git a/TVHome/TVHome/Views/SubPanel.xaml.cs b/TVHome/TVHome/Views/SubPanel.xaml.cs index 36b891f..2504bde 100755 --- a/TVHome/TVHome/Views/SubPanel.xaml.cs +++ b/TVHome/TVHome/Views/SubPanel.xaml.cs @@ -42,9 +42,9 @@ namespace TVHome.Views private List ButtonViewList; /// - /// A Command will be executed the button is moved. + /// A Command will be executed the option menus are showed. /// - public ICommand OnMoveCommand { get; set; } + public ICommand OnShowOptionsCommand { get; set; } /// /// SubPanel icon's transition height value when it focused. @@ -64,6 +64,7 @@ namespace TVHome.Views InitializeComponent(); isFocused = false; isMoveMode = false; + isShowOptions = false; ButtonList = new List(); ButtonViewList = new List(); @@ -71,13 +72,21 @@ namespace TVHome.Views MessagingCenter.Subscribe(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); + } } } } @@ -116,37 +125,38 @@ namespace TVHome.Views button = new SubPanelButton(); button.OnMoveCommand = new Command((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); }); } @@ -180,6 +190,10 @@ namespace TVHome.Views AppShortcutInfo shortcut = (AppShortcutInfo)button.View.BindingContext; OnUnpinVMCommand.Execute(shortcut.AppID); }); + button.OnDefaultModeCommand = new Command(() => + { + ChangeToDefaultMode(); + }); PanelButtonStack.Children.Add(button.View); ButtonViewList.Add(button.View); @@ -216,29 +230,17 @@ namespace TVHome.Views /// A method is called when apps subpanel is changed to move mode and change item's IsEnabled property. /// /// A selected button view to move - 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; } } } - /// - /// A method for changing button's LayoutOptions in SubPanel according to parameter - /// - /// A flag indicates whether the SubPanel is MoveMode or not - private void ChangeLayoutButtons(bool isMoveMode) - { - foreach (var item in ButtonList) - { - item.ChangeLayoutOptions(isMoveMode); - } - } - /// /// A method for hiding the panel /// @@ -327,12 +329,13 @@ namespace TVHome.Views 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 @@ -341,14 +344,28 @@ namespace TVHome.Views } } - 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); } } @@ -356,8 +373,9 @@ namespace TVHome.Views /// A method for moving the selected item to right /// /// A index of item to be moved - 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) @@ -386,7 +404,7 @@ namespace TVHome.Views 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)) { @@ -401,8 +419,9 @@ namespace TVHome.Views /// A method for moving the selected item to left /// /// A index of item to be moved - 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; @@ -432,7 +451,7 @@ namespace TVHome.Views 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) {