-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1181 from Automattic/lantean/magic-links-auth-mk4
Magic Link Login: Mk 4
- Loading branch information
Showing
10 changed files
with
350 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
2.21 | ||
----- | ||
- Added shortcuts to Simplenote Mac!! | ||
- New Magic Link Authentication support | ||
|
||
2.20 | ||
----- | ||
|
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import Foundation | ||
import SwiftUI | ||
|
||
|
||
// MARK: - MagicLinkConfirmationView | ||
// | ||
struct MagicLinkConfirmationView: View { | ||
|
||
@State var displaysInvalidLink = false | ||
|
||
var onDismissRequest: (() -> Void)? | ||
|
||
var body: some View { | ||
VStack(spacing: Metrics.stackSpacing) { | ||
if displaysInvalidLink { | ||
invalidLinkText | ||
invalidLinkButton | ||
} else { | ||
authorizingText | ||
progressIndicator | ||
} | ||
} | ||
.padding() | ||
.background(.white) | ||
.frame(width: Metrics.expectedSize.width, height: Metrics.expectedSize.height) | ||
.onReceive(NotificationCenter.default.publisher(for: .magicLinkAuthDidFail)) { _ in | ||
Task { @MainActor in | ||
displaysInvalidLink = true | ||
} | ||
} | ||
} | ||
|
||
private var authorizingText: some View { | ||
Text("Logging In...") | ||
.font(.title3) | ||
.foregroundColor(.gray) | ||
} | ||
|
||
private var progressIndicator: some View { | ||
ProgressView() | ||
.progressViewStyle(CircularProgressViewStyle()) | ||
.controlSize(.small) | ||
} | ||
|
||
private var invalidLinkText: some View { | ||
Text("Link was no longer valid") | ||
.font(.title3) | ||
.foregroundColor(.gray) | ||
} | ||
|
||
private var invalidLinkButton: some View { | ||
SwiftUI.Button(action: switchToAuthenticationUI) { | ||
Text("Accept") | ||
.fontWeight(.bold) | ||
.foregroundStyle(Color(nsColor: .simplenoteBrandColor)) | ||
.onHover { inside in | ||
if inside { | ||
NSCursor.pointingHand.set() | ||
} else { | ||
NSCursor.arrow.set() | ||
} | ||
} | ||
} | ||
.buttonStyle(PlainButtonStyle()) | ||
} | ||
|
||
func switchToAuthenticationUI() { | ||
onDismissRequest?() | ||
} | ||
} | ||
|
||
|
||
// MARK: - Metrics | ||
// | ||
private struct Metrics { | ||
static let stackSpacing: CGFloat = 20 | ||
static let expectedSize = CGSize(width: 380, height: 200) | ||
} |
Oops, something went wrong.