ProMotion 1.2.1 → 2.0.0.rc1

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 (99) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -10
  3. data/lib/ProMotion.rb +11 -2
  4. data/lib/ProMotion/cocoatouch/ns_string.rb +5 -0
  5. data/lib/ProMotion/cocoatouch/ns_url.rb +5 -0
  6. data/lib/ProMotion/cocoatouch/tab_bar_controller.rb +5 -7
  7. data/lib/ProMotion/cocoatouch/table_view_cell.rb +0 -16
  8. data/lib/ProMotion/cocoatouch/table_view_controller.rb +2 -3
  9. data/lib/ProMotion/cocoatouch/view_controller.rb +3 -6
  10. data/lib/ProMotion/delegate/delegate.rb +0 -3
  11. data/lib/ProMotion/delegate/delegate_module.rb +24 -20
  12. data/lib/ProMotion/{containers → ipad}/split_screen.rb +30 -32
  13. data/lib/ProMotion/{logger.rb → logger/logger.rb} +6 -5
  14. data/lib/ProMotion/screen/nav_bar_module.rb +126 -0
  15. data/lib/ProMotion/screen/screen.rb +0 -3
  16. data/lib/ProMotion/screen/screen_module.rb +54 -177
  17. data/lib/ProMotion/screen/screen_navigation.rb +29 -40
  18. data/lib/ProMotion/{view → styling}/styling.rb +17 -47
  19. data/lib/ProMotion/table/cell/table_view_cell_module.rb +76 -123
  20. data/lib/ProMotion/table/data/table_data.rb +1 -1
  21. data/lib/ProMotion/table/extensions/longpressable.rb +24 -0
  22. data/lib/ProMotion/table/extensions/refreshable.rb +1 -0
  23. data/lib/ProMotion/table/grouped_table_screen.rb +0 -5
  24. data/lib/ProMotion/table/table.rb +63 -83
  25. data/lib/ProMotion/table/table_screen.rb +0 -4
  26. data/lib/ProMotion/{containers → tabs}/tabs.rb +20 -21
  27. data/lib/ProMotion/version.rb +1 -1
  28. data/lib/ProMotion/web/web_screen.rb +0 -4
  29. data/lib/ProMotion/web/web_screen_module.rb +8 -5
  30. data/spec/functional/func_screen_spec.rb +14 -18
  31. data/spec/functional/func_split_screen_spec.rb +2 -2
  32. data/spec/functional/func_table_screen_spec.rb +54 -40
  33. data/spec/functional/func_web_screen_spec.rb +12 -17
  34. data/spec/helpers/test_helper.rb +27 -0
  35. data/spec/unit/delegate_spec.rb +4 -67
  36. data/spec/unit/image_title_screen.rb +9 -0
  37. data/spec/unit/image_view_title_screen.rb +9 -0
  38. data/spec/unit/load_view_spec.rb +27 -0
  39. data/spec/unit/main_spec.rb +0 -6
  40. data/spec/unit/screen_helpers_spec.rb +23 -17
  41. data/spec/unit/screen_spec.rb +21 -17
  42. data/spec/unit/searchable_table_spec.rb +55 -0
  43. data/spec/unit/split_screen_in_tab_bar_spec.rb +5 -5
  44. data/spec/unit/split_screen_spec.rb +4 -4
  45. data/spec/unit/tab_bar_spec.rb +79 -0
  46. data/spec/unit/tab_spec.rb +11 -5
  47. data/spec/unit/tables/table_module_spec.rb +22 -8
  48. data/spec/unit/tables/table_screen_spec.rb +1 -1
  49. data/spec/unit/tables/table_view_cell_spec.rb +16 -16
  50. data/spec/unit/view_helper_spec.rb +6 -81
  51. data/spec/unit/view_title_screen.rb +10 -0
  52. data/spec/unit/web_spec.rb +31 -37
  53. metadata +37 -111
  54. data/.gitignore +0 -33
  55. data/.travis.yml +0 -4
  56. data/CONTRIBUTING.md +0 -20
  57. data/Gemfile +0 -5
  58. data/LICENSE +0 -22
  59. data/ProMotion.gemspec +0 -30
  60. data/Rakefile +0 -66
  61. data/app/app_delegate.rb +0 -7
  62. data/app/screens/basic_screen.rb +0 -15
  63. data/lib/ProMotion/delegate/delegate_notifications.rb +0 -70
  64. data/lib/ProMotion/extensions/conversions.rb +0 -20
  65. data/lib/ProMotion/map/map_screen.rb +0 -10
  66. data/lib/ProMotion/map/map_screen_annotation.rb +0 -65
  67. data/lib/ProMotion/map/map_screen_module.rb +0 -212
  68. data/lib/ProMotion/push_notification/push_notification.rb +0 -58
  69. data/resources/WebScreen.html +0 -6
  70. data/resources/list.png +0 -0
  71. data/resources/test.png +0 -0
  72. data/spec/functional/func_image_title_screen.rb +0 -20
  73. data/spec/functional/func_image_view_title_screen.rb +0 -20
  74. data/spec/functional/func_map_screen_spec.rb +0 -162
  75. data/spec/functional/func_searchable_table_spec.rb +0 -56
  76. data/spec/functional/func_tab_bar_spec.rb +0 -78
  77. data/spec/functional/func_view_title_screen.rb +0 -21
  78. data/spec/helpers/basic_screen.rb +0 -3
  79. data/spec/helpers/custom_title_view.rb +0 -4
  80. data/spec/helpers/detail_screen.rb +0 -3
  81. data/spec/helpers/dummy_class.rb +0 -3
  82. data/spec/helpers/functional_screen.rb +0 -15
  83. data/spec/helpers/home_screen.rb +0 -19
  84. data/spec/helpers/image_title_screen.rb +0 -15
  85. data/spec/helpers/image_view_title_screen.rb +0 -15
  86. data/spec/helpers/map_screen.rb +0 -53
  87. data/spec/helpers/master_screen.rb +0 -3
  88. data/spec/helpers/present_screen.rb +0 -26
  89. data/spec/helpers/screen_module_view_controller.rb +0 -55
  90. data/spec/helpers/tab_screen.rb +0 -4
  91. data/spec/helpers/table_screen.rb +0 -117
  92. data/spec/helpers/table_screen_indexable.rb +0 -18
  93. data/spec/helpers/table_screen_refreshable.rb +0 -11
  94. data/spec/helpers/table_screen_searchable.rb +0 -72
  95. data/spec/helpers/test_delegate.rb +0 -34
  96. data/spec/helpers/test_delegate_colors.rb +0 -17
  97. data/spec/helpers/view_title_screen.rb +0 -15
  98. data/spec/helpers/web_screen.rb +0 -23
  99. data/spec/unit/map_spec.rb +0 -71
