コード例 #1
0
        public SwipeButton(
            Context context,
            int id,
            Func <int, string> text,
            int imageResId,
            Func <int, Color> backgroundColor,
            Color iconColor,
            Color textColor,
            int textSize = 14,
            UnderlayButtonPosition position    = UnderlayButtonPosition.Right,
            ISwipeButtonClickListener listener = null)
        {
            _context    = context;
            _getBgColor = backgroundColor;
            _getText    = text;

            Id         = id;
            ImageResId = imageResId;
            IconColor  = iconColor;
            TextColor  = textColor;
            TextSize   = textSize;
            Position   = position;
            Listener   = listener;

            Init();
        }
コード例 #2
0
        private void DrawButtons(Canvas c, View itemView, List <SwipeButton> buffer, int pos, float dX, UnderlayButtonPosition position)
        {
            float right        = itemView.Right;
            float left         = itemView.Left;
            float dButtonWidth = (-1) * dX / buffer.Where(b => b.Position == position).Count();

            //System.Diagnostics.Debug.WriteLine($"Width = {itemView.Width} - MeasuredWdith = {itemView.MeasuredWidth}");
            foreach (var button in buffer)
            {
                if (dX < 0 && position == button.Position)
                {
                    left = right - dButtonWidth;
                    button.OnDraw(
                        c,
                        new RectF(
                            left,
                            itemView.Top,
                            right,
                            itemView.Bottom
                            ),
                        pos, dX, itemView
                        //(to draw button on right)
                        );
                    //System.Diagnostics.Debug.WriteLine($"Recf Right = {right} - Left = {left} - Top = {itemView.Top} - Bottom = {itemView.Bottom}");
                    right = left;
                }
                else if (dX > 0 && position == button.Position)
                {
                    right = left - dButtonWidth;
                    button.OnDraw(c,
                                  new RectF(
                                      left,
                                      itemView.Top,
                                      right,
                                      itemView.Bottom
                                      ), pos, dX, itemView
                                  //(to draw button on left)

                                  );
                    //System.Diagnostics.Debug.WriteLine($"Recf Right = {right} - Left = {left} - Top = {itemView.Top} - Bottom = {itemView.Bottom}");
                    left = right;
                }
            }
            //System.Diagnostics.Debug.WriteLine("Buttons were drawn");
        }