Skip to content

Commit 4a68548

Browse files
committed
Add dismissAllHints to hint presenter protocol and implementations
1 parent 0f6e2bf commit 4a68548

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Instead of calling `present` on your hints and tutorials, now use the presenters
1515
The presenter protocols have also been refactored. The first parameter names are
1616
now implicit.
1717

18+
`HintPresenter` now has a `dismissAllHints()` function. It's implemented by some
19+
of the presenters, where applicable.
20+
1821

1922

2023
## 1.3.0

Tutti/Hints/Presenters/AlertHintPresenter.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ public class AlertingHintPresenter: HintPresenter {
2222

2323
public init() {}
2424

25+
public func dismiss(_ hint: Hint) { }
26+
27+
public func dismissAllHints() {}
28+
2529
public func present(_ hint: Hint, in vc: UIViewController, from view: UIView) {
2630
tryPresent(hint) {
2731
alert(hint: hint, from: vc)
@@ -33,8 +37,6 @@ public class AlertingHintPresenter: HintPresenter {
3337
alert(hint: hint, from: vc)
3438
}
3539
}
36-
37-
public func dismiss(_ hint: Hint) { }
3840
}
3941

4042
private extension AlertingHintPresenter {

Tutti/Hints/Presenters/CalloutHintPresenter.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ public class CalloutHintPresenter: HintPresenter, CalloutViewDelegate {
3232

3333

3434
// MARK: - Public Functions
35+
36+
open func dismiss(_ hint: Hint) {
37+
let callouts = presentedCallouts.filter { $0.text == hint.text }
38+
callouts.forEach { $0.dismiss() }
39+
}
40+
41+
open func dismissAllHints() {
42+
presentedCallouts.forEach { $0.dismiss() }
43+
}
3544

3645
open func present(_ hint: Hint, in vc: UIViewController, from view: UIView) {
3746
tryPresent(hint) {
@@ -45,11 +54,6 @@ public class CalloutHintPresenter: HintPresenter, CalloutViewDelegate {
4554
}
4655
}
4756

48-
open func dismiss(_ hint: Hint) {
49-
let callouts = presentedCallouts.filter { $0.text == hint.text }
50-
callouts.forEach { $0.dismiss() }
51-
}
52-
5357

5458
// MARK: - CalloutViewDelegate
5559

Tutti/Hints/Presenters/HintPresenter.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import UIKit
1717
public protocol HintPresenter: OnboardingPresenter {
1818

1919
func dismiss(_ hint: Hint)
20+
func dismissAllHints()
2021
func present(_ hint: Hint, in vc: UIViewController, from view: UIView)
2122
func present(_ hint: Hint, in vc: UIViewController, from barButtonItem: UIBarButtonItem)
2223
}

0 commit comments

Comments
 (0)