ProMotion 2.7.1 → 2.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ff30153aea5024d65f20bfacc4de9b03237997c
4
- data.tar.gz: 85cfd76f2fbd7ded2051be9b6ccdc816b26e60ea
3
+ metadata.gz: 4d0c2893ec28afedac3c71606028a215ba4dbc6e
4
+ data.tar.gz: 35313a6617437f5c92a3eb0c0448939c4bca13e5
5
5
  SHA512:
6
- metadata.gz: 9956829eb6dc692feca9a05fb8d913ccf27ef04a46c2b8cd8645e09638aa56f6a6f05dfe5b317a5a66c95bfce55383c2b0a1a9fe4d08df7c1dd03424810f9184
7
- data.tar.gz: b6eef1cc874010a91ef179597209b04a58d9c3bd70e43d9ba47be44322d79c5f1a389332e7de6e54f2e755548d9f61f9ecacbb940832c23aa88f686f3f3f79c8
6
+ metadata.gz: c23d851b8bd4aae82dcf6b72cb80d3e88b7d9d1980f20a6b3a056b52a6211337e5985b4d07dd6af63da6983870d7c06da2a0e0bca1fa326b2356406532ec4f9c
7
+ data.tar.gz: 90dd32dcc1281d9b49f87ab21e00cb61946e37e6e7a7e68aa471bfbb6a1f2243724a2da3a070a64c7fce804206b5206a7da9aa7424ced972bc274a67c7f39c2b
@@ -51,7 +51,7 @@ module ProMotion
51
51
  end
52
52
 
53
53
  def open(screen, args={})
54
- screen = screen.new if screen.respond_to?(:new)
54
+ screen = set_up_screen_for_open(screen, args)
55
55
 
56
56
  self.home_screen = screen
57
57
 
@@ -65,6 +65,27 @@ module ProMotion
65
65
  alias :open_screen :open
66
66
  alias :open_root_screen :open_screen
67
67
 
68
+ def set_up_screen_for_open(screen, args={})
69
+ # Instantiate screen if given a class
70
+ screen = screen.new(args) if screen.respond_to?(:new)
71
+
72
+ # Store screen options
73
+ screen.screen_options.merge(args) if screen.respond_to?(:screen_options)
74
+
75
+ # Set title & modal properties
76
+ screen.title = args[:title] if args[:title] && screen.respond_to?(:title=)
77
+ screen.modal = args[:modal] if args[:modal] && screen.respond_to?(:modal=)
78
+
79
+ # Hide bottom bar?
80
+ screen.hidesBottomBarWhenPushed = args[:hide_tab_bar] == true
81
+
82
+ # Wrap in a PM::NavigationController?
83
+ screen.add_nav_bar(args) if screen.respond_to?(:add_nav_bar)
84
+
85
+ # Return modified screen instance
86
+ screen
87
+ end
88
+
68
89
  # DEPRECATED
69
90
  def status_bar?
70
91
  mp "The default behavior of `status_bar?` has changed. Calling `status_bar?` on AppDelegate may not return the correct result.", force_color: :yellow
@@ -48,10 +48,16 @@ module ProMotion
48
48
 
49
49
  def add_nav_bar(args = {})
50
50
  args = self.class.get_nav_bar.merge(args)
51
- return unless args[:nav_bar]
51
+ return unless args[:nav_bar] || args[:nav_controller]
52
52
  self.navigationController ||= begin
53
53
  self.first_screen = true if self.respond_to?(:first_screen=)
54
- nav = (args[:nav_controller] || NavigationController).alloc.initWithRootViewController(self)
54
+ nav_controller_class = args[:nav_controller] || NavigationController
55
+ if nav_controller_class.is_a? Class
56
+ nav = nav_controller_class.alloc.initWithRootViewController(self)
57
+ else
58
+ nav = nav_controller_class
59
+ nav.setViewControllers([self], animated: false)
60
+ end
55
61
  nav.setModalTransitionStyle(args[:transition_style]) if args[:transition_style]
56
62
  nav.setModalPresentationStyle(args[:presentation_style]) if args[:presentation_style]
57
63
  nav
@@ -59,9 +65,11 @@ module ProMotion
59
65
  self.navigationController.toolbarHidden = !args[:toolbar] unless args[:toolbar].nil?
60
66
  end
61
67
 
62
- def view_will_appear(animated)
63
- if @screen_options && !@screen_options[:hide_nav_bar].nil?
64
- self.navigationController.setNavigationBarHidden(@screen_options[:hide_nav_bar], animated: false)
68
+ def update_nav_bar_visibility(animated)
69
+ return unless navigationController
70
+ hidden = @screen_options[:hide_nav_bar]
71
+ unless hidden.nil?
72
+ navigationController.setNavigationBarHidden(hidden, animated: animated)
65
73
  end
