ProMotion 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +6 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +5 -1
  5. data/README.md +237 -138
  6. data/Rakefile +4 -9
  7. data/app/app_delegate.rb +3 -0
  8. data/app/screens/basic_screen.rb +27 -0
  9. data/lib/ProMotion.rb +3 -5
  10. data/lib/ProMotion/cocoatouch/SplitViewController.rb +25 -0
  11. data/lib/ProMotion/cocoatouch/TableViewController.rb +5 -5
  12. data/lib/ProMotion/cocoatouch/ViewController.rb +5 -5
  13. data/lib/ProMotion/{app_delegate.rb → delegate.rb} +23 -23
  14. data/lib/ProMotion/helpers/console.rb +6 -4
  15. data/lib/ProMotion/helpers/logger.rb +73 -0
  16. data/lib/ProMotion/helpers/view_helper.rb +45 -13
  17. data/lib/ProMotion/screen_helpers/_tables/_refreshable_table.rb +42 -0
  18. data/lib/ProMotion/screen_helpers/_tables/_searchable_table.rb +2 -2
  19. data/lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb +46 -41
  20. data/lib/ProMotion/screen_helpers/_tables/grouped_table.rb +2 -1
  21. data/lib/ProMotion/screen_helpers/_tables/plain_table.rb +1 -0
  22. data/lib/ProMotion/screen_helpers/screen_elements.rb +16 -11
  23. data/lib/ProMotion/screen_helpers/screen_navigation.rb +15 -16
  24. data/lib/ProMotion/screen_helpers/screen_tabs.rb +20 -16
  25. data/lib/ProMotion/screen_helpers/split_screen.rb +42 -0
  26. data/lib/ProMotion/screens/_screen_module.rb +44 -35
  27. data/lib/ProMotion/screens/_table_screen_module.rb +18 -1
  28. data/lib/ProMotion/screens/screen.rb +1 -1
  29. data/lib/ProMotion/version.rb +1 -1
  30. data/spec/helpers/table_screen.rb +48 -0
  31. data/spec/helpers/table_screen_refreshable.rb +11 -0
  32. data/spec/helpers/table_screen_searchable.rb +5 -0
  33. data/spec/helpers/test_delegate.rb +9 -0
  34. data/spec/ios_version_spec.rb +6 -6
  35. data/spec/logger_spec.rb +68 -0
  36. data/spec/main_spec.rb +1 -1
  37. data/spec/screen_helpers_spec.rb +35 -6
  38. data/spec/{view_controller_spec.rb → screen_spec.rb} +1 -1
  39. data/spec/split_screen_in_tab_bar_spec.rb +49 -0
  40. data/spec/split_screen_open_screen_spec.rb +46 -0
  41. data/spec/split_screen_spec.rb +35 -0
  42. data/spec/table_screen_spec.rb +72 -0
  43. data/spec/view_helper_spec.rb +112 -8
  44. metadata +29 -8
  45. data/lib/ProMotion/helpers/tab_bar.rb +0 -115
  46. data/spec/helpers/.gitkeep +0 -0
@@ -1,5 +1,5 @@
1
1
  describe "screen properties" do
2
-
2
+
3
3
  before do
4
4
 
5
5
  # Simulate AppDelegate setup of main screen
