Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM-14175 - Replace vault illustration on create account screen #1102

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,42 @@ struct StartRegistrationView: View {
// MARK: View

var body: some View {
VStack(spacing: 16) {
if store.state.isCreateAccountFeatureFlagEnabled {
Image(decorative: Asset.Images.Illustrations.vault)
.resizable()
.frame(width: 132, height: 132)
.padding(.top, 24)
.padding(.bottom, 32)
mainContent
.navigationBar(
title: Localizations.createAccount,
titleDisplayMode: .inline
)
.task {
await store.perform(.appeared)
}

name

VStack(alignment: .leading, spacing: 0) {
email
.padding(.bottom, 8)

RegionSelector(
selectorLabel: Localizations.creatingOn,
regionName: store.state.region.baseUrlDescription
) {
await store.perform(.regionTapped)
.toolbar {
cancelToolbarItem {
store.send(.dismiss)
}
}
.toast(
store.binding(
get: \.toast,
send: StartRegistrationAction.toastShown
)
)
}

receiveMarketingToggle

continueButton
// MARK: Private views

termsAndPrivacyText
.frame(maxWidth: .infinity)
}
.navigationBar(title: Localizations.createAccount, titleDisplayMode: .inline)
.scrollView()
.task {
await store.perform(.appeared)
}
.toolbar {
cancelToolbarItem {
store.send(.dismiss)
/// The button pressed when the user attempts to create the account.
private var continueButton: some View {
Button {
Task {
await store.perform(.startRegistration)
}
} label: {
Text(Localizations.continue)
}
.toast(store.binding(
get: \.toast,
send: StartRegistrationAction.toastShown
))
.accessibilityIdentifier("ContinueButton")
.buttonStyle(.primary())
}

// MARK: Private views

/// The text fields for the user's email and password.
private var email: some View {
BitwardenTextField(
Expand All @@ -77,6 +65,30 @@ struct StartRegistrationView: View {
.textFieldConfiguration(.email)
}

/// The main content view that displays a scrollable layout of registration details.
private var mainContent: some View {
GeometryReader { proxy in
VStack(spacing: 0) {
if store.state.isCreateAccountFeatureFlagEnabled {
Spacer(minLength: 24)

Image(decorative: Asset.Images.logo)
.resizable()
.scaledToFit()
.foregroundColor(Asset.Colors.iconSecondary.swiftUIColor)
.frame(maxWidth: .infinity, maxHeight: 34)
.padding(.horizontal, 12)

Spacer(minLength: 24)
}

registrationDetails
}
.frame(minHeight: store.state.isCreateAccountFeatureFlagEnabled ? proxy.size.height : 0)
.scrollView(showsIndicators: false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โ›๏ธ I think if we fix the frame to the height of the view, we need to remove the padding that scrollView adds and manually add it before the frame modifier. Otherwise, the content size is larger than the scroll bounds and it will scroll slightly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did i fix this right? my eyes are being deceiving right now... the min spacer height i think is messing with me. Did i add a double top padding here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a conditional for the top padding and it looks better to me

}
}

/// The text fields for the user's email and password.
private var name: some View {
BitwardenTextField(
Expand All @@ -90,29 +102,6 @@ struct StartRegistrationView: View {
.textFieldConfiguration(.username)
}

/// The button pressed when the user attempts to create the account.
private var continueButton: some View {
Button {
Task {
await store.perform(.startRegistration)
}
} label: {
Text(Localizations.continue)
}
.accessibilityIdentifier("ContinueButton")
.buttonStyle(.primary())
}

/// The button pressed when the user attempts to create the account.
private var termsAndPrivacyText: some View {
Text(LocalizedStringKey(store.state.termsAndPrivacyDisclaimerText))
.styleGuide(.footnote)
.tint(Asset.Colors.textInteraction.swiftUIColor)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
.padding([.bottom], 32)
.multilineTextAlignment(.center)
}

/// A toggle for the terms and privacy agreement.
@ViewBuilder private var receiveMarketingToggle: some View {
if store.state.showReceiveMarketingToggle {
Expand All @@ -131,6 +120,40 @@ struct StartRegistrationView: View {
.id(ViewIdentifier.StartRegistration.receiveMarketing)
}
}

/// The section of the view containing input fields, and action buttons.
private var registrationDetails: some View {
VStack(spacing: 16) {
name

VStack(alignment: .leading, spacing: 0) {
email
.padding(.bottom, 8)

RegionSelector(
selectorLabel: Localizations.creatingOn,
regionName: store.state.region.baseUrlDescription
) {
await store.perform(.regionTapped)
}
}

receiveMarketingToggle
continueButton
termsAndPrivacyText
.frame(maxWidth: .infinity)
}
}

/// The button pressed when the user attempts to create the account.
private var termsAndPrivacyText: some View {
Text(LocalizedStringKey(store.state.termsAndPrivacyDisclaimerText))
.styleGuide(.footnote)
.tint(Asset.Colors.textInteraction.swiftUIColor)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
.padding([.bottom], 32)
.multilineTextAlignment(.center)
}
}

// MARK: Previews
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class StartRegistrationViewTests: BitwardenTestCase {
@MainActor
func test_snapshot_nativeCreateAccountFeatureFlag() {
processor.state.isCreateAccountFeatureFlagEnabled = true
assertSnapshot(of: subject, as: .defaultPortrait)
assertSnapshots(of: subject, as: [.defaultPortrait, .defaultPortraitDark])
}

/// Tests the view renders correctly when the text fields are all populated.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
/// The background color to apply to the scroll view.
var backgroundColor: Color

/// Whether or not to show the scrolling indicators .
var showsIndicators = true

Check warning on line 17 in BitwardenShared/UI/Platform/Application/Appearance/Modifiers/ScrollViewModifier.swift

View check run for this annotation

Codecov / codecov/patch

BitwardenShared/UI/Platform/Application/Appearance/Modifiers/ScrollViewModifier.swift#L17

Added line #L17 was not covered by tests

// MARK: View

func body(content: Content) -> some View {
ScrollView {
ScrollView(showsIndicators: showsIndicators) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matt-livefront this was also added in the other PR for the LandingView. Which over goes in first ill fix any conflicts that arise. I just didnt want to forge this on both.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also not sure why this isn't being picked up by tests... do you see anything i did wrong herE?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind hiding the scroll indicators?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i should have explained that, my bad. I ran this by Emily and was asked to hide them.

content
.padding(.horizontal, 16)
.padding([.top, .bottom], addVerticalPadding ? 16 : 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ extension View {
///
func scrollView(
addVerticalPadding: Bool = true,
backgroundColor: Color = Asset.Colors.backgroundPrimary.swiftUIColor
backgroundColor: Color = Asset.Colors.backgroundPrimary.swiftUIColor,
showsIndicators: Bool = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐ŸŽจ Can you add this to the docs above?

) -> some View {
modifier(ScrollViewModifier(
addVerticalPadding: addVerticalPadding,
backgroundColor: backgroundColor
backgroundColor: backgroundColor,
showsIndicators: showsIndicators
))
}

Expand Down
Loading