Skip to content

Commit

Permalink
Several changes to VPN tips
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Oct 15, 2024
1 parent ab8e06c commit 888b67a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
29 changes: 18 additions & 11 deletions DuckDuckGo/NetworkProtectionStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
11 changes: 7 additions & 4 deletions DuckDuckGo/TipKit/TipGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/VPNAddWidgetTip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/VPNUseSnoozeTip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down

0 comments on commit 888b67a

Please sign in to comment.