Skip to content

Commit

Permalink
address feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimet-livefront committed Jan 14, 2025
1 parent c1d5bc9 commit 72f43c3
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 27 deletions.
8 changes: 4 additions & 4 deletions BitwardenShared/Core/Platform/Utilities/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ enum Constants {
/// The device type, iOS = 1.
static let deviceType: DeviceType = 1

/// The Id for Password Generator button to be scrolled to during the Guided Tour.
/// The ID for Password Generator button to be scrolled to during the Guided Tour.
static let guidedTourPasswordGenerator = "TourPasswordGenerator"

/// The Id for Totp field to be scrolled to during the Guided Tour.
/// The ID for Totp field to be scrolled to during the Guided Tour.
static let guidedTourTotp = "TourTotp"
/// The Id for Uri field to be scrolled to during the Guided Tour.

/// The ID for Uri field to be scrolled to during the Guided Tour.
static let guidedTourUri = "TourUri"

/// The length of a masked password.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"URI" = "URI";
"UseFingerprintToUnlock" = "Use fingerprint to unlock";
"UseThisButtonToGenerateANewUniquePassword" = "Use this button to generate a new unique password.";
"LoginGuidedTourStep2" = "You'll only need to set up Authenticator Key for logins that require two-factor authentication with a code. The key will continuously generate six-digit codes you can use to log in.";
"YouWillOnlyNeedToSetUpAnAuthenticatorKeyDescriptionLong" = "You'll only need to set up Authenticator Key for logins that require two-factor authentication with a code. The key will continuously generate six-digit codes you can use to log in.";
"YouMustAddAWebAddressToUseAutofillToAccessThisAccount" = "You must add a web address to use autofill to access this account.";
"Username" = "Username";
"ValidationFieldRequired" = "The %1$@ field is required.";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import SwiftUI

/// A view that removes the background of a full-screen cover.
/// This view is being used when we present guided tour view where we need to present a full-screen cover
/// and remove the default background provided by SwiftUI.
///
struct FullScreenCoverBackgroundRemovalView: UIViewRepresentable {

private class BackgroundRemovalView: UIView {

override func didMoveToWindow() {
super.didMoveToWindow()

Expand All @@ -13,9 +14,8 @@ struct FullScreenCoverBackgroundRemovalView: UIViewRepresentable {
}

func makeUIView(context: Context) -> UIView {
return BackgroundRemovalView()
BackgroundRemovalView()
}

func updateUIView(_ uiView: UIView, context: Context) { }
func updateUIView(_ uiView: UIView, context: Context) {}
}

Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension GuidedTourState {
spotlightShape: .rectangle,
spotlightCornerRadius: 8,
totalStep: 3,
title: Localizations.loginGuidedTourStep2
title: Localizations.youWillOnlyNeedToSetUpAnAuthenticatorKeyDescriptionLong
)

/// The third step of the learn new login guided tour.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import SwiftUI

/// A view that displays dimmed background with a spotlight and a coach-mark card.
///
struct GuidedTourView: View {
/// An environment variable for getting the vertical size class of the view.
@Environment(\.verticalSizeClass) var verticalSizeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ final class AddEditItemProcessor: StateProcessor<// swiftlint:disable:this type_
state.isLearnNewLoginActionCardEligible = false
await services.stateService.setLearnNewLoginActionCardStatus(.complete)
state.guidedTourState = .loginStep1
if let frame: CGRect = state.spotLight[.step1] {
if let frame: CGRect = state.spotlights[.step1] {
state.guidedTourState?.spotlightRegion.origin = frame.origin
state.guidedTourState?.spotlightRegion.size = frame.size
}
Expand All @@ -164,7 +164,7 @@ final class AddEditItemProcessor: StateProcessor<// swiftlint:disable:this type_
case let .toggleGuidedTourVisibilityChanged(show):
state.showGuidedTour = show
case let .didRenderViewToSpotlight(frame, step):
state.spotLight[step] = frame
state.spotlights[step] = frame
if state.guidedTourState?.step == step.rawValue {
state.guidedTourState?.spotlightRegion.origin = CGPoint(x: frame.minX, y: frame.minY)
state.guidedTourState?.spotlightRegion.size = CGSize(width: frame.width, height: frame.height)
Expand Down Expand Up @@ -294,21 +294,21 @@ final class AddEditItemProcessor: StateProcessor<// swiftlint:disable:this type_
case 1:
state.guidedTourState = .loginStep1
state.guidedTourStep = .step1
if let frame: CGRect = state.spotLight[.step1] {
if let frame: CGRect = state.spotlights[.step1] {
state.guidedTourState?.spotlightRegion.origin = frame.origin
state.guidedTourState?.spotlightRegion.size = frame.size
}
case 2:
state.guidedTourState = .loginStep2
state.guidedTourStep = .step2
if let frame: CGRect = state.spotLight[.step2] {
if let frame: CGRect = state.spotlights[.step2] {
state.guidedTourState?.spotlightRegion.origin = frame.origin
state.guidedTourState?.spotlightRegion.size = frame.size
}
case 3:
state.guidedTourState = .loginStep3
state.guidedTourStep = .step3
if let frame: CGRect = state.spotLight[.step3] {
if let frame: CGRect = state.spotlights[.step3] {
state.guidedTourState?.spotlightRegion.origin = frame.origin
state.guidedTourState?.spotlightRegion.size = frame.size
}

Check warning on line 314 in BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemProcessor.swift

View check run for this annotation

Codecov / codecov/patch

BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemProcessor.swift#L312-L314

Added lines #L312 - L314 were not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ class AddEditItemProcessorTests: BitwardenTestCase {
@MainActor
func test_perform_showLearnNewLoginGuidedTour() async {
subject.state.isLearnNewLoginActionCardEligible = true
subject.state.spotLight[.step1] = step1Spotlight
subject.state.spotlights[.step1] = step1Spotlight
await subject.perform(.showLearnNewLoginGuidedTour)
XCTAssertFalse(subject.state.isLearnNewLoginActionCardEligible)
XCTAssertEqual(stateService.learnNewLoginActionCardStatus, .complete)
Expand All @@ -1569,7 +1569,7 @@ class AddEditItemProcessorTests: BitwardenTestCase {
@MainActor
func test_receive_backPressed() {
subject.state.guidedTourState = .loginStep3
subject.state.spotLight = [
subject.state.spotlights = [
.step1: step1Spotlight,
.step2: step2Spotlight,
.step3: step3Spotlight,
Expand All @@ -1586,7 +1586,7 @@ class AddEditItemProcessorTests: BitwardenTestCase {
@MainActor
func test_receive_backPressed_updatesSpotlightRegion() {
subject.state.guidedTourState = .loginStep3
subject.state.spotLight = [
subject.state.spotlights = [
.step1: step1Spotlight,
.step2: step2Spotlight,
.step3: step3Spotlight,
Expand Down Expand Up @@ -1637,27 +1637,27 @@ class AddEditItemProcessorTests: BitwardenTestCase {
XCTAssertEqual(subject.state.collectionIds, ["2"])
}

/// `receive(_:)` with `.didRenderViewToSpotlight` updates `.spotLight`,
/// `receive(_:)` with `.didRenderViewToSpotlight` updates `.spotlights`,
/// and will not update the `spotlightRegion`, if the current guided tour step not match the step.
@MainActor
func test_receive_didRenderViewToSpotlight() {
XCTAssertEqual(subject.state.spotLight, [:])
XCTAssertEqual(subject.state.spotlights, [:])
subject.state.guidedTourState = .loginStep2

subject.receive(.didRenderViewToSpotlight(frame: step1Spotlight, step: .step1))
XCTAssertEqual(subject.state.spotLight[.step1], step1Spotlight)
XCTAssertEqual(subject.state.spotlights[.step1], step1Spotlight)
XCTAssertEqual(subject.state.guidedTourState?.spotlightRegion, .zero)
}

/// `receive(_:)` with `.didRenderViewToSpotlight` updates `.spotLight`,
/// `receive(_:)` with `.didRenderViewToSpotlight` updates `.spotlights`,
/// and will not update the guided tour state, if the current guided tour step not match the step.
@MainActor
func test_receive_didRenderViewToSpotlight_updateSpotlightRegion() {
XCTAssertEqual(subject.state.spotLight, [:])
XCTAssertEqual(subject.state.spotlights, [:])
subject.state.guidedTourState = .loginStep1

subject.receive(.didRenderViewToSpotlight(frame: step1Spotlight, step: .step1))
XCTAssertEqual(subject.state.spotLight[.step1], step1Spotlight)
XCTAssertEqual(subject.state.spotlights[.step1], step1Spotlight)
XCTAssertEqual(subject.state.guidedTourState?.spotlightRegion, step1Spotlight)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protocol AddEditItemState: Sendable {
var shouldShowLearnNewLoginActionCard: Bool { get }

/// The spotlight region for each step in the guided tour.
var spotLight: [LearnLoginGuidedTourStep: CGRect] { get set }
var spotlights: [LearnLoginGuidedTourStep: CGRect] { get set }

/// The SSH key item state.
var sshKeyState: SSHKeyItemState { get set }
Expand Down
2 changes: 1 addition & 1 deletion BitwardenShared/UI/Vault/VaultItem/CipherItemState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct CipherItemState: Equatable {
var showMasterPasswordReprompt: Bool

/// The spotlight for each step in the guided tour.
var spotLight: [LearnLoginGuidedTourStep: CGRect] = [:]
var spotlights: [LearnLoginGuidedTourStep: CGRect] = [:]

/// The SSH key item state.
var sshKeyState: SSHKeyItemState
Expand Down

0 comments on commit 72f43c3

Please sign in to comment.