@@ -0,0 +1,49 @@
1
+ describe "split screen in tab bar functionality" do
2
+
3
+ before do
4
+ @app = TestDelegate.new
5
+
6
+ @master_screen = HomeScreen.new nav_bar: true
7
+ @detail_screen = BasicScreen.new nav_bar: true
8
+
9
+ @split_screen = @app.create_split_screen @master_screen, @detail_screen
10
+ @tab = @app.open_tab_bar @split_screen, HomeScreen, BasicScreen
11
+ end
12
+
13
+ it "should create a UISplitViewController" do
14
+ @split_screen.is_a?(UISplitViewController).should == true
15
+ end
16
+
17
+ it "should have two viewControllers" do
18
+ @split_screen.viewControllers.length.should == 2
19
+ end
20
+
21
+ it "should set the root view to the tab bar" do
22
+ @app.window.rootViewController.should == @tab
23
+ end
24
+
25
+ it "should return screens for the master_screen and detail_screen methods" do
26
+ @split_screen.master_screen.is_a?(PM::Screen).should == true
27
+ @split_screen.detail_screen.is_a?(PM::Screen).should == true
28
+ end
29
+
30
+ it "should return navigationControllers" do
31
+ @split_screen.viewControllers.first.is_a?(UINavigationController).should == true
32
+ @split_screen.viewControllers.last.is_a?(UINavigationController).should == true
33
+ end
34
+
35
+ it "should set the first viewController to HomeScreen's main controller" do
36
+ @split_screen.master_screen.should == @master_screen
37
+ @split_screen.viewControllers.first.should == @master_screen.main_controller
38
+ end
39
+
40
+ it "should set the second viewController to BasicScreen's main controller" do
41
+ @split_screen.detail_screen.should == @detail_screen
42
+ @split_screen.viewControllers.last.should == @detail_screen.main_controller
43
+ end
44
+
45
+ it "should set the tab bar first viewController to the split screen" do
46
+ @tab.viewControllers.first.should == @split_screen
47
+ end
48
+
49
+ end
@@ -0,0 +1,46 @@
1
+ describe "split screen `open` functionality" do
2
+
3
+ before do
4
+ @app = TestDelegate.new
5
+
6
+ @master_screen = HomeScreen.new nav_bar: true
7
+ @detail_screen_1 = BasicScreen.new # no nav_bar on this one
8
+ @detail_screen_2 = BasicScreen.new(nav_bar: true)
9
+
10
+ @split_screen = @app.open_split_screen @master_screen, @detail_screen_1
11
+ end
12
+
13
+ it "should open a new screen in the detail view" do
14
+ @master_screen.open @detail_screen_2, in_detail: true
15
+ @split_screen.detail_screen.should == @detail_screen_2
16
+ @split_screen.viewControllers.first.should == @master_screen.main_controller
17
+ @split_screen.viewControllers.last.should == @detail_screen_2.main_controller
18
+ end
19
+
20
+ it "should open a new screen in the master view" do
21
+ @detail_screen_1.open @detail_screen_2, in_master: true
22
+ @split_screen.master_screen.should == @detail_screen_2
23
+ @split_screen.viewControllers.first.should == @detail_screen_2.main_controller
24
+ @split_screen.viewControllers.last.should == @detail_screen_1.main_controller
25
+ end
26
+
27
+ it "should open a new screen in the master view's navigation controller" do
28
+ @master_screen.open @detail_screen_2
29
+ @split_screen.detail_screen.should == @detail_screen_1 # no change
30
+ @master_screen.navigationController.topViewController.should == @detail_screen_2
31
+ end
32
+
33
+ it "should open a new modal screen in the detail view" do
34
+ @detail_screen_1.open @detail_screen_2, modal: true
35
+ @split_screen.detail_screen.should == @detail_screen_1
36
+ @detail_screen_1.presentedViewController.should == @detail_screen_2.main_controller
37
+ end
38
+
39
+ it "should not interfere with normal non-split screen navigation" do
40
+ home = HomeScreen.new(nav_bar: true)
41
+ child = BasicScreen.new
42
+ home.open child, in_detail: true, in_master: true
43
+ home.navigation_controller.topViewController.should == child
44
+ end
45
+
46
+ end
@@ -0,0 +1,35 @@
1
+ describe "split screen functionality" do
2
+
3
+ before do
4
+ @app = TestDelegate.new
5
+
6
+ @master_screen = HomeScreen.new nav_bar: true
7
+ @detail_screen = BasicScreen.new # no nav_bar on this one
8
+
9
+ @split_screen = @app.open_split_screen @master_screen, @detail_screen
10
+ end
11
+
12
+ it "should have created a split screen" do
13
+ @split_screen.should != nil
14
+ @split_screen.is_a?(UISplitViewController).should == true
15
+ end
16
+
17
+ it "should have two viewControllers" do
18
+ @split_screen.viewControllers.length.should == 2
19
+ end
20
+
21
+ it "should set the root view to the UISplitScreenViewController" do
22
+ @app.window.rootViewController.should == @split_screen
23
+ end
24
+
25
+ it "should set the first viewController to HomeScreen" do
26
+ @split_screen.master_screen.should == @master_screen
27
+ @split_screen.viewControllers.first.should == @master_screen.main_controller
28
+ end
29
+
30
+ it "should set the second viewController to BasicScreen" do
31
+ @split_screen.detail_screen.should == @detail_screen
32
+ @split_screen.viewControllers.last.should == @detail_screen.main_controller
33
+ end
34
+
35
+ end
@@ -0,0 +1,72 @@
1
+ describe "table screens" do
2
+
3
+ describe "basic functionality" do
4
+
5
+ before do
6
+ UIView.setAnimationsEnabled false # avoid animation issues
7
+
8
+ @screen = TableScreen.new
9
+ @screen.on_load
10
+ end
11
+
12
+ it "should display 2 sections" do
13
+ @screen.tableView.numberOfSections.should == 2
14
+ end
15
+
16
+ it "should have proper cell numbers" do
17
+ @screen.tableView.numberOfRowsInSection(0).should == 3
18
+ @screen.tableView.numberOfRowsInSection(1).should == 2
19
+ end
20
+
21
+ it "should have a placeholder image in the last cell" do
22
+ index_path = NSIndexPath.indexPathForRow(1, inSection: 1)
23
+
24
+ @screen.tableView(@screen.tableView, cellForRowAtIndexPath: index_path).imageView.class.should == UIImageView
25
+ end
26
+
27
+ end
28
+
29
+ describe "search functionality" do
30
+
31
+ before do
32
+ @screen = TableScreenSearchable.new
33
+ @screen.on_load
34
+ end
35
+
36
+ it "should be searchable" do
37
+ @screen.class.get_searchable.should == true
38
+ end
39
+
40
+ it "should create a search header" do
41
+ @screen.table_view.tableHeaderView.class.should == UISearchBar
42
+ end
43
+
44
+ end
45
+
46
+ describe "refresh functionality" do
47
+
48
+ # Note this test only works if on iOS 6+ or when using CKRefreshControl.
49
+
50
+ before do
51
+ @screen = TableScreenRefreshable.new
52
+ @screen.on_load
53
+ end
54
+
55
+ it "should be refreshable" do
56
+ @screen.class.get_refreshable.should == true
57
+ end
58
+
59
+ it "should create a refresh object" do
60
+ @screen.instance_variable_get("@refresh_control").class.should == UIRefreshControl
61
+ end
62
+
63
+ it "should respond to start_refreshing and end_refreshing" do
64
+ @screen.respond_to?(:start_refreshing).should == true
65
+ @screen.respond_to?(:end_refreshing).should == true
66
+ end
67
+
68
+ # Animations cause the refresh object to fail when tested. Test manually.
69
+
70
+ end
71
+
72
+ end
@@ -3,25 +3,59 @@ describe "view helpers" do
3
3
  def equal_rect(rect)
