class BW::UIAlertView

Constants

KEYBOARD_TYPES

Attributes

callbacks[R]
clicked_button[RW]
handlers[R]

Public Class Methods

default(options = {}, &block) click to toggle source
# File motion/ui/ui_alert_view.rb, line 58
def default(options = {}, &block)
  options = {buttons: "OK"}.merge!(options)
  options[:style] = :default
  new(options, &block)
end
login_and_password_input(options = {}, &block) click to toggle source
# File motion/ui/ui_alert_view.rb, line 84
def login_and_password_input(options = {}, &block)
  options = {buttons: ["Cancel", "Log in"],
             cancel_button_index: 0}.merge!(options)
  options[:style] = :login_and_password_input
  new(options, &block)
end
new(options = {}, &block) click to toggle source
# File motion/ui/ui_alert_view.rb, line 32
def new(options = {}, &block)
  view = alloc.initWithTitle(options[:title],
    message: options[:message],
    delegate: nil,
    cancelButtonTitle: nil,
    otherButtonTitles: nil
  )

  Array(options[:buttons]).each { |title| view.addButtonWithTitle(title) }

  view.style               = options[:style]
  view.delegate            = view
  view.cancel_button_index = options[:cancel_button_index]

  view.instance_variable_set(:@handlers, {})
  block.weak! if block && BubbleWrap.use_weak_callbacks?

  options[:on_click] ||= block

  callbacks.each do |callback|
    view.send(callback, &options[callback]) if options[callback]
  end

  view
end
plain_text_input(options = {}, &block) click to toggle source
# File motion/ui/ui_alert_view.rb, line 64
def plain_text_input(options = {}, &block)
  options = {buttons: ["Cancel", "OK"],
             cancel_button_index: 0}.merge!(options)
  options[:style] = :plain_text_input
  new(options, &block).tap do |view|
    view.textFieldAtIndex(0).tap do |tf|
      tf.text = options[:text] if options[:text]
      tf.placeholder = options[:placeholder] if options[:placeholder]
      tf.keyboardType = (KEYBOARD_TYPES[options[:keyboard_type]] || options[:keyboard_type]) if options[:keyboard_type]
    end
  end
end
secure_text_input(options = {}, &block) click to toggle source
# File motion/ui/ui_alert_view.rb, line 77
def secure_text_input(options = {}, &block)
  options = {buttons: ["Cancel", "OK"],
             cancel_button_index: 0}.merge!(options)
  options[:style] = :secure_text_input
  new(options, &block)
end

Public Instance Methods

alertView(alert, clickedButtonAtIndex:index) click to toggle source
# File motion/ui/ui_alert_view.rb, line 160
def alertView(alert, clickedButtonAtIndex:index)
  alert.clicked_button = ClickedButton.new(alert, index)
  handlers[:on_click].call(alert) if handlers[:on_click]
end
alertViewCancel(alert) click to toggle source
# File motion/ui/ui_alert_view.rb, line 150
def alertViewCancel(alert)
  alert.clicked_button = nil
  handlers[:on_system_cancel].call(alert) if handlers[:on_system_cancel]
end
alertViewShouldEnableFirstOtherButton(alert) click to toggle source
# File motion/ui/ui_alert_view.rb, line 155
def alertViewShouldEnableFirstOtherButton(alert)
  alert.clicked_button = nil
  handlers[:enable_first_other_button?].call(alert) if handlers[:enable_first_other_button?]
end
cancel_button_index() click to toggle source
# File motion/ui/ui_alert_view.rb, line 100
def cancel_button_index
  cancelButtonIndex
end
cancel_button_index=(value) click to toggle source
# File motion/ui/ui_alert_view.rb, line 104
def cancel_button_index=(value)
  self.cancelButtonIndex = value if value
end
didPresentAlertView(alert) click to toggle source
# File motion/ui/ui_alert_view.rb, line 145
def didPresentAlertView(alert)
  alert.clicked_button = nil
  handlers[:did_present].call(alert) if handlers[:did_present]
end
login_text_field() click to toggle source
# File motion/ui/ui_alert_view.rb, line 185
def login_text_field
  textFieldAtIndex(0) if style == UIAlertViewStyleLoginAndPasswordInput
end
password_text_field() click to toggle source
# File motion/ui/ui_alert_view.rb, line 189
def password_text_field
  textFieldAtIndex(1) if style == UIAlertViewStyleLoginAndPasswordInput
end
plain_text_field() click to toggle source
# File motion/ui/ui_alert_view.rb, line 177
def plain_text_field
  textFieldAtIndex(0) if style == UIAlertViewStylePlainTextInput
end
secure_text_field() click to toggle source
# File motion/ui/ui_alert_view.rb, line 181
def secure_text_field
  textFieldAtIndex(0) if style == UIAlertViewStyleSecureTextInput
end
style() click to toggle source
# File motion/ui/ui_alert_view.rb, line 92
def style
  alertViewStyle
end
style=(value) click to toggle source
# File motion/ui/ui_alert_view.rb, line 96
def style=(value)
  self.alertViewStyle = Constants.get("UIAlertViewStyle", value) if value
end
willPresentAlertView(alert) click to toggle source

UIAlertViewDelegate protocol ################################################################

# File motion/ui/ui_alert_view.rb, line 140
def willPresentAlertView(alert)
  alert.clicked_button = nil
  handlers[:will_present].call(alert) if handlers[:will_present]
end