Exemplo n.º 1
0
        private void HandleMenuCenterClicked()
        {
            InnerButtonMenu.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    if (!_isAnimating)
                    {
                        _isAnimating = true;

                        InnerButtonClose.IsVisible = true;
                        InnerButtonMenu.IsVisible  = true;

                        InnerButtonMenu.RotateTo(360, _animationDelay);
                        InnerButtonMenu.FadeTo(0, _animationDelay);
                        InnerButtonClose.RotateTo(360, _animationDelay);
                        InnerButtonClose.FadeTo(1, _animationDelay);

                        await OuterCircle.ScaleTo(3.3, 1000, Easing.BounceIn);
                        await ShowButtons();
                        InnerButtonMenu.IsVisible = false;

                        _isAnimating = false;
                    }
                }),
                NumberOfTapsRequired = 1
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds tap gesture recognizer to open button in the middle of round menu.
        /// </summary>
        private void ConnectOpenWithClick()
        {
            InnerButtonMenu.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    if (!isAnimating)
                    {
                        isAnimating = true;

                        InnerButtonClose.IsVisible = true;
                        InnerButtonMenu.IsVisible  = true;

                        InnerButtonMenu.RotateTo(360, animationDelay);
                        InnerButtonMenu.FadeTo(0, animationDelay);
                        InnerButtonClose.RotateTo(360, animationDelay);
                        InnerButtonClose.FadeTo(1, animationDelay);

                        await OuterCircle.ScaleTo(3.3, 1000, Easing.BounceIn);
                        await ShowMenuItems();
                        InnerButtonMenu.IsVisible = false;

                        isAnimating = false;
                    }
                }),
                NumberOfTapsRequired = 1
            });
        }