4
4
  ->(obj) { CGRectEqualToRect obj, rect }
5
5
  end
6
-
6
+
7
7
  before do
8
8
  @dummy = UIView.alloc.initWithFrame CGRectZero
9
9
  @dummy.extend ProMotion::ViewHelper
10
10
  end
11
11
 
12
- it "#frame_from_array should return zero rect for bad input" do
13
- @dummy.frame_from_array([]).should equal_rect(CGRectZero)
12
+ it "should allow you to set attributes" do
13
+ @dummy.set_attributes @dummy, backgroundColor: UIColor.redColor
14
+ @dummy.backgroundColor.should == UIColor.redColor
14
15
  end
15
16
 
16
- it "#frame_from_array should return a valid CGRect" do
17
- @dummy.frame_from_array([0,0,320,480]).should equal_rect(CGRectMake(0,0,320,480))
17
+ it "should allow you to set nested attributes" do
18
+ layered_view = UIView.alloc.initWithFrame(CGRectMake(0, 0, 10, 10))
19
+
20
+ @dummy.set_attributes layered_view, {
21
+ layer: {
22
+ backgroundColor: UIColor.redColor.CGColor
23
+ }
24
+ }
25
+
26
+ layered_view.layer.backgroundColor.should == UIColor.redColor.CGColor
18
27
  end
19
28
 
20
- it "should allow you to set attributes" do
21
- @dummy.set_attributes @dummy, backgroundColor: UIColor.redColor
22
- @dummy.backgroundColor.should == UIColor.redColor
29
+ it "should allow you to set multiple nested attributes" do
30
+ mask_layer = CAShapeLayer.layer
31
+ layered_view = UIView.alloc.initWithFrame(CGRectMake(0, 0, 10, 10))
32
+ layered_view.layer.mask = mask_layer
33
+ @dummy.set_attributes layered_view, {
34
+ layer: {
35
+ mask: {
36
+ backgroundColor: UIColor.redColor.CGColor
37
+ }
38
+ }
39
+ }
40
+
41
+ layered_view.layer.mask.backgroundColor.should == UIColor.redColor.CGColor
23
42
  end
