Sha256: 831ac02b2f09d9b2f72c85d3e75d605f85c88ff45be7c9d6d2e9ff5014e42fe6

Contents?: true

Size: 1.24 KB

Versions: 53

Compression:

Stored size: 1.24 KB

Contents

module MotionPrime
  module SupportPaddingAttribute
    extend ::MotionSupport::Concern

    included do
      attr_accessor :paddingLeft, :paddingRight, :paddingTop, :paddingBottom, :padding
    end

    module ClassMethods
      def default_padding_top
        0
      end

      def default_padding_left
        0
      end

      def default_padding_right
        0
      end

      def default_padding_bottom
        0
      end
    end

    def padding_left
      self.paddingLeft || self.padding || self.class.default_padding_left
    end

    def padding_right
      self.paddingRight || self.padding || self.class.default_padding_right
    end

    def padding_top
      self.paddingTop || self.padding || self.class.default_padding_top
    end

    def padding_bottom
      self.paddingBottom || self.padding || self.class.default_padding_bottom
    end

    def padding_insets
      UIEdgeInsetsMake(padding_top, padding_left, padding_bottom, padding_right)
    end

    def apply_padding(rect)
      return unless apply_padding?
      apply_padding!(rect)
    end

    def apply_padding!(rect)
      raise "requires implementation"
    end

    def apply_padding?
      ![padding_top, padding_left, padding_right, padding_bottom].all?(&:zero?)
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
motion-prime-1.0.7 motion-prime/support/_padding_attribute.rb
motion-prime-1.0.6 motion-prime/support/_padding_attribute.rb
motion-prime-1.0.5 motion-prime/support/_padding_attribute.rb
motion-prime-1.0.4 motion-prime/support/_padding_attribute.rb
motion-prime-1.0.3 motion-prime/support/_padding_attribute.rb
motion-prime-1.0.2 motion-prime/support/_padding_attribute.rb
motion-prime-1.0.1 motion-prime/support/_padding_attribute.rb
motion-prime-1.0.0 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.9.2 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.9.1 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.9 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.8 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.7 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.6 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.5 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.4 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.3 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.2 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.1 motion-prime/support/_padding_attribute.rb
motion-prime-0.9.0 motion-prime/support/_padding_attribute.rb