generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BIT-83: Adds draft login screen (#30)
- Loading branch information
1 parent
7997124
commit a463db7
Showing
17 changed files
with
686 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,14 @@ class LandingProcessorTests: BitwardenTestCase { | |
|
||
/// `receive(_:)` with `.continuePressed` navigates to the login screen. | ||
func test_receive_continuePressed() { | ||
subject.state.email = "[email protected]" | ||
|
||
subject.receive(.continuePressed) | ||
XCTAssertEqual(coordinator.routes.last, .login) | ||
XCTAssertEqual(coordinator.routes.last, .login( | ||
username: "[email protected]", | ||
region: "region", | ||
isLoginWithDeviceVisible: false | ||
)) | ||
} | ||
|
||
/// `receive(_:)` with `.createAccountPressed` navigates to the create account screen. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// MARK: - LoginAction | ||
|
||
/// Actions that can be processed by a `LoginProcessor`. | ||
enum LoginAction: Equatable { | ||
/// The get master password hint button was pressed. | ||
case getMasterPasswordHintPressed | ||
|
||
/// The enterprise single sign-on button was pressed. | ||
case enterpriseSingleSignOnPressed | ||
|
||
/// The login with device button was pressed. | ||
case loginWithDevicePressed | ||
|
||
/// The login with master password button was pressed. | ||
case loginWithMasterPasswordPressed | ||
|
||
/// The value for the master password was changed. | ||
case masterPasswordChanged(String) | ||
|
||
/// The more button was pressed. | ||
case morePressed | ||
|
||
/// The not you? button was pressed. | ||
case notYouPressed | ||
|
||
/// The reveal master password field button was pressed. | ||
case revealMasterPasswordFieldPressed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// MARK: LoginProcessor | ||
|
||
/// The processor used to manage state and handle actions for the login screen. | ||
/// | ||
class LoginProcessor: StateProcessor<LoginState, LoginAction, Void> { | ||
// MARK: Private Properties | ||
|
||
/// The `Coordinator` that handles navigation. | ||
private var coordinator: AnyCoordinator<AuthRoute> | ||
|
||
// MARK: Initialization | ||
|
||
/// Creates a new `LoginProcessor`. | ||
/// | ||
/// - Parameters: | ||
/// - coordinator: The coordinator that handles navigation. | ||
/// - state: The initial state of the processor. | ||
/// | ||
init(coordinator: AnyCoordinator<AuthRoute>, state: LoginState) { | ||
self.coordinator = coordinator | ||
super.init(state: state) | ||
} | ||
|
||
// MARK: Methods | ||
|
||
override func receive(_ action: LoginAction) { | ||
switch action { | ||
case .enterpriseSingleSignOnPressed: | ||
coordinator.navigate(to: .enterpriseSingleSignOn) | ||
case .getMasterPasswordHintPressed: | ||
coordinator.navigate(to: .masterPasswordHint) | ||
case .loginWithDevicePressed: | ||
coordinator.navigate(to: .loginWithDevice) | ||
case .loginWithMasterPasswordPressed: | ||
// Add login functionality here: BIT-132 | ||
print("login with master password") | ||
case let .masterPasswordChanged(newValue): | ||
state.masterPassword = newValue | ||
case .morePressed: | ||
coordinator.navigate(to: .loginOptions) | ||
case .notYouPressed: | ||
coordinator.navigate(to: .landing) | ||
case .revealMasterPasswordFieldPressed: | ||
state.isMasterPasswordRevealed.toggle() | ||
} | ||
} | ||
} |
Oops, something went wrong.