Skip to content

Commit

Permalink
fix: ios: Fix and improve Add Derived Keys screen interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
krodak committed Nov 30, 2023
1 parent f5ab7a5 commit 3395974
Showing 1 changed file with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ struct AddDerivedKeysView: View {
ActionButton(
action: viewModel.onMainActionTap,
text: Localizable.AddDerivedKeys.Action.main.key,
style: .secondary()
style: .primary(isDisabled: .constant(
viewModel.dynamicDerivationsPreview.keySet.derivations
.isEmpty
))
)
.padding(Spacing.large)
}
Expand Down Expand Up @@ -103,27 +106,31 @@ struct AddDerivedKeysView: View {
viewModel.dataModel.keySets,
id: \.keySetName
) { keySet in
LazyVStack(alignment: .leading, spacing: 0) {
Text(keySet.keySetName)
.font(PrimaryFont.titleS.font)
.foregroundColor(.textAndIconsPrimary)
.multilineTextAlignment(.leading)
.padding(Spacing.medium)
Divider()
.padding(.horizontal, Spacing.medium)
ForEach(
keySet.derivedKeys,
id: \.base58
) { key in
derivedKey(for: key)
if key != keySet.derivedKeys.last {
Divider()
.padding(.horizontal, Spacing.medium)
if !keySet.derivedKeys.isEmpty {
LazyVStack(alignment: .leading, spacing: 0) {
Text(keySet.keySetName)
.font(PrimaryFont.titleS.font)
.foregroundColor(.textAndIconsPrimary)
.multilineTextAlignment(.leading)
.padding(Spacing.medium)
Divider()
.padding(.horizontal, Spacing.medium)
ForEach(
keySet.derivedKeys,
id: \.base58
) { key in
derivedKey(for: key)
if key != keySet.derivedKeys.last {
Divider()
.padding(.horizontal, Spacing.medium)
}
}
}
.containerBackground()
.padding(.bottom, Spacing.extraSmall)
} else {
EmptyView()
}
.containerBackground()
.padding(.bottom, Spacing.extraSmall)
}
}
.padding(.horizontal, Spacing.medium)
Expand Down Expand Up @@ -203,7 +210,7 @@ extension AddDerivedKeysView {

final class ViewModel: ObservableObject {
private let onCompletion: (OnCompletionAction) -> Void
private let dynamicDerivationsPreview: DdPreview
let dynamicDerivationsPreview: DdPreview
private let derivedKeysService: CreateDerivedKeyService
private let seedsMediator: SeedsMediating
let dataModel: AddDerivedKeysData
Expand Down Expand Up @@ -238,19 +245,27 @@ extension AddDerivedKeysView {
}

func onAddCancelationTap() {
isPresented = false
onCompletion(.onCancel)
onCancel()
}

func onBackTap() {
isPresentingAddKeysCancelation = true
if dynamicDerivationsPreview.keySet.derivations.isEmpty {
onCancel()
} else {
isPresentingAddKeysCancelation = true
}
}

private func onSuccess() {
isPresented = false
onCompletion(.onDone)
}

private func onCancel() {
isPresented = false
onCompletion(.onCancel)
}

private func continueCreation() {
derivedKeysService.createDerivedKeys(
dynamicDerivationsPreview.keySet.seedName,
Expand Down

0 comments on commit 3395974

Please sign in to comment.