Skip to content

Commit 06bf078

Browse files
[PM-20366] Add pre-login settings button to landing screen (#1555)
1 parent c6993cd commit 06bf078

File tree

11 files changed

+49
-0
lines changed

11 files changed

+49
-0
lines changed

BitwardenShared/Core/Platform/Models/Enum/FeatureFlag.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ extension FeatureFlag: @retroactive CaseIterable {
5959
/// A feature flag for the create account flow.
6060
static let nativeCreateAccountFlow = FeatureFlag(rawValue: "native-create-account-flow")
6161

62+
/// A feature flag for the pre-login settings.
63+
static let preLoginSettings = FeatureFlag(
64+
rawValue: "enable-pm-prelogin-settings",
65+
isRemotelyConfigured: false
66+
)
67+
6268
/// A feature flag for the refactor on the SSO details endpoint.
6369
static let refactorSsoDetailsEndpoint = FeatureFlag(rawValue: "pm-12337-refactor-sso-details-endpoint")
6470

@@ -85,6 +91,7 @@ extension FeatureFlag: @retroactive CaseIterable {
8591
.importLoginsFlow,
8692
.mobileErrorReporting,
8793
.nativeCreateAccountFlow,
94+
.preLoginSettings,
8895
.refactorSsoDetailsEndpoint,
8996
.restrictCipherItemDeletion,
9097
.simpleLoginSelfHostAlias,

BitwardenShared/Core/Platform/Models/Enum/FeatureFlagTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ final class FeatureFlagTests: BitwardenTestCase {
2929
XCTAssertFalse(FeatureFlag.flightRecorder.isRemotelyConfigured)
3030
XCTAssertFalse(FeatureFlag.ignore2FANoticeEnvironmentCheck.isRemotelyConfigured)
3131
XCTAssertFalse(FeatureFlag.mobileErrorReporting.isRemotelyConfigured)
32+
XCTAssertFalse(FeatureFlag.preLoginSettings.isRemotelyConfigured)
3233
}
3334
}

BitwardenShared/UI/Auth/Landing/LandingAction.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ enum LandingAction: Equatable {
1414
/// The value for the remember me toggle was changed.
1515
case rememberMeChanged(Bool)
1616

17+
/// Show the pre-login app settings.
18+
case showPreLoginSettings
19+
1720
/// The toast was shown or hidden.
1821
case toastShown(Toast?)
1922
}

BitwardenShared/UI/Auth/Landing/LandingProcessor.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ class LandingProcessor: StateProcessor<LandingState, LandingAction, LandingEffec
9696
if !newValue {
9797
updateRememberedEmail()
9898
}
99+
case .showPreLoginSettings:
100+
// TODO: BIT-20367 Show Pre-Login Settings
101+
break
99102
case let .toastShown(toast):
100103
state.toast = toast
101104
}
@@ -122,6 +125,10 @@ class LandingProcessor: StateProcessor<LandingState, LandingAction, LandingEffec
122125
defaultValue: false,
123126
isPreAuth: true
124127
)
128+
state.isPreLoginSettingsEnabled = await services.configService.getFeatureFlag(
129+
.preLoginSettings,
130+
isPreAuth: true
131+
)
125132
}
126133

127134
/// Validate the currently entered email address and navigate to the login screen.

