diff --git a/PocketKit/Sources/PocketKit/Article/ReadableViewController.swift b/PocketKit/Sources/PocketKit/Article/ReadableViewController.swift index d98e03dd7..928b8537d 100644 --- a/PocketKit/Sources/PocketKit/Article/ReadableViewController.swift +++ b/PocketKit/Sources/PocketKit/Article/ReadableViewController.swift @@ -154,6 +154,7 @@ class ReadableViewController: UIViewController { super.viewDidAppear(animated) scrollToLastKnownPosition() if #available(iOS 17.0, *) { + PocketTipEvents.showSwipeHighlightsTip.sendDonation() displayTip(SwipeHighlightsTip(), configuration: nil, sourceView: nil) } } diff --git a/PocketKit/Sources/PocketKit/Home/HomeViewController.swift b/PocketKit/Sources/PocketKit/Home/HomeViewController.swift index 63ce64825..810983821 100644 --- a/PocketKit/Sources/PocketKit/Home/HomeViewController.swift +++ b/PocketKit/Sources/PocketKit/Home/HomeViewController.swift @@ -172,6 +172,7 @@ class HomeViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if #available(iOS 17.0, *), let sourceView = navigationController?.view ?? view { + PocketTipEvents.showNewRecommendationsWidgetTip.sendDonation() let x = view.bounds.width / 2 let y: CGFloat = 0 let sourceRect = CGRect(x: x, y: y, width: 0, height: 0) diff --git a/PocketKit/Sources/PocketKit/MyList/ItemsList/UIKit/ItemsListViewController.swift b/PocketKit/Sources/PocketKit/MyList/ItemsList/UIKit/ItemsListViewController.swift index b8aeae02e..62ff47f79 100644 --- a/PocketKit/Sources/PocketKit/MyList/ItemsList/UIKit/ItemsListViewController.swift +++ b/PocketKit/Sources/PocketKit/MyList/ItemsList/UIKit/ItemsListViewController.swift @@ -74,6 +74,7 @@ class ItemsListViewController: UIViewController, override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if #available(iOS 17.0, *) { + PocketTipEvents.showSwipeArchiveTip.sendDonation() displayTip(SwipeArchiveTip(), configuration: nil, sourceView: nil) } } diff --git a/PocketKit/Sources/PocketKit/Tips/PocketTips.swift b/PocketKit/Sources/PocketKit/Tips/PocketTips.swift index 5aeb069d1..9350df163 100644 --- a/PocketKit/Sources/PocketKit/Tips/PocketTips.swift +++ b/PocketKit/Sources/PocketKit/Tips/PocketTips.swift @@ -12,29 +12,51 @@ import TipKit /// Swipe highlights, Reader @available(iOS 17.0, *) struct SwipeHighlightsTip: Tip { - var id = UUID() + let id = "pocketTips.reader.swipeHighlights" let title: Text = Text(Localization.Tips.SwipeHighlights.title) let message: Text? = Text(Localization.Tips.SwipeHighlights.message) let image: Image? = Image(uiImage: UIImage(asset: .highlights)) - let options = [Tips.MaxDisplayCount(3)] + let options = [Tips.MaxDisplayCount(1)] + var rules: [Rule] { + #Rule(PocketTipEvents.showSwipeHighlightsTip) { + $0.donations.count == 1 + } + } } /// Swipe to archive, Saves @available(iOS 17.0, *) struct SwipeArchiveTip: Tip { - var id = UUID() + let id = "pocketTips.saves.swipeArchive" let title = Text(Localization.Tips.SwipeToArchive.title) let message: Text? = Text(Localization.Tips.SwipeToArchive.message) let image: Image? = Image(uiImage: UIImage(asset: .archive)) - let options = [Tips.MaxDisplayCount(3)] + let options = [Tips.MaxDisplayCount(1)] + var rules: [Rule] { + #Rule(PocketTipEvents.showSwipeArchiveTip) { + $0.donations.count == 1 + } + } } /// New Recommendation Widget, Home @available(iOS 17.0, *) struct NewRecommendationsWidgetTip: Tip { - var id = UUID() + let id = "pocketTips.home.newRecommendationsWidget" let title = Text(Localization.Tips.RecommendationsWidget.SelectTopic.title) let message: Text? = Text(Localization.Tips.RecommendationsWidget.SelectTopic.message) let image: Image? = nil let options = [Tips.MaxDisplayCount(1)] + var rules: [Rule] { + #Rule(PocketTipEvents.showNewRecommendationsWidgetTip) { + $0.donations.count == 1 + } + } +} + +@available(iOS 17.0, *) +enum PocketTipEvents { + static let showNewRecommendationsWidgetTip = Tips.Event(id: "pocketTips.events.showNewRecommendationsWidgetTip") + static let showSwipeHighlightsTip = Tips.Event(id: "pocketTips.events.showSwipeHighlightsTip") + static let showSwipeArchiveTip = Tips.Event(id: "pocketTips.events.showSwipeArchiveTip") } diff --git a/PocketKit/Sources/PocketKit/Tips/TippableViewController.swift b/PocketKit/Sources/PocketKit/Tips/TippableViewController.swift index f05c156ef..eea383a14 100644 --- a/PocketKit/Sources/PocketKit/Tips/TippableViewController.swift +++ b/PocketKit/Sources/PocketKit/Tips/TippableViewController.swift @@ -31,7 +31,7 @@ struct TipUIConfiguration { extension TippableViewController { @available(iOS 17.0, *) func displayTip(_ tip: T, configuration: TipUIConfiguration?, sourceView: UIView?) { - tipObservationTask = tipObservationTask ?? Task.delayed(byTimeInterval: 0.3) { @MainActor [weak self] in + tipObservationTask = tipObservationTask ?? Task.delayed(byTimeInterval: 0.5) { @MainActor [weak self] in guard let self else { return }