From 71143bea12826f598307a4d6b09f76ba9d812fa9 Mon Sep 17 00:00:00 2001 From: Ermat Date: Thu, 7 Sep 2023 15:30:58 +0600 Subject: [PATCH] Refactor BtcBlockchainSettings module to SwiftUI --- .../project.pbxproj | 65 +++++++- .../Models/BtcRestoreMode.swift | 6 +- .../BtcBlockchainSettingsModule.swift | 6 +- .../BtcBlockchainSettingsService.swift | 29 +--- .../BtcBlockchainSettingsView.swift | 76 ++++++++++ .../BtcBlockchainSettingsViewController.swift | 141 ------------------ .../BtcBlockchainSettingsViewModel.swift | 57 ++----- .../Modules/Info/InfoModule.swift | 20 ++- .../ExperimentalFeaturesView.swift | 2 +- .../SimpleActivate/SimpleActivateView.swift | 13 +- .../UserInterface/SwiftUI/ClickableRow.swift | 16 ++ .../UserInterface/SwiftUI/ListSection.swift | 14 +- .../SwiftUI/ListSectionFooter.swift | 12 ++ .../SwiftUI/ListSectionHeader.swift | 13 ++ .../SwiftUI/ListSectionInfoHeader.swift | 24 +++ .../UserInterface/SwiftUI/NavigationRow.swift | 2 +- .../UserInterface/SwiftUI/ThemeView.swift | 14 +- 17 files changed, 265 insertions(+), 245 deletions(-) create mode 100644 UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsView.swift delete mode 100644 UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewController.swift create mode 100644 UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ClickableRow.swift create mode 100644 UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionFooter.swift create mode 100644 UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionHeader.swift create mode 100644 UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionInfoHeader.swift diff --git a/UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj b/UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj index 629603607e..4e4910259c 100644 --- a/UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj +++ b/UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 11B35068706B5C13888F7E22 /* EvmSyncSourceRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35B56F5C8138085588EE5 /* EvmSyncSourceRecord.swift */; }; 11B35068E05BC58C6C9A93D7 /* AccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35872950C107E4810AB6B /* AccountManager.swift */; }; 11B3506ECD6D4D8D0C7717B6 /* MarketAdvancedSearchViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B356BEB2B4DFC3E9C950C5 /* MarketAdvancedSearchViewModel.swift */; }; + 11B35076A96AD17809CE1F62 /* ClickableRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35D179817528224E926D1 /* ClickableRow.swift */; }; 11B350778F2EA9FF364558E4 /* RestoreBinanceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35B2F781F7EDA04E955BB /* RestoreBinanceViewModel.swift */; }; 11B3507DDEBA587C023CE898 /* DashAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B358CA18471A93188933B4 /* DashAdapter.swift */; }; 11B3507F17791BC895872490 /* BrandFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35E930EFEBA58B8F1FDC4 /* BrandFooterView.swift */; }; @@ -187,6 +188,7 @@ 11B352210BEEE91481291D4C /* FormCautionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3568F6FAF721301DEC188 /* FormCautionView.swift */; }; 11B35228CD314AB9DC68DDAA /* EnabledWalletCacheManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3566B18FBFBA85D98D824 /* EnabledWalletCacheManager.swift */; }; 11B352309B81355B88BF6B66 /* OneInchKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3514BC3FF2FAC76ADF9F7 /* OneInchKit.swift */; }; + 11B3523397D1FA961BFE9967 /* ClickableRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35D179817528224E926D1 /* ClickableRow.swift */; }; 11B352339E8052E6EE9CA3CF /* EnabledWalletCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35D2FC6A2DABFE73D1025 /* EnabledWalletCache.swift */; }; 11B352346D3565C7D6395D21 /* PasteInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3575530EE722514F89A61 /* PasteInputView.swift */; }; 11B3523E47942D2118DBC290 /* ManageAccountService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35DC48EEBE1160676B269 /* ManageAccountService.swift */; }; @@ -213,7 +215,9 @@ 11B352841C5901ABCC0096C2 /* BlockchainSettingsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3573A58F426A72669A948 /* BlockchainSettingsService.swift */; }; 11B35286305AB7DA6114F1D0 /* SwitchAccountService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B359D884F1698E70F2536E /* SwitchAccountService.swift */; }; 11B35289269C634BC9219362 /* RecoveryPhraseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3558ACECAA1C886FA82C0 /* RecoveryPhraseViewController.swift */; }; + 11B3528B1101D2E02ECB4631 /* ListSectionInfoHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35B23F86488FDB41CC862 /* ListSectionInfoHeader.swift */; }; 11B3528DFBD66C380A185CB7 /* TransactionsCoinSelectViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35B4D1E2433F5439D9F9A /* TransactionsCoinSelectViewModel.swift */; }; + 11B3528E5D5EF27D8B64E087 /* BtcBlockchainSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B352782BB83C4E447092DB /* BtcBlockchainSettingsView.swift */; }; 11B352980B127688D7EB06C5 /* CexCoinSelectModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35D04F465245548A31205 /* CexCoinSelectModule.swift */; }; 11B3529895DBE58FBAA17E12 /* BlockchainSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35358315865EDCBD1316F /* BlockchainSettingsViewController.swift */; }; 11B35299107843A4663542F9 /* WalletAdapterService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35D1E91C730437BA69676 /* WalletAdapterService.swift */; }; @@ -455,6 +459,7 @@ 11B355B56270FCD8A17A49B5 /* CexWithdrawNetworkRaw.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35EC03BB5316524050518 /* CexWithdrawNetworkRaw.swift */; }; 11B355B5E78279B792F102BB /* CoinType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B357B2D07C69579BAEC997 /* CoinType.swift */; }; 11B355B7E336EB3AED69FA38 /* AddressParserFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B353450DED12F9F024BAD0 /* AddressParserFactory.swift */; }; + 11B355B94EB2D73559DF2AC0 /* ListSectionFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B352970EA9924258E5BB75 /* ListSectionFooter.swift */; }; 11B355BAFD9BA42E5B856845 /* WatchEvmAddressViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35A8370C726989F4F456E /* WatchEvmAddressViewModel.swift */; }; 11B355BBBE08D87E80D853E6 /* WatchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B355B70AB1BC7B6F8B5241 /* WatchViewController.swift */; }; 11B355C5BB0C447A0395168C /* GuidesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35D9767615D8FBF7A314F /* GuidesManager.swift */; }; @@ -491,7 +496,6 @@ 11B3564706CBCF6F6A30FF65 /* EnabledWalletCacheStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35025FD5E96FD1AB359E9 /* EnabledWalletCacheStorage.swift */; }; 11B356476D5E88F21C297B52 /* ManageAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35A38C734DF3157C84678 /* ManageAccountViewController.swift */; }; 11B356485CB62582F79D4877 /* CheckboxCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35216E1F4300730E08C5D /* CheckboxCell.swift */; }; - 11B3564C09AB663A2F146BE8 /* BtcBlockchainSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B359CAE8509E2408CCE422 /* BtcBlockchainSettingsViewController.swift */; }; 11B3564C551C6C76ECCE387D /* SendEvmViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35F6B511DA5E0C60ED156 /* SendEvmViewModel.swift */; }; 11B3564FBC180A0E6D30BCFA /* TransactionsModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35828C8D50D0A5B915B2A /* TransactionsModule.swift */; }; 11B3565070D890657E004402 /* ManageWalletsModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35CBBFEC11CAE6FDBCFFA /* ManageWalletsModule.swift */; }; @@ -521,6 +525,7 @@ 11B356C6C07BE3588A5D52DE /* NftAdapterManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3551049F83912B54DB356 /* NftAdapterManager.swift */; }; 11B356C6E9FC6594917B3FF6 /* ActiveAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35F98E89F83A30870F404 /* ActiveAccount.swift */; }; 11B356C6FEEFD7A1B854FB46 /* AccountRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35E9B9C7A88B7584507DF /* AccountRecord.swift */; }; + 11B356C983C2A2B552D214A4 /* ListSectionFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B352970EA9924258E5BB75 /* ListSectionFooter.swift */; }; 11B356CF0D78F2DC6F28B4BD /* LaunchErrorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35A4096D259C9B1540D10 /* LaunchErrorViewController.swift */; }; 11B356CF55DB1BE22071B24E /* MarketMultiSortHeaderViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B350FAB6F1A6E1FCFACB2F /* MarketMultiSortHeaderViewModel.swift */; }; 11B356D1A2017A37012D3763 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3532F755C7B758D5AB2A2 /* AboutViewController.swift */; }; @@ -628,6 +633,7 @@ 11B35831AF48B09CE3349E5C /* BalanceCoinIconHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3560C1FC3F73833FA4439 /* BalanceCoinIconHolder.swift */; }; 11B358362F756E91646878D0 /* CoinValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3513A7417C236F56E5383 /* CoinValue.swift */; }; 11B35837076F6B350DFA89E7 /* NftDatabaseStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35A47AB0887477EDB200C /* NftDatabaseStorage.swift */; }; + 11B3583BA552486FB2141F63 /* BtcBlockchainSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B352782BB83C4E447092DB /* BtcBlockchainSettingsView.swift */; }; 11B3583C1A73A11974ADAEBB /* EvmNftAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35C2397749C5654830540 /* EvmNftAdapter.swift */; }; 11B3583C648DBE72892FEEDB /* WalletSorter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B355ABE6F12B78194DDEDD /* WalletSorter.swift */; }; 11B3583C77D7B2BD613D6269 /* BalanceViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3591AD106DAC0D18FEDD7 /* BalanceViewItem.swift */; }; @@ -767,6 +773,7 @@ 11B359D10C2A7258AF0F2B60 /* CexDepositNetworkSelectViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35DDED1BC5B541DB6B4B3 /* CexDepositNetworkSelectViewModel.swift */; }; 11B359DBC1A8C5226C025E0D /* TokenTransactionsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35DB5445B83B51C69D7AE /* TokenTransactionsService.swift */; }; 11B359DDFEAF887EEE3063A7 /* MarketAdvancedSearchService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35C19608F6A314CF1F0C5 /* MarketAdvancedSearchService.swift */; }; + 11B359E225E30E97A6354FAC /* ListSectionInfoHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35B23F86488FDB41CC862 /* ListSectionInfoHeader.swift */; }; 11B359E7632FC042278ED912 /* ContactBookManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35A6DE18A1E6E837DFB21 /* ContactBookManager.swift */; }; 11B359E8FA2FD4E7CF6A40AD /* WalletConnectRequestModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B356C2E5AF8ED41E2B545D /* WalletConnectRequestModule.swift */; }; 11B359F074038D1507C23747 /* EnabledWallet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35BDC2E3F845A52C442AD /* EnabledWallet.swift */; }; @@ -962,6 +969,7 @@ 11B35C59583AFCDFD828B9D1 /* TextFieldStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35921FBDF6F9BBAA88803 /* TextFieldStackView.swift */; }; 11B35C5E7A90AA7B302EB0CD /* MarketListMarketFieldDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B353B060BDF272932D3522 /* MarketListMarketFieldDecorator.swift */; }; 11B35C68D57727AB0DAC7753 /* NftAddressMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35BEEB24CDB82D3F4E7C0 /* NftAddressMetadata.swift */; }; + 11B35C7425B861D2F32384E8 /* ListSectionHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B350C0CB7083E2738D356C /* ListSectionHeader.swift */; }; 11B35C78C16D1F89FBC8F222 /* ReceiveViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B359D1A38D53951CEE6F84 /* ReceiveViewController.swift */; }; 11B35C7BB534F9FFE5B6B3A6 /* TokenType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3519AE11DC423E0D078E2 /* TokenType.swift */; }; 11B35C81D9DFBF07955D2461 /* CoinRankModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B358A22655004017228F65 /* CoinRankModule.swift */; }; @@ -997,6 +1005,7 @@ 11B35CCC9D6B7596502B4381 /* CoinInvestment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35264F7CE80AD5D9A540A /* CoinInvestment.swift */; }; 11B35CD199C820EC89FBB546 /* MarketListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B355BEB95969D89B3F8876 /* MarketListViewModel.swift */; }; 11B35CD742378BF04CDB73F0 /* NSAttributedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B350BD364F07D1AC759865 /* NSAttributedString.swift */; }; + 11B35CDC811A92DFAAF2C923 /* ListSectionHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B350C0CB7083E2738D356C /* ListSectionHeader.swift */; }; 11B35CE67B7F5C5A5244C951 /* MainService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35B6D6FCA3745DE0750BD /* MainService.swift */; }; 11B35CF897C3C30DACC27693 /* NftStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3502AEB7EF95A590A7B1B /* NftStorage.swift */; }; 11B35CFD84BE04CC93DE7DF9 /* UnlinkWatchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35592753D3F2A9CCA5809 /* UnlinkWatchViewController.swift */; }; @@ -1169,7 +1178,6 @@ 11B35EC3B9E9C778183E1136 /* EvmNftAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35C2397749C5654830540 /* EvmNftAdapter.swift */; }; 11B35EC7F06AEAB8E555B833 /* AppStatusViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3525406D0B011EB76ACE6 /* AppStatusViewModel.swift */; }; 11B35ECCE5D888A506D7144A /* RestoreBinanceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B354D96A80987DAB3B64A6 /* RestoreBinanceViewController.swift */; }; - 11B35ED1E3C6A4DB8509EF85 /* BtcBlockchainSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B359CAE8509E2408CCE422 /* BtcBlockchainSettingsViewController.swift */; }; 11B35ED22837284580055F0A /* BalanceData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35BDEB703708795B71C4E /* BalanceData.swift */; }; 11B35ED89BE760771022E8A8 /* BlockchainTokensService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35219C4AB26DC0D104E30 /* BlockchainTokensService.swift */; }; 11B35ED9D5F95988E9335440 /* CoinAnalyticsModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3545402F742FE641B9B6C /* CoinAnalyticsModule.swift */; }; @@ -2645,6 +2653,8 @@ D3C187EA290FD00E00FE1900 /* StorageKit in Frameworks */ = {isa = PBXBuildFile; productRef = D3C187E9290FD00E00FE1900 /* StorageKit */; }; D3E1D00B2990D9BE00C68F00 /* Hodler in Frameworks */ = {isa = PBXBuildFile; productRef = D3E1D00A2990D9BE00C68F00 /* Hodler */; }; D3E1D00D2990DA0400C68F00 /* Hodler in Frameworks */ = {isa = PBXBuildFile; productRef = D3E1D00C2990DA0400C68F00 /* Hodler */; }; + D3E6756E2AA9A21300F2BF60 /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = D3E6756D2AA9A21300F2BF60 /* SDWebImageSwiftUI */; }; + D3E675702AA9A24900F2BF60 /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = D3E6756F2AA9A24900F2BF60 /* SDWebImageSwiftUI */; }; D3F7D6412A94D53500477BB1 /* BaseTransactionsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B35B106BD8E4DBD67B7700 /* BaseTransactionsService.swift */; }; /* End PBXBuildFile section */ @@ -2675,6 +2685,7 @@ 11B350BC3E707879846AC0AA /* SwitchAccountViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwitchAccountViewModel.swift; sourceTree = ""; }; 11B350BD0CE4F979CA88EFF0 /* RestoreModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RestoreModule.swift; sourceTree = ""; }; 11B350BD364F07D1AC759865 /* NSAttributedString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSAttributedString.swift; sourceTree = ""; }; + 11B350C0CB7083E2738D356C /* ListSectionHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListSectionHeader.swift; sourceTree = ""; }; 11B350CAB1C54A2CAA4C76F6 /* MarketCategoryModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarketCategoryModule.swift; sourceTree = ""; }; 11B350CCAA0C9F2F5279F680 /* TransactionsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionsViewController.swift; sourceTree = ""; }; 11B350CD0F79715E1A5EE8BF /* NftCollectionAssetsService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NftCollectionAssetsService.swift; sourceTree = ""; }; @@ -2752,10 +2763,12 @@ 11B35269B569B8588DB9A23C /* WalletViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletViewController.swift; sourceTree = ""; }; 11B3526A40F07F6C8E77BEF9 /* BlockchainSettingRecord_v_0_24.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlockchainSettingRecord_v_0_24.swift; sourceTree = ""; }; 11B3526E11EC0F9CFCC69D17 /* SendAvailableBalanceViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SendAvailableBalanceViewModel.swift; sourceTree = ""; }; + 11B352782BB83C4E447092DB /* BtcBlockchainSettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BtcBlockchainSettingsView.swift; sourceTree = ""; }; 11B3527F1528AA697AAA6E61 /* TopPlatformViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TopPlatformViewModel.swift; sourceTree = ""; }; 11B3528090862B6792A76DA4 /* FaqCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FaqCell.swift; sourceTree = ""; }; 11B352884D47E0B23DCF2C2C /* AppManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppManager.swift; sourceTree = ""; }; 11B3529499CD211CC5A21CA2 /* NftCollectionService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NftCollectionService.swift; sourceTree = ""; }; + 11B352970EA9924258E5BB75 /* ListSectionFooter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListSectionFooter.swift; sourceTree = ""; }; 11B352972B14FA6EBEFD6904 /* Text.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Text.swift; sourceTree = ""; }; 11B3529B6C7C426755CE9E14 /* ManageWalletsService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManageWalletsService.swift; sourceTree = ""; }; 11B3529D276325D741CAEEF5 /* UnlinkModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnlinkModule.swift; sourceTree = ""; }; @@ -3045,7 +3058,6 @@ 11B359BBFCD82C3C6DC06F96 /* FeeRateProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeeRateProvider.swift; sourceTree = ""; }; 11B359C5AF7EE92A5756CCFF /* CoinManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoinManager.swift; sourceTree = ""; }; 11B359C62F476065C11EE049 /* TextDropDownAndSettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextDropDownAndSettingsView.swift; sourceTree = ""; }; - 11B359CAE8509E2408CCE422 /* BtcBlockchainSettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BtcBlockchainSettingsViewController.swift; sourceTree = ""; }; 11B359CC2E1E7853CD1547B3 /* LogoHeaderCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogoHeaderCell.swift; sourceTree = ""; }; 11B359CE35C7483CCB956D13 /* CoinAnalyticsHoldersCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoinAnalyticsHoldersCell.swift; sourceTree = ""; }; 11B359D1A38D53951CEE6F84 /* ReceiveViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReceiveViewController.swift; sourceTree = ""; }; @@ -3110,6 +3122,7 @@ 11B35B143F359BE790EC392B /* EvmAddressService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EvmAddressService.swift; sourceTree = ""; }; 11B35B176A5FDEBBE94D307E /* BitcoinCashCoinType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BitcoinCashCoinType.swift; sourceTree = ""; }; 11B35B18D0C02E331540538B /* InputStateWrapperView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputStateWrapperView.swift; sourceTree = ""; }; + 11B35B23F86488FDB41CC862 /* ListSectionInfoHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListSectionInfoHeader.swift; sourceTree = ""; }; 11B35B2465CB748311AF03D5 /* CexWithdrawViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CexWithdrawViewModel.swift; sourceTree = ""; }; 11B35B2C6C103AFF4CCC6E91 /* CoinRecord_v19.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoinRecord_v19.swift; sourceTree = ""; }; 11B35B2E5AB093ABD8228769 /* CexCoinSelectViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CexCoinSelectViewModel.swift; sourceTree = ""; }; @@ -3187,6 +3200,7 @@ 11B35D04F465245548A31205 /* CexCoinSelectModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CexCoinSelectModule.swift; sourceTree = ""; }; 11B35D0672D73C973EBE5E1B /* BinanceKitManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BinanceKitManager.swift; sourceTree = ""; }; 11B35D0EBAF33901578520E1 /* HorizontalDivider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalDivider.swift; sourceTree = ""; }; + 11B35D179817528224E926D1 /* ClickableRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClickableRow.swift; sourceTree = ""; }; 11B35D1E91C730437BA69676 /* WalletAdapterService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletAdapterService.swift; sourceTree = ""; }; 11B35D26C9E9E47E4FD46772 /* BaseCurrencySettingsService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseCurrencySettingsService.swift; sourceTree = ""; }; 11B35D2FC6A2DABFE73D1025 /* EnabledWalletCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EnabledWalletCache.swift; sourceTree = ""; }; @@ -4002,6 +4016,7 @@ D3C187E2290FD00E00FE1900 /* ComponentKit in Frameworks */, D3604E9428F03DC00066C366 /* PinKit in Frameworks */, D339A93F29126D2A00B895BE /* HsCryptoKit in Frameworks */, + D3E675702AA9A24900F2BF60 /* SDWebImageSwiftUI in Frameworks */, D3604E9628F03DC00066C366 /* ModuleKit in Frameworks */, D3C187E6290FD00E00FE1900 /* LanguageKit in Frameworks */, ); @@ -4021,6 +4036,7 @@ D3604E6928F02DF30066C366 /* BitcoinCashKit in Frameworks */, D3993DC228F42992008720FB /* UnstoppableDomainsResolution in Frameworks */, D3604E8528F03CDC0066C366 /* BinanceChainKit in Frameworks */, + D3E6756E2AA9A21300F2BF60 /* SDWebImageSwiftUI in Frameworks */, D3C187BA2907CFAB00FE1900 /* Checkpoints in Frameworks */, 6BDA29AD29D6F384003847ED /* ECashKit in Frameworks */, D3604E4D28F02AB40066C366 /* NftKit in Frameworks */, @@ -4509,6 +4525,10 @@ 11B35AC2D01DF06DC50EAC6A /* HighlightedTextView.swift */, 11B3578FB80AA013BD351A26 /* NavigationRow.swift */, 11B35BAA4EA85B4A3A173498 /* RowButton.swift */, + 11B35D179817528224E926D1 /* ClickableRow.swift */, + 11B352970EA9924258E5BB75 /* ListSectionFooter.swift */, + 11B350C0CB7083E2738D356C /* ListSectionHeader.swift */, + 11B35B23F86488FDB41CC862 /* ListSectionInfoHeader.swift */, ); path = SwiftUI; sourceTree = ""; @@ -5748,8 +5768,8 @@ children = ( 11B3589893A8995F86F08B1C /* BtcBlockchainSettingsModule.swift */, 11B358830357DB1F87FCA006 /* BtcBlockchainSettingsViewModel.swift */, - 11B359CAE8509E2408CCE422 /* BtcBlockchainSettingsViewController.swift */, 11B35469BE6FC454CD6D15B5 /* BtcBlockchainSettingsService.swift */, + 11B352782BB83C4E447092DB /* BtcBlockchainSettingsView.swift */, ); path = BtcBlockchainSettings; sourceTree = ""; @@ -7620,6 +7640,7 @@ D3AF5A9229FFD87500C1399E /* RxSwift */, D023D2642A24B9DC004F65B0 /* TronKit */, D0EC34DC2A4450D200BB308B /* HCaptcha */, + D3E6756F2AA9A24900F2BF60 /* SDWebImageSwiftUI */, ); productName = Wallet; productReference = D38405CE218317DF007D50AD /* Unstoppable D.app */; @@ -7685,6 +7706,7 @@ D023D2622A249E59004F65B0 /* TronKit */, D0EC34DA2A4450B100BB308B /* HCaptcha */, 6B5546202A6E73190054B524 /* UIExtensions */, + D3E6756D2AA9A21300F2BF60 /* SDWebImageSwiftUI */, ); productName = Wallet; productReference = D38406BE21831B3D007D50AD /* Unstoppable.app */; @@ -7771,6 +7793,7 @@ D023D2612A249E59004F65B0 /* XCRemoteSwiftPackageReference "TronKit.Swift" */, D0EC34D92A4450B100BB308B /* XCRemoteSwiftPackageReference "HCaptcha-ios-sdk" */, 6B55461F2A6E73190054B524 /* XCRemoteSwiftPackageReference "UIExtensions.Swift" */, + D3E6756C2AA9A21300F2BF60 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */, ); productRefGroup = D3285F4320BD158E00644076 /* Products */; projectDirPath = ""; @@ -8518,7 +8541,6 @@ 11B350918797E615D4FF6677 /* BlockchainSettingRecordStorage.swift in Sources */, 11B35B7132B99D12DC745064 /* BtcBlockchainSettingsModule.swift in Sources */, 11B35F6B92C2FB142E522828 /* BtcBlockchainSettingsViewModel.swift in Sources */, - 11B3564C09AB663A2F146BE8 /* BtcBlockchainSettingsViewController.swift in Sources */, 11B35CC0D8AC06CE594F84DA /* BtcBlockchainSettingsService.swift in Sources */, 11B35328EA42C49649B1E3F6 /* SyncMode_v_0_24.swift in Sources */, 11B3539E833ABB2D6F696916 /* BlockchainSettingRecord_v_0_24.swift in Sources */, @@ -9082,6 +9104,11 @@ ABC9A0337DAB77500E7A631D /* WalletConnectPairingService.swift in Sources */, ABC9ADAAB5CC80BBE7E1D9FE /* WalletConnectPairingViewModel.swift in Sources */, ABC9A0B37693470DAD0FFE20 /* WalletConnectMainService.swift in Sources */, + 11B3528E5D5EF27D8B64E087 /* BtcBlockchainSettingsView.swift in Sources */, + 11B3523397D1FA961BFE9967 /* ClickableRow.swift in Sources */, + 11B356C983C2A2B552D214A4 /* ListSectionFooter.swift in Sources */, + 11B35C7425B861D2F32384E8 /* ListSectionHeader.swift in Sources */, + 11B359E225E30E97A6354FAC /* ListSectionInfoHeader.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -9794,7 +9821,6 @@ 11B35696E9CD808522BEFCD6 /* BlockchainSettingRecordStorage.swift in Sources */, 11B3581F4D975FC21B9A25F2 /* BtcBlockchainSettingsModule.swift in Sources */, 11B359131D838F3191A8C520 /* BtcBlockchainSettingsViewModel.swift in Sources */, - 11B35ED1E3C6A4DB8509EF85 /* BtcBlockchainSettingsViewController.swift in Sources */, 11B35D2C28E3116F58A543E2 /* BtcBlockchainSettingsService.swift in Sources */, 11B358AE5241256C9AAFB588 /* SyncMode_v_0_24.swift in Sources */, 11B359AA9A3F1FD68323C64E /* BlockchainSettingRecord_v_0_24.swift in Sources */, @@ -10355,6 +10381,11 @@ ABC9A6D1CDF470FB73EF4816 /* WalletConnectPairingService.swift in Sources */, ABC9A92D7F9ADCE00CBCED09 /* WalletConnectPairingViewModel.swift in Sources */, ABC9A2559D001CA67E8F10C7 /* WalletConnectMainService.swift in Sources */, + 11B3583BA552486FB2141F63 /* BtcBlockchainSettingsView.swift in Sources */, + 11B35076A96AD17809CE1F62 /* ClickableRow.swift in Sources */, + 11B355B94EB2D73559DF2AC0 /* ListSectionFooter.swift in Sources */, + 11B35CDC811A92DFAAF2C923 /* ListSectionHeader.swift in Sources */, + 11B3528B1101D2E02ECB4631 /* ListSectionInfoHeader.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -10456,7 +10487,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = UnstoppableWallet/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -10528,7 +10559,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = UnstoppableWallet/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -11001,6 +11032,14 @@ version = 1.0.2; }; }; + D3E6756C2AA9A21300F2BF60 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SDWebImage/SDWebImageSwiftUI.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.0.0; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -11459,6 +11498,16 @@ package = D3E1D0092990D9BE00C68F00 /* XCRemoteSwiftPackageReference "Hodler.Swift" */; productName = Hodler; }; + D3E6756D2AA9A21300F2BF60 /* SDWebImageSwiftUI */ = { + isa = XCSwiftPackageProductDependency; + package = D3E6756C2AA9A21300F2BF60 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */; + productName = SDWebImageSwiftUI; + }; + D3E6756F2AA9A24900F2BF60 /* SDWebImageSwiftUI */ = { + isa = XCSwiftPackageProductDependency; + package = D3E6756C2AA9A21300F2BF60 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */; + productName = SDWebImageSwiftUI; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = D3285F3A20BD158E00644076 /* Project object */; diff --git a/UnstoppableWallet/UnstoppableWallet/Models/BtcRestoreMode.swift b/UnstoppableWallet/UnstoppableWallet/Models/BtcRestoreMode.swift index 36285020fd..89aae0dae6 100644 --- a/UnstoppableWallet/UnstoppableWallet/Models/BtcRestoreMode.swift +++ b/UnstoppableWallet/UnstoppableWallet/Models/BtcRestoreMode.swift @@ -1,7 +1,11 @@ -enum BtcRestoreMode: String, CaseIterable { +enum BtcRestoreMode: String, CaseIterable, Identifiable { case api case blockchain + var id: Self { + self + } + var title: String { switch self { case .api: return "API" diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsModule.swift b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsModule.swift index 9c933987fe..2a992068f8 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsModule.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsModule.swift @@ -1,5 +1,5 @@ +import SwiftUI import UIKit -import ThemeKit import MarketKit struct BtcBlockchainSettingsModule { @@ -7,9 +7,9 @@ struct BtcBlockchainSettingsModule { static func viewController(blockchain: Blockchain) -> UIViewController { let service = BtcBlockchainSettingsService(blockchain: blockchain, btcBlockchainManager: App.shared.btcBlockchainManager) let viewModel = BtcBlockchainSettingsViewModel(service: service) - let viewController = BtcBlockchainSettingsViewController(viewModel: viewModel) + let view = BtcBlockchainSettingsView(viewModel: viewModel) - return ThemeNavigationController(rootViewController: viewController) + return UIHostingController(rootView: view) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsService.swift b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsService.swift index dc5d33aac5..63d2c3b59b 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsService.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsService.swift @@ -1,45 +1,24 @@ -import RxSwift -import RxRelay import MarketKit class BtcBlockchainSettingsService { let blockchain: Blockchain private let btcBlockchainManager: BtcBlockchainManager - private let disposeBag = DisposeBag() - var restoreMode: BtcRestoreMode { - didSet { - syncHasChanges() - } - } - - private let hasChangesRelay = BehaviorRelay(value: false) + let currentRestoreMode: BtcRestoreMode init(blockchain: Blockchain, btcBlockchainManager: BtcBlockchainManager) { self.blockchain = blockchain self.btcBlockchainManager = btcBlockchainManager - restoreMode = btcBlockchainManager.restoreMode(blockchainType: blockchain.type) - } - - private func syncHasChanges() { - let initialRestoreMode = btcBlockchainManager.restoreMode(blockchainType: blockchain.type) - - hasChangesRelay.accept(restoreMode != initialRestoreMode) + currentRestoreMode = btcBlockchainManager.restoreMode(blockchainType: blockchain.type) } } extension BtcBlockchainSettingsService { - var hasChangesObservable: Observable { - hasChangesRelay.asObservable() - } - - func save() { - if restoreMode != btcBlockchainManager.restoreMode(blockchainType: blockchain.type) { - btcBlockchainManager.save(restoreMode: restoreMode, blockchainType: blockchain.type) - } + func save(restoreMode: BtcRestoreMode) { + btcBlockchainManager.save(restoreMode: restoreMode, blockchainType: blockchain.type) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsView.swift new file mode 100644 index 0000000000..d8f39af812 --- /dev/null +++ b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsView.swift @@ -0,0 +1,76 @@ +import SwiftUI +import SDWebImageSwiftUI + +struct BtcBlockchainSettingsView: View { + @ObservedObject var viewModel: BtcBlockchainSettingsViewModel + + @Environment(\.presentationMode) var presentationMode + @State var infoPresented = false + + var body: some View { + ThemeNavigationView { + ThemeView { + VStack(spacing: 0) { + ScrollView { + VStack(spacing: .margin24) { + HighlightedTextView(text: "btc_blockchain_settings.restore_source.alert".localized(viewModel.title)) + + VStack(spacing: 0) { + ListSectionInfoHeader(text: "btc_blockchain_settings.restore_source".localized) { + infoPresented = true + } + .sheet(isPresented: $infoPresented) { + InfoModule.restoreSourceInfo + } + + ListSection { + ForEach(viewModel.restoreModes) { restoreMode in + ClickableRow(action: { + viewModel.selectedRestoreMode = restoreMode + }) { + VStack(spacing: 1) { + Text(restoreMode.title).themeBody() + Text(restoreMode.description).themeSubhead2() + } + + if restoreMode == viewModel.selectedRestoreMode { + Image("check_1_20").themeIcon(color: .themeJacob) + } + } + } + } + + ListSectionFooter(text: "btc_blockchain_settings.restore_source.description".localized) + } + } + .padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin32, trailing: .margin16)) + } + + Button(action: { + viewModel.onTapSave() + presentationMode.wrappedValue.dismiss() + }) { + Text("Save") + } + .disabled(!viewModel.saveEnabled) + } + } + .navigationBarTitle(viewModel.title) + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + WebImage(url: URL(string: viewModel.iconUrl)) + .resizable() + .scaledToFit() + .frame(width: .iconSize24, height: .iconSize24) + } + + ToolbarItem(placement: .navigationBarTrailing) { + Button("button.cancel".localized) { + presentationMode.wrappedValue.dismiss() + } + } + } + } + } + +} diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewController.swift deleted file mode 100644 index b32b7273a0..0000000000 --- a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewController.swift +++ /dev/null @@ -1,141 +0,0 @@ -import UIKit -import RxSwift -import RxCocoa -import ThemeKit -import ComponentKit -import SectionsTableView - -class BtcBlockchainSettingsViewController: ThemeViewController { - private let viewModel: BtcBlockchainSettingsViewModel - private let disposeBag = DisposeBag() - - private let tableView = SectionsTableView(style: .grouped) - private let iconImageView = UIImageView() - - private let saveButtonHolder = BottomGradientHolder() - private let saveButton = PrimaryButton() - - private var restoreModeViewItems = [BtcBlockchainSettingsViewModel.ViewItem]() - private var loaded = false - - init(viewModel: BtcBlockchainSettingsViewModel) { - self.viewModel = viewModel - - super.init() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override func viewDidLoad() { - super.viewDidLoad() - - title = viewModel.title - - navigationItem.leftBarButtonItem = UIBarButtonItem(customView: iconImageView) - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "button.cancel".localized, style: .plain, target: self, action: #selector(onTapCancel)) - - iconImageView.snp.makeConstraints { make in - make.size.equalTo(CGFloat.iconSize24) - } - iconImageView.cornerRadius = .cornerRadius4 - iconImageView.cornerCurve = .continuous - iconImageView.setImage(withUrlString: viewModel.iconUrl, placeholder: UIImage(named: "placeholder_rectangle_24")) - - view.addSubview(tableView) - tableView.snp.makeConstraints { maker in - maker.leading.top.trailing.equalToSuperview() - } - - tableView.separatorStyle = .none - tableView.backgroundColor = .clear - - tableView.sectionDataSource = self - - saveButtonHolder.add(to: self, under: tableView) - saveButtonHolder.addSubview(saveButton) - - saveButton.set(style: .yellow) - saveButton.setTitle("button.save".localized, for: .normal) - saveButton.addTarget(self, action: #selector(onTapSave), for: .touchUpInside) - - subscribe(disposeBag, viewModel.restoreModeViewItemsDriver) { [weak self] in self?.sync(restoreModeViewItems: $0) } - subscribe(disposeBag, viewModel.canSaveDriver) { [weak self] in self?.sync(canSave: $0) } - subscribe(disposeBag, viewModel.finishSignal) { [weak self] in self?.dismiss(animated: true) } - - tableView.buildSections() - loaded = true - } - - @objc private func onTapSave() { - viewModel.onTapSave() - } - - @objc private func onTapCancel() { - dismiss(animated: true) - } - - private func sync(restoreModeViewItems: [BtcBlockchainSettingsViewModel.ViewItem]) { - self.restoreModeViewItems = restoreModeViewItems - reloadTable() - } - - private func sync(canSave: Bool) { - saveButton.isEnabled = canSave - } - - private func reloadTable() { - if loaded { - tableView.reload(animated: true) - } - } - - private func openRestoreModeInfo() { - present(InfoModule.restoreSourceInfo, animated: true) - } - -} - -extension BtcBlockchainSettingsViewController: SectionsDataSource { - - private func row(id: String, viewItem: BtcBlockchainSettingsViewModel.ViewItem, index: Int, isFirst: Bool, isLast: Bool, action: @escaping () -> ()) -> RowProtocol { - tableView.universalRow62( - id: "\(id)-\(index)", - title: .body(viewItem.name), - description: .subhead2(viewItem.description), - accessoryType: .check(viewItem.selected), - hash: "\(viewItem.selected)", - autoDeselect: true, - isFirst: isFirst, - isLast: isLast, - action: action - ) - } - - func buildSections() -> [SectionProtocol] { - [ - Section( - id: "restore-alert", - rows: [ - tableView.highlightedDescriptionRow(id: "restore-alert", text: "btc_blockchain_settings.restore_source.alert".localized(viewModel.title)) - ] - ), - Section( - id: "restore-mode", - headerState: .margin(height: .margin12), - footerState: tableView.sectionFooter(text: "btc_blockchain_settings.restore_source.description".localized), - rows: [ - tableView.subtitleWithInfoButtonRow(text: "btc_blockchain_settings.restore_source".localized) { [weak self] in - self?.openRestoreModeInfo() - } - ] + restoreModeViewItems.enumerated().map { index, viewItem in - row(id: "restore", viewItem: viewItem, index: index, isFirst: index == 0, isLast: index == restoreModeViewItems.count - 1) { [weak self] in - self?.viewModel.onSelectRestoreMode(index: index) - } - } - ) - ] - } - -} diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewModel.swift index 2da1d5e7dd..85134703a6 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewModel.swift @@ -1,42 +1,27 @@ -import RxSwift -import RxRelay -import RxCocoa +import SwiftUI -class BtcBlockchainSettingsViewModel { +class BtcBlockchainSettingsViewModel: ObservableObject { private let service: BtcBlockchainSettingsService - private let disposeBag = DisposeBag() - private let restoreModeViewItemsRelay = BehaviorRelay<[ViewItem]>(value: []) - private let finishRelay = PublishRelay<()>() + let restoreModes: [BtcRestoreMode] = BtcRestoreMode.allCases - init(service: BtcBlockchainSettingsService) { - self.service = service - - syncRestoreModeState() - } - - private func syncRestoreModeState() { - let viewItems = BtcRestoreMode.allCases.map { mode in - ViewItem(name: mode.title, description: mode.description, selected: mode == service.restoreMode) + @Published var selectedRestoreMode: BtcRestoreMode { + didSet { + saveEnabled = selectedRestoreMode != service.currentRestoreMode } - restoreModeViewItemsRelay.accept(viewItems) } -} + @Published var saveEnabled = false -extension BtcBlockchainSettingsViewModel { + init(service: BtcBlockchainSettingsService) { + self.service = service - var restoreModeViewItemsDriver: Driver<[ViewItem]> { - restoreModeViewItemsRelay.asDriver() + selectedRestoreMode = service.currentRestoreMode } - var canSaveDriver: Driver { - service.hasChangesObservable.asDriver(onErrorJustReturn: false) - } +} - var finishSignal: Signal<()> { - finishRelay.asSignal() - } +extension BtcBlockchainSettingsViewModel { var title: String { service.blockchain.name @@ -46,24 +31,8 @@ extension BtcBlockchainSettingsViewModel { service.blockchain.type.imageUrl } - func onSelectRestoreMode(index: Int) { - service.restoreMode = BtcRestoreMode.allCases[index] - syncRestoreModeState() - } - func onTapSave() { - service.save() - finishRelay.accept(()) - } - -} - -extension BtcBlockchainSettingsViewModel { - - struct ViewItem { - let name: String - let description: String - let selected: Bool + service.save(restoreMode: selectedRestoreMode) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Info/InfoModule.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Info/InfoModule.swift index 5d9a9fc023..1503da0691 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Info/InfoModule.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Info/InfoModule.swift @@ -1,3 +1,4 @@ +import SwiftUI import UIKit import ThemeKit @@ -37,13 +38,14 @@ extension InfoModule { ) } - static var restoreSourceInfo: UIViewController { - viewController( + static var restoreSourceInfo: some View { + InfoView( viewItems: [ .header1(text: "blockchain_settings.info.restore_source".localized), .text(text: "blockchain_settings.info.restore_source.content".localized(AppConfig.appName)), ] ) + .ignoresSafeArea() } static var transactionInputsOutputsInfo: UIViewController { @@ -85,3 +87,17 @@ extension InfoModule { } } + +struct InfoView: UIViewControllerRepresentable { + typealias UIViewControllerType = UIViewController + + let viewItems: [InfoModule.ViewItem] + + func makeUIViewController(context: Context) -> UIViewController { + InfoModule.viewController(viewItems: viewItems) + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + } + +} diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/ExperimentalFeatures/ExperimentalFeaturesView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/ExperimentalFeatures/ExperimentalFeaturesView.swift index efa69413fd..120559076c 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/ExperimentalFeatures/ExperimentalFeaturesView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/ExperimentalFeatures/ExperimentalFeaturesView.swift @@ -18,7 +18,7 @@ struct ExperimentalFeaturesView: View { } .padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin32, trailing: .margin16)) } - .navigationBarTitle("settings.experimental_features.title".localized) + .navigationTitle("settings.experimental_features.title".localized) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/SimpleActivate/SimpleActivateView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/SimpleActivate/SimpleActivateView.swift index 850d099d9a..68be8559ed 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Settings/SimpleActivate/SimpleActivateView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Settings/SimpleActivate/SimpleActivateView.swift @@ -10,17 +10,20 @@ struct SimpleActivateView: View { var body: some View { ScrollableThemeView { VStack(spacing: .margin32) { - ListSection(footerText: description) { - ListRow { - Toggle(isOn: $viewModel.activated) { - Text(toggleText).themeBody() + VStack(spacing: 0) { + ListSection { + ListRow { + Toggle(isOn: $viewModel.activated) { + Text(toggleText).themeBody() + } } } + ListSectionFooter(text: description) } } .padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin32, trailing: .margin16)) } - .navigationBarTitle(title) + .navigationTitle(title) } } diff --git a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ClickableRow.swift b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ClickableRow.swift new file mode 100644 index 0000000000..827a58792a --- /dev/null +++ b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ClickableRow.swift @@ -0,0 +1,16 @@ +import SwiftUI + +struct ClickableRow: View { + let action: () -> Void + @ViewBuilder let content: Content + + var body: some View { + Button(action: action, label: { + ListRow { + content + } + }) + .buttonStyle(RowButton()) + .contentShape(Rectangle()) + } +} diff --git a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSection.swift b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSection.swift index b8b2080b23..a2116d81f9 100644 --- a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSection.swift +++ b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSection.swift @@ -1,13 +1,7 @@ import SwiftUI struct ListSection: View { - var content: Content - var footerText: String? - - init(footerText: String? = nil, @ViewBuilder content: @escaping () -> Content) { - self.content = content() - self.footerText = footerText - } + @ViewBuilder let content: Content var body: some View { VStack(spacing: 0) { @@ -16,12 +10,6 @@ struct ListSection: View { } .background(RoundedRectangle(cornerRadius: .cornerRadius12, style: .continuous).fill(Color.themeLawrence)) .clipShape(RoundedRectangle(cornerRadius: .cornerRadius12, style: .continuous)) - - if let footerText { - Text(footerText) - .themeSubhead2() - .padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: 0, trailing: .margin16)) - } } } diff --git a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionFooter.swift b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionFooter.swift new file mode 100644 index 0000000000..6a045caa3e --- /dev/null +++ b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionFooter.swift @@ -0,0 +1,12 @@ +import SwiftUI + +struct ListSectionFooter: View { + let text: String + + var body: some View { + Text(text) + .themeSubhead2() + .padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: 0, trailing: .margin16)) + } + +} diff --git a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionHeader.swift b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionHeader.swift new file mode 100644 index 0000000000..46dbccee6c --- /dev/null +++ b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionHeader.swift @@ -0,0 +1,13 @@ +import SwiftUI + +struct ListSectionHeader: View { + let text: String + + var body: some View { + Text(text.uppercased()) + .themeSubhead1() + .frame(height: .margin32) + .padding(EdgeInsets(top: 0, leading: .margin16, bottom: 0, trailing: .margin16)) + } + +} diff --git a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionInfoHeader.swift b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionInfoHeader.swift new file mode 100644 index 0000000000..b9e5f14081 --- /dev/null +++ b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ListSectionInfoHeader.swift @@ -0,0 +1,24 @@ +import SwiftUI + +struct ListSectionInfoHeader: View { + let text: String + let action: () -> Void + + var body: some View { + HStack { + Button(action: action) { + HStack { + Text(text.uppercased()) + .font(.themeSubhead1) + .foregroundColor(.themeGray) + Image("circle_information_20").themeIcon() + } + } + .frame(height: .margin32) + .padding(EdgeInsets(top: 0, leading: .margin16, bottom: 0, trailing: .margin16)) + + Spacer() + } + } + +} diff --git a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/NavigationRow.swift b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/NavigationRow.swift index 0455b0a296..fa9efa3195 100644 --- a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/NavigationRow.swift +++ b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/NavigationRow.swift @@ -1,7 +1,7 @@ import SwiftUI struct NavigationRow: View { - @ViewBuilder let destination: () -> Destination + @ViewBuilder let destination: Destination @ViewBuilder let content: Content var body: some View { diff --git a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ThemeView.swift b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ThemeView.swift index 729d7cfd47..5798a9168e 100644 --- a/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ThemeView.swift +++ b/UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/ThemeView.swift @@ -5,7 +5,7 @@ struct ThemeView: View { var body: some View { ZStack { - Color.themeTyler.edgesIgnoringSafeArea(.all) + Color.themeTyler.ignoresSafeArea() content } } @@ -24,3 +24,15 @@ struct ScrollableThemeView: View { } } + +struct ThemeNavigationView: View { + @ViewBuilder let content: Content + + var body: some View { + NavigationView { + content + } + .accentColor(.themeJacob) + } + +}