Skip to content

Commit

Permalink
#181: Update verification modal.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Sep 15, 2022
1 parent e5eba32 commit 385e30f
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 119 deletions.
10 changes: 6 additions & 4 deletions DesignKit/Sources/Buttons/ElementActionButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public struct ElementActionButtonStyle: ButtonStyle {
public var size: ElementControlSize
public var color: Color

private var verticalPadding: CGFloat { size == .xLarge ? 12 : 4 }
private var cornerRadius: CGFloat { size == .xLarge ? 14 : 8 }
private var verticalPadding: CGFloat { size == .xLarge ? 14 : 4 }
private var maxWidth: CGFloat? { size == .xLarge ? .infinity : nil }

private var fontColor: Color {
// Always white unless disabled with a dark theme.
.white.opacity(colorScheme == .dark && !isEnabled ? 0.3 : 1.0)
Color.element.systemPrimaryBackground
.opacity(colorScheme == .dark && !isEnabled ? 0.3 : 1.0)
}

public init(size: ElementControlSize = .regular, color: Color = .element.accent) {
Expand All @@ -53,9 +55,9 @@ public struct ElementActionButtonStyle: ButtonStyle {
.padding(.vertical, verticalPadding)
.frame(maxWidth: maxWidth)
.foregroundColor(fontColor)
.font(.element.body)
.font(.element.bodyBold)
.background(color.opacity(backgroundOpacity(when: configuration.isPressed)))
.cornerRadius(8.0)
.cornerRadius(cornerRadius)
}

private func backgroundOpacity(when isPressed: Bool) -> CGFloat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"action_confirm" = "Confirm";
"action_next" = "Next";
"action_match" = "Match";

"screenshot_detected_title" = "You took a screenshot";
"screenshot_detected_message" = "Would you like to submit a bug report?";
Expand All @@ -17,6 +18,8 @@

"session_verification_banner_title" = "Help keep your messages secure";
"session_verification_banner_message" = "Looks like you’re using a new device. Verify its you.";
"session_verification_screen_emojis_title" = "Lets check if these";
"session_verification_screen_emojis_message" = "Open Element on one of your other sessions to compare.";

// MARK: - Authentication

Expand Down
6 changes: 6 additions & 0 deletions ElementX/Sources/Generated/Strings+Untranslated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import Foundation
extension ElementL10n {
/// Confirm
public static let actionConfirm = ElementL10n.tr("Untranslated", "action_confirm")
/// Match
public static let actionMatch = ElementL10n.tr("Untranslated", "action_match")
/// Next
public static let actionNext = ElementL10n.tr("Untranslated", "action_next")
/// Forgot password
Expand Down Expand Up @@ -54,6 +56,10 @@ extension ElementL10n {
public static let sessionVerificationBannerMessage = ElementL10n.tr("Untranslated", "session_verification_banner_message")
/// Help keep your messages secure
public static let sessionVerificationBannerTitle = ElementL10n.tr("Untranslated", "session_verification_banner_title")
/// Open Element on one of your other sessions to compare.
public static let sessionVerificationScreenEmojisMessage = ElementL10n.tr("Untranslated", "session_verification_screen_emojis_message")
/// Lets check if these
public static let sessionVerificationScreenEmojisTitle = ElementL10n.tr("Untranslated", "session_verification_screen_emojis_title")
/// Timeline Style
public static let settingsTimelineStyle = ElementL10n.tr("Untranslated", "settings_timeline_style")
/// Untranslated
Expand Down
2 changes: 1 addition & 1 deletion ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct HomeScreen: View {
.foregroundColor(.element.systemPrimaryLabel)
Text(ElementL10n.sessionVerificationBannerMessage)
.font(.element.footnote)
.foregroundColor(.element.systemSecondaryLabel.opacity(0.6))
.foregroundColor(.element.systemSecondaryLabel)
}

HStack(spacing: 16) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,34 @@ enum SessionVerificationViewModelAction {
struct SessionVerificationViewState: BindableState {
var verificationState: SessionVerificationStateMachine.State = .initial

var shouldDisableDismissButton: Bool {
verificationState != .verified
var title: String? {
switch verificationState {
case .showingChallenge:
return ElementL10n.sessionVerificationScreenEmojisTitle
default:
return nil
}
}

var shouldDisableCancelButton: Bool {
verificationState == .verified
var message: String {
switch verificationState {
case .initial:
return ElementL10n.verificationOpenOtherToVerify
case .requestingVerification:
return ElementL10n.verificationRequestWaiting
case .acceptingChallenge:
return ElementL10n.verificationRequestWaiting
case .decliningChallenge:
return ElementL10n.verificationRequestWaiting
case .cancelling:
return ElementL10n.verificationRequestWaiting
case .showingChallenge:
return ElementL10n.sessionVerificationScreenEmojisMessage
case .verified:
return ElementL10n.verificationConclusionOkSelfNotice
case .cancelled:
return ElementL10n.verificationCancelled
}
}
}

Expand All @@ -41,6 +63,5 @@ enum SessionVerificationViewAction {
case restart
case accept
case decline
case dismiss
case cancel
case close
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVer
stateMachine.processEvent(.requestVerification)
case .restart:
stateMachine.processEvent(.restart)
case .dismiss:
callback?(.finished)
case .cancel:
case .close:
guard stateMachine.state == .initial ||
stateMachine.state == .verified ||
stateMachine.state == .cancelled else {
Expand Down
Loading

0 comments on commit 385e30f

Please sign in to comment.