motion-alert 0.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 +12 -8
- data/lib/project/motion_alert.rb +19 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22b3d7db8129c6b046fdd95ffd4c36a73521f141
|
4
|
+
data.tar.gz: 963319f14db7c36da75d2c413e9927cc2679934b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7a56b0a7d1d95e0b089f116e5e06e9a5ba3dcd5247cdc5ed4cfe1a1b98a46e3ca937fa5a8bb530332319866cc337bfe1fc4c2f93bb3d96f7a62d850b8953dd
|
7
|
+
data.tar.gz: bb8d90f0964e80037a71b94b24869a0960f0908e34a9c83f62c0ca4be79901e983d40948afa013cb07d15a7eb77fecdb4275f8b700f9bf7678c91c15c7e79566
|
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
Motion-Alert
|
1
|
+
# Motion-Alert
|
2
|
+
[![Build Status](https://travis-ci.org/squidpunch/motion-alert.svg?branch=master)](https://travis-ci.org/squidpunch/motion-alert)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/motion-alert.svg)](http://badge.fury.io/rb/motion-alert)
|
2
4
|
|
3
5
|
Want to just show an alert to your no matter what version of iOS you are on?
|
4
6
|
Motion-alert is for you. Did you know `UIAlert` is deprecated in iOS 8? You
|
5
7
|
should be using `UIAlertController` but if you use that controller on a prior
|
6
|
-
iOS version, you're bound to have a bad time.
|
8
|
+
iOS version, you're bound to have a bad time. **Motion Alert** manages this for
|
9
|
+
you, you just say you want an alert, buttons to show and the actions on those
|
10
|
+
buttons and Motion Alert handles the rest.
|
7
11
|
|
8
12
|
## Installation
|
9
13
|
|
@@ -21,13 +25,13 @@ Or install it yourself as:
|
|
21
25
|
|
22
26
|
## Usage
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
def show_alert
|
29
|
+
Motion::Alert.new({title: "Alert!", message:"message"}).tap do |a|
|
30
|
+
a.add_action("OK", Proc.new { puts 'OK!' })
|
31
|
+
a.add_action("Cancel", Proc.new { puts 'Cancel!' })
|
32
|
+
a.show
|
33
|
+
end
|
29
34
|
end
|
30
|
-
end
|
31
35
|
|
32
36
|
## Contributing
|
33
37
|
|
data/lib/project/motion_alert.rb
CHANGED
@@ -30,6 +30,14 @@ module Motion
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def selected(index)
|
34
|
+
if action = self.actions[index].action
|
35
|
+
action.call
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
33
41
|
def alert_view_controller
|
34
42
|
alert_view_controller =
|
35
43
|
UIAlertController.alertControllerWithTitle(
|
@@ -50,29 +58,21 @@ module Motion
|
|
50
58
|
end
|
51
59
|
|
52
60
|
def alert_view
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
@alert_view.addButtonWithTitle(a.title)
|
64
|
-
end
|
61
|
+
alert_view = UIAlertView.alloc.initWithTitle(
|
62
|
+
title,
|
63
|
+
message: message,
|
64
|
+
delegate: UIApplication.sharedApplication.delegate,
|
65
|
+
cancelButtonTitle: nil,
|
66
|
+
otherButtonTitles:
|
67
|
+
nil
|
68
|
+
)
|
69
|
+
self.actions.each do |a|
|
70
|
+
alert_view.addButtonWithTitle(a.title)
|
65
71
|
end
|
66
72
|
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
def selected(index)
|
71
|
-
self.actions[index].action.call
|
73
|
+
alert_view
|
72
74
|
end
|
73
75
|
|
74
|
-
private
|
75
|
-
|
76
76
|
def can_show_controller?
|
77
77
|
!!UIDevice.currentDevice.systemVersion.match("^8")
|
78
78
|
end
|
@@ -80,6 +80,5 @@ module Motion
|
|
80
80
|
def root_controller
|
81
81
|
UIApplication.sharedApplication.keyWindow.rootViewController
|
82
82
|
end
|
83
|
-
|
84
83
|
end
|
85
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-alert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Larrabee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|