Welcome Screen (#1259)

* the screen renders and changed the analytics checkmark to be more generic

* welcome screen

* transition

* tests... TODO

* changelog

* changed assets and added multilineTextAlignment

* better naming

* fix for missing after migration but has a weird presentaiton bug

* fix

* icon color
This commit is contained in:
Mauro
2023-07-05 19:55:24 +02:00
committed by GitHub
parent 9ebc57e1cf
commit 00636d98da
17 changed files with 501 additions and 49 deletions
@@ -58,17 +58,32 @@ struct AnalyticsPromptScreen: View {
.foregroundColor(.compound.textSecondary)
}
}
@ViewBuilder
private var checkMark: some View {
Image(systemName: "checkmark.circle")
.symbolVariant(.fill)
.symbolRenderingMode(.palette)
.foregroundStyle(Color.compound.iconAccentTertiary, Color.compound.textOnSolidPrimary)
}
/// The list of re-assurances about analytics.
private var checkmarkList: some View {
VStack(alignment: .leading, spacing: 4) {
AnalyticsPromptScreenCheckmarkItem(title: context.viewState.strings.point1, listPosition: .top)
AnalyticsPromptScreenCheckmarkItem(title: context.viewState.strings.point2, listPosition: .middle)
AnalyticsPromptScreenCheckmarkItem(title: context.viewState.strings.point3, listPosition: .bottom)
checkMarkItem(title: context.viewState.strings.point1, position: .top)
checkMarkItem(title: context.viewState.strings.point2, position: .middle)
checkMarkItem(title: context.viewState.strings.point3, position: .bottom)
}
.fixedSize(horizontal: false, vertical: true)
.frame(maxWidth: .infinity)
}
@ViewBuilder
private func checkMarkItem(title: String, position: ListPosition) -> some View {
RoundedLabelItem(title: title, listPosition: position) {
checkMark
}
}
/// The stack of enable/disable buttons.
private var buttons: some View {
@@ -16,33 +16,31 @@
import SwiftUI
struct AnalyticsPromptScreenCheckmarkItem: View {
/// Represents the position of a checkmark item in a list.
enum ListPosition {
case top, middle, bottom
/// The corners that should be rounded for this position.
var roundedCorners: UIRectCorner {
switch self {
case .top:
return [.topLeft, .topRight]
case .middle:
return []
case .bottom:
return [.bottomLeft, .bottomRight]
}
/// Represents the position of a checkmark item in a list.
enum ListPosition {
case top, middle, bottom
/// The corners that should be rounded for this position.
var roundedCorners: UIRectCorner {
switch self {
case .top:
return [.topLeft, .topRight]
case .middle:
return []
case .bottom:
return [.bottomLeft, .bottomRight]
}
}
}
struct RoundedLabelItem<Icon: View>: View {
let title: String
let listPosition: ListPosition
let iconContent: () -> Icon
var body: some View {
Label { Text(title) } icon: {
Image(systemName: "checkmark.circle")
.symbolVariant(.fill)
.symbolRenderingMode(.palette)
.foregroundStyle(Color.compound.iconAccentTertiary, Color.compound.textOnSolidPrimary)
iconContent()
}
.labelStyle(CheckmarkLabelStyle())
.padding(.horizontal, 20)
@@ -68,14 +66,32 @@ private struct CheckmarkLabelStyle: LabelStyle {
struct AnalyticsPromptScreenCheckmarkItem_Previews: PreviewProvider {
static let strings = AnalyticsPromptScreenStrings(termsURL: ServiceLocator.shared.settings.analyticsConfiguration.termsURL)
@ViewBuilder
static var testImage1: some View {
Image(systemName: "circle")
}
@ViewBuilder
static var testImage2: some View {
Image(systemName: "square")
}
static var previews: some View {
VStack(alignment: .leading, spacing: 4) {
AnalyticsPromptScreenCheckmarkItem(title: strings.point1, listPosition: .top)
AnalyticsPromptScreenCheckmarkItem(title: strings.point2, listPosition: .middle)
AnalyticsPromptScreenCheckmarkItem(title: "This is a short string.", listPosition: .middle)
AnalyticsPromptScreenCheckmarkItem(title: "This is a very long string that will be used to test the layout over multiple lines of text to ensure everything is correct.",
listPosition: .bottom)
RoundedLabelItem(title: strings.point1, listPosition: .top) {
testImage1
}
RoundedLabelItem(title: strings.point2, listPosition: .middle) {
testImage2
}
RoundedLabelItem(title: "This is a short string.", listPosition: .middle) {
testImage1
}
RoundedLabelItem(title: "This is a very long string that will be used to test the layout over multiple lines of text to ensure everything is correct.",
listPosition: .bottom) {
testImage2
}
}
.padding()
}