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-0.10.4 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.3 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.2 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.1 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.10.0 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.9.6 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.9.4 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.9.3 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.9.2 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.9.1 lib/motion-kit-ios/layouts/layout_device.rb
motion-kit-0.9.0 lib/motion-kit-ios/layouts/layout_device.rb