Example #1
0
        public static Drawable CreateItemBackgroundDrawable()
        {
            var stateList     = ColorStateList.ValueOf(Colors.Black.MultiplyAlpha(0.2f).ToNative());
            var colorDrawable = new ColorDrawable(AColor.White);

            return(new RippleDrawable(stateList, colorDrawable, null));
        }
Example #2
0
        public static Drawable CreateItemBackgroundDrawable()
        {
            var stateList     = ColorStateList.ValueOf(Color.Black.MultiplyAlpha(0.2).ToAndroid());
            var colorDrawable = new ColorDrawable(AColor.White);

            if (Forms.IsLollipopOrNewer)
            {
                return(new RippleDrawable(stateList, colorDrawable, null));
            }

            return(colorDrawable);
        }
Example #3
0
        protected virtual BottomSheetDialog CreateMoreBottomSheet(Action <int, BottomSheetDialog> selectCallback)
        {
            var bottomSheetDialog = new BottomSheetDialog(Context);
            var bottomSheetLayout = new LinearLayout(Context);

            using (var bottomShellLP = new LP(LP.MatchParent, LP.WrapContent))
                bottomSheetLayout.LayoutParameters = bottomShellLP;
            bottomSheetLayout.Orientation = Orientation.Vertical;

            // handle the more tab
            for (int i = _bottomView.MaxItemCount - 1; i < ShellItem.Items.Count; i++)
            {
                var closure_i    = i;
                var shellContent = ShellItem.Items[i];

                using (var innerLayout = new LinearLayout(Context))
                {
                    innerLayout.SetClipToOutline(true);
                    innerLayout.SetBackground(CreateItemBackgroundDrawable());
                    innerLayout.SetPadding(0, (int)Context.ToPixels(6), 0, (int)Context.ToPixels(6));
                    innerLayout.Orientation = Orientation.Horizontal;
                    using (var param = new LP(LP.MatchParent, LP.WrapContent))
                        innerLayout.LayoutParameters = param;

                    // technically the unhook isn't needed
                    // we dont even unhook the events that dont fire
                    void clickCallback(object s, EventArgs e)
                    {
                        selectCallback(closure_i, bottomSheetDialog);
                        if (!innerLayout.IsDisposed())
                        {
                            innerLayout.Click -= clickCallback;
                        }
                    }

                    innerLayout.Click += clickCallback;

                    var image = new ImageView(Context);
                    var lp    = new LinearLayout.LayoutParams((int)Context.ToPixels(32), (int)Context.ToPixels(32))
                    {
                        LeftMargin   = (int)Context.ToPixels(20),
                        RightMargin  = (int)Context.ToPixels(20),
                        TopMargin    = (int)Context.ToPixels(6),
                        BottomMargin = (int)Context.ToPixels(6),
                        Gravity      = GravityFlags.Center
                    };
                    image.LayoutParameters = lp;
                    lp.Dispose();

                    image.ImageTintList = ColorStateList.ValueOf(Color.Black.MultiplyAlpha(0.6).ToAndroid());
                    ShellContext.ApplyDrawableAsync(shellContent, ShellSection.IconProperty, icon =>
                    {
                        if (!image.IsDisposed())
                        {
                            image.SetImageDrawable(icon);
                        }
                    });

                    innerLayout.AddView(image);

                    using (var text = new TextView(Context))
                    {
                        text.Typeface = "sans-serif-medium".ToTypeFace();
                        text.SetTextColor(AColor.Black);
                        text.Text = shellContent.Title;
                        lp        = new LinearLayout.LayoutParams(0, LP.WrapContent)
                        {
                            Gravity = GravityFlags.Center,
                            Weight  = 1
                        };
                        text.LayoutParameters = lp;
                        lp.Dispose();

                        innerLayout.AddView(text);
                    }

                    bottomSheetLayout.AddView(innerLayout);
                }
            }

            bottomSheetDialog.SetContentView(bottomSheetLayout);
            bottomSheetLayout.Dispose();

            return(bottomSheetDialog);
        }
        protected virtual Drawable CreateItemBackgroundDrawable()
        {
            var stateList = ColorStateList.ValueOf(Color.Black.MultiplyAlpha(0.2).ToAndroid());

            return(new RippleDrawable(stateList, new ColorDrawable(AColor.White), null));
        }