@@ -1,58 +0,0 @@
1
- module ProMotion
2
- class PushNotification
3
-
4
- attr_accessor :notification
5
-
6
- def initialize(n)
7
- self.notification = n
8
- end
9
-
10
- def to_s
11
- self.notification.inspect
12
- end
13
-
14
- def to_json
15
- PM.logger.warn "PM::PushNotification.to_json not implemented yet."
16
- end
17
-
18
- def aps
19
- self.notification["aps"]
20
- end
21
-
22
- def alert
23
- aps["alert"] if aps
24
- end
25
-
26
- def badge
27
- aps["badge"] if aps
28
- end
29
-
30
- def sound
31
- aps["sound"] if aps
32
- end
33
-
34
- def method_missing(meth, *args, &block)
35
- aps[meth.to_s] || aps[meth.to_sym] || self.notification[meth.to_s] || self.notification[meth.to_sym] || super
36
- end
37
-
38
- # For testing from the REPL
39
- # > PM::PushNotification.simulate alert: "My test message", badge: 4
40
- def self.simulate(args = {})
41
- UIApplication.sharedApplication.delegate.on_push_notification self.fake_notification(args), args[:launched]
42
- end
43
-
44
- def self.fake_notification(args = {})
45
- self.new({
46
- "aps" => {
47
- "alert" => args.delete(:alert) || "Test Push Notification",
48
- "badge" => args.delete(:badge) || 2,
49
- "sound" => args.delete(:sound) || "default"
50
- },
51
- "channels" => args.delete(:channels) || [
52
- "channel_name"
53
- ]
54
- }.merge(args))
55
- end
56
-
57
- end
58
- end
@@ -1,6 +0,0 @@
1
- <html>
2
- <head></head>
3
- <body>
4
- <h1>Test</h1>
5
- </body>
6
- </html>
data/resources/list.png DELETED
Binary file
data/resources/test.png DELETED
Binary file
@@ -1,20 +0,0 @@
1
- describe "ProMotion::Screen UIImage title functionality" do
2
- tests PM::Screen
3
-
4
- # Override controller to properly instantiate
5
- def controller
6
- rotate_device to: :portrait, button: :bottom
7
- @image_title_screen ||= ImageTitleScreen.new(nav_bar: true)
8
- @root_screen = @image_title_screen
9
- @image_title_screen.navigationController
10
- end
11
-
12
- after do
13
- @controller = nil
14
- @root_screen = nil
15
- end
16
-
17
- it "should allow an image title" do
18
- @root_screen.navigationItem.titleView.should.be.kind_of UIImageView
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- describe "ProMotion::Screen UIImageView title functionality" do
2
- tests PM::Screen
3
-
4
- # Override controller to properly instantiate
5
- def controller
6
- rotate_device to: :portrait, button: :bottom
7
- @image_title_screen ||= ImageViewTitleScreen.new(nav_bar: true)
8
- @root_screen = @image_title_screen
9
- @image_title_screen.navigationController
10
- end
11
-
12
- after do
13
- @controller = nil
14
- @root_screen = nil
15
- end
16
-
17
- it "should allow an image title" do
18
- @root_screen.navigationItem.titleView.should.be.kind_of UIImageView
19
- end
20
- end
@@ -1,162 +0,0 @@
1
- describe "ProMotion::TestMapScreen functionality" do
2
- tests PM::TestMapScreen
3
-
4
- # Override controller to properly instantiate
5
- def controller
6
- rotate_device to: :portrait, button: :bottom
7
- @map ||= TestMapScreen.new(nav_bar: true)
8
- @map.will_appear
9
- @map.navigationController
10
- end
11
-
12
- def add_image_annotation
13
- ann = {
14
- longitude: -82.965972900392,
15
- latitude: 35.090648651124,
16
- title: "My Cool Image Pin",
17
- subtitle: "Image pin subtitle",
18
- image: UIImage.imageNamed("test.png")
19
- }
20
- @map.annotations.count.should == 5
21
- @map.add_annotation ann
22
- @map.set_region @map.region(coordinate: @map.annotations.last.coordinate, span: [0.05, 0.05])
23
- end
24
-
25
- after do
26
- @map = nil
27
- end
28
-
29
- it "should have a navigation bar" do
30
- @map.navigationController.should.be.kind_of(UINavigationController)
31
- end
32
-
33
- it "should have the map properly centered" do
34
- center_coordinate = @map.center
35
- center_coordinate.latitude.should.be.close 35.090648651123, 0.02
36
- center_coordinate.longitude.should.be.close -82.965972900391, 0.02
37
- end
38
-
39
- it "should move the map center" do
40
- @map.center = {latitude: 35.07496, longitude: -82.95916, animated: true}
41
-
42
- wait 0.75 do
43
- center_coordinate = @map.center
44
- center_coordinate.latitude.should.be.close 35.07496, 0.001
45
- center_coordinate.longitude.should.be.close -82.95916, 0.001
46
- end
47
- end
48
-
49
- it "should select an annotation" do
50
- @map.selected_annotations.should == nil
51
- @map.select_annotation @map.annotations.first
52
- wait 0.75 do
53
- @map.selected_annotations.count.should == 1
54
- end
55
- end
56
-
57
- it "should select an annotation by index" do
58
- @map.selected_annotations.should == nil
59
- @map.select_annotation_at 2
60
- wait 0.75 do
61
- @map.selected_annotations.count.should == 1
62
- @map.selected_annotations[0].should == @map.promotion_annotation_data[2]
63
- end
64
- end
65
-
66
- it "should select another annotation and check that the title is correct" do
67
- @map.selected_annotations.should == nil
68
- @map.select_annotation @map.annotations[1]
69
- wait 0.75 do
70
- @map.selected_annotations.count.should == 1
71
- end
72
-
73
- @map.selected_annotations.first.title.should == "Turtleback Falls"
74
- @map.selected_annotations.first.subtitle.should == "Nantahala National Forest"
75
-
76
- end
77
-
78
- it "should deselect selected annotations" do
79
- @map.select_annotation @map.annotations.last
80
- wait 0.75 do
81
- # @map.selected_annotations.count.should == 1
82
- end
83
-
84
- @map.deselect_annotations
85
- wait 0.75 do
86
- @map.selected_annotations.should == nil
87
- end
88
- end
89
-
90
- it "should add an annotation and be able to zoom immediately" do
91
- ann = {
92
- longitude: -82.966093558105,
93
- latitude: 35.092520895652,
94
- title: "Something Else"
95
- }
96
- @map.annotations.count.should == 5
97
- @map.add_annotation ann
98
- @map.annotations.count.should == 6
99
- @map.set_region @map.region(coordinate: @map.annotations.last.coordinate, span: [0.05, 0.05])
100
- @map.select_annotation @map.annotations.last
101
- end
102
-
103
- it "should be able to overwrite all annotations" do
104
- anns = [{
105
- longitude: -122.029620,
106
- latitude: 37.331789,
107
- title: "My Cool Pin"
108
- },{
109
- longitude: -80.8498118 ,
110
- latitude: 35.2187218,
111
- title: "My Cool Pin"
112
- }]
113
- @map.annotations.count.should == 5
114
- @map.add_annotations anns
115
- @map.annotations.count.should == 2
116
- end
117
-
118
- it "should add an image based annotation" do
119
- add_image_annotation
120
- @map.annotations.count.should == 6
121
-
122
- # Checking that it conforms to the MKAnnotation protocol manually since this doesn't work in iOS 7:
123
- # @map.annotations.last.conformsToProtocol(MKAnnotation).should.be.true
124
- # See this 8 month old bug - https://github.com/siuying/rubymotion-protocol-bug
125
-
126
- checking = @map.annotations.last
127
- %w(title subtitle coordinate).each do |method|
128
- defined?(checking.send(method.to_sym)).nil?.should.be.false
129
- end
130
- end
131
-
132
- it "should select an image annotation" do
133
- add_image_annotation
134
- @map.selected_annotations.should == nil
135
- @map.select_annotation @map.annotations.last
136
- wait 0.75 do
137
- @map.selected_annotations.count.should == 1
138
- end
139
- end
140
-
141
- it "should select an image annotation by index" do
142
- add_image_annotation
143
- @map.selected_annotations.should == nil
144
- @map.select_annotation_at 5
145
- wait 0.75 do
146
- @map.selected_annotations.count.should == 1
147
- @map.selected_annotations[0].should == @map.promotion_annotation_data[5]
148
- end
149
- end
150
-
151
- it "should select an image annotation and check that the title is correct" do
152
- add_image_annotation
153
- @map.selected_annotations.should == nil
154
- @map.select_annotation @map.annotations[5]
155
- wait 0.75 do
156
- @map.selected_annotations.count.should == 1
157
- end
158
- @map.selected_annotations.first.title.should == "My Cool Image Pin"
159
- @map.selected_annotations.first.subtitle.should == "Image pin subtitle"
160
- end
161
-
162
- end
@@ -1,56 +0,0 @@
1
- describe "Searchable table spec" do
2
- tests TableScreenSearchable
3
-
4
- # Override controller to properly instantiate
5
- def controller
6
- @controller ||= TableScreenSearchable.new(nav_bar: true)
7
- @controller.on_load
8
- @controller.navigationController
9
- end
10
-
11
- it "should be rotated in portrait mode" do
12
- rotate_device to: :portrait, button: :bottom
13
- true.should == true
14
- end
15
-
16
- it "should show all 50 states" do
17
- @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 50
18
- end
19
-
20
- it "should allow searching for all the 'New' states" do
21
- @controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"New")
22
- @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 4
23
- end
24
-
25
- it "should allow ending searches" do
26
- @controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"North")
27
- @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 2
28
- @controller.searchDisplayControllerWillEndSearch(@controller)
29
- @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 50
30
- end
31
-
32
- it "should expose the search_string variable and clear it properly" do
33
- @controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"North")
34
-
35
- @controller.search_string.should == "north"
36
- @controller.original_search_string.should == "North"
37
-
38
- @controller.searchDisplayControllerWillEndSearch(@controller)
39
-
40
- @controller.search_string.should == false
41
- @controller.original_search_string.should == false
42
- end
43
-
44
- it "should call the start and stop searching callbacks properly" do
45
- @controller.will_begin_search_called.should == nil
46
- @controller.will_end_search_called.should == nil
47
-
48
- @controller.searchDisplayControllerWillBeginSearch(@controller)
49
- @controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"North")
50
- @controller.will_begin_search_called.should == true
51
-
52
- @controller.searchDisplayControllerWillEndSearch(@controller)
53
- @controller.will_end_search_called.should == true
54
- end
55
-
56
- end
@@ -1,78 +0,0 @@
1
- describe "PM::Tabs" do
2
- tests PM::Tabs
3
-
4
- # Override controller to properly instantiate
5
- def controller
6
- @app ||= TestDelegate.new
7
-
8
- @screen1 = BasicScreen.new(nav_bar: true, title: "Screen 1")
9
- @screen2 = BasicScreen.new(nav_bar: true, title: "Screen 2")
10
- @screen3 = BasicScreen.new(title: "Screen 3")
11
- @screen4 = BasicScreen.new(title: "Screen 4")
12
-
13
- @controller ||= @app.open_tab_bar(@screen1, @screen2, @screen3, @screen4)
14
- @tab_bar = @controller
15
- end
16
-
17
- it "should create a UITabBarController" do
18
- @app.window.rootViewController.should.be.kind_of UITabBarController
19
- end
20
-
21
- it "should have four tabs" do
22
- @tab_bar.viewControllers.length.should == 4
23
- end
24
-
25
- it "should have the right screens in the right places" do
26
- @tab_bar.viewControllers[0].should == @screen1.navigationController
27
- @tab_bar.viewControllers[1].should == @screen2.navigationController
28
- @tab_bar.viewControllers[2].should == @screen3
29
- @tab_bar.viewControllers[3].should == @screen4
30
- end
31
-
32
- it "should allow opening a tab by the name from any screen" do
33
- @screen1.open_tab "Screen 2"
34
- @tab_bar.selectedIndex.should == 1
35
- @screen2.open_tab "Screen 3"
36
- @tab_bar.selectedIndex.should == 2
37
- @screen3.open_tab "Screen 4"
38
- @tab_bar.selectedIndex.should == 3
39
- @screen4.open_tab "Screen 1"
40
- @tab_bar.selectedIndex.should == 0
41
- end
42
-
43
- it "should allow opening a tab by the index from any screen" do
44
- @screen1.open_tab 1
45
- @tab_bar.selectedIndex.should == 1
46
- @screen2.open_tab 2
47
- @tab_bar.selectedIndex.should == 2
48
- @screen3.open_tab 3
49
- @tab_bar.selectedIndex.should == 3
50
- @screen4.open_tab 0
51
- @tab_bar.selectedIndex.should == 0
52
- end
53
-
54
- it "should allow opening a tab from the app_delegate" do
55
- @app.open_tab "Screen 2"
56
- @tab_bar.selectedIndex.should == 1
57
- @app.open_tab "Screen 3"
58
- @tab_bar.selectedIndex.should == 2
59
- @app.open_tab "Screen 4"
60
- @tab_bar.selectedIndex.should == 3
61
- @app.open_tab "Screen 1"
62
- @tab_bar.selectedIndex.should == 0
63
- end
64
-
65
- it "should allow opening a tab by accessing the tab bar directly" do
66
- @tab_bar.open_tab "Screen 2"
67
- @tab_bar.selectedIndex.should == 1
68
- @tab_bar.open_tab "Screen 3"
69
- @tab_bar.selectedIndex.should == 2
70
- @tab_bar.open_tab "Screen 4"
71
- @tab_bar.selectedIndex.should == 3
72
- @tab_bar.open_tab "Screen 1"
73
- @tab_bar.selectedIndex.should == 0
74
- end
75
-
76
-
77
-
78
- end
@@ -1,21 +0,0 @@
1
- describe "ProMotion::Screen UIView title functionality" do
2
- tests PM::Screen
3
-
4
- # Override controller to properly instantiate
5
- def controller
6
- rotate_device to: :portrait, button: :bottom
7
- @image_title_screen ||= ViewTitleScreen.new(nav_bar: true)
8
- @root_screen = @image_title_screen
9
- @image_title_screen.navigationController
10
- end
11
-
12
- after do
13
- @controller = nil
14
- @root_screen = nil
15
- end
16
-
17
- it "should allow an image title" do
18
- @root_screen.navigationItem.titleView.should.not.be.kind_of UIImageView
19
- @root_screen.navigationItem.titleView.should.be.kind_of UIView
20
- end
21
- end
@@ -1,3 +0,0 @@
1
- class BasicScreen < ProMotion::Screen
2
- title "Basic"
3
- end
@@ -1,4 +0,0 @@
1
- class CustomTitleView < UITableViewCell
2
- attr_accessor :title
3
- end
4
-