Sha256: ecc9ddb9ecb92ada26b090f19d2d7549db2e607eabcbe640b7ea68c99c20fdc2

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

# @requires MotionKit::BaseLayout
module MotionKit
  class BaseLayout

    def iphone?
      UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
    end

    def iphone55?
      iphone? && UIScreen.mainScreen.bounds.size.width == 414 && UIScreen.mainScreen.bounds.size.height == 736
    end

    def iphone47?
      iphone? && UIScreen.mainScreen.bounds.size.width == 375 && UIScreen.mainScreen.bounds.size.height == 667
    end

    def iphone4?
      iphone? && UIScreen.mainScreen.bounds.size.width == 320 && UIScreen.mainScreen.bounds.size.height == 568
    end

    def iphone35?
      iphone? && UIScreen.mainScreen.bounds.size.width == 320 && UIScreen.mainScreen.bounds.size.height == 480
    end

    def ipad?
      UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad
    end

    def retina?
      UIScreen.mainScreen.respond_to?(:scale) && UIScreen.mainScreen.scale == 2
    end

    [:iphone, :iphone4, :iphone35, :ipad, :retina].each do |method_name|
      define_method(method_name) do |&block|
        block.call if self.send("#{method_name}?")
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
motion-kit-1.1.1 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-1.1.0 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-1.0.3 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-1.0.2 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-1.0.1 lib/motion-kit-ios/helpers/layout_device.rb