Exemplo n.º 3
0
        private async Task CloseMenu()
        {
            if (!_isAnimating)
            {
                _isAnimating = true;

                InnerButtonMenu.IsVisible  = true;
                InnerButtonClose.IsVisible = true;
                await HideButtons();

                await InnerButtonClose.RotateTo(0, _animationDelay);

                await InnerButtonClose.FadeTo(0, _animationDelay);

                await InnerButtonMenu.RotateTo(0, _animationDelay);

                await InnerButtonMenu.FadeTo(1, _animationDelay);

                await OuterCircle.ScaleTo(1, 100, Easing.Linear);

                InnerButtonClose.IsVisible = false;

                _isAnimating = false;
            }
        }
        void ItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if (MenuItemsSource == null)
            {
                return;
            }

            var notifyCollection = newValue as INotifyCollectionChanged;

            if (notifyCollection != null)
            {
                HideButtons(MenuItemsSource, 0);
                OuterCircle.Draw();
                InnerButtonMenu.Draw();
                InnerButtonClose.Draw();
                BackButton.Draw();
                foreach (RadialMenuItem newItem in MenuItemsSource)
                {
                    OrganizeItem(newItem);
                    if (!mainGrid.Children.Contains(newItem))
                    {
                        mainGrid.Children.Add(newItem);
                    }
                    var source = (Xamarin.Forms.FileImageSource)newItem.Source;
                    HandleOptionClicked(newItem, newItem.Location);
                }

                notifyCollection.CollectionChanged += (sender, e) =>
                {
                    if (e.NewItems != null)
                    {
                        var tempList = new List <object>();
                        if (e.NewItems != null)
                        {
                            foreach (RadialMenuItem newItem in e.NewItems)
                            {
                                tempList.Add(newItem);
                                OrganizeItem(newItem);
                                if (!mainGrid.Children.Contains(newItem))
                                {
                                    mainGrid.Children.Add(newItem);
                                }
                                var source = (Xamarin.Forms.FileImageSource)newItem.Source;
                                HandleOptionClicked(newItem, newItem.Location);
                            }
                            foreach (var newItem in MenuItemsSource)
                            {
                                var item = newItem as RadialMenuItem;
                                tempList.Add(item);
                            }

                            MenuItemsSource = tempList;
                        }
                    }
                };
            }
        }
        private async Task GoBack()
        {
            if (!_isAnimating)
            {
                _isAnimating      = true;
                IsChildItemOpened = false;
                await HideButtons(ParentInBackgroundItem.ChildItems);

                InnerButtonMenu.IsVisible  = false;
                InnerButtonClose.IsVisible = true;
                BackButton.IsVisible       = true;
                //await HideButtons(MenuItemsSource);


                InnerButtonMenu.RotateTo(360, _animationDelay);
                InnerButtonMenu.FadeTo(0, _animationDelay);
                BackButton.RotateTo(0, _animationDelay);
                BackButton.FadeTo(0, _animationDelay);
                InnerButtonClose.RotateTo(360, _animationDelay);
                InnerButtonClose.FadeTo(1, _animationDelay);

                await OuterCircle.ScaleTo(1, (uint)ChildShrinkAnimationDuration, ChildShrinkEasing);

                await OuterCircle.ScaleTo(3.3, (uint)ChildGrowAnimationDuration, ChildGrowEasing);

                ClearGridButtons();

                //Show Main buttons again
                for (int j = 0; j < MenuItemsSource.Count; j++)
                {
                    var childItem = MenuItemsSource[j] as RadialMenuItem;
                    OrganizeItem(childItem);
                    mainGrid.Children.Add(childItem);
                    HandleOptionClicked(childItem, childItem.Location);
                }

                await ShowButtons(MenuItemsSource);

                InnerButtonMenu.IsVisible = false;
                BackButton.IsVisible      = false;
                _isAnimating = false;

                HandleMenuCenterClicked();
                HandleCloseClicked();
                BackButton.GestureRecognizers.Clear();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Closes the menu.
        /// </summary>
        private async Task CloseMenu()
        {
            if (!isAnimating)
            {
                isAnimating = true;

                InnerButtonMenu.IsVisible  = true;
                InnerButtonClose.IsVisible = true;
                await HideMenuItems();

                InnerButtonClose.RotateTo(0, animationDelay);
                InnerButtonClose.FadeTo(0, animationDelay);
                InnerButtonMenu.RotateTo(0, animationDelay);
                InnerButtonMenu.FadeTo(1, animationDelay);
                await OuterCircle.ScaleTo(1, 400, Easing.BounceOut);

                InnerButtonClose.IsVisible = false;

                isAnimating = false;
            }
        }
        public async Task OpenMenu()
        {
            if (!_isAnimating)
            {
                _isAnimating = true;

                InnerButtonClose.IsVisible = true;
                InnerButtonMenu.IsVisible  = true;

                InnerButtonMenu.RotateTo(360, _animationDelay);
                InnerButtonMenu.FadeTo(0, _animationDelay);
                InnerButtonClose.RotateTo(360, _animationDelay);
                InnerButtonClose.FadeTo(1, _animationDelay);

                await OuterCircle.ScaleTo(3.3, (uint)MenuOpenAnimationDuration, MenuOpenEasing);
                await ShowButtons(MenuItemsSource);

                InnerButtonMenu.IsVisible = false;

                _isAnimating = false;
            }
        }
Exemplo n.º 8
0
        public async Task CloseMenu()
        {
            if (!_isAnimating)
            {
                _isAnimating = true;

                InnerButtonMenu.IsVisible  = true;
                InnerButtonClose.IsVisible = true;
                await HideButtons();

                InnerButtonClose.RotateTo(0, _animationDelay);
                InnerButtonClose.FadeTo(0, _animationDelay);
                InnerButtonMenu.RotateTo(0, _animationDelay);
                InnerButtonMenu.FadeTo(1, _animationDelay);
                await OuterCircle.ScaleTo(1, 1000, Easing.BounceOut);

                InnerButtonClose.IsVisible = false;

                _isAnimating = false;
                IsOpened     = false;
            }
        }
Exemplo n.º 9
0
        public async Task OpenMenu()
        {
            if (!_isAnimating)
            {
                _isAnimating = true;

                InnerButtonClose.IsVisible = true;
                InnerButtonMenu.IsVisible  = true;

                InnerButtonMenu.RotateTo(360, _animationDelay);
                InnerButtonMenu.FadeTo(0, _animationDelay);
                InnerButtonClose.RotateTo(360, _animationDelay);
                InnerButtonClose.FadeTo(1, _animationDelay);

                await OuterCircle.ScaleTo(3.3, 1000, Easing.BounceIn);
                await ShowButtons();

                InnerButtonMenu.IsVisible = false;

                _isAnimating = false;
            }
        }
Exemplo n.º 10
0
 /// <summary>
        /// Adds tap gesture recognizer to open button in the middle of round menu.
        /// </summary>
        private void ConnectOpenWithClick()
        {
            InnerButtonMenu.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async () =>
                {
                    if (!isAnimating)
                    {
                        isAnimating = true;

                        InnerButtonClose.IsVisible = true;
                        InnerButtonMenu.IsVisible = true;

                        InnerButtonMenu.RotateTo(360, animationDelay);
                        InnerButtonMenu.FadeTo(0, animationDelay);
                        InnerButtonClose.RotateTo(360, animationDelay);
                        InnerButtonClose.FadeTo(1, animationDelay);

                        await OuterCircle.ScaleTo(3.3, 1000, Easing.BounceIn);
                        await ShowMenuItems();
                        InnerButtonMenu.IsVisible = false;

                        isAnimating = false;

                    }
                }),
                NumberOfTapsRequired = 1
            });

        }

        /// <summary>
        /// Closes the menu.
        /// </summary>
        private async Task CloseMenu()
        {
            if (!isAnimating)
            {

                isAnimating = true;

                InnerButtonMenu.IsVisible = true;
                InnerButtonClose.IsVisible = true;
                await HideMenuItems();

                InnerButtonClose.RotateTo(0, animationDelay);
                InnerButtonClose.FadeTo(0, animationDelay);
                InnerButtonMenu.RotateTo(0, animationDelay);
                InnerButtonMenu.FadeTo(1, animationDelay);
                await OuterCircle.ScaleTo(1, 400, Easing.BounceOut);
                InnerButtonClose.IsVisible = false;

                isAnimating = false;
            }
        }

        /// <summary>
        /// Hides the menu items.
        /// </summary>
        private async Task HideMenuItems()
        {
            var speed = 25U;
            await Settings.FadeTo(0, speed);
            await Followings.FadeTo(0, speed);
            await UserMap.FadeTo(0, speed);
        }

        /// <summary>
        /// Shows the menu items.
        /// </summary>
        private async Task ShowMenuItems()
        {
            var speed = 25U;
            await Settings.FadeTo(1, speed);
            await Followings.FadeTo(1, speed);
            await UserMap.FadeTo(1, speed);
        }
    }
}

        public async Task CloseMenu(RadialMenuItem itemTapped = null)
        {
            if (!_isAnimating)
            {
                if (itemTapped == null)
                {
                    _isAnimating = true;

                    InnerButtonMenu.IsVisible  = true;
                    InnerButtonClose.IsVisible = true;
                    await HideButtons(MenuItemsSource);

                    BackButton.RotateTo(0, _animationDelay);
                    BackButton.FadeTo(0, _animationDelay);
                    InnerButtonClose.RotateTo(0, _animationDelay);
                    InnerButtonClose.FadeTo(0, _animationDelay);
                    InnerButtonMenu.RotateTo(0, _animationDelay);
                    InnerButtonMenu.FadeTo(1, _animationDelay);
                    await OuterCircle.ScaleTo(1, (uint)MenuCloseAnimationDuration, MenuCloseEasing);

                    InnerButtonClose.IsVisible = false;
                    BackButton.IsVisible       = false;
                    _isAnimating = false;
                }
                else
                {
                    _isAnimating = true;

                    InnerButtonMenu.IsVisible  = false;
                    InnerButtonClose.IsVisible = true;
                    BackButton.IsVisible       = true;
                    await HideButtons(MenuItemsSource);

                    InnerButtonClose.RotateTo(0, _animationDelay);
                    InnerButtonClose.FadeTo(0, _animationDelay);
                    InnerButtonMenu.RotateTo(360, _animationDelay);
                    InnerButtonMenu.FadeTo(1, _animationDelay);
                    BackButton.RotateTo(360, _animationDelay);
                    BackButton.FadeTo(1, _animationDelay);


                    await OuterCircle.ScaleTo(1, (uint)ChildShrinkAnimationDuration, ChildShrinkEasing);

                    await OuterCircle.ScaleTo(3.3, (uint)ChildGrowAnimationDuration, ChildGrowEasing);



                    ClearGridButtons();
                    if (itemTapped.ChildItems != null && itemTapped.ChildItems.Count > 0)
                    {
                        for (int j = 0; j < itemTapped.ChildItems.Count; j++)
                        {
                            var childItem = itemTapped.ChildItems[j];
                            OrganizeItem(childItem);
                            mainGrid.Children.Add(childItem);
                            HandleChildOptionClicked(childItem, childItem.Location);
                        }
                    }
                    await ShowButtons(itemTapped.ChildItems);

                    //ParentInBackgroundItem = itemTapped;

                    InnerButtonClose.IsVisible = false;
                    InnerButtonMenu.IsVisible  = false;

                    HandleBackClicked();
                    InnerButtonMenu.GestureRecognizers.Clear();
                    InnerButtonClose.GestureRecognizers.Clear();

                    _isAnimating = false;
                }
            }
        }
        private void HandleChildOptionClicked(RadialMenuItem parentItem, Enumerations.Enumerations.RadialMenuLocation value)
        {
            parentItem.GestureRecognizers.Clear();
            parentItem.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(async() =>
                {
                    //IsOpened = false;
                    ChildItemTapped?.Invoke(this, new Models.ChildItemTapped()
                    {
                        Parent = ParentInBackgroundItem, ItemTapped = value
                    });
                    if (CloseMenuWhenChildTapped)
                    {
                        IsOpened          = false;
                        IsChildItemOpened = false;
                        if (!_isAnimating)
                        {
                            _isAnimating = true;

                            InnerButtonMenu.IsVisible  = true;
                            InnerButtonClose.IsVisible = false;
                            BackButton.IsVisible       = true;

                            await HideButtons(ParentInBackgroundItem.ChildItems);

                            InnerButtonClose.RotateTo(0, _animationDelay);
                            InnerButtonClose.FadeTo(0, _animationDelay);

                            BackButton.RotateTo(0, _animationDelay);
                            BackButton.FadeTo(0, _animationDelay);

                            InnerButtonMenu.RotateTo(0, _animationDelay);
                            InnerButtonMenu.FadeTo(1, _animationDelay);

                            ClearGridButtons();

                            await OuterCircle.ScaleTo(1, (uint)MenuCloseAnimationDuration, MenuCloseEasing);


                            InnerButtonClose.IsVisible = false;
                            BackButton.IsVisible       = false;

                            BackButton.GestureRecognizers.Clear();
                            InnerButtonMenu.GestureRecognizers.Clear();
                            InnerButtonClose.GestureRecognizers.Clear();
                            HandleMenuCenterClicked();
                            HandleCloseClicked();

                            foreach (var i in MenuItemsSource)
                            {
                                var item = i as RadialMenuItem;
                                //OrganizeItem(item);
                                mainGrid.Children.Add(item);
                                //HandleOptionClicked(item, item.Location);
                            }

                            _isAnimating = false;
                        }
                    }
                    else
                    {
                        GoBack();
                    }
                }),
                NumberOfTapsRequired = 1
            });
        }