From 888b67a289d3e770aab0b8ef9760683ba8d8b399 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 15 Oct 2024 14:39:08 +0200 Subject: [PATCH] Several changes to VPN tips --- DuckDuckGo/NetworkProtectionStatusView.swift | 29 ++++++++++++-------- DuckDuckGo/TipKit/TipGroup.swift | 11 +++++--- DuckDuckGo/VPNAddWidgetTip.swift | 5 +++- DuckDuckGo/VPNUseSnoozeTip.swift | 5 +++- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/DuckDuckGo/NetworkProtectionStatusView.swift b/DuckDuckGo/NetworkProtectionStatusView.swift index 4cf52c9f11..202cd2d765 100644 --- a/DuckDuckGo/NetworkProtectionStatusView.swift +++ b/DuckDuckGo/NetworkProtectionStatusView.swift @@ -93,19 +93,23 @@ struct NetworkProtectionStatusView: View { } .padding([.top, .bottom], 2) + snooze() + + } header: { + header() + } + .increaseHeaderProminence() + .listRowBackground(Color(designSystemColor: .surface)) + + Section { if #available(iOS 17.0, *) { widgetTip() } - snooze() - if #available(iOS 17.0, *) { snoozeTip() } - } header: { - header() } - .increaseHeaderProminence() .listRowBackground(Color(designSystemColor: .surface)) } @@ -195,15 +199,18 @@ struct NetworkProtectionStatusView: View { NetworkProtectionLocationItemView(title: nearestLocationAttributedString, imageName: imageName) } } - - if #available(iOS 17.0, *) { - geolocationTip() - } } header: { Text(statusModel.isNetPEnabled ? UserText.vpnLocationConnected : UserText.vpnLocationSelected) .foregroundColor(.init(designSystemColor: .textSecondary)) } .listRowBackground(Color(designSystemColor: .surface)) + + Section { + if #available(iOS 17.0, *) { + geolocationTip() + } + } + .listRowBackground(Color(designSystemColor: .surface)) } @ViewBuilder @@ -296,9 +303,9 @@ struct NetworkProtectionStatusView: View { @ViewBuilder private func geolocationTip() -> some View { if statusModel.canShowTips, - let changeLocationTip = statusModel.vpnEnabledTips.currentTip as? VPNChangeLocationTip { + let geolocationTip = statusModel.vpnEnabledTips.currentTip as? VPNChangeLocationTip { - TipView(changeLocationTip) + TipView(geolocationTip) .removeGroupedListStyleInsets() .tipCornerRadius(0) .tipBackground(Color(designSystemColor: .surface)) diff --git a/DuckDuckGo/TipKit/TipGroup.swift b/DuckDuckGo/TipKit/TipGroup.swift index 4da7815a61..89949a17b6 100644 --- a/DuckDuckGo/TipKit/TipGroup.swift +++ b/DuckDuckGo/TipKit/TipGroup.swift @@ -61,16 +61,19 @@ struct LegacyTipGroup: TipGrouping { } private let priority: Priority - private let tips: [any Tip] - init(_ priority: Priority, @LegacyTipGroupBuilder _ builder: () -> [any Tip]) { + @LegacyTipGroupBuilder + private let tipBuilder: () -> [any Tip] + + init(_ priority: Priority = .ordered, @LegacyTipGroupBuilder _ tipBuilder: @escaping () -> [any Tip]) { + self.priority = priority - self.tips = builder() + self.tipBuilder = tipBuilder } @MainActor var currentTip: (any Tip)? { - return tips.first { + return tipBuilder().first { switch $0.status { case .available: return true diff --git a/DuckDuckGo/VPNAddWidgetTip.swift b/DuckDuckGo/VPNAddWidgetTip.swift index cc3d88cb8c..459f51803a 100644 --- a/DuckDuckGo/VPNAddWidgetTip.swift +++ b/DuckDuckGo/VPNAddWidgetTip.swift @@ -54,7 +54,10 @@ extension VPNAddWidgetTip: Tip { } var actions: [Action] { - [Action(id: ActionIdentifiers.addWidget.rawValue, title: "Add widget")] + [Action(id: ActionIdentifiers.addWidget.rawValue) { + Text("Add widget") + .foregroundStyle(Color(designSystemColor: .accent)) + }] } var rules: [Rule] { diff --git a/DuckDuckGo/VPNUseSnoozeTip.swift b/DuckDuckGo/VPNUseSnoozeTip.swift index ae0bf68f08..a97e397705 100644 --- a/DuckDuckGo/VPNUseSnoozeTip.swift +++ b/DuckDuckGo/VPNUseSnoozeTip.swift @@ -52,7 +52,10 @@ extension VPNUseSnoozeTip: Tip { } var actions: [Action] { - [Action(id: ActionIdentifiers.learnMore.rawValue, title: "Learn more")] + [Action(id: ActionIdentifiers.learnMore.rawValue) { + Text("Learn more") + .foregroundStyle(Color(designSystemColor: .accent)) + }] } var rules: [Rule] {