diff --git a/ios/PolkadotVault.xcodeproj/project.pbxproj b/ios/PolkadotVault.xcodeproj/project.pbxproj index a877e3ac3f..06dc643582 100644 --- a/ios/PolkadotVault.xcodeproj/project.pbxproj +++ b/ios/PolkadotVault.xcodeproj/project.pbxproj @@ -50,7 +50,6 @@ 6D042AF22901B3FB00B3F4F7 /* QRCodeImageGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D042AF12901B3FB00B3F4F7 /* QRCodeImageGenerator.swift */; }; 6D042AF42901B40400B3F4F7 /* ExportMultipleKeysModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D042AF32901B40400B3F4F7 /* ExportMultipleKeysModal.swift */; }; 6D0677AC29BB0C6000D76D90 /* AppLaunchMediator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0677AB29BB0C6000D76D90 /* AppLaunchMediator.swift */; }; - 6D0677AE29BB0D0000D76D90 /* WarningStateMediator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0677AD29BB0D0000D76D90 /* WarningStateMediator.swift */; }; 6D07D370292B40D2001A0B79 /* TransactionSummaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D07D36F292B40D2001A0B79 /* TransactionSummaryView.swift */; }; 6D09912A2A7AA10800DF75EC /* BlockiesIdenticonViewPreviews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0991292A7AA10800DF75EC /* BlockiesIdenticonViewPreviews.swift */; }; 6D0BF95229F2BBF500F5B569 /* NetworkIconCapsuleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D0BF95129F2BBF500F5B569 /* NetworkIconCapsuleView.swift */; }; @@ -210,7 +209,7 @@ 6DA2ACAC2939E87600AAEADC /* Event+Value.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DA2ACAB2939E87600AAEADC /* Event+Value.swift */; }; 6DA2ACAE2939EAC300AAEADC /* Event+isImportant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DA2ACAD2939EAC300AAEADC /* Event+isImportant.swift */; }; 6DA2ACB0293A17DF00AAEADC /* Address+DisplayablePath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DA2ACAF293A17DF00AAEADC /* Address+DisplayablePath.swift */; }; - 6DA317C1299E3DDF005DD060 /* OnboardingAirgapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DD860E4299CAAA70000D81E /* OnboardingAirgapView.swift */; }; + 6DA317C1299E3DDF005DD060 /* NoAirgapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DD860E4299CAAA70000D81E /* NoAirgapView.swift */; }; 6DA317C3299F6FF1005DD060 /* AirgapMediatorAssembler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DA317C2299F6FF1005DD060 /* AirgapMediatorAssembler.swift */; }; 6DA501CC290A48190096DA4E /* KeyDetails+ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DA501CB290A48190096DA4E /* KeyDetails+ViewModel.swift */; }; 6DA501D4290BC55A0096DA4E /* KeyDetailsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DA501D3290BC55A0096DA4E /* KeyDetailsService.swift */; }; @@ -221,8 +220,6 @@ 6DAA6CB329BF7155002329A8 /* OnboardingMediator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DAA6CB229BF7155002329A8 /* OnboardingMediator.swift */; }; 6DB39AA42A4579E0004B8FAA /* AddDerivedKeysView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB39AA32A4579E0004B8FAA /* AddDerivedKeysView.swift */; }; 6DB39AA92A45C909004B8FAA /* TransparentHelpBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB39AA82A45C909004B8FAA /* TransparentHelpBox.swift */; }; - 6DB99035295C1080001101DC /* ConnectivityAlertButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB99034295C1080001101DC /* ConnectivityAlertButton.swift */; }; - 6DB99037295C160D001101DC /* ConnectivityAlertOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB99036295C160D001101DC /* ConnectivityAlertOverlay.swift */; }; 6DB99039295E95E9001101DC /* NetworkCapsuleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB99038295E95E9001101DC /* NetworkCapsuleView.swift */; }; 6DB9903B295EA7DE001101DC /* ActionableInfoBoxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB9903A295EA7DE001101DC /* ActionableInfoBoxView.swift */; }; 6DB9903D2962A619001101DC /* MTransaction+ImportDerivedKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB9903C2962A619001101DC /* MTransaction+ImportDerivedKeys.swift */; }; @@ -393,7 +390,6 @@ 6D042AF12901B3FB00B3F4F7 /* QRCodeImageGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QRCodeImageGenerator.swift; sourceTree = ""; }; 6D042AF32901B40400B3F4F7 /* ExportMultipleKeysModal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportMultipleKeysModal.swift; sourceTree = ""; }; 6D0677AB29BB0C6000D76D90 /* AppLaunchMediator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLaunchMediator.swift; sourceTree = ""; }; - 6D0677AD29BB0D0000D76D90 /* WarningStateMediator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WarningStateMediator.swift; sourceTree = ""; }; 6D07D36F292B40D2001A0B79 /* TransactionSummaryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionSummaryView.swift; sourceTree = ""; }; 6D0991292A7AA10800DF75EC /* BlockiesIdenticonViewPreviews.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlockiesIdenticonViewPreviews.swift; sourceTree = ""; }; 6D0AE5572A6129100042282A /* Blockies */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Blockies; sourceTree = ""; }; @@ -563,8 +559,6 @@ 6DAA6CB229BF7155002329A8 /* OnboardingMediator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingMediator.swift; sourceTree = ""; }; 6DB39AA32A4579E0004B8FAA /* AddDerivedKeysView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddDerivedKeysView.swift; sourceTree = ""; }; 6DB39AA82A45C909004B8FAA /* TransparentHelpBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransparentHelpBox.swift; sourceTree = ""; }; - 6DB99034295C1080001101DC /* ConnectivityAlertButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectivityAlertButton.swift; sourceTree = ""; }; - 6DB99036295C160D001101DC /* ConnectivityAlertOverlay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectivityAlertOverlay.swift; sourceTree = ""; }; 6DB99038295E95E9001101DC /* NetworkCapsuleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkCapsuleView.swift; sourceTree = ""; }; 6DB9903A295EA7DE001101DC /* ActionableInfoBoxView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionableInfoBoxView.swift; sourceTree = ""; }; 6DB9903C2962A619001101DC /* MTransaction+ImportDerivedKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MTransaction+ImportDerivedKeys.swift"; sourceTree = ""; }; @@ -600,7 +594,7 @@ 6DD17CA32A77A3DD008442FD /* Error+RustDisplayError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Error+RustDisplayError.swift"; sourceTree = ""; }; 6DD4A6A329E9404200FA6746 /* CreateKeySetService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateKeySetService.swift; sourceTree = ""; }; 6DD4A6A529E9480700FA6746 /* KeyListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyListService.swift; sourceTree = ""; }; - 6DD860E4299CAAA70000D81E /* OnboardingAirgapView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingAirgapView.swift; sourceTree = ""; }; + 6DD860E4299CAAA70000D81E /* NoAirgapView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoAirgapView.swift; sourceTree = ""; }; 6DD860E7299CAD140000D81E /* OnboadingAirgapView+Components.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OnboadingAirgapView+Components.swift"; sourceTree = ""; }; 6DD860E9299CED3F0000D81E /* AirgapMediator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AirgapMediator.swift; sourceTree = ""; }; 6DD9FF1528C8B85300FB6195 /* HorizontalActionsBottomModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HorizontalActionsBottomModal.swift; sourceTree = ""; }; @@ -1639,7 +1633,6 @@ isa = PBXGroup; children = ( 6DBF6E4A28EC51D600CC959F /* GenericError.swift */, - 6DB99036295C160D001101DC /* ConnectivityAlertOverlay.swift */, ); path = Errors; sourceTree = ""; @@ -1685,7 +1678,7 @@ isa = PBXGroup; children = ( 6DD860E7299CAD140000D81E /* OnboadingAirgapView+Components.swift */, - 6DD860E4299CAAA70000D81E /* OnboardingAirgapView.swift */, + 6DD860E4299CAAA70000D81E /* NoAirgapView.swift */, 6DD860E9299CED3F0000D81E /* AirgapMediator.swift */, 6DA317C2299F6FF1005DD060 /* AirgapMediatorAssembler.swift */, ); @@ -1727,7 +1720,6 @@ 6D2D244E28CE5C1B00862726 /* NavbarActionButton.swift */, 6D16687E28F86DE0008C664A /* CameraButton.swift */, 6DF8316628F9BA4A00CB2BCE /* CapsuleButton.swift */, - 6DB99034295C1080001101DC /* ConnectivityAlertButton.swift */, 6D2A5D102AA607C7009E0C3A /* ActionSheetCircleButton.swift */, 6D699FB42AA9CC7A0043B23A /* QRCodeButton.swift */, ); @@ -1837,7 +1829,6 @@ isa = PBXGroup; children = ( 6D0677AB29BB0C6000D76D90 /* AppLaunchMediator.swift */, - 6D0677AD29BB0D0000D76D90 /* WarningStateMediator.swift */, 6DAA6CB029BF482E002329A8 /* AuthenticatedStateMediator.swift */, 6DAA6CB229BF7155002329A8 /* OnboardingMediator.swift */, 6D7DE0D32ACB178800BFAACA /* DatabaseVersionMediator.swift */, @@ -2275,7 +2266,6 @@ 6D019974289D183B00F4C317 /* UInt8+Formatting.swift in Sources */, 2D48F3D2277A0AB2004B27BE /* HistoryCardExtended.swift in Sources */, 6D34233A299615FD00F3BA27 /* MVerifier+Type.swift in Sources */, - 6DB99035295C1080001101DC /* ConnectivityAlertButton.swift in Sources */, 6DA2ACA52939D24000AAEADC /* LogsListView.swift in Sources */, 6DEFB52F28FEDA9B00762219 /* AnimatedQRCodeView.swift in Sources */, 6D0677AC29BB0C6000D76D90 /* AppLaunchMediator.swift in Sources */, @@ -2284,7 +2274,6 @@ 6DA2ACAE2939EAC300AAEADC /* Event+isImportant.swift in Sources */, 6D8973A52A08E18C0046A2F3 /* ScanTabService.swift in Sources */, 2DA5F84327566BE300D8DD29 /* TransactionCardSelector.swift in Sources */, - 6D0677AE29BB0D0000D76D90 /* WarningStateMediator.swift in Sources */, 6D699FB52AA9CC7A0043B23A /* QRCodeButton.swift in Sources */, 6DB99039295E95E9001101DC /* NetworkCapsuleView.swift in Sources */, 6DFE588B297A5F09002BFDBF /* ApplicationStatePublisher.swift in Sources */, @@ -2294,7 +2283,6 @@ 6D476A1929FC05ED00326F74 /* AddKeySetUpNetworksStepOneView.swift in Sources */, 2DAA82A927885FCF002917C0 /* TCTXSpecPlain.swift in Sources */, 6DD860EA299CED3F0000D81E /* AirgapMediator.swift in Sources */, - 6DB99037295C160D001101DC /* ConnectivityAlertOverlay.swift in Sources */, 6DFAF36B28AF7F8A0048763B /* Spacing.swift in Sources */, 2DA5F87227566C3600D8DD29 /* TCFieldNumber.swift in Sources */, 2DA5F86D27566C3600D8DD29 /* TCAuthorPlain.swift in Sources */, @@ -2356,7 +2344,7 @@ 6D95E97528B500EE00E28A11 /* Heights.swift in Sources */, 6D8045DE28D087D400237F8C /* QRCodeRootFooterView.swift in Sources */, 6D09912A2A7AA10800DF75EC /* BlockiesIdenticonViewPreviews.swift in Sources */, - 6DA317C1299E3DDF005DD060 /* OnboardingAirgapView.swift in Sources */, + 6DA317C1299E3DDF005DD060 /* NoAirgapView.swift in Sources */, 6DFE588D297A72B1002BFDBF /* JailbreakDetectionPublisher.swift in Sources */, 6D42793728DB147800C141DC /* PrivateKeyQRCodeService.swift in Sources */, 6D77F323296D4D8900044C7C /* CreateDerivedKeyService.swift in Sources */, diff --git a/ios/PolkadotVault/Backend/NavigationServices/ScanTabService.swift b/ios/PolkadotVault/Backend/NavigationServices/ScanTabService.swift index 6ac0cc007a..9b674edd6e 100644 --- a/ios/PolkadotVault/Backend/NavigationServices/ScanTabService.swift +++ b/ios/PolkadotVault/Backend/NavigationServices/ScanTabService.swift @@ -50,10 +50,6 @@ final class ScanTabService { func attemptPassword(_ password: String) -> ActionResult? { navigation.performFake(navigation: .init(action: .goForward, details: password)) } - - func onSuccessfullPasswordEntry() { - navigation.performFake(navigation: .init(action: .goBack)) - } } private extension ScanTabService { diff --git a/ios/PolkadotVault/Backend/Services/CreateDerivedKeyService.swift b/ios/PolkadotVault/Backend/Services/CreateDerivedKeyService.swift index b0947d1aa1..60e12c556d 100644 --- a/ios/PolkadotVault/Backend/Services/CreateDerivedKeyService.swift +++ b/ios/PolkadotVault/Backend/Services/CreateDerivedKeyService.swift @@ -65,18 +65,15 @@ enum ImportDerivedKeyError: Error { } final class CreateDerivedKeyService { - private let databaseMediator: DatabaseMediating private let backendService: BackendService private let seedsMediator: SeedsMediating private let createKeyNameService: CreateDerivedKeyNameService init( - databaseMediator: DatabaseMediating = DatabaseMediator(), seedsMediator: SeedsMediating = ServiceLocator.seedsMediator, backendService: BackendService = BackendService(), createKeyNameService: CreateDerivedKeyNameService = CreateDerivedKeyNameService() ) { - self.databaseMediator = databaseMediator self.seedsMediator = seedsMediator self.backendService = backendService self.createKeyNameService = createKeyNameService diff --git a/ios/PolkadotVault/Backend/Services/ExportPrivateKeyService.swift b/ios/PolkadotVault/Backend/Services/ExportPrivateKeyService.swift index 9269b1d6c2..c2cb527328 100644 --- a/ios/PolkadotVault/Backend/Services/ExportPrivateKeyService.swift +++ b/ios/PolkadotVault/Backend/Services/ExportPrivateKeyService.swift @@ -8,17 +8,14 @@ import Foundation final class ExportPrivateKeyService { - private let databaseMediator: DatabaseMediating private let seedsMediator: SeedsMediating private let backendService: BackendService init( backendService: BackendService = BackendService(), - databaseMediator: DatabaseMediating = DatabaseMediator(), seedsMediator: SeedsMediating = ServiceLocator.seedsMediator ) { self.backendService = backendService - self.databaseMediator = databaseMediator self.seedsMediator = seedsMediator } diff --git a/ios/PolkadotVault/Components/Buttons/ActionButton.swift b/ios/PolkadotVault/Components/Buttons/ActionButton.swift index 515b24951a..15e7fae19d 100644 --- a/ios/PolkadotVault/Components/Buttons/ActionButton.swift +++ b/ios/PolkadotVault/Components/Buttons/ActionButton.swift @@ -64,14 +64,6 @@ struct ActionButtonStyle: ButtonStyle { isDisabled: isDisabled ) } - - static func white(isDisabled: Binding = Binding.constant(false)) -> ActionButtonStyle { - ActionButtonStyle( - backgroundColor: .accentForegroundText, - foregroundColor: .accentPink500, - isDisabled: isDisabled - ) - } } struct ActionButton: View { diff --git a/ios/PolkadotVault/Components/Buttons/ActionSheetCircleButton.swift b/ios/PolkadotVault/Components/Buttons/ActionSheetCircleButton.swift index d33bc28786..de6c8e1a36 100644 --- a/ios/PolkadotVault/Components/Buttons/ActionSheetCircleButton.swift +++ b/ios/PolkadotVault/Components/Buttons/ActionSheetCircleButton.swift @@ -16,9 +16,7 @@ struct ActionSheetCircleButtonStyle: ButtonStyle { .font(PrimaryFont.titleS.font) } - static let destructive = ActionSheetCircleButtonStyle(foregroundColor: .accentRed400) static let `default` = ActionSheetCircleButtonStyle(foregroundColor: .textAndIconsSecondary) - static let hightlighted = ActionSheetCircleButtonStyle(foregroundColor: .textAndIconsPrimary) } struct ActionSheetCircleButton: View { diff --git a/ios/PolkadotVault/Components/Buttons/ConnectivityAlertButton.swift b/ios/PolkadotVault/Components/Buttons/ConnectivityAlertButton.swift deleted file mode 100644 index 67db66f0fc..0000000000 --- a/ios/PolkadotVault/Components/Buttons/ConnectivityAlertButton.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// ConnectivityAlertButton.swift -// Polkadot Vault -// -// Created by Krzysztof Rodak on 28/12/2022. -// - -import SwiftUI - -struct ConnectivityAlertButton: View { - private let action: () -> Void - private let isConnectivityOn: Bool - - init( - action: @escaping () -> Void, - isConnectivityOn: Bool - ) { - self.action = action - self.isConnectivityOn = isConnectivityOn - } - - var body: some View { - Button( - action: action, - label: { - ZStack { - Circle() - .frame( - width: Sizes.connectivityAlertDiameter, - height: Sizes.connectivityAlertDiameter, - alignment: .center - ) - .foregroundColor(.accentRed400) - if isConnectivityOn { - Image(.connectivityIsOn) - .foregroundColor(.accentForegroundText) - } else { - Image(.connectivityWasOn) - .foregroundColor(.accentForegroundText) - } - } - } - ) - } -} diff --git a/ios/PolkadotVault/Components/Camera/CameraPreview.swift b/ios/PolkadotVault/Components/Camera/CameraPreview.swift index 2f35ed8234..a618015053 100644 --- a/ios/PolkadotVault/Components/Camera/CameraPreview.swift +++ b/ios/PolkadotVault/Components/Camera/CameraPreview.swift @@ -20,7 +20,7 @@ struct CameraPreview: UIViewRepresentable { } func makeUIView(context _: UIViewRepresentableContext) -> CameraPreview.UIViewType { - let uiView = CameraPreviewUIView(session: session) + let uiView = CameraPreviewUIView() let previewLayer = AVCaptureVideoPreviewLayer(session: session) previewLayer.videoGravity = .resizeAspectFill uiView.layer.addSublayer(previewLayer) diff --git a/ios/PolkadotVault/Components/Camera/CameraPreviewUIView.swift b/ios/PolkadotVault/Components/Camera/CameraPreviewUIView.swift index c630019ecd..d643f32e8e 100644 --- a/ios/PolkadotVault/Components/Camera/CameraPreviewUIView.swift +++ b/ios/PolkadotVault/Components/Camera/CameraPreviewUIView.swift @@ -11,10 +11,8 @@ import UIKit /// UIKit wrapper for `AVCaptureSession` camera layer final class CameraPreviewUIView: UIView { var videoPreviewLayer: AVCaptureVideoPreviewLayer? - let session: AVCaptureSession - init(session: AVCaptureSession) { - self.session = session + init() { super.init(frame: .zero) } diff --git a/ios/PolkadotVault/Components/Errors/ConnectivityAlertOverlay.swift b/ios/PolkadotVault/Components/Errors/ConnectivityAlertOverlay.swift deleted file mode 100644 index d5f546ee46..0000000000 --- a/ios/PolkadotVault/Components/Errors/ConnectivityAlertOverlay.swift +++ /dev/null @@ -1,84 +0,0 @@ -// -// ConnectivityAlertOverlay.swift -// Polkadot Vault -// -// Created by Krzysztof Rodak on 28/12/2022. -// - -import SwiftUI - -struct ConnectivityAlertOverlay: View { - @StateObject var viewModel: ViewModel - - var body: some View { - VStack(alignment: .trailing) { - if viewModel.isConnectivityAlertOn { - HStack { - Spacer() - ConnectivityAlertButton( - action: viewModel.onTapAction, - isConnectivityOn: viewModel.connectivityMediator.isConnectivityOn - ) - .padding(Spacing.medium) - } - } else { - EmptyView() - } - } - .fullScreenModal( - isPresented: $viewModel.isPresentingConnectivityAlert - ) { - ErrorBottomModal( - viewModel: viewModel.errorModalViewModel(), - isShowingBottomAlert: $viewModel.isPresentingConnectivityAlert - ) - .clearModalBackground() - } - } -} - -extension ConnectivityAlertOverlay { - final class ViewModel: ObservableObject { - @Published var isPresentingConnectivityAlert = false - @Published var isConnectivityAlertOn = false - let connectivityMediator: ConnectivityMediator - private let warningStateMediator: WarningStateMediator - private let cancelBag = CancelBag() - - init( - warningStateMediator: WarningStateMediator = ServiceLocator.warningStateMediator, - connectivityMediator: ConnectivityMediator = ServiceLocator.connectivityMediator - ) { - self.warningStateMediator = warningStateMediator - self.connectivityMediator = connectivityMediator - listenToConnectivityUpdates() - } - - func listenToConnectivityUpdates() { - warningStateMediator.$alert.sink { - self.isConnectivityAlertOn = $0 - } - .store(in: cancelBag) - connectivityMediator.$isConnectivityOn.sink { - guard $0 else { return } - self.isConnectivityAlertOn = $0 - } - .store(in: cancelBag) - } - - func errorModalViewModel() -> ErrorBottomModalViewModel { - connectivityMediator.isConnectivityOn ? - .connectivityOn() : - // swiftformat:disable all - .connectivityWasOn(continueAction: self.onTapContinueAction()) - } - - func onTapAction() { - isPresentingConnectivityAlert = true - } - - func onTapContinueAction() { - warningStateMediator.resetConnectivityWarnings() - } - } -} diff --git a/ios/PolkadotVault/Components/QRCode/AnimatedQRCodeView.swift b/ios/PolkadotVault/Components/QRCode/AnimatedQRCodeView.swift index ec1124dbc9..018e4031e2 100644 --- a/ios/PolkadotVault/Components/QRCode/AnimatedQRCodeView.swift +++ b/ios/PolkadotVault/Components/QRCode/AnimatedQRCodeView.swift @@ -23,7 +23,6 @@ struct AnimatedQRCodeView: View { static let qrCodeWidthForLargerDevices: CGFloat = 320 } - @EnvironmentObject var applicationStatePublisher: ApplicationStatePublisher @Binding var viewModel: AnimatedQRCodeViewModel private let qrCodesGenerator: QRCodeImageGenerator @State private var images: [UIImage] = [] diff --git a/ios/PolkadotVault/Core/Connectivity/ConnectivityMediator.swift b/ios/PolkadotVault/Core/Connectivity/ConnectivityMediator.swift index da62fc3474..cad128fdaf 100644 --- a/ios/PolkadotVault/Core/Connectivity/ConnectivityMediator.swift +++ b/ios/PolkadotVault/Core/Connectivity/ConnectivityMediator.swift @@ -9,16 +9,13 @@ import Foundation final class ConnectivityMediator: ObservableObject { private let connectivityMonitor: ConnectivityMonitoring - private let databaseMediator: DatabaseMediating @Published private(set) var isConnectivityOn: Bool = false init( - connectivityMonitor: ConnectivityMonitoring = ConnectivityMonitoringAssembler().assemble(), - databaseMediator: DatabaseMediating = DatabaseMediator() + connectivityMonitor: ConnectivityMonitoring = ConnectivityMonitoringAssembler().assemble() ) { self.connectivityMonitor = connectivityMonitor - self.databaseMediator = databaseMediator setUpConnectivityMonitoring() } } @@ -27,9 +24,6 @@ private extension ConnectivityMediator { func setUpConnectivityMonitoring() { connectivityMonitor.startMonitoring { [weak self] isConnected in guard let self else { return } - if isConnected, databaseMediator.isDatabaseAvailable() { - try? historyDeviceWasOnline() - } isConnectivityOn = isConnected } } diff --git a/ios/PolkadotVault/Core/Data/AppState.swift b/ios/PolkadotVault/Core/Data/AppState.swift index e9d07e0e00..a451d3207f 100644 --- a/ios/PolkadotVault/Core/Data/AppState.swift +++ b/ios/PolkadotVault/Core/Data/AppState.swift @@ -19,16 +19,13 @@ extension AppState { final class UserData { var allNetworks: [MmNetwork] = [] var selectedNetworks: [MmNetwork] = [] - @Published var keyListRequiresUpdate: Bool init( allNetworks: [MmNetwork] = [], - selectedNetworks: [MmNetwork] = [], - keyListRequiresUpdate: Bool = false + selectedNetworks: [MmNetwork] = [] ) { self.allNetworks = allNetworks self.selectedNetworks = selectedNetworks - _keyListRequiresUpdate = .init(initialValue: keyListRequiresUpdate) } } } diff --git a/ios/PolkadotVault/Core/JailbreakDetectionPublisher.swift b/ios/PolkadotVault/Core/JailbreakDetectionPublisher.swift index 2a145f3ad6..73c79ed8c6 100644 --- a/ios/PolkadotVault/Core/JailbreakDetectionPublisher.swift +++ b/ios/PolkadotVault/Core/JailbreakDetectionPublisher.swift @@ -23,7 +23,9 @@ final class JailbreakDetectionPublisher: ObservableObject { .sink { self.isJailbroken = $0 } .store(in: cancelBag) } +} +private extension JailbreakDetectionPublisher { func detectJailbreak() -> AnyPublisher { Future { promise in let isJailbroken = [ @@ -36,17 +38,17 @@ final class JailbreakDetectionPublisher: ObservableObject { }.eraseToAnyPublisher() } - private func checkJailbreakFilesAndDirectories() -> Bool { + func checkJailbreakFilesAndDirectories() -> Bool { Constants.jailbreakApplicationPaths .contains { FileManager.default.fileExists(atPath: $0) } } - private func checkSystemModifications() -> Bool { + func checkSystemModifications() -> Bool { Constants.inaccessibleSystemPaths .contains { FileManager.default.fileExists(atPath: $0) } } - private func checkJailbreakTools() -> Bool { + func checkJailbreakTools() -> Bool { let jailbreakTools = [ Constants.jailbreakToolCydia, Constants.jailbreakToolIcy, @@ -56,7 +58,7 @@ final class JailbreakDetectionPublisher: ObservableObject { return jailbreakTools.contains { UIApplication.shared.canOpenURL($0!) } } - private func checkEnvironmentVariables() -> Bool { + func checkEnvironmentVariables() -> Bool { let environmentVariables = [ Constants.environmentVariableDyldInsertLibraries, Constants.environmentVariableDyldPrintToFile, diff --git a/ios/PolkadotVault/Core/ServiceLocator.swift b/ios/PolkadotVault/Core/ServiceLocator.swift index eba202f593..a8f1e17449 100644 --- a/ios/PolkadotVault/Core/ServiceLocator.swift +++ b/ios/PolkadotVault/Core/ServiceLocator.swift @@ -12,7 +12,6 @@ enum ServiceLocator { /// As long as we have `SharedDataModel` as tech debt, we need to have seeds mediator as singleton which is /// unfortunate but necessary for now; to be able to use it outside SwiftUI views it can't be `@EnvironmentalObject` static var seedsMediator: SeedsMediating = SeedsMediator() - static var warningStateMediator: WarningStateMediator = WarningStateMediator() static var connectivityMediator: ConnectivityMediator = ConnectivityMediator() static var authenticationStateMediator: AuthenticatedStateMediator = AuthenticatedStateMediator() static var onboardingMediator: OnboardingMediator = OnboardingMediator() diff --git a/ios/PolkadotVault/Design/Heights.swift b/ios/PolkadotVault/Design/Heights.swift index 60f2a098bc..f004278bae 100644 --- a/ios/PolkadotVault/Design/Heights.swift +++ b/ios/PolkadotVault/Design/Heights.swift @@ -97,8 +97,6 @@ enum Sizes { static let chevronCircleButton: CGFloat = 28 static let rightChevronContainerSize: CGFloat = 28 static let roundedQuestionmark: CGFloat = 24 - /// Diameter for connectivity alert button, 56pt - static let connectivityAlertDiameter: CGFloat = 56 static let pointCircle: CGFloat = 32 static let signSpecsIdenticonSize: CGFloat = 36 static let chevronDownKeyDetails: CGFloat = 16 diff --git a/ios/PolkadotVault/Modals/Errors/ErrorBottomModal.swift b/ios/PolkadotVault/Modals/Errors/ErrorBottomModal.swift index 7712024c31..ea77240e76 100644 --- a/ios/PolkadotVault/Modals/Errors/ErrorBottomModal.swift +++ b/ios/PolkadotVault/Modals/Errors/ErrorBottomModal.swift @@ -126,15 +126,6 @@ struct ErrorBottomModal: View { struct ErrorBottomModal_Previews: PreviewProvider { static var previews: some View { Group { - // Connectivity - ErrorBottomModal( - viewModel: .connectivityOn(), - isShowingBottomAlert: Binding.constant(true) - ) - ErrorBottomModal( - viewModel: .connectivityWasOn(backAction: {}(), continueAction: {}()), - isShowingBottomAlert: Binding.constant(true) - ) // General Error ErrorBottomModal( viewModel: .alertError( diff --git a/ios/PolkadotVault/Modals/Errors/ErrorBottomModalViewModel.swift b/ios/PolkadotVault/Modals/Errors/ErrorBottomModalViewModel.swift index 541bbd8783..ab42618196 100644 --- a/ios/PolkadotVault/Modals/Errors/ErrorBottomModalViewModel.swift +++ b/ios/PolkadotVault/Modals/Errors/ErrorBottomModalViewModel.swift @@ -119,28 +119,6 @@ struct ErrorBottomModalViewModel { ) } - static func connectivityOn(_ action: @escaping @autoclosure () -> Void = {}()) -> ErrorBottomModalViewModel { - ErrorBottomModalViewModel( - icon: Image(.wifiOn), - title: Localizable.Connectivity.Label.title.string, - content: Localizable.Connectivity.Label.content.string, - secondaryAction: .init(label: Localizable.ErrorModal.Action.ok.key, action: action) - ) - } - - static func connectivityWasOn( - backAction: @escaping @autoclosure () -> Void = {}(), - continueAction: @escaping @autoclosure () -> Void - ) -> ErrorBottomModalViewModel { - ErrorBottomModalViewModel( - icon: Image(.wifiWasOn), - title: Localizable.PastConnectivity.Label.title.string, - content: Localizable.PastConnectivity.Label.content.string, - primaryAction: .init(label: Localizable.PastConnectivity.Action.back.key, action: backAction), - tertiaryAction: .init(label: Localizable.PastConnectivity.Action.continue.key, action: continueAction) - ) - } - static func alertError( message: String, _ action: @escaping @autoclosure () -> Void = {}() diff --git a/ios/PolkadotVault/Resources/en.lproj/Localizable.strings b/ios/PolkadotVault/Resources/en.lproj/Localizable.strings index db8b1fbd23..31f99adf78 100644 --- a/ios/PolkadotVault/Resources/en.lproj/Localizable.strings +++ b/ios/PolkadotVault/Resources/en.lproj/Localizable.strings @@ -171,14 +171,6 @@ "PublicKeyDetailsModal.Confirmation.Action.Remove" = "Remove Key"; "PublicKeyDetailsModal.Confirmation.Snackbar" = "Key Has Been Removed"; -"Connectivity.Label.Title" = "Network Connected"; -"Connectivity.Label.Content" = "Polkadot Vault detects currently connected network; please enable airplane mode, disconnect all cables and handle security breach according with your security protocol."; -"Connectivity.Action.Ok" = "Got It"; -"PastConnectivity.Label.Title" = "Network Was Connected!"; -"PastConnectivity.Label.Content" = "Your Polkadot Vault device has connected to a WIFI, tether or Bluetooth network since your last acknowledgement and should be considered unsafe to use."; -"PastConnectivity.Action.Back" = "Go Back"; -"PastConnectivity.Action.Continue" = "Acknowledge and Proceed"; - "BackupModal.Label.Secret" = "Secret Recovery Phrase"; "BackupModal.Label.Derived" = "Derived keys"; "BackupModal.Label.QRCode" = "Backup with QR Code"; @@ -529,13 +521,15 @@ "Onboarding.Screenshots.Label.Confirmation" = "I'm aware of the risks involved in taking screenshots"; "Onboarding.Screenshots.Action.Next" = "Next"; -"Onboarding.Airgap.Label.Title" = "Set Up\nAir Gap Mode"; -"Onboarding.Airgap.Label.Content" = "Please follow these steps to enable Air Gap mode and keep it permanently enabled."; -"Onboarding.Airgap.Label.Airplane" = "Enable Airplane Mode"; -"Onboarding.Airgap.Label.Wifi" = "Turn off WiFi Connection"; -"Onboarding.Airgap.Label.Cables" = "Disconnect all cables"; -"Onboarding.Airgap.Label.Cables.Confirmation" = "I confirm that all Cables are Disconnected"; -"Onboarding.Airgap.Action.Next" = "Next"; +"Airgap.Label.Title.Setup" = "Set Up\nAir Gap Mode"; +"Airgap.Label.Title.Broken" = "Please Enable\nAir Gap Mode"; +"Airgap.Label.Content" = "Please follow these steps to enable Air Gap mode and keep it permanently enabled."; +"Airgap.Label.Airplane" = "Enable Airplane Mode"; +"Airgap.Label.Wifi" = "Turn off WiFi Connection"; +"Airgap.Label.Cables" = "Disconnect all cables"; +"Airgap.Label.Cables.Confirmation" = "I confirm that all Cables are Disconnected"; +"Airgap.Action.Next" = "Next"; +"Airgap.Action.Done" = "Done"; "Onboarding.SetUpNetworks.Label.Title" = "Set Up Networks On Which You Will Sign Transactions"; "Onboarding.SetUpNetworks.Label.Content" = "Polkadot Vault is a fully Decentralised wallet, which means users have to manage networks themselves. Follow the tutorial to learn more."; diff --git a/ios/PolkadotVault/Screens/Containers/AuthenticatedScreenContainer.swift b/ios/PolkadotVault/Screens/Containers/AuthenticatedScreenContainer.swift index d96fe77c24..668f53665d 100644 --- a/ios/PolkadotVault/Screens/Containers/AuthenticatedScreenContainer.swift +++ b/ios/PolkadotVault/Screens/Containers/AuthenticatedScreenContainer.swift @@ -9,7 +9,6 @@ import Combine import SwiftUI struct AuthenticatedScreenContainer: View { - @EnvironmentObject private var connectivityMediator: ConnectivityMediator @EnvironmentObject private var navigation: NavigationCoordinator @EnvironmentObject private var appState: AppState @StateObject var viewModel: ViewModel diff --git a/ios/PolkadotVault/Screens/Containers/MainScreenContainer.swift b/ios/PolkadotVault/Screens/Containers/MainScreenContainer.swift index 857ecc3613..6b663b9b27 100644 --- a/ios/PolkadotVault/Screens/Containers/MainScreenContainer.swift +++ b/ios/PolkadotVault/Screens/Containers/MainScreenContainer.swift @@ -36,6 +36,11 @@ struct MainScreenContainer: View { ) .clearModalBackground() } + .fullScreenModal( + isPresented: $viewModel.isPresentingNoAirgap + ) { + NoAirgapView(viewModel: viewModel.noAirgapViewModel()) + } } } @@ -54,9 +59,12 @@ extension MainScreenContainer { private let passwordProtectionStatePublisher: PasswordProtectionStatePublisher private let databaseVersionMediator: DatabaseVersionMediator private let appLaunchMediator: AppLaunchMediating + private let connectivityMediator: ConnectivityMediator + private let cancelBag = CancelBag() @Published var viewState: ViewState = .deviceLocked @Published var isPresentingError: Bool = false + @Published var isPresentingNoAirgap: Bool = false @Published var presentableError: ErrorBottomModalViewModel = .alertError(message: "") init( @@ -64,67 +72,83 @@ extension MainScreenContainer { onboardingMediator: OnboardingMediator = ServiceLocator.onboardingMediator, passwordProtectionStatePublisher: PasswordProtectionStatePublisher = PasswordProtectionStatePublisher(), databaseVersionMediator: DatabaseVersionMediator = DatabaseVersionMediator(), - appLaunchMediator: AppLaunchMediating = AppLaunchMediator() + appLaunchMediator: AppLaunchMediating = AppLaunchMediator(), + connectivityMediator: ConnectivityMediator = ServiceLocator.connectivityMediator ) { self.authenticationStateMediator = authenticationStateMediator self.onboardingMediator = onboardingMediator self.passwordProtectionStatePublisher = passwordProtectionStatePublisher self.databaseVersionMediator = databaseVersionMediator self.appLaunchMediator = appLaunchMediator + self.connectivityMediator = connectivityMediator initialiseAppRun() } - private func initialiseAppRun() { - appLaunchMediator.finaliseInitialisation { result in - switch result { - case .success: - self.checkInitialState() - case let .failure(error): - self.presentableError = .alertError(message: error.localizedDescription) - self.isPresentingError = true - } + func noAirgapViewModel() -> NoAirgapView.ViewModel { + .init(mode: .noAirgap) { + self.isPresentingNoAirgap = false } } + } +} - private func checkInitialState() { - databaseVersionMediator.checkDatabaseScheme { result in - switch result { - case .success: - self.listenToStateChanges() - case let .failure(error): - switch error { - case .invalidVersion: - self.viewState = .updateRequired - case let .error(serviceError): - /// If DB version check was unavailable, assume user needs to update - /// If that's not the case (i.e. there is no newer version), app restart will fix it so should - /// be ok - self.viewState = .updateRequired - self.presentableError = .alertError(message: serviceError.localizedDescription) - self.isPresentingError = true - } - } +private extension MainScreenContainer.ViewModel { + func initialiseAppRun() { + appLaunchMediator.finaliseInitialisation { result in + switch result { + case .success: + self.checkInitialState() + case let .failure(error): + self.presentableError = .alertError(message: error.localizedDescription) + self.isPresentingError = true } } + } - private func listenToStateChanges() { - Publishers.CombineLatest3( - onboardingMediator.$onboardingDone, - authenticationStateMediator.$authenticated, - passwordProtectionStatePublisher.$isProtected - ) - .map { - let (onboardingDone, authenticated, isProtected) = $0 - if !isProtected { - return .noPincode - } - if !onboardingDone { - return .onboarding + func checkInitialState() { + databaseVersionMediator.checkDatabaseScheme { result in + switch result { + case .success: + self.listenToStateChanges() + case let .failure(error): + switch error { + case .invalidVersion: + self.viewState = .updateRequired + case let .error(serviceError): + /// If DB version check was unavailable, assume user needs to update + /// If that's not the case (i.e. there is no newer version), app restart will fix it so should + /// be ok + self.viewState = .updateRequired + self.presentableError = .alertError(message: serviceError.localizedDescription) + self.isPresentingError = true } - return authenticated ? .authenticated : .deviceLocked } - .assign(to: \.viewState, on: self) - .store(in: cancelBag) } } + + func listenToStateChanges() { + Publishers.CombineLatest3( + onboardingMediator.$onboardingDone, + authenticationStateMediator.$authenticated, + passwordProtectionStatePublisher.$isProtected + ) + .map { + let (onboardingDone, authenticated, isProtected) = $0 + if !isProtected { + return .noPincode + } + if !onboardingDone { + return .onboarding + } + return authenticated ? .authenticated : .deviceLocked + } + .assign(to: \.viewState, on: self) + .store(in: cancelBag) + connectivityMediator.$isConnectivityOn + .sink(receiveValue: { newValue in + guard !self.isPresentingNoAirgap, newValue else { return } + self.isPresentingNoAirgap = newValue + }) + .store(in: cancelBag) + } } diff --git a/ios/PolkadotVault/Screens/Errors/UnlockDeviceView.swift b/ios/PolkadotVault/Screens/Errors/UnlockDeviceView.swift index 18f6735d1e..011dc6f602 100644 --- a/ios/PolkadotVault/Screens/Errors/UnlockDeviceView.swift +++ b/ios/PolkadotVault/Screens/Errors/UnlockDeviceView.swift @@ -41,19 +41,15 @@ struct UnlockDeviceView: View { extension UnlockDeviceView { final class ViewModel: ObservableObject { private let seedsMediator: SeedsMediating - private let warningStateMediator: WarningStateMediator init( - seedsMediator: SeedsMediating = ServiceLocator.seedsMediator, - warningStateMediator: WarningStateMediator = ServiceLocator.warningStateMediator + seedsMediator: SeedsMediating = ServiceLocator.seedsMediator ) { self.seedsMediator = seedsMediator - self.warningStateMediator = warningStateMediator } func onUnlockTap() { seedsMediator.refreshSeeds() - warningStateMediator.updateWarnings() } } } diff --git a/ios/PolkadotVault/Screens/KeyDetails/Views/KeyDetails+ViewModel.swift b/ios/PolkadotVault/Screens/KeyDetails/Views/KeyDetails+ViewModel.swift index ac0d34c87c..17215a56f3 100644 --- a/ios/PolkadotVault/Screens/KeyDetails/Views/KeyDetails+ViewModel.swift +++ b/ios/PolkadotVault/Screens/KeyDetails/Views/KeyDetails+ViewModel.swift @@ -22,7 +22,6 @@ extension KeyDetailsView { final class ViewModel: ObservableObject { let keyDetailsService: KeyDetailsService private let networksService: GetManagedNetworksService - private let warningStateMediator: WarningStateMediator private let cancelBag = CancelBag() private let exportPrivateKeyService: PrivateKeyQRCodeService @@ -38,7 +37,6 @@ extension KeyDetailsView { @Published var isShowingActionSheet = false @Published var isShowingRemoveConfirmation = false @Published var isShowingBackupModal = false - @Published var isPresentingConnectivityAlert = false @Published var isPresentingExportKeySelection = false @Published var isPresentingRootDetails = false @Published var isPresentingKeyDetails = false @@ -79,7 +77,6 @@ extension KeyDetailsView { keyDetailsService: KeyDetailsService = KeyDetailsService(), networksService: GetManagedNetworksService = GetManagedNetworksService(), keyDetailsActionsService: KeyDetailsActionService = KeyDetailsActionService(), - warningStateMediator: WarningStateMediator = ServiceLocator.warningStateMediator, appState: AppState = ServiceLocator.appState, seedsMediator: SeedsMediating = ServiceLocator.seedsMediator ) { @@ -88,7 +85,6 @@ extension KeyDetailsView { self.keyDetailsService = keyDetailsService self.networksService = networksService self.keyDetailsActionsService = keyDetailsActionsService - self.warningStateMediator = warningStateMediator self.appState = appState self.seedsMediator = seedsMediator _keyName = .init(initialValue: initialKeyName) @@ -329,11 +325,6 @@ extension KeyDetailsView.ViewModel { } } } - - func onConnectivityAlertTap() { - warningStateMediator.resetConnectivityWarnings() - shouldPresentBackupModal.toggle() - } } // MARK: - Modals @@ -344,24 +335,19 @@ extension KeyDetailsView.ViewModel { } func onActionSheetDismissal() { - let isAlertVisible = warningStateMediator.alert if shouldPresentRemoveConfirmationModal { shouldPresentRemoveConfirmationModal.toggle() isShowingRemoveConfirmation.toggle() } if shouldPresentBackupModal { shouldPresentBackupModal.toggle() - if isAlertVisible { - isPresentingConnectivityAlert.toggle() - } else { - keyDetailsActionsService.performBackupSeed(seedName: keyName) { result in - switch result { - case .success: - self.tryToPresentBackupModal() - case let .failure(error): - self.presentableError = .alertError(message: error.localizedDescription) - self.isPresentingError = true - } + keyDetailsActionsService.performBackupSeed(seedName: keyName) { result in + switch result { + case .success: + self.tryToPresentBackupModal() + case let .failure(error): + self.presentableError = .alertError(message: error.localizedDescription) + self.isPresentingError = true } } } diff --git a/ios/PolkadotVault/Screens/KeyDetails/Views/KeyDetailsView.swift b/ios/PolkadotVault/Screens/KeyDetails/Views/KeyDetailsView.swift index 24ffd3f451..9e5fa17176 100644 --- a/ios/PolkadotVault/Screens/KeyDetails/Views/KeyDetailsView.swift +++ b/ios/PolkadotVault/Screens/KeyDetails/Views/KeyDetailsView.swift @@ -9,7 +9,6 @@ import SwiftUI struct KeyDetailsView: View { @StateObject var viewModel: ViewModel - @EnvironmentObject private var connectivityMediator: ConnectivityMediator var body: some View { NavigationView { @@ -43,9 +42,6 @@ struct KeyDetailsView: View { viewModel.onAppear() } .background(.backgroundPrimary) - VStack(spacing: 0) { - ConnectivityAlertOverlay(viewModel: .init()) - } HStack(alignment: .center) { Spacer() QRCodeButton(action: viewModel.onQRScannerTap) @@ -128,21 +124,6 @@ struct KeyDetailsView: View { EmptyView() } } - .fullScreenModal( - isPresented: $viewModel.isPresentingConnectivityAlert, - onDismiss: { - // iOS 15 handling of following .fullscreen presentation after dismissal, we need to dispatch this async - DispatchQueue.main.async { viewModel.onActionSheetDismissal() } - } - ) { - ErrorBottomModal( - viewModel: connectivityMediator.isConnectivityOn ? .connectivityOn() : .connectivityWasOn( - continueAction: viewModel.onConnectivityAlertTap() - ), - isShowingBottomAlert: $viewModel.isPresentingConnectivityAlert - ) - .clearModalBackground() - } .fullScreenModal( isPresented: $viewModel.isShowingKeysExportModal ) { diff --git a/ios/PolkadotVault/Screens/Logs/Views/LogsListView.swift b/ios/PolkadotVault/Screens/Logs/Views/LogsListView.swift index 95a31c2596..3ae70eb323 100644 --- a/ios/PolkadotVault/Screens/Logs/Views/LogsListView.swift +++ b/ios/PolkadotVault/Screens/Logs/Views/LogsListView.swift @@ -40,7 +40,6 @@ struct LogsListView: View { } } .background(.backgroundPrimary) - ConnectivityAlertOverlay(viewModel: .init()) } .onAppear { viewModel.loadData() diff --git a/ios/PolkadotVault/Screens/Onboarding/Airgap/OnboardingAirgapView.swift b/ios/PolkadotVault/Screens/Onboarding/Airgap/NoAirgapView.swift similarity index 84% rename from ios/PolkadotVault/Screens/Onboarding/Airgap/OnboardingAirgapView.swift rename to ios/PolkadotVault/Screens/Onboarding/Airgap/NoAirgapView.swift index 512513e6d3..fb5a9dd058 100644 --- a/ios/PolkadotVault/Screens/Onboarding/Airgap/OnboardingAirgapView.swift +++ b/ios/PolkadotVault/Screens/Onboarding/Airgap/NoAirgapView.swift @@ -1,5 +1,5 @@ // -// OnboardingAirgapView.swift +// NoAirgapView.swift // NativeSigner // // Created by Krzysztof Rodak on 15/02/2023. @@ -7,7 +7,7 @@ import SwiftUI -struct OnboardingAirgapView: View { +struct NoAirgapView: View { @StateObject var viewModel: ViewModel var body: some View { @@ -15,13 +15,13 @@ struct OnboardingAirgapView: View { ScrollView { VStack(alignment: .center, spacing: 0) { // Header text - Localizable.Onboarding.Airgap.Label.title.text + Text(viewModel.title) .font(PrimaryFont.titleL.font) .foregroundColor(.textAndIconsPrimary) .multilineTextAlignment(.center) .padding(.top, Spacing.extraLarge) .padding(.horizontal, Spacing.large) - Localizable.Onboarding.Airgap.Label.content.text + Localizable.Airgap.Label.content.text .font(PrimaryFont.bodyM.font) .foregroundColor(.textAndIconsTertiary) .multilineTextAlignment(.center) @@ -48,7 +48,7 @@ struct OnboardingAirgapView: View { Image(.airgapCables) .padding(.leading, Spacing.extraSmall) .foregroundColor(.textAndIconsTertiary) - Localizable.Onboarding.Airgap.Label.cables.text + Localizable.Airgap.Label.cables.text .foregroundColor(.textAndIconsTertiary) .font(PrimaryFont.bodyL.font) } @@ -65,7 +65,7 @@ struct OnboardingAirgapView: View { } } .padding(.leading, Spacing.extraSmall) - Localizable.Onboarding.Airgap.Label.Cables.confirmation.text + Localizable.Airgap.Label.Cables.confirmation.text .multilineTextAlignment(.leading) .fixedSize(horizontal: false, vertical: true) .foregroundColor(.textAndIconsPrimary) @@ -85,7 +85,7 @@ struct OnboardingAirgapView: View { Spacer() PrimaryButton( action: viewModel.onDoneTap, - text: Localizable.Onboarding.Screenshots.Action.next.key, + text: viewModel.actionTitle, style: .primary(isDisabled: $viewModel.isActionDisabled) ) .padding(Spacing.large) @@ -112,7 +112,12 @@ struct OnboardingAirgapView: View { } } -extension OnboardingAirgapView { +extension NoAirgapView { + enum Mode { + case onboarding + case noAirgap + } + struct AirgapComponentStatus: Equatable, Hashable { let component: AirgapComponent let isChecked: Bool @@ -123,15 +128,26 @@ extension OnboardingAirgapView { @Published var isActionDisabled: Bool = true @Published var isAirplaneModeChecked: Bool = false @Published var isWifiChecked: Bool = false + private let mode: Mode private let airgapMediator: AirgapMediating - private let onNextTap: () -> Void + private let onActionTap: () -> Void + var title: String { + mode == .onboarding ? Localizable.Airgap.Label.Title.setup.string : Localizable.Airgap.Label.Title.broken + .string + } + + var actionTitle: LocalizedStringKey { + mode == .onboarding ? Localizable.Airgap.Action.next.key : Localizable.Airgap.Action.done.key + } init( + mode: Mode, airgapMediator: AirgapMediating = AirgapMediatorAssembler().assemble(), - onNextTap: @escaping () -> Void + onActionTap: @escaping () -> Void ) { + self.mode = mode self.airgapMediator = airgapMediator - self.onNextTap = onNextTap + self.onActionTap = onActionTap subscribeToUpdates() } @@ -144,7 +160,7 @@ extension OnboardingAirgapView { } func onDoneTap() { - onNextTap() + onActionTap() } func toggleCheckbox() { @@ -159,10 +175,10 @@ extension OnboardingAirgapView { } #if DEBUG - struct OnboardingAirgapView_Previews: PreviewProvider { + struct NoAirgapView_Previews: PreviewProvider { static var previews: some View { - OnboardingAirgapView( - viewModel: .init(onNextTap: {}) + NoAirgapView( + viewModel: .init(mode: .onboarding, onActionTap: {}) ) .preferredColorScheme(.dark) } diff --git a/ios/PolkadotVault/Screens/Onboarding/Airgap/OnboadingAirgapView+Components.swift b/ios/PolkadotVault/Screens/Onboarding/Airgap/OnboadingAirgapView+Components.swift index 0f8face7f1..906b1f2275 100644 --- a/ios/PolkadotVault/Screens/Onboarding/Airgap/OnboadingAirgapView+Components.swift +++ b/ios/PolkadotVault/Screens/Onboarding/Airgap/OnboadingAirgapView+Components.swift @@ -19,9 +19,9 @@ extension AirgapComponent { var title: String { switch self { case .aiplaneMode: - Localizable.Onboarding.Airgap.Label.airplane.string + Localizable.Airgap.Label.airplane.string case .wifi: - Localizable.Onboarding.Airgap.Label.wifi.string + Localizable.Airgap.Label.wifi.string } } diff --git a/ios/PolkadotVault/Screens/Onboarding/OnboardingState.swift b/ios/PolkadotVault/Screens/Onboarding/OnboardingState.swift index f007b32d9d..cc29d66591 100644 --- a/ios/PolkadotVault/Screens/Onboarding/OnboardingState.swift +++ b/ios/PolkadotVault/Screens/Onboarding/OnboardingState.swift @@ -31,11 +31,11 @@ final class OnboardingStateMachine: ObservableObject { func currentView() -> some View { switch currentState { case .terms: - OnboardingAgreementsView(viewModel: .init(onNextTap: { self.onAgreementNextTap() })) + OnboardingAgreementsView(viewModel: .init { self.onAgreementNextTap() }) case .airgap: - OnboardingAirgapView(viewModel: .init(onNextTap: { self.onAirgapNextTap() })) + NoAirgapView(viewModel: .init(mode: .onboarding) { self.onAirgapNextTap() }) case .screenshots: - OnboardingScreenshotsView(viewModel: .init(onNextTap: { self.onScreenshotNextTap() })) + OnboardingScreenshotsView(viewModel: .init { self.onScreenshotNextTap() }) case .setUpNetworksIntro: SetUpNetworksIntroView( viewModel: .init( diff --git a/ios/PolkadotVault/Screens/PublicKey/KeyDetailsPublicKeyView.swift b/ios/PolkadotVault/Screens/PublicKey/KeyDetailsPublicKeyView.swift index c55340e2eb..a7f374e9f1 100644 --- a/ios/PolkadotVault/Screens/PublicKey/KeyDetailsPublicKeyView.swift +++ b/ios/PolkadotVault/Screens/PublicKey/KeyDetailsPublicKeyView.swift @@ -10,7 +10,6 @@ import SwiftUI struct KeyDetailsPublicKeyView: View { @StateObject var viewModel: ViewModel - @EnvironmentObject private var connectivityMediator: ConnectivityMediator @Environment(\.presentationMode) var presentationMode var body: some View { @@ -122,21 +121,6 @@ struct KeyDetailsPublicKeyView: View { ) .clearModalBackground() } - .fullScreenModal( - isPresented: $viewModel.isPresentingConnectivityAlert, - onDismiss: { - // iOS 15 handling of following .fullscreen presentation after dismissal, we need to dispatch this async - DispatchQueue.main.async { viewModel.checkForActionsPresentation() } - } - ) { - ErrorBottomModal( - viewModel: connectivityMediator.isConnectivityOn ? .connectivityOn() : .connectivityWasOn( - continueAction: viewModel.onConnectivityErrorContinueTap() - ), - isShowingBottomAlert: $viewModel.isPresentingConnectivityAlert - ) - .clearModalBackground() - } .fullScreenModal( isPresented: $viewModel.isPresentingError ) { @@ -229,7 +213,6 @@ extension KeyDetailsPublicKeyView { private let publicKeyDetailsService: PublicKeyDetailsService private let exportPrivateKeyService: ExportPrivateKeyService private let keyDetailsService: KeyDetailsActionService - private let warningStateMediator: WarningStateMediator @Published var keyDetails: MKeyDetails @Published var exportPrivateKeyViewModel: ExportPrivateKeyViewModel! @@ -238,7 +221,6 @@ extension KeyDetailsPublicKeyView { @Published var isShowingActionSheet = false @Published var isPresentingExportKeysWarningModal = false @Published var isPresentingExportKeysModal = false - @Published var isPresentingConnectivityAlert = false @Published var shouldPresentExportKeysWarningModal = false @Published var shouldPresentExportKeysModal = false @Published var shouldPresentRemoveConfirmationModal = false @@ -262,7 +244,6 @@ extension KeyDetailsPublicKeyView { publicKeyDetailsService: PublicKeyDetailsService = PublicKeyDetailsService(), exportPrivateKeyService: ExportPrivateKeyService = ExportPrivateKeyService(), keyDetailsService: KeyDetailsActionService = KeyDetailsActionService(), - warningStateMediator: WarningStateMediator = ServiceLocator.warningStateMediator, onCompletion: @escaping (OnCompletionAction) -> Void ) { _keyDetails = .init(initialValue: keyDetails) @@ -270,7 +251,6 @@ extension KeyDetailsPublicKeyView { self.publicKeyDetailsService = publicKeyDetailsService self.exportPrivateKeyService = exportPrivateKeyService self.keyDetailsService = keyDetailsService - self.warningStateMediator = warningStateMediator self.onCompletion = onCompletion _renderable = .init(initialValue: KeyDetailsPublicKeyViewModel(keyDetails)) } @@ -282,18 +262,14 @@ extension KeyDetailsPublicKeyView { func checkForActionsPresentation() { if shouldPresentExportKeysWarningModal { shouldPresentExportKeysWarningModal = false - if warningStateMediator.alert { - isPresentingConnectivityAlert = true - } else { - exportPrivateKeyService.exportPrivateKey(keyDetails) { result in - switch result { - case let .success(model): - self.exportPrivateKeyViewModel = model - self.isPresentingExportKeysWarningModal = true - case let .failure(error): - self.presentableError = .alertError(message: error.message) - self.isPresentingError = true - } + exportPrivateKeyService.exportPrivateKey(keyDetails) { result in + switch result { + case let .success(model): + self.exportPrivateKeyViewModel = model + self.isPresentingExportKeysWarningModal = true + case let .failure(error): + self.presentableError = .alertError(message: error.message) + self.isPresentingError = true } } } @@ -326,11 +302,6 @@ extension KeyDetailsPublicKeyView { } } - func onConnectivityErrorContinueTap() { - warningStateMediator.resetConnectivityWarnings() - shouldPresentExportKeysWarningModal.toggle() - } - func onRemoveKeyTap() { publicKeyDetailsService.forgetSingleKey( address: addressKey, diff --git a/ios/PolkadotVault/Screens/Settings/SettingsView.swift b/ios/PolkadotVault/Screens/Settings/SettingsView.swift index e60fbcff25..53c4330fcf 100644 --- a/ios/PolkadotVault/Screens/Settings/SettingsView.swift +++ b/ios/PolkadotVault/Screens/Settings/SettingsView.swift @@ -46,10 +46,6 @@ struct SettingsView: View { .navigationBarHidden(true), isActive: $viewModel.isDetailsPresented ) { EmptyView() } - VStack(spacing: 0) { - ConnectivityAlertOverlay(viewModel: .init()) - } - .background(.backgroundPrimary) } .onAppear { viewModel.loadData() diff --git a/ios/PolkadotVault/Screens/Settings/Subviews/Backup/BackupSelectKeyView.swift b/ios/PolkadotVault/Screens/Settings/Subviews/Backup/BackupSelectKeyView.swift index 5ca2b5f3e3..f5864a8b83 100644 --- a/ios/PolkadotVault/Screens/Settings/Subviews/Backup/BackupSelectKeyView.swift +++ b/ios/PolkadotVault/Screens/Settings/Subviews/Backup/BackupSelectKeyView.swift @@ -50,17 +50,6 @@ struct BackupSelectKeyView: View { ) .clearModalBackground() } - .fullScreenModal( - isPresented: $viewModel.isPresentingConnectivityAlert - ) { - ErrorBottomModal( - viewModel: viewModel.connectivityMediator.isConnectivityOn ? .connectivityOn() : .connectivityWasOn( - continueAction: viewModel.onConnectivityWarningTap() - ), - isShowingBottomAlert: $viewModel.isPresentingConnectivityAlert - ) - .clearModalBackground() - } } @ViewBuilder @@ -85,43 +74,20 @@ struct BackupSelectKeyView: View { extension BackupSelectKeyView { final class ViewModel: ObservableObject { @Published var isPresentingBackupModal = false - @Published var isPresentingConnectivityAlert = false @Published var seedPhraseToPresent: SettingsBackupViewModel = .init( keyName: "", seedPhrase: .init(seedPhrase: "") ) - private var awaitingSeedName: String? - weak var connectivityMediator: ConnectivityMediator! let seedsMediator: SeedsMediating - private let warningStateMediator: WarningStateMediator init( - seedsMediator: SeedsMediating = ServiceLocator.seedsMediator, - warningStateMediator: WarningStateMediator = ServiceLocator.warningStateMediator, - connectivityMediator: ConnectivityMediator = ServiceLocator.connectivityMediator + seedsMediator: SeedsMediating = ServiceLocator.seedsMediator ) { self.seedsMediator = seedsMediator - self.warningStateMediator = warningStateMediator - self.connectivityMediator = connectivityMediator } func onSeedNameTap(_ seedName: String) { - if connectivityMediator.isConnectivityOn || warningStateMediator.alert { - isPresentingConnectivityAlert = true - awaitingSeedName = seedName - } else { - presentBackupModal(seedName) - } - } - - func onConnectivityWarningTap() { - warningStateMediator.resetConnectivityWarnings() - isPresentingConnectivityAlert = false - guard let awaitingSeedName else { return } - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { - self.presentBackupModal(awaitingSeedName) - self.isPresentingBackupModal = true - } + presentBackupModal(seedName) } private func presentBackupModal(_ seedName: String) { @@ -132,7 +98,6 @@ extension BackupSelectKeyView { ) ) isPresentingBackupModal = true - awaitingSeedName = nil } } } diff --git a/ios/PolkadotVault/StateMediators/OnboardingMediator.swift b/ios/PolkadotVault/StateMediators/OnboardingMediator.swift index 5aa78609e7..f11966257f 100644 --- a/ios/PolkadotVault/StateMediators/OnboardingMediator.swift +++ b/ios/PolkadotVault/StateMediators/OnboardingMediator.swift @@ -12,19 +12,16 @@ final class OnboardingMediator: ObservableObject { private let navigationInitialisationService: NavigationInitialisationService private let seedsMediator: SeedsMediating private let databaseMediator: DatabaseMediating - private let warningStateMediator: WarningStateMediator @Published var onboardingDone: Bool = false init( navigationInitialisationService: NavigationInitialisationService = NavigationInitialisationService(), seedsMediator: SeedsMediating = ServiceLocator.seedsMediator, - databaseMediator: DatabaseMediating = DatabaseMediator(), - warningStateMediator: WarningStateMediator = ServiceLocator.warningStateMediator + databaseMediator: DatabaseMediating = DatabaseMediator() ) { self.navigationInitialisationService = navigationInitialisationService self.seedsMediator = seedsMediator self.databaseMediator = databaseMediator - self.warningStateMediator = warningStateMediator onboardingDone = databaseMediator.isDatabaseAvailable() } @@ -35,7 +32,6 @@ final class OnboardingMediator: ObservableObject { guard let self else { return } seedsMediator.refreshSeeds() onboardingDone = true - warningStateMediator.updateWarnings() } } } diff --git a/ios/PolkadotVault/StateMediators/WarningStateMediator.swift b/ios/PolkadotVault/StateMediators/WarningStateMediator.swift deleted file mode 100644 index c7357c6d70..0000000000 --- a/ios/PolkadotVault/StateMediators/WarningStateMediator.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// WarningStateMediator.swift -// PolkadotVault -// -// Created by Krzysztof Rodak on 10/03/2023. -// - -import Foundation - -final class WarningStateMediator: ObservableObject { - @Published var alert: Bool = false - - private let connectivityMediator: ConnectivityMediator - - init( - connectivityMediator: ConnectivityMediator = ServiceLocator.connectivityMediator - ) { - self.connectivityMediator = connectivityMediator - setUpConnectivityMonitoring() - } - - func updateWarnings() { - do { - alert = try historyGetWarnings() - } catch { - alert = true - } - } - - func resetConnectivityWarnings() { - try? historyAcknowledgeWarnings() - _ = try? historyGetWarnings() - alert = false - } -} - -private extension WarningStateMediator { - func setUpConnectivityMonitoring() { - alert = connectivityMediator.isConnectivityOn - } -}