66
74
  end
67
75
 
@@ -9,7 +9,7 @@ module ProMotion
9
9
  include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad || (UIDevice.currentDevice.systemVersion.to_i >= 8 )
10
10
 
11
11
  attr_reader :parent_screen
12
- attr_accessor :first_screen, :modal, :split_screen
12
+ attr_accessor :screen_options, :first_screen, :modal, :split_screen
13
13
 
14
14
  def screen_init(args = {})
15
15
  @screen_options = args
@@ -41,7 +41,8 @@ module ProMotion
41
41
  end
42
42
 
43
43
  def view_will_appear(animated)
44
- super
44
+ update_nav_bar_visibility(animated)
45
+
45
46
  self.will_appear
46
47
 
47
48
  self.will_present if isMovingToParentViewController
@@ -186,7 +187,7 @@ module ProMotion
186
187
  end
187
188
 
188
189
  def apply_properties(args)
189
- reserved_args = [ :nav_bar, :hide_nav_bar, :hide_tab_bar, :animated, :close_all, :in_tab, :in_detail, :in_master, :to_screen, :toolbar ]
190
+ reserved_args = [ :nav_bar, :nav_controller, :hide_nav_bar, :hide_tab_bar, :animated, :close_all, :replace_nav_stack, :in_tab, :in_detail, :in_master, :to_screen, :toolbar ]
190
191
  set_attributes self, args.dup.delete_if { |k,v| reserved_args.include?(k) }
191
192
  end
192
193
 
@@ -10,11 +10,12 @@ module ProMotion
10
10
  ensure_wrapper_controller_in_place(screen, args)
11
11
 
12
12
  opened ||= open_in_split_screen(screen, args) if self.split_screen
13
- opened ||= open_root_screen(screen) if args[:close_all]
13
+ opened ||= open_root_screen(screen, args) if args[:close_all]
14
+ opened ||= replace_nav_stack([screen], args) if args[:replace_nav_stack]
14
15
  opened ||= present_modal_view_controller(screen, args) if args[:modal]
15
16
  opened ||= open_in_tab(screen, args[:in_tab]) if args[:in_tab]
16
17
  opened ||= push_view_controller(screen, self.navigationController, !!args[:animated]) if self.navigationController
17
- opened ||= open_root_screen(screen.navigationController || screen)
18
+ opened ||= open_root_screen(screen.navigationController || screen, args)
18
19
  screen
19
20
  end
20
21
  alias :open :open_screen
@@ -25,8 +26,8 @@ module ProMotion
25
26
  args[:in_detail] || args[:in_master]
26
27
  end
27
28
 
28
- def open_root_screen(screen)
29
- app_delegate.open_root_screen(screen)
29
+ def open_root_screen(screen, args = {})
30
+ app_delegate.open_root_screen(screen, args)
30
31
  end
31
32
 
32
33
  def open_modal(screen, args = {})
@@ -75,15 +76,19 @@ module ProMotion
75
76
  nav_controller.pushViewController(vc, animated: animated)
76
77
  end
77
78
 
79
+ def replace_nav_stack(screens, args = {})
80
+ args[:animated] ||= true
81
+ navigationController.setViewControllers(screens, animated: !!args[:animated])
82
+ end
83
+
78
84
  protected
79
85
 
80
86
  def set_up_screen_for_open(screen, args={})
81
-
82
87
  # Instantiate screen if given a class
83
- screen = screen.new if screen.respond_to?(:new)
88
+ screen = screen.new(args) if screen.respond_to?(:new)
84
89
 
85
90
  # Store screen options
86
- screen.instance_variable_set(:@screen_options, args)
91
+ screen.screen_options.merge(args) if screen.respond_to?(:screen_options)
87
92
 
88
93
  # Set parent
89
94
  screen.parent_screen = self if screen.respond_to?(:parent_screen=)
@@ -96,11 +101,10 @@ module ProMotion
96
101
  screen.hidesBottomBarWhenPushed = args[:hide_tab_bar] == true
97
102
 
98
103
  # Wrap in a PM::NavigationController?
99
- screen.add_nav_bar(args) if args[:nav_bar] && screen.respond_to?(:add_nav_bar)
104
+ screen.add_nav_bar(args) if screen.respond_to?(:add_nav_bar)
100
105
 
101
106
  # Return modified screen instance
102
107
  screen
103
-
104
108
  end
105
109
 
106
110
  def ensure_wrapper_controller_in_place(screen, args={})
@@ -79,6 +79,8 @@ module ProMotion
79
79
  self.filtered_data << new_section
80
80
  end
81
81
  end
82
+
83
+ self.filtered_data
82
84
  end
83
85
 
84
86
  def clear_filter
@@ -2,11 +2,14 @@ module ProMotion
2
2
  module Table
3
3
  module Searchable