24
43
 
44
+ it "should allow you to set snake_case attributes" do
45
+ layered_view = UIView.alloc.initWithFrame(CGRectMake(0, 0, 10, 10))
46
+
47
+ @dummy.set_attributes layered_view, {
48
+ layer: {
49
+ background_color: UIColor.redColor.CGColor
50
+ },
51
+ content_mode: UIViewContentModeBottom
52
+ }
53
+
54
+ layered_view.contentMode.should == UIViewContentModeBottom
55
+ layered_view.layer.backgroundColor.should == UIColor.redColor.CGColor
56
+ end
57
+
58
+
25
59
  describe "content height" do
26
60
 
27
61
  before do
@@ -40,4 +74,74 @@ describe "view helpers" do
40
74
 
41
75
  end
42
76
 
77
+ describe "set_easy_attributes" do
78
+
79
+ before do
80
+ @dummy = UIView.alloc.initWithFrame CGRectZero
81
+ @dummy.extend ProMotion::ViewHelper
82
+
83
+ @parent = UIView.alloc.initWithFrame(CGRectMake(0, 0, 320, 480))
84
+ @child = UIView.alloc.initWithFrame(CGRectZero)
85
+ end
86
+
87
+ it "Should set the autoresizingMask for all" do
88
+ @dummy.set_easy_attributes @parent, @child, {
89
+ resize: [:left, :right, :top, :bottom, :width, :height]
90
+ }
91
+
92
+ mask = UIViewAutoresizingFlexibleLeftMargin |
93
+ UIViewAutoresizingFlexibleRightMargin |
94
+ UIViewAutoresizingFlexibleTopMargin |
95
+ UIViewAutoresizingFlexibleBottomMargin |
96
+ UIViewAutoresizingFlexibleWidth |
97
+ UIViewAutoresizingFlexibleHeight
98
+
99
+ @child.autoresizingMask.should == mask
100
+ end
101
+
102
+ it "Should set the autoresizingMask for half" do
103
+ @dummy.set_easy_attributes @parent, @child, {
104
+ resize: [:left, :right, :top]
105
+ }
106
+
107
+ mask = UIViewAutoresizingFlexibleLeftMargin |
108
+ UIViewAutoresizingFlexibleRightMargin |
109
+ UIViewAutoresizingFlexibleTopMargin
110
+
111
+ @child.autoresizingMask.should == mask
112
+ end
113
+
114
+ it "Should set the autoresizingMask for the second half" do
115
+ @dummy.set_easy_attributes @parent, @child, {
116
+ resize: [:bottom, :width, :height]
117
+ }
118
+
119
+ mask = UIViewAutoresizingFlexibleBottomMargin |
120
+ UIViewAutoresizingFlexibleWidth |
121
+ UIViewAutoresizingFlexibleHeight
122
+
123
+ @child.autoresizingMask.should == mask
124
+ end
125
+
126
+ it "Should not set the autoresizingMask" do
127
+ @dummy.set_easy_attributes @parent, @child, {}
128
+
129
+ mask = UIViewAutoresizingNone
130
+
131
+ @child.autoresizingMask.should == mask
132
+ end
133
+
134
+ it "Should create a frame" do
135
+ @dummy.set_easy_attributes @parent, @child, {
136
+ left: 10,
137
+ top: 20,
138
+ width: 100,
139
+ height: 50
140
+ }
141
+
142
+ @child.frame.should == CGRectMake(10, 20, 100, 50)
143
+ end
144
+
145
+ end
146
+
43
147
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ProMotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-03-28 00:00:00.000000000 Z
14
+ date: 2013-05-15 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: ProMotion is a new way to easily build RubyMotion iOS apps.
17
17
  email:
@@ -25,6 +25,7 @@ files:
25
25
  - .gitignore
26
26
  - .ruby-gemset
27
27
  - .ruby-version
28
+ - .travis.yml
28
29
  - Gemfile
29
30
  - Gemfile.lock
30
31
  - LICENSE
@@ -32,19 +33,22 @@ files:
32
33
  - README.md
33
34
  - Rakefile
34
35
  - app/app_delegate.rb
