diff --git a/ios/PolkadotVault/Modals/Alerts/VerticalActionsBottomModal.swift b/ios/PolkadotVault/Modals/Alerts/VerticalActionsBottomModal.swift index aa2d98f7fa..174884d505 100644 --- a/ios/PolkadotVault/Modals/Alerts/VerticalActionsBottomModal.swift +++ b/ios/PolkadotVault/Modals/Alerts/VerticalActionsBottomModal.swift @@ -12,6 +12,8 @@ struct VerticalActionsBottomModalViewModel { let content: String? let dismissActionLabel: LocalizedStringKey let mainActionLabel: LocalizedStringKey + var mainActionStyle: ActionButtonStyle = .primaryDestructive() + var contentAlignment: TextAlignment = .center static let removeGeneralVerifier = VerticalActionsBottomModalViewModel( title: Localizable.Settings.Modal.GeneralVerifier.Label.title.string, @@ -19,6 +21,15 @@ struct VerticalActionsBottomModalViewModel { dismissActionLabel: Localizable.Settings.Modal.GeneralVerifier.Action.cancel.key, mainActionLabel: Localizable.Settings.Modal.GeneralVerifier.Action.remove.key ) + + static let confirmDerivedKeysCreation = VerticalActionsBottomModalViewModel( + title: Localizable.AddDerivedKeys.Modal.Label.title.string, + content: Localizable.AddDerivedKeys.Modal.Label.content.string, + dismissActionLabel: Localizable.AddDerivedKeys.Modal.Action.cancel.key, + mainActionLabel: Localizable.AddDerivedKeys.Modal.Action.confirm.key, + mainActionStyle: .primary(), + contentAlignment: .center + ) } struct VerticalActionsBottomModal: View { @@ -48,19 +59,20 @@ struct VerticalActionsBottomModal: View { content: { VStack(alignment: .leading, spacing: Spacing.medium) { Text(viewModel.title) + .multilineTextAlignment(viewModel.contentAlignment) .font(PrimaryFont.titleL.font) if let content = viewModel.content { Text(content) .font(PrimaryFont.bodyL.font) .lineSpacing(Spacing.extraExtraSmall) - .multilineTextAlignment(.leading) + .multilineTextAlignment(viewModel.contentAlignment) .foregroundColor(Asset.textAndIconsSecondary.swiftUIColor) } VStack { PrimaryButton( action: { animateDismissal(mainAction()) }, text: viewModel.mainActionLabel, - style: .primaryDestructive() + style: viewModel.mainActionStyle ) SecondaryButton( action: animateDismissal(dismissAction()), diff --git a/ios/PolkadotVault/Resources/en.lproj/Localizable.strings b/ios/PolkadotVault/Resources/en.lproj/Localizable.strings index 58817ff048..73234d7916 100644 --- a/ios/PolkadotVault/Resources/en.lproj/Localizable.strings +++ b/ios/PolkadotVault/Resources/en.lproj/Localizable.strings @@ -622,3 +622,7 @@ "AddDerivedKeys.Error.AlreadyImported" = "Some are hidden from the list because they have already been imported."; "AddDerivedKeys.Error.DerivedKeyForNetwork.Content" = "Derived key %@ could not be created: %@"; "AddDerivedKeys.Error.DerivedKeyForNetwork.Title" = "There was an issue importing keys."; +"AddDerivedKeys.Modal.Label.Title" = "Please confirm derived key import with the PIN code"; +"AddDerivedKeys.Modal.Label.Content" = "Please confirm that you scanned the QR code back into the app. Once confirmed, the imported key will be added to the key set."; +"AddDerivedKeys.Modal.Action.Confirm" = "Confirm with PIN code"; +"AddDerivedKeys.Modal.Action.Cancel" = "Cancel"; diff --git a/ios/PolkadotVault/Screens/Scan/DynamicDerivations/AddDerivedKeysView.swift b/ios/PolkadotVault/Screens/Scan/DynamicDerivations/AddDerivedKeysView.swift index 87b77e7c4f..58a3b10ee4 100644 --- a/ios/PolkadotVault/Screens/Scan/DynamicDerivations/AddDerivedKeysView.swift +++ b/ios/PolkadotVault/Screens/Scan/DynamicDerivations/AddDerivedKeysView.swift @@ -53,6 +53,16 @@ struct AddDerivedKeysView: View { ) .clearModalBackground() } + .fullScreenModal( + isPresented: $viewModel.isPresentingAddKeysConfirmation + ) { + VerticalActionsBottomModal( + viewModel: .confirmDerivedKeysCreation, + mainAction: viewModel.onConfirmTap(), + isShowingBottomAlert: $viewModel.isPresentingAddKeysConfirmation + ) + .clearModalBackground() + } } @ViewBuilder @@ -183,6 +193,7 @@ extension AddDerivedKeysView { private let seedsMediator: SeedsMediating let dataModel: AddDerivedKeysData @Binding var isPresented: Bool + @Published var isPresentingAddKeysConfirmation: Bool = false @Published var isPresentingDerivationPath: Bool = false @Published var isPresentingError: Bool = false @Published var presentableError: ErrorBottomModalViewModel = .importDynamicDerivedKeys(content: "") @@ -204,26 +215,26 @@ extension AddDerivedKeysView { } func onDoneTap() { - let success = { [weak self] in - self?.isPresented = false - self?.onCompletion(.onDone) - } if !dynamicDerivationsPreview.keySet.derivations.isEmpty { - derivedKeysService.createDerivedKeys( - dynamicDerivationsPreview.keySet.seedName, - seedsMediator.getSeed(seedName: dynamicDerivationsPreview.keySet.seedName), - keysToImport: dynamicDerivationsPreview.keySet.derivations - ) { [weak self] result in - switch result { - case .success: - success() - case let .failure(error): - self?.presentableError = .importDynamicDerivedKeys(content: error.localizedDescription) - self?.isPresentingError = true - } - } + isPresentingAddKeysConfirmation = true } else { - success() + onSuccess() + } + } + + func onConfirmTap() { + derivedKeysService.createDerivedKeys( + dynamicDerivationsPreview.keySet.seedName, + seedsMediator.getSeed(seedName: dynamicDerivationsPreview.keySet.seedName), + keysToImport: dynamicDerivationsPreview.keySet.derivations + ) { [weak self] result in + switch result { + case .success: + self?.onSuccess() + case let .failure(error): + self?.presentableError = .importDynamicDerivedKeys(content: error.localizedDescription) + self?.isPresentingError = true + } } } @@ -231,6 +242,11 @@ extension AddDerivedKeysView { isPresented = false onCompletion(.onCancel) } + + private func onSuccess() { + isPresented = false + onCompletion(.onDone) + } } }