BitwardenShared/UI/Auth/Landing/LandingProcessorTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,28 +143,34 @@ class LandingProcessorTests: BitwardenTestCase { // swiftlint:disable:this type_
143143
@MainActor
144144
func test_perform_appeared_loadsFeatureFlag_true() async {
145145
configService.featureFlagsBoolPreAuth[.emailVerification] = true
146+
configService.featureFlagsBoolPreAuth[.preLoginSettings] = true
146147
subject.state.emailVerificationFeatureFlag = false
148+
subject.state.isPreLoginSettingsEnabled = false
147149

148150
let task = Task {
149151
await subject.perform(.appeared)
150152
}
151153
await task.value
152154
XCTAssertEqual(configService.configMocker.invokedParam?.isPreAuth, true)
153155
XCTAssertTrue(subject.state.emailVerificationFeatureFlag)
156+
XCTAssertTrue(subject.state.isPreLoginSettingsEnabled)
154157
}
155158

156159
/// `perform(.appeared)` with feature flag for .emailVerification set to false
157160
@MainActor
158161
func test_perform_appeared_loadsFeatureFlag_false() async {
159162
configService.featureFlagsBoolPreAuth[.emailVerification] = false
163+
configService.featureFlagsBoolPreAuth[.preLoginSettings] = false
160164
subject.state.emailVerificationFeatureFlag = true
165+
subject.state.isPreLoginSettingsEnabled = true
161166

162167
let task = Task {
163168
await subject.perform(.appeared)
164169
}
165170
await task.value
166171
XCTAssertEqual(configService.configMocker.invokedParam?.isPreAuth, true)
167172
XCTAssertFalse(subject.state.emailVerificationFeatureFlag)
173+
XCTAssertFalse(subject.state.isPreLoginSettingsEnabled)
168174
}
169175

170176
/// `perform(.appeared)` with feature flag defaulting to false
@@ -179,6 +185,7 @@ class LandingProcessorTests: BitwardenTestCase { // swiftlint:disable:this type_
179185
await task.value
180186
XCTAssertEqual(configService.configMocker.invokedParam?.isPreAuth, true)
181187
XCTAssertFalse(subject.state.emailVerificationFeatureFlag)
188+
XCTAssertFalse(subject.state.isPreLoginSettingsEnabled)
182189
}
183190

184191
/// `perform(.appeared)` with an active account and accounts should yield a profile switcher state.

BitwardenShared/UI/Auth/Landing/LandingState.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ struct LandingState: Equatable {
1515
!email.isEmpty
1616
}
1717

18+
/// Whether the pre-login settings feature flag is enabled.
19+
var isPreLoginSettingsEnabled = false
20+
1821
/// A flag indicating if the "Remember Me" toggle is on.
1922
var isRememberMeOn: Bool
2023

BitwardenShared/UI/Auth/Landing/LandingView.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ struct LandingView: View {
150150
Spacer()
151151
}
152152
.styleGuide(.footnote)
153+
154+
if store.state.isPreLoginSettingsEnabled {
155+
Button {
156+
store.send(.showPreLoginSettings)
157+
} label: {
158+
Label(Localizations.appSettings, image: Asset.Images.cog16.swiftUIImage)
159+
}
160+
.buttonStyle(.bitwardenBorderless)
161+
.frame(maxWidth: .infinity, alignment: .center)
162+
}
153163
}
154164
}
155165
}

BitwardenShared/UI/Auth/Landing/LandingViewTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ class LandingViewTests: BitwardenTestCase {
3131

3232
// MARK: Tests
3333

34+
/// Tapping the app settings button dispatches the `.showPreLoginSettings` action.
35+
@MainActor
36+
func test_appSettings_tap() throws {
37+
processor.state.isPreLoginSettingsEnabled = true
38+
let button = try subject.inspect().find(button: Localizations.appSettings)
39+
try button.tap()
40+
XCTAssertEqual(processor.dispatchedActions.last, .showPreLoginSettings)
41+
}
42+
3443
/// The continue button should be disabled when there is no value in the email field.
3544
@MainActor
3645
func test_continueButton_disabled() throws {
@@ -99,6 +108,7 @@ class LandingViewTests: BitwardenTestCase {
99108
/// Check the snapshot for the empty state.
100109
@MainActor
101110
func test_snapshot_empty() {
111+
processor.state.isPreLoginSettingsEnabled = true
102112
assertSnapshots(of: subject, as: [.defaultPortrait, .defaultPortraitDark, .defaultPortraitAX5])
103113
}
104114

Loading
Loading

BitwardenShared/UI/Platform/Application/Support/Localizations/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,3 +1180,4 @@
11801180
"KeyConnectorConfirmDomainWithAdmin" = "Please confirm the domain below with your organization administrator.\n\nKey Connector domain:\n%1$@";
11811181
"DoYouReallyWantToDeleteThisLog" = "Do you really want to delete this log?";
11821182
"DoYouReallyWantToDeleteAllRecordedLogs" = "Do you really want to delete all recorded logs?";
1183+
"AppSettings" = "App settings";

0 commit comments

Comments
 (0)