Skip to content

Commit

Permalink
Require passing in isPinCorrect function
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenperera committed Dec 12, 2024
1 parent ce2dcf1 commit fa3d24f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ios/Cove/SettingsScreen/ChangePinView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct ChangePinView: View {
case .current:
NumberPadPinView(
title: "Enter Current PIN",
isPinCorrect: isPinCorrect,
backAction: backAction,
onUnlock: { _ in
withAnimation {
Expand All @@ -37,6 +38,7 @@ struct ChangePinView: View {
case .new:
NumberPadPinView(
title: "Enter new PIN",
isPinCorrect: { _ in true },
backAction: backAction,
onUnlock: { enteredPin in
withAnimation {
Expand Down
17 changes: 10 additions & 7 deletions ios/Cove/Views/NumberPadPinView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct NumberPadPinView: View {
public init(
title: String = "Enter Pin",
isUnlocked: Binding<Bool> = .constant(false),
isPinCorrect: @escaping (String) -> Bool = { _ in true },
isPinCorrect: @escaping (String) -> Bool,
pinLength: Int = 6,
backAction: (() -> Void)? = nil,
onUnlock: @escaping (String) -> Void = { _ in },
Expand Down Expand Up @@ -143,23 +143,26 @@ struct NumberPadPinView: View {
.tint(.white)
}

/// 0 and Back Button
// take up space
Button(action: {}) {}

Button(action: {
if !pin.isEmpty { pin.removeLast() }
guard pin.count < pinLength else { return }
pin.append("0")
}, label: {
Image(systemName: "delete.backward")
Text("0")
.font(.title)
.frame(maxWidth: .infinity)
.padding(.vertical, 20)
.contentShape(.rect)
})
.tint(.white)

/// 0 and Back Button
Button(action: {
guard pin.count < pinLength else { return }
pin.append("0")
if !pin.isEmpty { pin.removeLast() }
}, label: {
Text("0")
Image(systemName: "delete.backward")
.font(.title)
.frame(maxWidth: .infinity)
.padding(.vertical, 20)
Expand Down

0 comments on commit fa3d24f

Please sign in to comment.