4
4
 
5
+ def search_controller
6
+ @search_controller ||= UISearchController.alloc.initWithSearchResultsController(nil)
7
+ end
8
+
5
9
  def make_searchable(params = nil) # params argument is deprecated. No longer need to use it.
6
10
  params = get_searchable_params
7
11
 
8
12
  self.definesPresentationContext = true
9
- search_controller = UISearchController.alloc.initWithSearchResultsController(nil)
10
13
  search_controller.delegate = params[:delegate]
11
14
  search_controller.searchResultsUpdater = params[:search_results_updater]
12
15
  search_controller.hidesNavigationBarDuringPresentation = params[:hides_nav_bar]
@@ -1,3 +1,3 @@
1
1
  module ProMotion
2
- VERSION = "2.7.1" unless defined?(ProMotion::VERSION)
2
+ VERSION = "2.8.0" unless defined?(ProMotion::VERSION)
3
3
  end
@@ -19,43 +19,37 @@ describe "Split screen functionality" do
19
19
  rotate_device to: :portrait, button: :bottom
20
20
  end
21
21
 
22
+ if TestHelper.lt_ios11 # FIXME: these tests no longer work since iOS 11 removed the private class UINavigationItemView
22
23
  it "should allow opening a detail view from the master view" do
23
-
24
24
  @master.open BasicScreen.new(nav_bar: true), in_detail: true, animated: false
25
25
 
26
26
  view("Master").should.be.kind_of UINavigationItemView
27
27
  view("Basic").should.be.kind_of UINavigationItemView
28
28
  views(UINavigationItemView).each { |v| v.title.should.not == "Detail" }
29
-
30
29
  end
31
30
 
32
31
  it "should allow opening another view from the master view" do
33
-
34
32
  @master.open BasicScreen.new(nav_bar: true), animated: false
35
33
 
36
34
  view("Basic").should.be.kind_of UINavigationItemView
37
35
  view("Detail").should.be.kind_of UINavigationItemView
38
-
39
36
  end
40
37
 
41
38
  it "should allow opening a master view from the detail view" do
42
-
43
39
  @detail.open BasicScreen.new(nav_bar: true), in_master: true, animated: false
44
40
 
45
41
  view("Basic").should.be.kind_of UINavigationItemView
46
42
  view("Detail").should.be.kind_of UINavigationItemView
47
43
  views(UINavigationItemView).each { |v| v.title.should.not == "Master" }
48
-
49
44
  end
50
45
 
51
46
  it "should allow opening another view from the detail view" do
52
-
53
47
  @detail.open BasicScreen.new(nav_bar: true), animated: false
54
48
 
55
49
  view("Basic").should.be.kind_of UINavigationItemView
56
50
  view("Master").should.be.kind_of UINavigationItemView
57
-
58
51
  end
52
+ end
59
53
 
60
54
  unless ENV['TRAVIS'] # TODO: Why won't Travis pass these tests??
61
55
  it "should override the title on the button" do
@@ -1,21 +1,30 @@
1
1
  class TestHelper
2
+ def self.ios_version
3
+ UIDevice.currentDevice.systemVersion.to_f
4
+ end
5
+
2
6
  def self.ios6
3
- UIDevice.currentDevice.systemVersion.to_f >= 6.0 &&
4
- UIDevice.currentDevice.systemVersion.to_f < 7.0
7
+ ios_version >= 6.0 && ios_version < 7.0
5
8
  end
6
9
 
7
10
  def self.ios7
8
- UIDevice.currentDevice.systemVersion.to_f >= 7.0 &&
9
- UIDevice.currentDevice.systemVersion.to_f < 8.0
11
+ ios_version >= 7.0 && ios_version < 8.0
10
12
  end
11
13
 
12
14
  def self.ios8
13
- UIDevice.currentDevice.systemVersion.to_f >= 8.0 &&
14
- UIDevice.currentDevice.systemVersion.to_f < 9.0
15
+ ios_version >= 8.0 && ios_version < 9.0
15
16
  end
16
17
 
17
18
  def self.gte_ios8
18
- UIDevice.currentDevice.systemVersion.to_f >= 8.0
19
+ ios_version >= 8.0
20
+ end
21
+
22
+ def self.lt_ios11
23
+ ios_version < 11.0
24
+ end
25
+
26
+ def self.gte_ios11
27
+ ios_version >= 11.0
19
28
  end
20
29
  end
21
30
 
@@ -155,7 +155,7 @@ describe "screen helpers" do
155
155
  end
156
156
 
157
157
  it "should open a root screen if :close_all is provided" do
158
- @screen.mock!(:open_root_screen) { |screen| screen.should.be.instance_of BasicScreen }
158
+ @screen.mock!(:open_root_screen) { |screen, args| screen.should.be.instance_of BasicScreen }
159
159
  screen = @screen.open BasicScreen, close_all: true
