-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
384 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ViewGeometry.swift | ||
// MullvadVPN | ||
// | ||
// Created by Jon Petersson on 2024-11-13. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// Struct for measuring view size. Typically used in a `.background()`, | ||
/// eg. `.background(ViewGeometry { actualViewSize in [...] }). | ||
struct ViewGeometry: View { | ||
let onSizeChange: (CGSize) -> Void | ||
|
||
var body: some View { | ||
GeometryReader { geometry in | ||
Color.clear | ||
.preference(key: ViewSizeKey.self, value: geometry.size) | ||
.onPreferenceChange(ViewSizeKey.self) { | ||
onSizeChange($0) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private struct ViewSizeKey: PreferenceKey { | ||
static var defaultValue: CGSize = .zero | ||
|
||
static func reduce(value: inout CGSize, nextValue: () -> CGSize) { | ||
value = nextValue() | ||
} | ||
} |
113 changes: 113 additions & 0 deletions
113
ios/MullvadVPN/Coordinators/Settings/Multihop/SettingsMultihopView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// | ||
// SettingsMultihopView.swift | ||
// MullvadVPN | ||
// | ||
// Created by Andrew Bulhak on 2024-09-23. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SettingsInfoViewModel { | ||
var body: [String] | ||
var images: [Image] | ||
} | ||
|
||
struct SettingsMultihopView: View { | ||
@State private var enabled = true | ||
|
||
var didToggleEnabled: ((Bool) -> Void)? | ||
|
||
var body: some View { | ||
ZStack { | ||
VStack(spacing: 24) { | ||
SettingsInfoView(viewModel: SettingsInfoViewModel()) | ||
|
||
SwitchRowView( | ||
enabled: enabled, | ||
text: NSLocalizedString( | ||
"SETTINGS_SWITCH_MULTIHOP", | ||
tableName: "Settings", | ||
value: "Enable", | ||
comment: "" | ||
), | ||
didToggle: { didToggleEnabled?($0) } | ||
) | ||
|
||
Spacer() | ||
} | ||
.padding(UIMetrics.contentInsets.toEdgeInsets) | ||
} | ||
.background(Color(.secondaryColor)) | ||
.foregroundColor(Color(.primaryTextColor)) | ||
} | ||
} | ||
|
||
#Preview { | ||
SettingsMultihopView { enabled in | ||
print("\(enabled)") | ||
} | ||
} | ||
|
||
struct SwitchRowView: View { | ||
@State private var enabled: Bool | ||
private let text: String | ||
|
||
let didToggle: ((Bool) -> Void) | ||
var didTapAction: (() -> Void)? | ||
|
||
init(enabled: Bool, text: String, didToggle: @escaping ((Bool) -> Void)) { | ||
self.enabled = enabled | ||
self.text = text | ||
self.didToggle = didToggle | ||
} | ||
|
||
var body: some View { | ||
HStack { | ||
Toggle(isOn: $enabled, label: { | ||
Text(text) | ||
}).onChange(of: enabled, perform: { enabled in | ||
didToggle(enabled) | ||
}) | ||
.toggleStyle(CustomToggleStyle { | ||
didTapAction?() | ||
}) | ||
.font(.body.weight(.semibold)) | ||
.accessibilityIdentifier(AccessibilityIdentifier.multihopSwitch.rawValue) | ||
} | ||
.frame(height: UIMetrics.SettingsViewCell.height) | ||
.padding(UIMetrics.SettingsViewCell.layoutMargins) | ||
.background(Color(.primaryColor)) | ||
.foregroundColor(Color(.primaryTextColor)) | ||
.cornerRadius(UIMetrics.SettingsViewCell.cornerRadius) | ||
} | ||
} | ||
|
||
#Preview { | ||
SwitchRowView(enabled: true, text: "Enable") { enabled in | ||
print("\(enabled)") | ||
} | ||
} | ||
|
||
struct SettingsInfoView: View { | ||
let viewModel: SettingsInfoViewModel | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 16) { | ||
Image(.multihopIllustration) | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
Text(NSLocalizedString( | ||
"SETTINGS_INFO_MULTIHOP", | ||
tableName: "Settings", | ||
value: """ | ||
Multihop routes your traffic into one WireGuard server and out another, making it \ | ||
harder to trace. This results in increased latency but increases anonymity online. | ||
""", | ||
comment: "" | ||
)) | ||
.font(.body.weight(.semibold)) | ||
.opacity(0.6) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// View+TapAreaSize.swift | ||
// MullvadVPN | ||
// | ||
// Created by Jon Petersson on 2024-11-13. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
extension View { | ||
/// Adjusts tappable area to at least minimum (default) size without changing | ||
/// actual view size. | ||
func adjustingTapAreaSize() -> some View { | ||
modifier(TappablePadding()) | ||
} | ||
} | ||
|
||
private struct TappablePadding: ViewModifier { | ||
@State var actualViewSize: CGSize = .zero | ||
let tappableViewSize = UIMetrics.Button.minimumTappableAreaSize | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.background(ViewGeometry { | ||
actualViewSize = $0 | ||
}) | ||
.frame( | ||
width: max(actualViewSize.width, tappableViewSize.width), | ||
height: max(actualViewSize.height, tappableViewSize.height) | ||
) | ||
.contentShape(Rectangle()) | ||
.frame(width: actualViewSize.width, height: actualViewSize.height) | ||
} | ||
} |
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconAccount.imageset/IconAccount.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconAlert.imageset/IconAlert.pdf
Binary file not shown.
Binary file modified
BIN
+104 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconArrow.imageset/IconArrow.pdf
Binary file not shown.
Binary file modified
BIN
+103 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconBack.imageset/IconBack.pdf
Binary file not shown.
Binary file modified
BIN
+103 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconChevron.imageset/IconChevron.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconChevronDown.imageset/IconChevronDown.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconChevronUp.imageset/IconChevronUp.pdf
Binary file not shown.
Binary file modified
BIN
+103 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconClose.imageset/IconClose.pdf
Binary file not shown.
Binary file modified
BIN
+104 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconCloseSml.imageset/IconCloseSml.pdf
Binary file not shown.
Binary file modified
BIN
+103 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconCopy.imageset/IconCopy.pdf
Binary file not shown.
Binary file modified
BIN
+104 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconExtlink.imageset/IconExtlink.pdf
Binary file not shown.
Binary file modified
BIN
+103 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconFail.imageset/IconFail.pdf
Binary file not shown.
Binary file modified
BIN
+103 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconInfo.imageset/IconInfo.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconObscure.imageset/IconObscure.pdf
Binary file not shown.
Binary file modified
BIN
+1.99 KB
(260%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconReload.imageset/IconReload.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconSettings.imageset/IconSettings.pdf
Binary file not shown.
Binary file modified
BIN
+101 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconSpinner.imageset/IconSpinner.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconSuccess.imageset/IconSuccess.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconTick.imageset/IconTick.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconTickSml.imageset/IconTickSml.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/IconUnobscure.imageset/IconUnobscure.pdf
Binary file not shown.
Binary file modified
BIN
+35 Bytes
(100%)
...N/Supporting Files/Assets.xcassets/LocationMarkerSecure.imageset/LocationMarkerSecure.pdf
Binary file not shown.
Binary file modified
BIN
+36 Bytes
(100%)
...pporting Files/Assets.xcassets/LocationMarkerUnsecure.imageset/LocationMarkerUnsecure.pdf
Binary file not shown.
Binary file modified
BIN
+102 Bytes
(110%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/LogoIcon.imageset/LogoIcon.pdf
Binary file not shown.
Binary file modified
BIN
+100 Bytes
(100%)
ios/MullvadVPN/Supporting Files/Assets.xcassets/LogoText.imageset/LogoText.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
ios/MullvadVPN/Supporting Files/Assets.xcassets/MultihopIllustration.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "MultihopIllustration.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
Binary file added
BIN
+11.7 KB
...N/Supporting Files/Assets.xcassets/MultihopIllustration.imageset/MultihopIllustration.pdf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.