Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change behavior of Random button in Passcode view #5283

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ struct PasscodeView: View {
Button(action: {
randomized.toggle()
}) {
Text(randomized ? "unlock.regular_mode".localized : "unlock.random_mode".localized)
Text("unlock.random".localized)
}
.buttonStyle(SecondaryButtonStyle(style: .default))
.buttonStyle(SecondaryButtonStyle(isActive: randomized))
.disabled(lockoutState.isLocked)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ import SwiftUI

struct SecondaryButtonStyle: ButtonStyle {
let style: Style
let isActive: Bool

init(style: Style = .default, isActive: Bool = false) {
self.style = style
self.isActive = isActive
}

@Environment(\.isEnabled) var isEnabled

func makeBody(configuration: Configuration) -> some View {
configuration.label
.padding(EdgeInsets(top: 5.5, leading: .margin16, bottom: 5.5, trailing: .margin16))
.font(.themeSubhead1)
.foregroundColor(style.foregroundColor(isEnabled: isEnabled, isPressed: configuration.isPressed))
.background(style.backgroundColor(isEnabled: isEnabled, isPressed: configuration.isPressed))
.foregroundColor(style.foregroundColor(isEnabled: isEnabled, isActive: isActive, isPressed: configuration.isPressed))
.background(style.backgroundColor(isEnabled: isEnabled, isActive: isActive, isPressed: configuration.isPressed))
.clipShape(Capsule(style: .continuous))
.animation(.easeOut(duration: 0.2), value: configuration.isPressed)
}
Expand All @@ -19,16 +25,16 @@ struct SecondaryButtonStyle: ButtonStyle {
case `default`
case transparent

func foregroundColor(isEnabled: Bool, isPressed: Bool) -> Color {
func foregroundColor(isEnabled: Bool, isActive: Bool, isPressed: Bool) -> Color {
switch self {
case .default, .transparent: return isEnabled ? (isPressed ? .themeGray : .themeLeah) : .themeGray50
case .default, .transparent: return isEnabled ? (isActive ? .themeDark : (isPressed ? .themeGray : .themeLeah)) : .themeGray50
}
}

func backgroundColor(isEnabled _: Bool, isPressed: Bool) -> Color {
func backgroundColor(isEnabled: Bool, isActive: Bool, isPressed: Bool) -> Color {
switch self {
case .default: return isPressed ? .themeSteel10 : .themeSteel20
case .transparent: return .clear
case .default: return isEnabled ? (isActive ? (isPressed ? .themeYellow50 : .themeYellow) : (isPressed ? .themeSteel10 : .themeSteel20)) : .themeSteel20
case .transparent: return isEnabled && isActive ? (isPressed ? .themeYellow50 : .themeYellow) : .clear
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,7 @@ Go to Settings - > %@ and allow access to the camera.";
"unlock.biometry_reason" = "Unlock wallet";
"unlock.attempts_left" = "Attempts left: %@";
"unlock.disabled_until" = "Disabled until: %@";
"unlock.regular_mode" = "Regular Mode";
"unlock.random_mode" = "Random Mode";
"unlock.random" = "Random";

"security_settings.delete_alert_button" = "Delete from Phone";

Expand Down