Feature/3616 privacy on login

This commit is contained in:
Frank Rotermund
2022-12-04 10:47:42 +00:00
parent 3ea3cfd4cf
commit b23657a4a1
16 changed files with 261 additions and 63 deletions

View File

@@ -32,53 +32,70 @@ struct AuthenticationLoginScreen: View {
@ObservedObject var viewModel: AuthenticationLoginViewModel.Context
var body: some View {
ScrollView {
VStack(spacing: 0) {
header
.padding(.top, OnboardingMetrics.topPaddingToNavigationBar)
.padding(.bottom, 28)
serverInfo
.padding(.leading, 12)
.padding(.bottom, 16)
Rectangle()
.fill(theme.colors.quinaryContent)
.frame(height: 1)
.padding(.bottom, 22)
if viewModel.viewState.homeserver.showLoginForm {
loginForm
}
VStack {
ScrollView {
VStack(spacing: 0) {
if BWIBuildSettings.shared.bumLoginFlowLayout {
ServerIcon(image: Asset.Images.welcomeExperience1, size: OnboardingMetrics.iconSize-18)
.padding(.top, OnboardingMetrics.topPaddingToNavigationBar)
.padding(.bottom, 16)
} else {
header
.padding(.top, OnboardingMetrics.topPaddingToNavigationBar)
.padding(.bottom, 28)
}
serverInfo
.padding(.leading, 12)
.padding(.bottom, 16)
Rectangle()
.fill(theme.colors.quinaryContent)
.frame(height: 1)
.padding(.bottom, 22)
if BWIBuildSettings.shared.bumLoginFlowLayout {
loginDescription
.padding(.bottom, 22)
}
if viewModel.viewState.homeserver.showLoginForm {
loginForm
}
if viewModel.viewState.homeserver.showQRLogin {
qrLoginButton
}
if viewModel.viewState.homeserver.showLoginForm, viewModel.viewState.showSSOButtons {
Text(VectorL10n.or)
.foregroundColor(theme.colors.secondaryContent)
.padding(.top, 16)
}
if viewModel.viewState.showSSOButtons {
ssoButtons
.padding(.top, 16)
}
if viewModel.viewState.homeserver.showQRLogin {
qrLoginButton
}
if viewModel.viewState.homeserver.showLoginForm, viewModel.viewState.showSSOButtons {
Text(VectorL10n.or)
.foregroundColor(theme.colors.secondaryContent)
.padding(.top, 16)
}
if viewModel.viewState.showSSOButtons {
ssoButtons
.padding(.top, 16)
}
if !viewModel.viewState.homeserver.showLoginForm, !viewModel.viewState.showSSOButtons {
fallbackButton
if !viewModel.viewState.homeserver.showLoginForm, !viewModel.viewState.showSSOButtons {
fallbackButton
}
}
.readableFrame()
.padding(.horizontal, 16)
}
if BWIBuildSettings.shared.bumLoginFlowLayout {
dataPrivacyForm
.frame(alignment: .bottom)
.padding(.bottom, 10)
}
.readableFrame()
.padding(.horizontal, 16)
.padding(.bottom, 16)
}
.background(theme.colors.background.ignoresSafeArea())
.alert(item: $viewModel.alertInfo) { $0.alert }
.accentColor(theme.colors.accent)
}
/// The header containing a Welcome Back title.
var header: some View {
Text(VectorL10n.authenticationLoginTitle)
@@ -167,6 +184,33 @@ struct AuthenticationLoginScreen: View {
.accessibilityIdentifier("fallbackButton")
}
var dataPrivacyForm: some View {
Button(action: {
let tosURL = URL.init(string: viewModel.viewState.dataPrivacyString)! // add your link here
if UIApplication.shared.canOpenURL(tosURL) {
UIApplication.shared.open(tosURL)
}
}, label: {
Text(BWIL10n.authenticationDataprivacyText)
.font(theme.fonts.footnote)
.foregroundColor(theme.colors.primaryContent)
+
Text(BWIL10n.authenticationDataprivacyLink)
.font(theme.fonts.footnote)
.foregroundColor(.blue)
.underline()
})
.padding([.horizontal], 20)
}
var loginDescription: some View {
HStack(spacing: 0) {
Text(BWIL10n.authenticationLoginDescription)
.font(theme.fonts.callout)
.foregroundColor(theme.colors.primaryContent)
}
}
/// Parses the username for a homeserver.
func usernameEditingChanged(isEditing: Bool) {
guard !isEditing, !viewModel.username.isEmpty else { return }