status_bar 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +14 -0
  3. data/Gemfile +10 -0
  4. data/Gemfile.lock +51 -0
  5. data/Guardfile +12 -0
  6. data/README.md +66 -0
  7. data/Rakefile +28 -0
  8. data/app/app_delegate.rb +10 -0
  9. data/app/controllers/demo_controller.rb +51 -0
  10. data/app/styles/demo_style.rb +88 -0
  11. data/lib/project/base.rb +101 -0
  12. data/lib/project/helper.rb +60 -0
  13. data/lib/project/style.rb +87 -0
  14. data/lib/project/view.rb +38 -0
  15. data/lib/resources/error.png +0 -0
  16. data/lib/resources/error@2x.png +0 -0
  17. data/lib/resources/success.png +0 -0
  18. data/lib/resources/success@2x.png +0 -0
  19. data/lib/status_bar.rb +37 -0
  20. data/resources/Default-568h@2x.png +0 -0
  21. data/resources/error.png +0 -0
  22. data/resources/error@2x.png +0 -0
  23. data/resources/success.png +0 -0
  24. data/resources/success@2x.png +0 -0
  25. data/screenshots/activity.png +0 -0
  26. data/screenshots/error.png +0 -0
  27. data/screenshots/notice.png +0 -0
  28. data/screenshots/success.png +0 -0
  29. data/spec/app_delegate_spec.rb +15 -0
  30. data/spec/demo_controller_spec.rb +52 -0
  31. data/status_bar.gemspec +24 -0
  32. data/vendor/Podfile.lock +10 -0
  33. data/vendor/Pods/.build/libPods-Reachability.a +0 -0
  34. data/vendor/Pods/.build/libPods.a +0 -0
  35. data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
  36. data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
  37. data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
  38. data/vendor/Pods/Headers/____Pods-environment.h +14 -0
  39. data/vendor/Pods/Manifest.lock +10 -0
  40. data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
  41. data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
  42. data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
  43. data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
  44. data/vendor/Pods/Pods-acknowledgements.markdown +17 -0
  45. data/vendor/Pods/Pods-acknowledgements.plist +47 -0
  46. data/vendor/Pods/Pods-dummy.m +5 -0
  47. data/vendor/Pods/Pods-environment.h +14 -0
  48. data/vendor/Pods/Pods-resources.sh +55 -0
  49. data/vendor/Pods/Pods.bridgesupport +100 -0
  50. data/vendor/Pods/Pods.xcconfig +4 -0
  51. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +960 -0
  52. data/vendor/Pods/Pods.xcodeproj/xcuserdata/holgersindbaek.xcuserdatad/xcschemes/Pods-Reachability.xcscheme +59 -0
  53. data/vendor/Pods/Pods.xcodeproj/xcuserdata/holgersindbaek.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
  54. data/vendor/Pods/Pods.xcodeproj/xcuserdata/holgersindbaek.xcuserdatad/xcschemes/xcschememanagement.plist +21 -0
  55. data/vendor/Pods/Reachability/LICENCE.txt +24 -0
  56. data/vendor/Pods/Reachability/README.md +65 -0
  57. data/vendor/Pods/Reachability/Reachability.h +109 -0
  58. data/vendor/Pods/Reachability/Reachability.m +527 -0
  59. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
  60. metadata +175 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzZlOGIwZTJkYmJkZTQzZDFjODI3MjIwMjBhOTZjOTMzYzI5NTEyMg==
