Add the Use Case selection screen to the onboarding flow.

This commit is contained in:
Doug
2022-02-02 12:24:22 +00:00
parent ad7c8dfa1b
commit 2cef1a7398
48 changed files with 1178 additions and 134 deletions
@@ -42,12 +42,10 @@ struct AnalyticsPrompt: View {
VStack {
Text("\(viewModel.viewState.promptType.message)\n")
AnalyticsPromptTermsText(attributedString: viewModel.viewState.promptType.termsStrings)
.accessibilityLabel(Text(viewModel.viewState.promptType.termsStrings.string))
.accessibilityValue(Text(VectorL10n.accessibilityButtonLabel))
.onTapGesture {
viewModel.send(viewAction: .openTermsURL)
}
InlineTextButton(viewModel.viewState.promptType.mainTermsString,
tappableText: viewModel.viewState.promptType.termsLinkString) {
viewModel.send(viewAction: .openTermsURL)
}
}
}
@@ -71,7 +69,7 @@ struct AnalyticsPrompt: View {
Image(uiImage: Asset.Images.analyticsLogo.image)
.padding(.bottom, 25)
Text(VectorL10n.analyticsPromptTitle(viewModel.viewState.strings.appDisplayName))
Text(VectorL10n.analyticsPromptTitle(AppInfo.current.displayName))
.font(theme.fonts.title2B)
.foregroundColor(theme.colors.primaryContent)
.padding(.bottom, 2)
@@ -125,6 +123,7 @@ struct AnalyticsPrompt: View {
.padding(.bottom, geometry.safeAreaInsets.bottom > 0 ? 0 : 16)
}
.background(theme.colors.background.ignoresSafeArea())
.accentColor(theme.colors.accent)
}
}
}
@@ -1,74 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import SwiftUI
@available(iOS 14.0, *)
/// The last line of text in the description with highlighting on the link string.
struct AnalyticsPromptTermsText: View {
// MARK: - Properties
// MARK: Private
@Environment(\.theme) private var theme
/// A string with a link attribute.
private struct StringComponent {
let string: String
let isLink: Bool
}
/// Internal representation of the string as composable parts.
private let components: [StringComponent]
// MARK: - Setup
init(attributedString: NSAttributedString) {
var components = [StringComponent]()
let range = NSRange(location: 0, length: attributedString.length)
let string = attributedString.string as NSString
attributedString.enumerateAttributes(in: range, options: []) { attributes, range, stop in
let isLink = attributes.keys.contains(.link)
components.append(StringComponent(string: string.substring(with: range), isLink: isLink))
}
self.components = components
}
// MARK: - Views
var body: some View {
components.reduce(Text("")) {
$0 + Text($1.string).foregroundColor($1.isLink ? theme.colors.accent : nil)
}
}
}
// MARK: - Previews
@available(iOS 14.0, *)
struct AnalyticsPromptTermsText_Previews: PreviewProvider {
static let strings = MockAnalyticsPromptStrings()
static var previews: some View {
VStack(spacing: 8) {
AnalyticsPromptTermsText(attributedString: strings.termsNewUser)
AnalyticsPromptTermsText(attributedString: strings.termsUpgrade)
}
}
}