36
+ - app/screens/basic_screen.rb
35
37
  - lib/ProMotion.rb
36
38
  - lib/ProMotion/.DS_Store
37
- - lib/ProMotion/app_delegate.rb
38
39
  - lib/ProMotion/cocoatouch/NavigationController.rb
40
+ - lib/ProMotion/cocoatouch/SplitViewController.rb
39
41
  - lib/ProMotion/cocoatouch/TableViewCell.rb
40
42
  - lib/ProMotion/cocoatouch/TableViewController.rb
41
43
  - lib/ProMotion/cocoatouch/ViewController.rb
44
+ - lib/ProMotion/delegate.rb
42
45
  - lib/ProMotion/helpers/console.rb
46
+ - lib/ProMotion/helpers/logger.rb
43
47
  - lib/ProMotion/helpers/measure_helper.rb
44
48
  - lib/ProMotion/helpers/system_helper.rb
45
- - lib/ProMotion/helpers/tab_bar.rb
46
49
  - lib/ProMotion/helpers/view_helper.rb
47
50
  - lib/ProMotion/pro_motion.rb
51
+ - lib/ProMotion/screen_helpers/_tables/_refreshable_table.rb
48
52
  - lib/ProMotion/screen_helpers/_tables/_searchable_table.rb
49
53
  - lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb
50
54
  - lib/ProMotion/screen_helpers/_tables/grouped_table.rb
@@ -52,19 +56,28 @@ files:
52
56
  - lib/ProMotion/screen_helpers/screen_elements.rb
53
57
  - lib/ProMotion/screen_helpers/screen_navigation.rb
54
58
  - lib/ProMotion/screen_helpers/screen_tabs.rb
59
+ - lib/ProMotion/screen_helpers/split_screen.rb
55
60
  - lib/ProMotion/screens/_screen_module.rb
56
61
  - lib/ProMotion/screens/_table_screen_module.rb
57
62
  - lib/ProMotion/screens/screen.rb
58
63
  - lib/ProMotion/screens/table_screen.rb
59
64
  - lib/ProMotion/version.rb
60
- - spec/helpers/.gitkeep
61
65
  - spec/helpers/basic_screen.rb
62
66
  - spec/helpers/dummy_class.rb
63
67
  - spec/helpers/home_screen.rb
68
+ - spec/helpers/table_screen.rb
69
+ - spec/helpers/table_screen_refreshable.rb
70
+ - spec/helpers/table_screen_searchable.rb
71
+ - spec/helpers/test_delegate.rb
64
72
  - spec/ios_version_spec.rb
73
+ - spec/logger_spec.rb
65
74
  - spec/main_spec.rb
66
75
  - spec/screen_helpers_spec.rb
67
- - spec/view_controller_spec.rb
76
+ - spec/screen_spec.rb
77
+ - spec/split_screen_in_tab_bar_spec.rb
78
+ - spec/split_screen_open_screen_spec.rb
79
+ - spec/split_screen_spec.rb
80
+ - spec/table_screen_spec.rb
68
81
  - spec/view_helper_spec.rb
69
82
  homepage: https://github.com/clearsightstudio/ProMotion
70
83
  licenses: []
@@ -94,12 +107,20 @@ summary: ProMotion is a new way to organize RubyMotion apps. Instead of dealing
94
107
  your app and include a ton of great utilities to make iOS development more like
95
108
  Ruby and less like Objective-C.
96
109
  test_files:
97
- - spec/helpers/.gitkeep
98
110
  - spec/helpers/basic_screen.rb
99
111
  - spec/helpers/dummy_class.rb
100
112
  - spec/helpers/home_screen.rb
113
+ - spec/helpers/table_screen.rb
114
+ - spec/helpers/table_screen_refreshable.rb
115
+ - spec/helpers/table_screen_searchable.rb
116
+ - spec/helpers/test_delegate.rb
101
117
  - spec/ios_version_spec.rb
118
+ - spec/logger_spec.rb
102
119
  - spec/main_spec.rb
103
120
  - spec/screen_helpers_spec.rb
104
- - spec/view_controller_spec.rb
121
+ - spec/screen_spec.rb
122
+ - spec/split_screen_in_tab_bar_spec.rb
123
+ - spec/split_screen_open_screen_spec.rb
124
+ - spec/split_screen_spec.rb
125
+ - spec/table_screen_spec.rb
105
126
  - spec/view_helper_spec.rb