5
+ data.tar.gz: !binary |-
6
+ YjllNGQ1YTg4YTRmOTNkN2VlZjQzNTQ3NmYzYTgxZGIyOThjZTMxMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YmRkMzRlMGJjMTg4OWVkMDA5YmY4MzJhZGVjODg4NjY0OWQ5YWM0ZTg0YmVl
10
+ ZDAwMTQ4NTY4YTliM2ZkNmE0MDRiNTNjNGY0NWE3OTA3N2U1OGIyODQ5N2Rm
11
+ ZjI0ZWQyNjg5NmM1MDVlNmQyMWY5MzM3Yzg4YzZlODEzMWQ1Mzg=
12
+ data.tar.gz: !binary |-
13
+ MzM5MmQ1NmVhNDhlMDQ0YTU0Yjg0ZTUxNzRmMDNkNzRjY2I1NzVjZDdjMmIw
14
+ YzlkOTc4ZDNmNTFmNzViY2QxYmRiMTA2NTVjNjQ2YmZiNDZhMWQ4OTdhM2Rk
15
+ MTNiYjljOGZiNTk0ZjY3OTQ0YTkyMzNiMGMwMzkzNmVjZTUwZTQ=
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ .repl_history
2
+ build
3
+ tags
4
+ app/pixate_code.rb
5
+ .DS_Store
6
+ nbproject
7
+ .redcar
8
+ #*#
9
+ *~
10
+ *.sw[po]
11
+ *.gem
12
+ .eprj
13
+ .sass-cache
14
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'status_bar', :path => '~/Projects/*Defaults/Misc/Gems/status_bar'
4
+ gem 'teacup', '2.1.13'
5
+ gem 'sugarcube', '1.3.2'
6
+
7
+ group :development do
8
+ gem 'awesome_print_motion'
9
+ gem 'guard-motion'
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GIT
2
+ remote: https://github.com/holgersindbaek/sugarcube
3
+ revision: 24c813f16f5799dd7ddffdf801d83a989270befa
4
+ specs:
5
+ sugarcube (1.3.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ awesome_print_motion (0.1.0)
11
+ celluloid (0.15.2)
12
+ timers (~> 1.1.0)
13
+ coderay (1.0.9)
14
+ ffi (1.9.3)
15
+ formatador (0.2.4)
16
+ guard (2.2.2)
17
+ formatador (>= 0.2.4)
18
+ listen (~> 2.1)
19
+ lumberjack (~> 1.0)
20
+ pry (>= 0.9.12)
21
+ thor (>= 0.18.1)
22
+ guard-motion (0.1.2)
23
+ guard (>= 1.1.0)
24
+ rake (>= 0.9)
25
+ listen (2.2.0)
26
+ celluloid (>= 0.15.2)
27
+ rb-fsevent (>= 0.9.3)
28
+ rb-inotify (>= 0.9)
29
+ lumberjack (1.0.4)
30
+ method_source (0.8.2)
31
+ pry (0.9.12.2)
32
+ coderay (~> 1.0.5)
33
+ method_source (~> 0.8)
34
+ slop (~> 3.4)
35
+ rake (10.1.0)
36
+ rb-fsevent (0.9.3)
37
+ rb-inotify (0.9.2)
38
+ ffi (>= 0.5.0)
39
+ slop (3.4.6)
40
+ teacup (2.1.13)
41
+ thor (0.18.1)
42
+ timers (1.1.0)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ awesome_print_motion
49
+ guard-motion
50
+ sugarcube!
51
+ teacup (= 2.1.13)
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'motion', :env => {:output => 'colored_spec_dox'}, :all_after_pass => false do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+
7
+ # RubyMotion App example
8
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
+
10
+ # RubyMotion gem example
11
+ watch(%r{^lib/[^/]+/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
12
+ end
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # StatusBar
2
+
3
+ ##Description
4
+
5
+ A utility class for displaying status updates in the iOS status bar. Inspired by Mailbox and designed to function similar to SVProgressHUD.
6
+
7
+ ## Installation
8
+
9
+ Add StatusBar to your Gemfile, and run `bundle install`:
10
+ ```ruby
11
+
12
+ gem 'status_bar'
13
+ ```
14
+
15
+ If you're making an iOS 7 app, this is a good idea as well:
16
+
17
+ ```ruby
18
+
19
+ Motion::Project::App.setup do |app|
20
+ # Setting the statusbarstyle to a light style in all the viewcontrollers
21
+ app.info_plist['UIViewControllerBasedStatusBarAppearance'] = false
22
+ app.info_plist['UIStatusBarStyle'] = "UIStatusBarStyleDefault"
23
+ end
24
+ ```
25
+ ## Usage
26
+
27
+ ``` ruby
28
+
29
+ # Initilize the status bar
30
+ statusbar = StatusBar::Base.new
31
+
32
+ # Show a notice... and hide it
33
+ statusbar.show_notice("Hello World")
34
+ statusbar.hide_notice
35
+
36
+ # Show notice with an indicator
37
+ statusbar.show_activity_notice("Somethings is happening")
38
+ statusbar.show_success_notice("Great success")
39
+ statusbar.show_error_notice("Awww... did't work out")
40
+
41
+ # Check if the status bar is currently visible
42
+ statusbar.visible?
43
+ ```
44
+
45
+ ## Demo Project
46
+
47
+ There's a demo project in this gem. Clone it and play around with it.
48
+
49
+ ##Screenshots
50
+
51
+ ![Notice](screenshots/notice.png)
52
+ ![Activity](screenshots/activity.png)
53
+ ![Success](screenshots/success.png)
54
+ ![Error](screenshots/error.png)
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
63
+
64
+ ## Thanks
65
+
66
+ * [Brian Partridge](https://github.com/brianpartridge) for [BPStatusBar](https://github.com/brianpartridge/BPStatusBar)
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ $:.unshift("/Library/RubyMotion/lib")
3
+
4
+ require 'motion/project/template/ios'
5
+
6
+ require 'awesome_print_motion'
7
+ require 'guard/motion'
8
+ require 'teacup'
9
+ require 'sugarcube-repl'
10
+ require 'sugarcube-uikit'
11
+ require 'sugarcube-color'
12
+ require 'sugarcube-uikit'
13
+ require './lib/status_bar'
14
+
15
+ begin
16
+ require 'bundler'
17
+ require 'motion/project/template/gem/gem_tasks'
18
+ Bundler.require
19
+ rescue LoadError
20
+ end
21
+
22
+ Motion::Project::App.setup do |app|
23
+ # Use `rake config' to see complete project settings.
24
+ app.name = 'status_bar'
25
+ app.info_plist['UIStatusBarHidden'] = false
26
+ app.info_plist['UIViewControllerBasedStatusBarAppearance'] = false
27
+ app.info_plist['UIStatusBarStyle'] = 'UIStatusBarStyleLightContent'
28
+ end
@@ -0,0 +1,10 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
4
+ @window.makeKeyAndVisible
5
+ @window.backgroundColor = "#000000".uicolor
6
+ @window.rootViewController = DemoController.new
7
+
8
+ true
9
+ end
10
+ end
@@ -0,0 +1,51 @@
1
+ class DemoController < UIViewController
2
+ stylesheet :demo
3
+
4
+ layout :demo_view do
5
+ @container = subview(UIView, :container) do
6
+ @show_notice_button = subview(UIButton.buttonWithType(UIButtonTypeRoundedRect), :show_notice_button)
7
+ @show_activity_button = subview(UIButton.buttonWithType(UIButtonTypeRoundedRect), :show_activity_button)
8
+ @show_success_button = subview(UIButton.buttonWithType(UIButtonTypeRoundedRect), :show_success_button)
9
+ @show_error_button = subview(UIButton.buttonWithType(UIButtonTypeRoundedRect), :show_error_button)
10
+ @hide_notice_button = subview(UIButton.buttonWithType(UIButtonTypeRoundedRect), :hide_notice_button)
11
+ @visibility_button = subview(UIButton.buttonWithType(UIButtonTypeRoundedRect), :visibility_button)
12
+ end
13
+ end
14
+
15
+ def viewDidLoad
16
+ super
17
+
18
+ ap "first viewDidLoad"
19
+
20
+ @status_bar = StatusBar::Base.new
21
+
22
+ @show_notice_button.when(UIControlEventTouchUpInside) {
23
+ @status_bar.show_notice "This is a notice"
24
+ }
25
+
26
+ @show_activity_button.when(UIControlEventTouchUpInside) {
27
+ @status_bar.show_activity_notice "Something's going on"
28
+ }
29
+
30
+ @show_success_button.when(UIControlEventTouchUpInside) {
31
+ @status_bar.show_success_notice "Wohoo... made it!"
32
+ }
33
+
34
+ @show_error_button.when(UIControlEventTouchUpInside) {
35
+ @status_bar.show_error_notice "Aww... no go"
36
+ }
37
+
38
+ @hide_notice_button.when(UIControlEventTouchUpInside) {
39
+ @status_bar.hide_notice
40
+ }
41
+
42
+ @visibility_button.when(UIControlEventTouchUpInside) {
43
+ ap @status_bar.visible?
44
+ }
45
+ end
46
+
47
+ def shouldAutorotate
48
+ true
49
+ end
50
+
51
+ end
@@ -0,0 +1,88 @@
1
+ Teacup::Stylesheet.new :demo do
2
+
3
+ style :demo_view,
4
+ backgroundColor: "#000000".uicolor
5
+
6
+ style :container,
7
+ top: 20,
8
+ backgroundColor: "#ffffff".uicolor,
9
+ portrait: {
10
+ width: "100%",
11
+ height: "100%-20"
12
+ },
13
+ landscape: {
14
+ width: "100%",
15
+ height: "100%-20"
16
+ }
17
+
18
+ style UIButton,
19
+ height: 40,
20
+ left: 10,
21
+ layer: {
22
+ borderWidth: 1,
23
+ borderColor: "#c8c7cc".uicolor.CGColor,
24
+ cornerRadius: 8
25
+ },
26
+ landscape: {
27
+ width: "50%-15"
28
+ },
29
+ portrait: {
30
+ width: "100%-20"
31
+ }
32
+
33
+ style :show_notice_button,
34
+ title: 'Show Notice',
35
+ top: 10
36
+
37
+ style :show_activity_button,
38
+ title: 'Show Activity',
39
+ portrait: {
40
+ top: 60,
41
+ left: 10
42
+ },
43
+ landscape: {
44
+ top: 10,
45
+ left: "50%+5"
46
+ }
47
+
48
+ style :show_success_button,
49
+ title: 'Show Success',
50
+ portrait: {
51
+ top: 110,
52
+ },
53
+ landscape: {
54
+ top: 60,
55
+ }
56
+
57
+ style :show_error_button,
58
+ title: 'Show Error',
59
+ portrait: {
60
+ top: 160,
61
+ left: 10
62
+ },
63
+ landscape: {
64
+ top: 60,
65
+ left: "50%+5"
66
+ }
67
+
68
+ style :hide_notice_button,
69
+ title: 'Hide Notice',
70
+ portrait: {
71
+ top: 210,
72
+ },
73
+ landscape: {
74
+ top: 110,
75
+ }
76
+
77
+ style :visibility_button,
78
+ title: 'Visible?',
79
+ portrait: {
80
+ top: 260,
81
+ left: 10
82
+ },
83
+ landscape: {
84
+ top: 110,
85
+ left: "50%+5"
86
+ }
87
+
88
+ end
@@ -0,0 +1,101 @@
1
+ module StatusBar
2
+ class Base
3
+
4
+ def initialize
5
+
6
+ @status_bar_view = StatusBar::View.new
7
+ App.shared.keyWindow.rootViewController.view.addSubview(@status_bar_view.view)
8
+ App.shared.keyWindow.rootViewController.view.sendSubviewToBack(@status_bar_view.view)
9
+
10
+ # Set old orientation and rotation effect
11
+ @current_notice_view = nil
12
+ @timer = nil
13
+
14
+ # Listen for rotation
15
+ App.notification_center.observe UIDeviceOrientationDidChangeNotification do |notification|
16
+ UIView.animate do
17
+ position_inner_views(@current_notice_view) unless @current_notice_view == nil
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+
24
+
25
+ # EXTERNAL COMMANDS
26
+ def show_notice(text)
27
+ show_notice_view(@status_bar_view.notice_view, text:text)
28
+ end
29
+
30
+ def show_activity_notice(text)
31
+ show_notice_view(@status_bar_view.activity_view, text:text)
32
+ end
33
+
34
+ def show_success_notice(text)
35
+ show_notice_view(@status_bar_view.success_view, text:text)
36
+ end
37
+
38
+ def show_error_notice(text)
39
+ show_notice_view(@status_bar_view.error_view, text:text)
40
+ end
41
+
42
+ def hide_notice
43
+ hide_status_bar_view
44
+ end
45
+
46
+ def visible?
47
+ StatusBar::Helper.view_visible?(@status_bar_view.status_bar_view)
48
+ end
49
+
50
+
51
+
52
+ # INTERNAL COMMANDS
53
+ def show_status_bar_view
54
+ if !visible?
55
+ App.shared.setStatusBarHidden(true, withAnimation:UIStatusBarAnimationSlide)
56
+ @status_bar_view.status_bar_view.move_to([0, 0])
57
+ end
58
+ end
59
+
60
+ def hide_status_bar_view
61
+ if visible?
62
+ @status_bar_view.status_bar_view.move_to([0, 20])
63
+ App.shared.setStatusBarHidden(false, withAnimation:UIStatusBarAnimationSlide)
64
+ end
65
+ end
66
+
67
+ def show_notice_view(notice_view, text:text)
68
+ label = StatusBar::Helper.label(notice_view)
69
+ accessory = StatusBar::Helper.accessory(notice_view)
70
+
71
+ EM.cancel_timer(@timer) unless @timer == nil
72
+ clear_notice_view(@current_notice_view) unless StatusBar::Helper.view_visible?(notice_view)
73
+
74
+ label.text = text
75
+ notice_view.y = 0 if !visible?
76
+ notice_view.move_to([0, 0]) if visible?
77
+ position_inner_views(notice_view)
78
+ @timer = EM.add_timer 3 { hide_status_bar_view } unless accessory == nil
79
+
80
+ show_status_bar_view unless visible?
81
+ @current_notice_view = notice_view
82
+ end
83
+
84
+ def clear_notice_view(view)
85
+ return if view == nil
86
+ view.move_to([0, -20]) { view.y = 20 } if visible?
87
+ view.y = 20 if !visible?
88
+ end
89
+
90
+ def position_inner_views(view)
91
+ label = StatusBar::Helper.label(view)
92
+ accessory = StatusBar::Helper.accessory(view)
93
+
94
+ return if accessory == nil
95
+ label.restyle!
96
+ label.x += 10
97
+ accessory.x = StatusBar::Helper.accessory_x(label.text)
98
+ end
99
+
100
+ end
101
+ end