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-0.8.12 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.11 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.10 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.9 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.8 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.7 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.6 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.5 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.4 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.3 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.2 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.1 motion-prime/support/_padding_attribute.rb
motion-prime-0.8.0 motion-prime/support/_padding_attribute.rb
motion-prime-0.7.2 motion-prime/support/_padding_attribute.rb
motion-prime-0.7.1 motion-prime/support/_padding_attribute.rb
motion-prime-0.7.0 motion-prime/support/_padding_attribute.rb
motion-prime-0.6.0 motion-prime/support/_padding_attribute.rb
motion-prime-0.5.7 motion-prime/support/_padding_attribute.rb
motion-prime-0.5.6 motion-prime/support/_padding_attribute.rb
motion-prime-0.5.5 motion-prime/support/_padding_attribute.rb