summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Views
diff options
context:
space:
mode:
authorJon Petersson <jon.petersson@mullvad.net>2024-12-04 10:18:22 +0100
committerJon Petersson <jon.petersson@mullvad.net>2024-12-13 14:31:41 +0100
commitc61b7d4e5a3a891562416692ee8d5b94de1e8549 (patch)
treee85b0edcfb08238a5714f59ddaa1a4b03662359e /ios/MullvadVPN/Views
parent9573f3ed7a449f2aeb9f8efe0c6f4335ed0c326c (diff)
downloadmullvadvpn-c61b7d4e5a3a891562416692ee8d5b94de1e8549.tar.xz
mullvadvpn-c61b7d4e5a3a891562416692ee8d5b94de1e8549.zip
Add state to new connection view
Diffstat (limited to 'ios/MullvadVPN/Views')
-rw-r--r--ios/MullvadVPN/Views/BlurView.swift22
-rw-r--r--ios/MullvadVPN/Views/MainButton.swift7
-rw-r--r--ios/MullvadVPN/Views/MainButtonStyle.swift16
-rw-r--r--ios/MullvadVPN/Views/SplitMainButton.swift8
-rw-r--r--ios/MullvadVPN/Views/VisualEffectView.swift4
5 files changed, 45 insertions, 12 deletions
diff --git a/ios/MullvadVPN/Views/BlurView.swift b/ios/MullvadVPN/Views/BlurView.swift
new file mode 100644
index 0000000000..eb976efb74
--- /dev/null
+++ b/ios/MullvadVPN/Views/BlurView.swift
@@ -0,0 +1,22 @@
+//
+// BlurView.swift
+// MullvadVPN
+//
+// Created by Jon Petersson on 2024-12-06.
+// Copyright © 2024 Mullvad VPN AB. All rights reserved.
+//
+
+import SwiftUI
+
+/// Blurred (background) view using a `UIBlurEffect`.
+struct BlurView: View {
+ var style: UIBlurEffect.Style
+
+ var body: some View {
+ Spacer()
+ .overlay {
+ VisualEffectView(effect: UIBlurEffect(style: style))
+ .opacity(0.8)
+ }
+ }
+}
diff --git a/ios/MullvadVPN/Views/MainButton.swift b/ios/MullvadVPN/Views/MainButton.swift
index a5d6f0f718..679b34a2cd 100644
--- a/ios/MullvadVPN/Views/MainButton.swift
+++ b/ios/MullvadVPN/Views/MainButton.swift
@@ -9,8 +9,9 @@
import SwiftUI
struct MainButton: View {
- var text: String
+ var text: LocalizedStringKey
var style: MainButtonStyle.Style
+ var disabled = false
var action: () -> Void
@@ -22,13 +23,13 @@ struct MainButton: View {
Spacer()
}
})
- .buttonStyle(MainButtonStyle(style))
+ .buttonStyle(MainButtonStyle(style, disabled: disabled))
.cornerRadius(UIMetrics.MainButton.cornerRadius)
}
}
#Preview {
- MainButton(text: "Connect", style: .default) {
+ MainButton(text: "Connect", style: .success) {
print("Tapped")
}
}
diff --git a/ios/MullvadVPN/Views/MainButtonStyle.swift b/ios/MullvadVPN/Views/MainButtonStyle.swift
index 06a32b5606..f638c87ac2 100644
--- a/ios/MullvadVPN/Views/MainButtonStyle.swift
+++ b/ios/MullvadVPN/Views/MainButtonStyle.swift
@@ -9,10 +9,12 @@
import SwiftUI
struct MainButtonStyle: ButtonStyle {
- @State var style: Style
+ var style: Style
+ @State var disabled: Bool
- init(_ style: Style) {
+ init(_ style: Style, disabled: Bool = false) {
self.style = style
+ self.disabled = disabled
}
func makeBody(configuration: Configuration) -> some View {
@@ -22,9 +24,15 @@ struct MainButtonStyle: ButtonStyle {
.foregroundColor(
configuration.isPressed
? UIColor.secondaryTextColor.color
- : UIColor.primaryTextColor.color
+ : disabled
+ ? UIColor.primaryTextColor.withAlphaComponent(0.2).color
+ : UIColor.primaryTextColor.color
+ )
+ .background(
+ disabled
+ ? style.color.darkened(by: 0.6)
+ : style.color
)
- .background(style.color)
.font(.body.weight(.semibold))
}
}
diff --git a/ios/MullvadVPN/Views/SplitMainButton.swift b/ios/MullvadVPN/Views/SplitMainButton.swift
index 59a5d1b2ea..11336f424b 100644
--- a/ios/MullvadVPN/Views/SplitMainButton.swift
+++ b/ios/MullvadVPN/Views/SplitMainButton.swift
@@ -9,9 +9,10 @@
import SwiftUI
struct SplitMainButton: View {
- var text: String
+ var text: LocalizedStringKey
var image: ImageResource
var style: MainButtonStyle.Style
+ var disabled = false
var primaryAction: () -> Void
var secondaryAction: () -> Void
@@ -37,14 +38,14 @@ struct SplitMainButton: View {
.aspectRatio(1, contentMode: .fit)
.sizeOfView { width = $0.width }
}
- .buttonStyle(MainButtonStyle(style))
+ .buttonStyle(MainButtonStyle(style, disabled: disabled))
.cornerRadius(UIMetrics.MainButton.cornerRadius)
}
}
#Preview {
SplitMainButton(
- text: "Connect",
+ text: "Select location",
image: .iconReload,
style: .default,
primaryAction: {
@@ -54,5 +55,4 @@ struct SplitMainButton: View {
print("Tapped secondary")
}
)
- .frame(maxWidth: .infinity)
}
diff --git a/ios/MullvadVPN/Views/VisualEffectView.swift b/ios/MullvadVPN/Views/VisualEffectView.swift
index 0cad1b06d7..f28b715065 100644
--- a/ios/MullvadVPN/Views/VisualEffectView.swift
+++ b/ios/MullvadVPN/Views/VisualEffectView.swift
@@ -12,7 +12,9 @@ struct VisualEffectView: UIViewRepresentable {
var effect: UIVisualEffect?
func makeUIView(context: UIViewRepresentableContext<Self>) -> UIVisualEffectView {
- UIVisualEffectView()
+ let view = UIVisualEffectView(effect: effect)
+ view.translatesAutoresizingMaskIntoConstraints = false
+ return view
}
func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext<Self>) {