motion-takeoff 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36d1a7021acb70fdd7682c051d70107226c7e281
4
- data.tar.gz: c7c3c6a64a3e321561abbf624bf0e4439096717b
3
+ metadata.gz: b7becad65c8a7d0ea9ef00dbdbc2e27e97166643
4
+ data.tar.gz: 2032db9db7424eb048da9792e87c31fff7a76ac5
5
5
  SHA512:
6
- metadata.gz: d34035e2141b19b6138e404ffbeec2e9510914430445fa320d8c8446d9d2db4f43ce02b5d52011c322d68f93a9b7696c8cf75263882d7bf57c084e84fe77d29f
7
- data.tar.gz: 49a3f1c4bb2a7e9391c212dad2178ab2db7dabb32e279e8dd3b64a53b05f16033bbb30bc9566987f26a692743e480fbcf3f297e2ab003e7d20f65c8575eade2b
6
+ metadata.gz: 8b32a72d25d07ddbb549d870be775e79f332ca9bb7d715d89d5a794b54e1fe07c685822e279f2c628732facc17f69099682f0f5331578131af5656e6e8d1cb05
7
+ data.tar.gz: f83ac94768809e355bb6ab9cca6a999a0a9e9677f3df6c25d66349286b7058bad5e8048d9d8ee3e7bbd982427951ca526c5d8f6ccc460cfd7c27f858f07466d1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # motion-takeoff [![Build Status](https://travis-ci.org/MohawkApps/motion-takeoff.png)](https://travis-ci.org/MohawkApps/motion-takeoff) [![Code Climate](https://codeclimate.com/github/MohawkApps/motion-takeoff.png)](https://codeclimate.com/github/MohawkApps/motion-takeoff) [![Gem Version](https://badge.fury.io/rb/motion-takeoff.png)](http://badge.fury.io/rb/motion-takeoff)
2
2
 
3
- A RubyMotion specific iOS gem that helps you do things at launch. Currently, there are two modules in this gem: `Messages` & `Reminders`.
3
+ A RubyMotion specific iOS gem for scheduling stuff. You can use motion-takeoff to display messages at certain launch counts and schedule local notifications. Currently, there are two modules in this gem: `Messages` & `Reminders`.
4
4
 
5
5
  The `Messages` module will allow you to schedule alerts to users at certain launch counts.
6
6
 
@@ -29,8 +29,26 @@ def applicationDidBecomeActive(application)
29
29
  messages.takeoff
30
30
  end
31
31
  ```
32
+
32
33
  This will display an alert to the user on the 1st, 3rd, and 500th launches of the app.
33
34
 
35
+ ### Asking for confirmation
36
+
37
+ You can use the Messages module to ask a user to do something. Just pass a `Proc` object to the `:action` option. You can send an array of strings using `:buttons` but it will default to `["Cancel", "OK"]`. When the user presses the "OK" button, the `Proc` will run.
38
+
39
+ ```ruby
40
+ def applicationDidBecomeActive(application)
41
+ messages = Takeoff::Messages.new
42
+ messages.schedule(
43
+ launch: 1,
44
+ title: "Welcome to #{App.name}!",
45
+ message: "So you want to view the settings?"
46
+ action: Proc.new{ App.delegate.viewController.showSettings }
47
+ )
48
+ messages.takeoff
49
+ end
50
+ ```
51
+
34
52
  ## Usage: Reminder Module
35
53
 
36
54
  The reminders module is a nice wrapper on `UILocalNotification` and makes it easy to schedule reminders to come back and use your app!
@@ -59,7 +77,7 @@ def applicationDidEnterBackground(application)
59
77
  end
60
78
  ```
61
79
 
62
- The `Takeoff::Reminders.schedule` method takes a hash of options that are send to the `UILocalNotification`. `body` and `fire_date` are required and will raise an exception if you try to schedule a notification without those teo options. Here's all the default options:
80
+ The `Takeoff::Reminders.schedule` method takes a hash of options that are send to the `UILocalNotification`. `body` and `fire_date` are required and will raise an exception if you try to schedule a notification without those two options. Here's all the default options:
63
81
 
64
82
  ```ruby
65
83
  {
@@ -19,12 +19,35 @@ module Takeoff
19
19
  def takeoff
20
20
  self.messages.each do |message|
21
21
  if message[:launch] == App::Persistence[@launch_key]
22
- App.alert(message[:title], message:message[:message])
22
+ if message.keys.include? :action
23
+ confirm_alert message
24
+ else
25
+ regular_alert message
26
+ end
23
27
  end
24
28
  end
25
29
  end
26
30
 
27
31
  private
32
+
33
+ def regular_alert message
34
+ App.alert(message[:title], message:message[:message])
35
+ end
36
+
37
+ def confirm_alert message
38
+ message = {
39
+ :buttons => ["Cancel", "OK"]
40
+ }.merge(message)
41
+
42
+ alert = BW::UIAlertView.default(message) do |alert|
43
+ if alert.clicked_button.title == "OK"
44
+ message[:action].call
45
+ end
46
+ end
47
+
48
+ alert.show
49
+ end
50
+
28
51
  def handle_launch
29
52
  if App::Persistence[@launch_key].nil?
30
53
  App::Persistence[@launch_key] = 1
@@ -1,3 +1,3 @@
1
1
  module Takeoff
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-takeoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rickert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-07 00:00:00.000000000 Z
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - '>'
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.0
41
- description: A RubyMotion specific iOS gem that helps you do things at launch.
41
+ description: A RubyMotion specific iOS gem for scheduling stuff.
42
42
  email:
43
43
  - mjar81@gmail.com
44
44
  executables: []
@@ -73,8 +73,7 @@ rubyforge_project:
73
73
  rubygems_version: 2.0.3
74
74
  signing_key:
75
75
  specification_version: 4
76
- summary: A RubyMotion specific iOS gem that helps you do things at launch. You can
77
- use this gem to display messages at certain launch counts and remind users to use
78
- your app.
76
+ summary: A RubyMotion specific iOS gem for scheduling stuff. You can use motion-takeoff
77
+ to display messages at certain launch counts and schedule local notifications.
79
78
  test_files: []
80
79
  has_rdoc: