summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceView.swift
blob: 1f71ba4303a21a6821df56f4e357239379853999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
//  TermsOfServiceView.swift
//  MullvadVPN
//
//  Created by Marco Nikic on 2025-06-05.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import SwiftUI

struct TermsOfServiceView: View {
    public var agreeToTermsAndServices: (() -> Void)?
    let padding = EdgeInsets(top: 24, leading: 16, bottom: 24, trailing: 16)
    @ScaledMetric(relativeTo: .footnote)
    var imageHeight = 20

    let termsOfService = LocalizedStringKey(
        """
        You have a right to privacy. That’s why we never store activity logs, don’t ask for personal \
        information, and encourage anonymous payments.

        In some situations, as outlined in our privacy policy, we might process personal data that you \
        choose to send, for example if you email us.

        We strongly believe in retaining as little data as possible because we want you to remain anonymous.
        """)

    let privacyPolicyLink =
        LocalizedStringKey(stringLiteral: "[Privacy Policy](\(ApplicationConfiguration.privacyPolicyLink))")
    var scrollableContent: some View {
        ScrollView {
            Text(LocalizedStringKey("Do you agree to remaining anonymous?"))
                .font(.mullvadLarge)
                .foregroundStyle(.white)
                .frame(maxWidth: .infinity, alignment: .leading)
                .padding(.bottom, 16)
            Text(termsOfService)
                .font(.mullvadSmall)
                .foregroundStyle(Color.secondaryTextColor)
        }
        .padding(padding)
    }

    var body: some View {
        VStack(alignment: .leading) {
            // Disable scrolling if the contents do not overflow
            if #available(iOS 16.4, *) {
                scrollableContent.scrollBounceBehavior(.basedOnSize)
            } else {
                scrollableContent
            }
            HStack {
                Text(privacyPolicyLink)
                    .font(.mullvadSmall)
                    .underline(true, color: .white)
                    .foregroundStyle(.white)
                    .tint(.white)
                Image(uiImage: UIImage.iconExtLink)
                    .resizable()
                    .scaledToFit()
                    .frame(height: imageHeight)
                    .foregroundStyle(.white)
            }
            .padding(padding)
            MainButton(
                text: LocalizedStringKey("Agree and continue"),
                style: .default,
                action: agreeToTermsAndServices ?? {}
            )
            .accessibilityIdentifier(AccessibilityIdentifier.agreeButton.asString)
            .padding(padding)
            .background(Color(UIColor.secondaryColor))
        }
        .background(Color(UIColor.primaryColor))
    }
}

#Preview {
    TermsOfServiceView()
        .frame(maxWidth: .infinity, maxHeight: .infinity)
}