RedAlert 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -3
- data/lib/project/button_templates.rb +5 -5
- data/lib/project/red_alert.rb +26 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb460bb7537e289c09e0a687625240722150b926
|
4
|
+
data.tar.gz: 8045ee75e15e7e3dd3b30d8f38e827ebc5b50c4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934d7a4b369c1fab4587fb4f0c83ad32f6a508baf64389f8467d1735e601ca755e2e9dc58eba5935a87469003395ce87ac8dd0c2c32a5e03016b4a7a3e9e8da1
|
7
|
+
data.tar.gz: 1839259b6393176975b33e3ac73f1b9721ac6962b3dd2ff87e868c1796476486cdda401bc9e470b0670056bbabbd3b3e4d4631ce8815836d3a02679a54a6dc7d
|
data/README.md
CHANGED
@@ -16,9 +16,9 @@ When run on iOS 7, RedAlert uses `UIAlertView` present alerts and `UIActionSheet
|
|
16
16
|
|
17
17
|
*:dart: RedAlert Means you don't have to worry about a thing!*
|
18
18
|
|
19
|
-
##
|
19
|
+
## In Action
|
20
20
|
|
21
|
-
<img src="./_art/
|
21
|
+
<img src="./_art/demo.gif" alt="Demo" width="369" height="677" />
|
22
22
|
|
23
23
|
## Installation
|
24
24
|
|
@@ -61,6 +61,19 @@ Add the **RedAlert** gem to your Gemfile.
|
|
61
61
|
end
|
62
62
|
```
|
63
63
|
|
64
|
+
You can pass in symbols or strings and we'll build the buttons for you:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
rmq.app.alert title: "Hey!", actions: [ "Go ahead", :cancel, :delete ] do |button_tag|
|
68
|
+
case button_tag
|
69
|
+
when :cancel then puts "Canceled!"
|
70
|
+
when :delete then puts "Deleted!"
|
71
|
+
when "Go ahead" then puts "Going ahead!"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
|
64
77
|
You can even use the `make_button` helper to create custom UIAction buttons to add:
|
65
78
|
```ruby
|
66
79
|
# Use custom UIAction buttons and add them
|
@@ -102,12 +115,14 @@ Because capabilities of iOS 7 & 8 alert-components are different, just a few edg
|
|
102
115
|
* `UIAlertView`'s `alertViewStyles` are not available through RedAlert as they aren't compatible with iOS 8. You'll have to call that directly.
|
103
116
|
|
104
117
|
|
105
|
-
##
|
118
|
+
## Credits and Info
|
106
119
|
|
107
120
|
**i18n support by [Mark Rickert](https://github.com/GantMan/RedAlert/pull/2)**
|
108
121
|
|
109
122
|
**iOS 7 support by [Steve Kellock](https://github.com/GantMan/RedAlert/pull/3)**
|
110
123
|
|
124
|
+
**Automatic button building by [Jamon Holmgren](https://github.com/GantMan/RedAlert/pull/7)**
|
125
|
+
|
111
126
|
Feel free to read up on UIAlertController to see what all is wrapped up in this gem.
|
112
127
|
* [Hayageek](http://hayageek.com/uialertcontroller-example-ios/)
|
113
128
|
* [NSHipster](http://nshipster.com/uialertcontroller/)
|
@@ -24,17 +24,17 @@ module RubyMotionQuery
|
|
24
24
|
[
|
25
25
|
rmq.app.make_button(title: yes, tag: :yes, &block),
|
26
26
|
rmq.app.make_button(title: no, tag: :no, &block),
|
27
|
-
rmq.app.make_button(
|
27
|
+
rmq.app.make_button(title: cancel, tag: :cancel, style: :cancel, &block)
|
28
28
|
]
|
29
29
|
when :ok_cancel
|
30
30
|
[
|
31
|
-
rmq.app.make_button(ok, &block),
|
32
|
-
rmq.app.make_button(
|
31
|
+
rmq.app.make_button(title: ok, &block),
|
32
|
+
rmq.app.make_button(title: cancel, tag: :cancel, style: :cancel, &block)
|
33
33
|
]
|
34
34
|
when :delete_cancel
|
35
35
|
[
|
36
|
-
rmq.app.make_button(
|
37
|
-
rmq.app.make_button(
|
36
|
+
rmq.app.make_button(title: delete, tag: :delete, style: :destructive, &block),
|
37
|
+
rmq.app.make_button(title: cancel, tag: :cancel, style: :cancel, &block)
|
38
38
|
]
|
39
39
|
else
|
40
40
|
[]
|
data/lib/project/red_alert.rb
CHANGED
@@ -39,7 +39,7 @@ module RubyMotionQuery
|
|
39
39
|
actions = []
|
40
40
|
if opts[:actions] && opts[:actions].is_a?(Array) && opts[:actions].length > 0
|
41
41
|
# caller has pre-defined actions
|
42
|
-
actions << opts[:actions]
|
42
|
+
actions << map_action_buttons(opts[:actions], &block)
|
43
43
|
elsif opts[:actions] && opts[:actions].is_a?(Symbol)
|
44
44
|
# caller wants a template
|
45
45
|
actions << add_template_actions(opts[:actions], &block)
|
@@ -77,6 +77,31 @@ module RubyMotionQuery
|
|
77
77
|
AlertAction.new(opts, &block)
|
78
78
|
end
|
79
79
|
|
80
|
+
# Returns an array of action buttons based on the symbols you pass in.
|
81
|
+
# Usage Example:
|
82
|
+
# rmq.app.alert title: "Hey!", actions: [ "Go ahead", :cancel, :delete ] do |button_tag|
|
83
|
+
# puts "#{button_text} pressed"
|
84
|
+
# end
|
85
|
+
def map_action_buttons(buttons, &block)
|
86
|
+
yes = NSLocalizedString("Yes", nil)
|
87
|
+
no = NSLocalizedString("No", nil)
|
88
|
+
cancel = NSLocalizedString("Cancel", nil)
|
89
|
+
ok = NSLocalizedString("OK", nil)
|
90
|
+
delete = NSLocalizedString("Delete", nil)
|
91
|
+
|
92
|
+
buttons.map do |button|
|
93
|
+
case button
|
94
|
+
when :cancel then make_button(title: cancel, tag: :cancel, style: :cancel, &block)
|
95
|
+
when :yes then make_button(title: yes, tag: :yes, &block)
|
96
|
+
when :no then make_button(title: no, tag: :no, &block)
|
97
|
+
when :ok then make_button(title: ok, tag: :ok, &block)
|
98
|
+
when :delete then make_button(title: delete, tag: :delete, style: :destructive, &block)
|
99
|
+
when String then make_button(title: button, tag: button, &block)
|
100
|
+
else button
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
80
105
|
end # close eigenclass
|
81
106
|
|
82
107
|
end # close App
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RedAlert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Gant
|
7
|
+
- Gant Laborde
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby_motion_query
|