Exemple #1
0
        public void SetAngel(IList <ActionButtonView> Lst, float radius, FrameLayout rl, int Degress, int Duration)
        {
            var degrees = Degress / Lst.Count;
            int i       = 0;

            foreach (var item in Lst)
            {
                var hOffset = radius * Math.Cos(i * degrees * 3.14 / 180);
                var vOffset = radius * Math.Sin(i * degrees * 3.14 / 180);
                var btn     = new CustomFloatingactionbutton(context, item, SubViewSpacing);
                btn.Alpha = 0;
                var ly = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                btn.CustomSize = (int)(item.HeightRequest * 2.5);

                if (ActionOrientation == StackActionOrientation.Right)
                {
                    ly.Gravity = GravityFlags.Right | GravityFlags.Bottom;
                }
                else if (ActionOrientation == StackActionOrientation.Center)
                {
                    ly.Gravity = GravityFlags.Center | GravityFlags.Bottom;
                }
                else if (ActionOrientation == StackActionOrientation.Left)
                {
                    ly.Gravity = GravityFlags.Left | GravityFlags.Bottom;
                }
                var mainbuttonmargins = (LinearLayout.LayoutParams)linearLayout.GetChildAt(0).LayoutParameters;
                var LinearLayoutprm   = (RelativeLayout.LayoutParams)linearLayout.LayoutParameters;
                ly.SetMargins(mainbuttonmargins.LeftMargin, 0, mainbuttonmargins.RightMargin, LinearLayoutprm.BottomMargin == 0 ? 30 : LinearLayoutprm.BottomMargin);

                //ly.AddRule(LayoutRules.AlignParentBottom);
                btn.LayoutParameters = ly;
                if (ActionOrientation == StackActionOrientation.Left)
                {
                    btn.Animate().TranslationX(-(float)(-1 * hOffset)).SetDuration(Duration);
                }
                else
                {
                    btn.Animate().TranslationX((float)(-1 * hOffset)).SetDuration(Duration);
                }
                btn.Animate().TranslationY(((float)(-1 * vOffset))).SetDuration(Duration);

                btn.Animate().Alpha(1).SetDuration(Duration);
                btn.Click += (sender, e) =>
                {
                    item.ClickAction();
                };
                //btn.SetIcon(item.Icon);
                rl.AddView(btn);
                i++;
            }
        }
Exemple #2
0
        public async Task <bool> ShowSubView(int Duration = 150)
        {
            try
            {
                if (SubViews.Count > 0)
                {
                    if (!IsSubShowing && IsShowing && !isProgress)
                    {
                        isProgress = true;
                        if (OpeningType != ActionOpeningType.Circle)
                        {
                            foreach (var item in SubViews)
                            {
                                var Btnn = new CustomFloatingactionbutton(context, item, SubViewSpacing);

                                if (OpeningType == ActionOpeningType.VerticalTop || OpeningType == ActionOpeningType.HorizontalLeft)
                                {
                                    linearLayout.AddView(Btnn, 0);
                                }
                                else
                                {
                                    linearLayout.AddView(Btnn);
                                }

                                //Animation animate = AnimationUtils.LoadAnimation(context, Resource.Animation.EnterFromLeft);
                                //Btnn.StartAnimation(animate);

                                switch (OpeningType)
                                {
                                case ActionOpeningType.HorizontalLeft:
                                    Btnn.Animate().TranslationX(-SubViewSpacing).SetDuration(Duration);
                                    break;

                                case ActionOpeningType.HorizontalRight:
                                    Btnn.Animate().TranslationX(+SubViewSpacing).SetDuration(Duration);
                                    break;

                                case ActionOpeningType.VerticalTop:
                                    Btnn.Animate().TranslationY(-SubViewSpacing).SetDuration(Duration);
                                    break;

                                case ActionOpeningType.VerticalBottom:
                                    Btnn.Animate().TranslationY(+SubViewSpacing).SetDuration(Duration);
                                    break;

                                default:
                                    break;
                                }


                                await Task.Delay(Duration);

                                if (OpeningType == ActionOpeningType.HorizontalLeft || OpeningType == ActionOpeningType.HorizontalRight)
                                {
                                    Btnn.Animate().TranslationX(0).SetDuration(Duration);
                                }
                                else
                                {
                                    Btnn.Animate().TranslationY(0).SetDuration(Duration);
                                }

                                Btnn.Click += (sender, e) => { item.ClickAction(); };
                            }
                        }
                        else
                        {
                            var RL      = new FrameLayout(context);
                            var metrics = Resources.System.DisplayMetrics;
                            var ly      = new RelativeLayout.LayoutParams(metrics.WidthPixels, metrics.HeightPixels);
                            ly.AddRule(LayoutRules.AlignParentBottom);
                            if (ActionOrientation == StackActionOrientation.Right)
                            {
                                ly.AddRule(LayoutRules.AlignParentEnd);
                            }
                            else if (ActionOrientation == StackActionOrientation.Center)
                            {
                                ly.AddRule(LayoutRules.CenterHorizontal);
                                ly.Width *= 2;
                            }
                            else if (ActionOrientation == StackActionOrientation.Right)
                            {
                                ly.AddRule(LayoutRules.AlignParentStart);
                            }


                            RL.LayoutParameters = ly;


                            RootView.View.AddView(RL, 1);
                            float AndroidCircle = (float)(CircleAngle * 2.5);
                            if (ActionOrientation == StackActionOrientation.Center)
                            {
                                if (SubViews.Count == 5)
                                {
                                    SetAngel(SubViews, AndroidCircle, RL, 225, Duration);
                                }
                                else if (SubViews.Count == 4)
                                {
                                    SetAngel(SubViews, AndroidCircle, RL, 240, Duration);
                                }
                                else if (SubViews.Count == 6)
                                {
                                    SetAngel(SubViews, AndroidCircle, RL, 220, Duration);
                                }
                                else if (SubViews.Count == 3)
                                {
                                    SetAngel(SubViews, AndroidCircle, RL, 270, Duration);
                                }
                                else if (SubViews.Count == 2)
                                {
                                    SetAngel(SubViews, AndroidCircle, RL, 360, Duration);
                                }
                                else if (SubViews.Count >= 7)
                                {
                                    SetAngel(SubViews, AndroidCircle, RL, 215, Duration);
                                }
                            }
                            else
                            {
                                SetAngel(SubViews, AndroidCircle, RL, 110, Duration);
                            }
                        }
                        isProgress      = false;
                        IsSubShowing    = true;
                        lastOpeningType = OpeningType;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw new FileNotFoundException("SubViews Null", ex);
            }
        }