Sha256: 701facf527b72668e6a5935cf59692b79df4f9ad3b2a8c4fa322583d42c7fc3c

Contents?: true

Size: 729 Bytes

Versions: 9

Compression:

Stored size: 729 Bytes

Contents

module UI
  class Alert
    def title=(title)
      proxy.title = title
    end

    def message=(message)
      proxy.message = message
    end

    def set_button(title, type)
      @buttons ||= {}
      pos = proxy.addButtonWithTitle(title)
      if type == :cancel
        proxy.cancelButtonIndex = pos
      end
      @buttons[pos] = type
    end

    def show(&block)
      @complete_block = (block or raise "expected block")
      proxy.show
    end

    def alertView(view, clickedButtonAtIndex:pos)
      @complete_block.call(@buttons[pos] || :default)
    end

    def proxy
      @proxy ||= UIAlertView.alloc.initWithTitle("", message:"", delegate:self, cancelButtonTitle:nil, otherButtonTitles:nil)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
motion-flow-0.1.8 flow/ui/cocoa/alert.rb
motion-flow-0.1.7 flow/ui/cocoa/alert.rb
motion-flow-0.1.6 flow/ui/cocoa/alert.rb
motion-flow-0.1.5 flow/ui/cocoa/alert.rb
motion-flow-0.1.4 flow/ui/cocoa/alert.rb
motion-flow-0.1.3 flow/ui/cocoa/alert.rb
motion-flow-0.1.2 flow/ui/cocoa/alert.rb
motion-flow-0.1.1 flow/ui/cocoa/alert.rb
motion-flow-0.1 flow/ui/cocoa/alert.rb