includes agreement to ToS, privacy rules, Login or Registration, agreement to location accessing and agreement to background measurements.
164 lines
5.7 KiB
Swift
164 lines
5.7 KiB
Swift
//
|
|
// TermsOfServiceView.swift
|
|
// app
|
|
//
|
|
// Created by Tobias Stottrop on 02.03.20.
|
|
// Copyright © 2020 Marcus Handte. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Foundation
|
|
|
|
struct TermsOfServiceView: View {
|
|
@EnvironmentObject var user: UserData
|
|
@EnvironmentObject var state: NavigationStack
|
|
@Binding var agreedToS: Bool
|
|
@Binding var agreedDSGVO: Bool
|
|
var agreedBoth: Bool {
|
|
return agreedToS && agreedDSGVO
|
|
}
|
|
|
|
private let tos_url: String = "https://www.mowesta.com/terms-of-service/"
|
|
private let privacy_url: String = "https://www.uni-due.de/en/privacy-policy.php"
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
VStack(alignment: .leading) {
|
|
Text("TVAgreement").padding(.top, 20)
|
|
Spacer()
|
|
HStack(spacing: 0) {
|
|
Button(action: {
|
|
self.toggleDSGVO()
|
|
|
|
}){
|
|
Image(systemName: agreedDSGVO ? "checkmark.square" : "square")
|
|
.foregroundColor(Color("mowesta-orange"))
|
|
|
|
}
|
|
.padding(.trailing, 10)
|
|
|
|
Text("TVPrivacy0")
|
|
.foregroundColor(.gray)
|
|
Text("TVPrivacy1")
|
|
.foregroundColor(Color("mowesta-orange"))
|
|
.underline()
|
|
.onTapGesture {
|
|
let url = URL.init(string: self.privacy_url)
|
|
guard let privacyUrl = url, UIApplication.shared.canOpenURL(privacyUrl) else { return }
|
|
UIApplication.shared.open(privacyUrl)
|
|
}
|
|
Text("TVPrivacy2")
|
|
.foregroundColor(.gray)
|
|
|
|
|
|
}.padding(.bottom)
|
|
|
|
HStack(spacing: 0) {
|
|
Button(action: {
|
|
self.toggleToS()
|
|
}){
|
|
Image(systemName: agreedToS ? "checkmark.square" : "square")
|
|
.foregroundColor(Color("mowesta-orange")) }
|
|
.padding(.trailing, 10)
|
|
|
|
Text("TVToS0")
|
|
.foregroundColor(.gray)
|
|
Text("TVToS1")
|
|
.foregroundColor(Color("mowesta-orange"))
|
|
.underline()
|
|
.onTapGesture {
|
|
let url = URL.init(string: self.tos_url)
|
|
guard let tosUrl = url, UIApplication.shared.canOpenURL(tosUrl) else { return }
|
|
UIApplication.shared.open(tosUrl)
|
|
}
|
|
Text("TVToS2")
|
|
.foregroundColor(.gray)
|
|
|
|
|
|
}
|
|
Spacer()
|
|
|
|
ZStack {
|
|
HStack {
|
|
|
|
Button(action: {
|
|
self.cancelAgreement()
|
|
}) {
|
|
Text("TVCancel")
|
|
}
|
|
Spacer()
|
|
}
|
|
|
|
HStack {
|
|
Spacer()
|
|
|
|
Circle()
|
|
.fill(Color("mowesta-green"))
|
|
.frame(width: 5, height: 5)
|
|
|
|
Circle()
|
|
.fill(Color("mowesta-green"))
|
|
.frame(width: 5, height: 5)
|
|
.opacity(0.5)
|
|
|
|
Circle()
|
|
.fill(Color("mowesta-green"))
|
|
.opacity(0.5)
|
|
.frame(width: 5, height: 5)
|
|
|
|
Circle()
|
|
.fill(Color("mowesta-green"))
|
|
.opacity(0.5)
|
|
.frame(width: 5, height: 5)
|
|
|
|
Spacer()
|
|
}
|
|
|
|
HStack {
|
|
Spacer()
|
|
|
|
Button(action: {
|
|
self.state.push(state: AuthState.LoginScreen)
|
|
}) {
|
|
HStack {
|
|
Text("TVNext")
|
|
.fontWeight(.semibold)
|
|
Image(systemName: "chevron.right")
|
|
}
|
|
.padding()
|
|
.foregroundColor(.white)
|
|
.background(buttonColor)
|
|
.cornerRadius(40)
|
|
.animation(.default)
|
|
}.disabled(!agreedBoth)
|
|
}
|
|
}
|
|
}
|
|
.padding()
|
|
.navigationBarTitle("TVWelcome")
|
|
}
|
|
}
|
|
|
|
var buttonColor: Color {
|
|
return agreedBoth ? Color("mowesta-green") : .gray
|
|
}
|
|
|
|
func cancelAgreement() {
|
|
let alert = MoWeStaAlert(title: "TVCancelHeadline", message: "TVCancelBody")
|
|
alert.addOkAction(onOk: {_ in
|
|
exit(0)
|
|
})
|
|
alert.addCancelAction()
|
|
alert.fire()
|
|
}
|
|
|
|
func toggleToS(){agreedToS = !agreedToS}
|
|
func toggleDSGVO(){agreedDSGVO = !agreedDSGVO}
|
|
}
|
|
|
|
struct TermsOfServiceView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
TermsOfServiceView(agreedToS: .constant(false), agreedDSGVO: .constant(false))
|
|
}
|
|
}
|