Sha256: 5449973a9548ac39923d0b75e06c851f3a9fda2e01d5ecc2c35cd4eeec8eef2d
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
class UnderOs::UI::Alert include UnderOs::Events def initialize(options={}) options = {message: options} if options.is_a?(String) self.on = options.delete[:on] if options[:on] @_ = CustomAlertView.alloc.initiWithOptions(self, options) @_.show unless options[:show] == false end def show @_.show self end def hide(animated=true) @_.dismissWithClickedButtonIndex(0, animated: animated) self end def visible @_.visible end def hidden !visible end class CustomAlertView < UIAlertView def initiWithOptions(wrapper, options) @wrapper = wrapper initWithTitle( options[:title] || "", message: options[:message] || "No message given", delegate: self, cancelButtonTitle: options[:button] || "Ok", otherButtonTitles: nil ) (options[:buttons] || []).each do |title| addButtonWithTitle title end self end def alertView(alertView, willDismissWithButtonIndex:buttonIndex) @wrapper.emit(:tap, buttonIndex: buttonIndex, buttonTitle: buttonTitleAtIndex(buttonIndex)) @wrapper.emit(:close) end end end
Version data entries
6 entries across 6 versions & 2 rubygems