status_bar 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +14 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +51 -0
- data/Guardfile +12 -0
- data/README.md +66 -0
- data/Rakefile +28 -0
- data/app/app_delegate.rb +10 -0
- data/app/controllers/demo_controller.rb +51 -0
- data/app/styles/demo_style.rb +88 -0
- data/lib/project/base.rb +101 -0
- data/lib/project/helper.rb +60 -0
- data/lib/project/style.rb +87 -0
- data/lib/project/view.rb +38 -0
- data/lib/resources/error.png +0 -0
- data/lib/resources/error@2x.png +0 -0
- data/lib/resources/success.png +0 -0
- data/lib/resources/success@2x.png +0 -0
- data/lib/status_bar.rb +37 -0
- data/resources/Default-568h@2x.png +0 -0
- data/resources/error.png +0 -0
- data/resources/error@2x.png +0 -0
- data/resources/success.png +0 -0
- data/resources/success@2x.png +0 -0
- data/screenshots/activity.png +0 -0
- data/screenshots/error.png +0 -0
- data/screenshots/notice.png +0 -0
- data/screenshots/success.png +0 -0
- data/spec/app_delegate_spec.rb +15 -0
- data/spec/demo_controller_spec.rb +52 -0
- data/status_bar.gemspec +24 -0
- data/vendor/Podfile.lock +10 -0
- data/vendor/Pods/.build/libPods-Reachability.a +0 -0
- data/vendor/Pods/.build/libPods.a +0 -0
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-environment.h +14 -0
- data/vendor/Pods/Manifest.lock +10 -0
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
- data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
- data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
- data/vendor/Pods/Pods-acknowledgements.markdown +17 -0
- data/vendor/Pods/Pods-acknowledgements.plist +47 -0
- data/vendor/Pods/Pods-dummy.m +5 -0
- data/vendor/Pods/Pods-environment.h +14 -0
- data/vendor/Pods/Pods-resources.sh +55 -0
- data/vendor/Pods/Pods.bridgesupport +100 -0
- data/vendor/Pods/Pods.xcconfig +4 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +960 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/holgersindbaek.xcuserdatad/xcschemes/Pods-Reachability.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/holgersindbaek.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
- data/vendor/Pods/Pods.xcodeproj/xcuserdata/holgersindbaek.xcuserdatad/xcschemes/xcschememanagement.plist +21 -0
- data/vendor/Pods/Reachability/LICENCE.txt +24 -0
- data/vendor/Pods/Reachability/README.md +65 -0
- data/vendor/Pods/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Reachability/Reachability.m +527 -0
- data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
- metadata +175 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
module StatusBar
|
2
|
+
class Helper
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def label_color
|
7
|
+
color = UIColor.blackColor
|
8
|
+
case App.shared.statusBarStyle
|
9
|
+
when UIStatusBarStyleDefault
|
10
|
+
color = "#bcbcbc".uicolor unless HS::Base.ios_7?
|
11
|
+
when UIStatusBarStyleLightContent
|
12
|
+
color = "#ffffff".uicolor
|
13
|
+
end
|
14
|
+
return color
|
15
|
+
end
|
16
|
+
|
17
|
+
def label_font
|
18
|
+
UIFont.boldSystemFontOfSize(HS::Base.ios_7? ? 12 : 14)
|
19
|
+
end
|
20
|
+
|
21
|
+
def label_alignment
|
22
|
+
HS::Base.ios_6? ? UITextAlignmentCenter : NSTextAlignmentCenter
|
23
|
+
end
|
24
|
+
|
25
|
+
def textwidth(text)
|
26
|
+
text.sizeWithFont(label_font).width
|
27
|
+
end
|
28
|
+
|
29
|
+
def accessory_x(text)
|
30
|
+
(HS::Base.rotation_width/2) - (textwidth(text) / 2) - 10
|
31
|
+
end
|
32
|
+
|
33
|
+
def label_x(text)
|
34
|
+
(HS::Base.rotation_width/2) - (textwidth(text) / 2)
|
35
|
+
end
|
36
|
+
|
37
|
+
def view_visible?(view)
|
38
|
+
view.y == 0
|
39
|
+
end
|
40
|
+
|
41
|
+
def label(view)
|
42
|
+
return_view = nil
|
43
|
+
view.subviews.each do |subview|
|
44
|
+
return_view = subview if subview.class == UILabel
|
45
|
+
end
|
46
|
+
return return_view
|
47
|
+
end
|
48
|
+
|
49
|
+
def accessory(view)
|
50
|
+
return_view = nil
|
51
|
+
view.subviews.each do |subview|
|
52
|
+
return_view = subview if subview.class == UIActivityIndicatorView || subview.class == UIImageView
|
53
|
+
end
|
54
|
+
return return_view
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
include StatusBar
|
2
|
+
|
3
|
+
Teacup::Stylesheet.new :status_bar_style do
|
4
|
+
|
5
|
+
style :status_bar_view,
|
6
|
+
height: 20,
|
7
|
+
left: 0,
|
8
|
+
top: 20,
|
9
|
+
clipsToBounds: true,
|
10
|
+
landscape: {
|
11
|
+
width: "100%"
|
12
|
+
},
|
13
|
+
portrait: {
|
14
|
+
width: "100%"
|
15
|
+
}
|
16
|
+
|
17
|
+
style UIView,
|
18
|
+
height: 20,
|
19
|
+
left: 0
|
20
|
+
|
21
|
+
style UILabel,
|
22
|
+
adjustsFontSizeToFitWidth: false,
|
23
|
+
textAlignment: StatusBar::Helper.label_alignment,
|
24
|
+
baselineAdjustment: UIBaselineAdjustmentAlignCenters,
|
25
|
+
textColor: StatusBar::Helper.label_color,
|
26
|
+
font: StatusBar::Helper.label_font
|
27
|
+
|
28
|
+
style UIImageView,
|
29
|
+
left: 0,
|
30
|
+
top: 3,
|
31
|
+
width: 14,
|
32
|
+
height: 14
|
33
|
+
|
34
|
+
style :standard_view,
|
35
|
+
height: 20,
|
36
|
+
landscape: {
|
37
|
+
width: "100%"
|
38
|
+
},
|
39
|
+
portrait: {
|
40
|
+
width: "100%"
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
style :notice_view, extends: :standard_view,
|
46
|
+
top: 20
|
47
|
+
|
48
|
+
style :notice_label, extends: :standard_view
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
style :activity_view, extends: :standard_view,
|
53
|
+
top: 20
|
54
|
+
|
55
|
+
style :activity_label, extends: :standard_view
|
56
|
+
|
57
|
+
style :activity_spinner,
|
58
|
+
left: 0,
|
59
|
+
top: 5,
|
60
|
+
width: 14,
|
61
|
+
height: 14,
|
62
|
+
activityIndicatorViewStyle: UIActivityIndicatorViewStyleWhite,
|
63
|
+
hidesWhenStopped: true,
|
64
|
+
color: StatusBar::Helper.label_color,
|
65
|
+
transform: CGAffineTransformMakeScale(0.75, 0.75)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
style :success_view, extends: :standard_view,
|
70
|
+
top: 20
|
71
|
+
|
72
|
+
style :success_label, extends: :standard_view
|
73
|
+
|
74
|
+
style :success_image,
|
75
|
+
image: "success".uiimage.overlay(StatusBar::Helper.label_color)
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
style :error_view, extends: :standard_view,
|
80
|
+
top: 20
|
81
|
+
|
82
|
+
style :error_label, extends: :standard_view
|
83
|
+
|
84
|
+
style :error_image,
|
85
|
+
image: "error".uiimage.overlay(StatusBar::Helper.label_color)
|
86
|
+
|
87
|
+
end
|
data/lib/project/view.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module StatusBar
|
2
|
+
class View < UIViewController
|
3
|
+
stylesheet :status_bar_style
|
4
|
+
|
5
|
+
attr_accessor :status_bar_view, :notice_view, :notice_label, :activity_view, :activity_spinner, :activity_label, :success_view, :success_image, :success_label, :error_view, :error_image, :error_label
|
6
|
+
|
7
|
+
layout :status_bar_view_controller do
|
8
|
+
|
9
|
+
@status_bar_view = subview(UIView, :status_bar_view) do
|
10
|
+
@notice_view = subview(UIView, :notice_view) do
|
11
|
+
@notice_label = subview(UILabel, :notice_label)
|
12
|
+
end
|
13
|
+
|
14
|
+
@activity_view = subview(UIView, :activity_view) do
|
15
|
+
@activity_spinner = subview(UIActivityIndicatorView, :activity_spinner).startAnimating
|
16
|
+
@activity_label = subview(UILabel, :activity_label)
|
17
|
+
end
|
18
|
+
|
19
|
+
@success_view = subview(UIView, :success_view) do
|
20
|
+
@success_image = subview(UIImageView, :success_image)
|
21
|
+
@success_label = subview(UILabel, :success_label)
|
22
|
+
end
|
23
|
+
|
24
|
+
@error_view = subview(UIView, :error_view) do
|
25
|
+
@error_image = subview(UIImageView, :error_image)
|
26
|
+
@error_label = subview(UILabel, :error_label)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def viewDidLoad
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/status_bar.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'hs'
|
2
|
+
require 'bubble-wrap/core'
|
3
|
+
require 'bubble-wrap/reactor'
|
4
|
+
require 'teacup'
|
5
|
+
require 'sugarcube-uikit'
|
6
|
+
require 'sugarcube-color'
|
7
|
+
require 'sugarcube-numbers'
|
8
|
+
require 'sugarcube-animations'
|
9
|
+
require 'sugarcube-timer'
|
10
|
+
require 'sugarcube-image'
|
11
|
+
|
12
|
+
unless defined?(Motion::Project::Config)
|
13
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
14
|
+
end
|
15
|
+
|
16
|
+
lib_dir_path = File.dirname(File.expand_path(__FILE__))
|
17
|
+
resource_dir = File.expand_path(File.join(lib_dir_path, '..', 'resources'))
|
18
|
+
|
19
|
+
Motion::Project::App.setup do |app|
|
20
|
+
teacup_insert_point = nil
|
21
|
+
app.files.each_index do |index|
|
22
|
+
file = app.files[index]
|
23
|
+
if file =~ /teacup/
|
24
|
+
teacup_insert_point = index + 1
|
25
|
+
elsif teacup_insert_point
|
26
|
+
# found one, so stop looking
|
27
|
+
break
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'project/**/*.rb')).reverse.each do |file|
|
32
|
+
app.files.insert(teacup_insert_point, file)
|
33
|
+
end
|
34
|
+
|
35
|
+
# app.files.unshift Dir.glob(File.join(lib_dir_path, "project/**/*.rb"))
|
36
|
+
app.resources_dirs << File.join(File.dirname(__FILE__), 'resources')
|
37
|
+
end
|
Binary file
|
data/resources/error.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe "A - AppDelegate" do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@app = UIApplication.sharedApplication
|
5
|
+
end
|
6
|
+
|
7
|
+
it "has one window" do
|
8
|
+
@app.windows.size.should == 1
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have correct root controller" do
|
12
|
+
@app.keyWindow.rootViewController.class.should == DemoController
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
describe "A - DemoController" do
|
2
|
+
tests DemoController
|
3
|
+
|
4
|
+
# I gave up testing, because things good weird. If anyone wants to take up this, I'd love to see how they'd do it.
|
5
|
+
|
6
|
+
context "B - Verify button existence" do
|
7
|
+
|
8
|
+
it "show notice button" do
|
9
|
+
view("Show Notice").should.not.equal nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "show activity button" do
|
13
|
+
view("Show Activity").should.not.equal nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "show success button" do
|
17
|
+
view("Show Success").should.not.equal nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "show error button" do
|
21
|
+
view("Show Error").should.not.equal nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "hide notice button" do
|
25
|
+
view("Hide Notice").should.not.equal nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "visible? button" do
|
29
|
+
view("Visible?").should.not.equal nil
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# context "B - Clicking buttons" do
|
37
|
+
|
38
|
+
# it "notice button should show notice"
|
39
|
+
|
40
|
+
# it "activity button should show activity"
|
41
|
+
|
42
|
+
# it "success button should show success"
|
43
|
+
|
44
|
+
# it "error button should show error"
|
45
|
+
|
46
|
+
# it "hide button should hide notice"
|
47
|
+
|
48
|
+
# it "visible buttons should check visibility"
|
49
|
+
|
50
|
+
# end
|
51
|
+
|
52
|
+
end
|
data/status_bar.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
STATUSBAR_VERSION = "0.2"
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "status_bar"
|
6
|
+
spec.version = STATUSBAR_VERSION
|
7
|
+
spec.authors = ["Holger Sindbaek"]
|
8
|
+
spec.email = ["holgersindbaek@gmail.com"]
|
9
|
+
spec.description = %q{This RubyMotion gem can show status updates in the status bar. Heavily inspired by https://github.com/brianpartridge/BPStatusBar.}
|
10
|
+
spec.summary = %q{RubyMotion status bar wrapper.}
|
11
|
+
spec.homepage = "https://github.com/holgersindbaek/status_bar"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($\)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
spec.add_dependency "sugarcube", "1.3.5"
|
21
|
+
spec.add_dependency "bubble-wrap", "1.4.0"
|
22
|
+
spec.add_dependency 'teacup', '2.1.13'
|
23
|
+
spec.add_dependency 'hs'
|
24
|
+
end
|
data/vendor/Podfile.lock
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,109 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2011, Tony Million.
|
3
|
+
All rights reserved.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
7
|
+
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
list of conditions and the following disclaimer.
|
10
|
+
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
13
|
+
and/or other materials provided with the distribution.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
19
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
+
POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
*/
|
27
|
+
|
28
|
+
#import <Foundation/Foundation.h>
|
29
|
+
#import <SystemConfiguration/SystemConfiguration.h>
|
30
|
+
|
31
|
+
#import <sys/socket.h>
|
32
|
+
#import <netinet/in.h>
|
33
|
+
#import <netinet6/in6.h>
|
34
|
+
#import <arpa/inet.h>
|
35
|
+
#import <ifaddrs.h>
|
36
|
+
#import <netdb.h>
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Does ARC support GCD objects?
|
40
|
+
* It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
|
41
|
+
*
|
42
|
+
* @see http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
|
43
|
+
**/
|
44
|
+
#if OS_OBJECT_USE_OBJC
|
45
|
+
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
|
46
|
+
#else
|
47
|
+
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
|
48
|
+
#endif
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X.
|
52
|
+
*
|
53
|
+
* @see http://nshipster.com/ns_enum-ns_options/
|
54
|
+
**/
|
55
|
+
#ifndef NS_ENUM
|
56
|
+
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
|
57
|
+
#endif
|
58
|
+
|
59
|
+
extern NSString *const kReachabilityChangedNotification;
|
60
|
+
|
61
|
+
typedef NS_ENUM(NSInteger, NetworkStatus) {
|
62
|
+
// Apple NetworkStatus Compatible Names.
|
63
|
+
NotReachable = 0,
|
64
|
+
ReachableViaWiFi = 2,
|
65
|
+
ReachableViaWWAN = 1
|
66
|
+
};
|
67
|
+
|
68
|
+
@class Reachability;
|
69
|
+
|
70
|
+
typedef void (^NetworkReachable)(Reachability * reachability);
|
71
|
+
typedef void (^NetworkUnreachable)(Reachability * reachability);
|
72
|
+
|
73
|
+
@interface Reachability : NSObject
|
74
|
+
|
75
|
+
@property (nonatomic, copy) NetworkReachable reachableBlock;
|
76
|
+
@property (nonatomic, copy) NetworkUnreachable unreachableBlock;
|
77
|
+
|
78
|
+
|
79
|
+
@property (nonatomic, assign) BOOL reachableOnWWAN;
|
80
|
+
|
81
|
+
+(Reachability*)reachabilityWithHostname:(NSString*)hostname;
|
82
|
+
+(Reachability*)reachabilityForInternetConnection;
|
83
|
+
+(Reachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
|
84
|
+
+(Reachability*)reachabilityForLocalWiFi;
|
85
|
+
|
86
|
+
-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
|
87
|
+
|
88
|
+
-(BOOL)startNotifier;
|
89
|
+
-(void)stopNotifier;
|
90
|
+
|
91
|
+
-(BOOL)isReachable;
|
92
|
+
-(BOOL)isReachableViaWWAN;
|
93
|
+
-(BOOL)isReachableViaWiFi;
|
94
|
+
|
95
|
+
// WWAN may be available, but not active until a connection has been established.
|
96
|
+
// WiFi may require a connection for VPN on Demand.
|
97
|
+
-(BOOL)isConnectionRequired; // Identical DDG variant.
|
98
|
+
-(BOOL)connectionRequired; // Apple's routine.
|
99
|
+
// Dynamic, on demand connection?
|
100
|
+
-(BOOL)isConnectionOnDemand;
|
101
|
+
// Is user intervention required?
|
102
|
+
-(BOOL)isInterventionRequired;
|
103
|
+
|
104
|
+
-(NetworkStatus)currentReachabilityStatus;
|
105
|
+
-(SCNetworkReachabilityFlags)reachabilityFlags;
|
106
|
+
-(NSString*)currentReachabilityString;
|
107
|
+
-(NSString*)currentReachabilityFlags;
|
108
|
+
|
109
|
+
@end
|