160
160
  screen.should.be.kind_of BasicScreen
161
161
  end
@@ -218,7 +218,7 @@ describe "screen helpers" do
218
218
  it "should open the provided view controller as root view if no other conditions are met" do
219
219
  parent_screen = HomeScreen.new
220
220
  new_screen = BasicScreen.new
221
- parent_screen.mock!(:open_root_screen) { |vc| vc.should.be == new_screen }
221
+ parent_screen.mock!(:open_root_screen) { |vc, args| vc.should.be == new_screen }
222
222
  screen = parent_screen.open_screen new_screen
223
223
  screen.should == new_screen
224
224
  end
@@ -18,7 +18,6 @@ describe "Searchable table spec" do
18
18
 
19
19
  it "should allow searching for all the 'New' states" do
20
20
  controller.willPresentSearchController(controller.search_controller)
21
- controller.searching?.should == true
22
21
  controller.search_controller.searchBar.text = "New"
23
22
  controller.updateSearchResultsForSearchController(controller.search_controller)
24
23
  controller.tableView(controller.tableView, numberOfRowsInSection:0).should == 4
@@ -37,34 +36,17 @@ describe "Searchable table spec" do
37
36
  controller.tableView(controller.tableView, numberOfRowsInSection:0).should == 50
38
37
  end
39
38
 
40
- it "should expose the search_string variable and clear it properly" do
41
- controller.willPresentSearchController(controller.search_controller)
42
- controller.search_controller.searchBar.text = "North"
43
- controller.updateSearchResultsForSearchController(controller.search_controller)
39
+ it "should call the start and stop searching callbacks properly" do
40
+ controller.will_begin_search_called.should == nil
41
+ controller.will_end_search_called.should == nil
44
42
 
45
- controller.search_string.should == "north"
46
- controller.original_search_string.should == "North"
43
+ controller.willPresentSearchController(controller.search_controller)
44
+ controller.will_begin_search_called.should == true
47
45
 
48
46
  controller.willDismissSearchController(controller.search_controller)
49
- controller.search_controller.searchBar.text = ""
50
- controller.updateSearchResultsForSearchController(controller.search_controller) # iOS calls this again
51
-
52
- controller.search_string.should == false
53
- controller.original_search_string.should == false
47
+ controller.will_end_search_called.should == true
54
48
  end
55
49
 
56
- # FIXME: Can't figure out why this test passes in isolation, but fails when run after the other tests.
57
- # it "should call the start and stop searching callbacks properly" do
58
- # controller.will_begin_search_called.should == nil
59
- # controller.will_end_search_called.should == nil
60
-
61
- # controller.willPresentSearchController(controller.search_controller)
62
- # controller.will_begin_search_called.should == true
63
-
64
- # controller.willDismissSearchController(controller.search_controller)
65
- # controller.will_end_search_called.should == true
66
- # end
67
-
68
50
  describe "custom search" do
69
51
  before do
70
52
  @stabby_controller = TableScreenStabbySearchable.new
@@ -8,20 +8,23 @@ describe "table screen searchable functionality" do
8
8
  @screen.class.get_searchable.should == true
9
9
  end
10
10
 
11
- it "should create a search header" do
12
- @screen.tableView.tableHeaderView.should.be.kind_of UISearchBar
13
- end
11
+ # Older than iOS 11 tests
12
+ if TestHelper.lt_ios11
13
+ it "should create a search header" do
14
+ @screen.tableView.tableHeaderView.should.be.kind_of UISearchBar
15
+ end
14
16
 
15
- it "should not hide the search bar initally by default" do
16
- @screen.tableView.contentOffset.should == CGPointMake(0,0)
17
- end
17
+ it "should not hide the search bar initally by default" do
18
+ @screen.tableView.contentOffset.should == CGPointMake(0,0)
19
+ end
18
20
 
19
- it "should allow hiding the search bar initally" do
20
- class HiddenSearchScreen < TableScreenSearchable
21
- searchable hide_initially: true
21
+ it "should allow hiding the search bar initally" do
22
+ class HiddenSearchScreen < TableScreenSearchable
23
+ searchable hide_initially: true
24
+ end
25
+ screen = HiddenSearchScreen.new
26
+ screen.on_load
27
+ screen.tableView.contentOffset.should == CGPointMake(0, screen.tableView.tableHeaderView.frame.size.height)
22
28
  end
23
- screen = HiddenSearchScreen.new
24
- screen.on_load
25
- screen.tableView.contentOffset.should == CGPointMake(0, screen.tableView.tableHeaderView.frame.size.height)
26
29
  end
27
30
  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: 2.7.1
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamon Holmgren
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-04-17 00:00:00.000000000 Z
13
+ date: 2018-04-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: methadone