Skip to content

Commit 0deb155

Browse files
authored
Merge pull request #12 from clutter/single-selection-toolbar-bug
Fix Toolbar Not Showing in `SingleSelectionController`
2 parents 5a76039 + 8bfd435 commit 0deb155

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

Example/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PODS:
22
- SwiftLint (0.34.0)
3-
- TiltUp (0.4.1)
4-
- TiltUpTest (0.4.1)
3+
- TiltUp (0.4.2)
4+
- TiltUpTest (0.4.2)
55

66
DEPENDENCIES:
77
- SwiftLint
@@ -20,8 +20,8 @@ EXTERNAL SOURCES:
2020

2121
SPEC CHECKSUMS:
2222
SwiftLint: 79d48a17c6565dc286c37efb8322c7b450f95c67
23-
TiltUp: 8625a9aa996f241edf86840c6faa2a8f23786612
24-
TiltUpTest: 404137458fbaf85e27e86fa72bec875c0ff9a536
23+
TiltUp: 0361700e865c524c86efee1796d12e0c1fcf87e2
24+
TiltUpTest: 6e9a851cb28630e793710fdeb03341bc4c894521
2525

2626
PODFILE CHECKSUM: c3ad4c36e5d17d3b4a90d5cf5f5b66d3221db5dd
2727

TiltUp.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'TiltUp'
11-
s.version = '0.4.1'
11+
s.version = '0.4.2'
1212
s.summary = 'Official Clutter SDK in Swift to access core iOS features.'
1313

1414
# This description is used to generate tags and improve search results.

TiltUp/Classes/Screens/SingleSelection/SingleSelectionController.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ public final class SingleSelectionController<Value: SingleSelectionableRow>: UIT
4747
viewModel.viewObservers.toolbarButtonTitle = { [weak self] title in
4848
guard let self = self else { return }
4949

50-
let item = UIBarButtonItem(title: title, style: .plain, target: self, action: #selector(self.tappedToolbarButton))
51-
self.setToolbarItems([item], animated: false)
50+
let spacer = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
51+
let button = UIBarButtonItem(title: title, style: .plain, target: self, action: #selector(self.tappedToolbarButton))
52+
self.setToolbarItems([spacer, button, spacer], animated: false)
53+
}
54+
55+
viewModel.viewObservers.toolbarHidden = { [weak self] hidden, animated in
56+
self?.navigationController?.setToolbarHidden(hidden, animated: animated)
5257
}
5358

5459
viewModel.viewObservers.rowUpdated = { [weak self] indexPath in
@@ -67,9 +72,7 @@ public final class SingleSelectionController<Value: SingleSelectionableRow>: UIT
6772
public override func viewWillAppear(_ animated: Bool) {
6873
super.viewWillAppear(animated)
6974

70-
viewModel.viewObservers.toolbarHidden = { [weak self] hidden in
71-
self?.navigationController?.setToolbarHidden(hidden, animated: animated)
72-
}
75+
viewModel.updateToolbarHidden(animated: animated)
7376
}
7477

7578
// MARK: - UITableViewDataSource

TiltUp/Classes/Screens/SingleSelection/SingleSelectionViewModel.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public enum SingleSelection {
3131
var navTitle: ((String) -> Void)?
3232
var confirmButtonEnabled: ((Bool) -> Void)?
3333
var confirmButtonTitle: ((String) -> Void)?
34-
var toolbarHidden: ((Bool) -> Void)?
34+
var toolbarHidden: ((_ hidden: Bool, _ animated: Bool) -> Void)?
3535
var toolbarButtonTitle: ((String?) -> Void)?
3636
var rowUpdated: ((IndexPath) -> Void)?
3737
}
@@ -98,8 +98,13 @@ public final class SingleSelectionViewModel<Value: SingleSelectionableRow> {
9898
viewObservers.navTitle?(navTitle)
9999
viewObservers.confirmButtonEnabled?(selectedIndexPath != nil)
100100
viewObservers.confirmButtonTitle?(confirmButtonTitle)
101-
viewObservers.toolbarHidden?(toolbarHidden)
102101
viewObservers.toolbarButtonTitle?(toolbarButtonTitle)
102+
103+
updateToolbarHidden(animated: false)
104+
}
105+
106+
public func updateToolbarHidden(animated: Bool) {
107+
viewObservers.toolbarHidden?(toolbarHidden, animated)
103108
}
104109

105110
var selectedIndexPath: IndexPath? {

TiltUpTest.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'TiltUpTest'
11-
s.version = '0.4.1'
11+
s.version = '0.4.2'
1212
s.summary = 'Official Clutter SDK in Swift to access core iOS test helpers.'
1313

1414
# This description is used to generate tags and improve search results.

0 commit comments

Comments
 (0)