Class: BW::UIAlertView
- Inherits:
-
UIAlertView
- Object
- UIAlertView
- BW::UIAlertView
- Defined in:
- motion/ui/ui_alert_view.rb
Defined Under Namespace
Classes: ClickedButton
Constant Summary collapse
- KEYBOARD_TYPES =
{ default: UIKeyboardTypeDefault, ascii: UIKeyboardTypeASCIICapable, numbers_punctuation: UIKeyboardTypeNumbersAndPunctuation, url: UIKeyboardTypeURL, number_pad: UIKeyboardTypeNumberPad, phone_pad: UIKeyboardTypePhonePad, name_phone_pad: UIKeyboardTypeNamePhonePad, email_address: UIKeyboardTypeEmailAddress, email: UIKeyboardTypeEmailAddress, # Duplicate to help developers decimal_pad: UIKeyboardTypeDecimalPad, twitter: UIKeyboardTypeTwitter, web_search: UIKeyboardTypeWebSearch, alphabet: UIKeyboardTypeASCIICapable }
Class Attribute Summary collapse
-
.callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
Instance Attribute Summary collapse
-
#clicked_button ⇒ Object
readonly
Returns the value of attribute clicked_button.
Class Method Summary collapse
- .default(options = {}, &block) ⇒ Object
- .login_and_password_input(options = {}, &block) ⇒ Object
- .new(options = {}, &block) ⇒ Object
- .plain_text_input(options = {}, &block) ⇒ Object
- .secure_text_input(options = {}, &block) ⇒ Object
Instance Method Summary collapse
- #alertView(alert, didDismissWithButtonIndex: index) ⇒ Object
- #alertViewCancel(alert) ⇒ Object
- #alertViewShouldEnableFirstOtherButton(alert) ⇒ Object
- #cancel_button_index ⇒ Object
- #cancel_button_index=(value) ⇒ Object
- #didPresentAlertView(alert) ⇒ Object
- #login_text_field ⇒ Object
- #password_text_field ⇒ Object
- #plain_text_field ⇒ Object
- #secure_text_field ⇒ Object
- #style ⇒ Object
- #style=(value) ⇒ Object
-
#willPresentAlertView(alert) ⇒ Object
UIAlertViewDelegate protocol ################################################################.
Class Attribute Details
.callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
30 31 32 |
# File 'motion/ui/ui_alert_view.rb', line 30 def callbacks @callbacks end |
Instance Attribute Details
#clicked_button ⇒ Object
Returns the value of attribute clicked_button.
110 111 112 |
# File 'motion/ui/ui_alert_view.rb', line 110 def end |
Class Method Details
.default(options = {}, &block) ⇒ Object
58 59 60 61 62 |
# File 'motion/ui/ui_alert_view.rb', line 58 def default( = {}, &block) = {buttons: "OK"}.merge!() [:style] = :default new(, &block) end |
.login_and_password_input(options = {}, &block) ⇒ Object
84 85 86 87 88 89 |
# File 'motion/ui/ui_alert_view.rb', line 84 def login_and_password_input( = {}, &block) = {buttons: ["Cancel", "Log in"], cancel_button_index: 0}.merge!() [:style] = :login_and_password_input new(, &block) end |
.new(options = {}, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'motion/ui/ui_alert_view.rb', line 32 def new( = {}, &block) view = alloc.initWithTitle([:title], message: [:message], delegate: nil, cancelButtonTitle: nil, otherButtonTitles: nil ) Array([:buttons]).each { |title| view.addButtonWithTitle(title) } view.style = [:style] view.delegate = view view. = [:cancel_button_index] view.instance_variable_set(:@handlers, {}) block.weak! if block && BubbleWrap.use_weak_callbacks? [:on_click] ||= block callbacks.each do |callback| view.send(callback, &[callback]) if [callback] end view end |
.plain_text_input(options = {}, &block) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'motion/ui/ui_alert_view.rb', line 64 def plain_text_input( = {}, &block) = {buttons: ["Cancel", "OK"], cancel_button_index: 0}.merge!() [:style] = :plain_text_input new(, &block).tap do |view| view.textFieldAtIndex(0).tap do |tf| tf.text = [:text] if [:text] tf.placeholder = [:placeholder] if [:placeholder] tf.keyboardType = (KEYBOARD_TYPES[[:keyboard_type]] || [:keyboard_type]) if [:keyboard_type] end end end |
.secure_text_input(options = {}, &block) ⇒ Object
77 78 79 80 81 82 |
# File 'motion/ui/ui_alert_view.rb', line 77 def secure_text_input( = {}, &block) = {buttons: ["Cancel", "OK"], cancel_button_index: 0}.merge!() [:style] = :secure_text_input new(, &block) end |
Instance Method Details
#alertView(alert, didDismissWithButtonIndex: index) ⇒ Object
160 161 162 163 |
# File 'motion/ui/ui_alert_view.rb', line 160 def alertView(alert, clickedButtonAtIndex:index) alert. = ClickedButton.new(alert, index) handlers[:on_click].call(alert) if handlers[:on_click] end |
#alertViewCancel(alert) ⇒ Object
150 151 152 153 |
# File 'motion/ui/ui_alert_view.rb', line 150 def alertViewCancel(alert) alert. = nil handlers[:on_system_cancel].call(alert) if handlers[:on_system_cancel] end |
#alertViewShouldEnableFirstOtherButton(alert) ⇒ Object
155 156 157 158 |
# File 'motion/ui/ui_alert_view.rb', line 155 def alertViewShouldEnableFirstOtherButton(alert) alert. = nil handlers[:enable_first_other_button?].call(alert) if handlers[:enable_first_other_button?] end |
#cancel_button_index ⇒ Object
100 101 102 |
# File 'motion/ui/ui_alert_view.rb', line 100 def cancelButtonIndex end |
#cancel_button_index=(value) ⇒ Object
104 105 106 |
# File 'motion/ui/ui_alert_view.rb', line 104 def (value) self.cancelButtonIndex = value if value end |
#didPresentAlertView(alert) ⇒ Object
145 146 147 148 |
# File 'motion/ui/ui_alert_view.rb', line 145 def didPresentAlertView(alert) alert. = nil handlers[:did_present].call(alert) if handlers[:did_present] end |
#login_text_field ⇒ Object
185 186 187 |
# File 'motion/ui/ui_alert_view.rb', line 185 def login_text_field textFieldAtIndex(0) if style == UIAlertViewStyleLoginAndPasswordInput end |
#password_text_field ⇒ Object
189 190 191 |
# File 'motion/ui/ui_alert_view.rb', line 189 def password_text_field textFieldAtIndex(1) if style == UIAlertViewStyleLoginAndPasswordInput end |
#plain_text_field ⇒ Object
177 178 179 |
# File 'motion/ui/ui_alert_view.rb', line 177 def plain_text_field textFieldAtIndex(0) if style == UIAlertViewStylePlainTextInput end |
#secure_text_field ⇒ Object
181 182 183 |
# File 'motion/ui/ui_alert_view.rb', line 181 def secure_text_field textFieldAtIndex(0) if style == UIAlertViewStyleSecureTextInput end |
#style ⇒ Object
92 93 94 |
# File 'motion/ui/ui_alert_view.rb', line 92 def style alertViewStyle end |
#style=(value) ⇒ Object
96 97 98 |
# File 'motion/ui/ui_alert_view.rb', line 96 def style=(value) self.alertViewStyle = Constants.get("UIAlertViewStyle", value) if value end |
#willPresentAlertView(alert) ⇒ Object
UIAlertViewDelegate protocol ################################################################
140 141 142 143 |
# File 'motion/ui/ui_alert_view.rb', line 140 def willPresentAlertView(alert) alert. = nil handlers[:will_present].call(alert) if handlers[:will_present] end |