Sha256: fdb80016ebaad4e4de2f4e7f937de04b7d7ccb78df778343f454e39aeb013943

Contents?: true

Size: 849 Bytes

Versions: 31

Compression:

Stored size: 849 Bytes

Contents

# @requires MotionKit::BaseLayout
module MotionKit
  class BaseLayout

    def iphone?
      UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
    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

31 entries across 31 versions & 1 rubygems

Version Path
motion-kit-1.0.0 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.18.0 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.17.0 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.16.0 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.15.0 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.14.2 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.14.1 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.14.0 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.13.0 lib/motion-kit-ios/helpers/layout_device.rb
motion-kit-0.12.0 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.11.2 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.11.1 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.11.0 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.11 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.10 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.9 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.8 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.7 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.6 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.5 lib/motion-kit-ios/layouts/layout_device.rb