-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor BlockchainSettings module to SwiftUI
- Loading branch information
Showing
9 changed files
with
133 additions
and
294 deletions.
There are no files selected for viewing
30 changes: 12 additions & 18 deletions
30
UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...llet/UnstoppableWallet/Modules/BtcBlockchainSettings/BtcBlockchainSettingsViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 7 additions & 10 deletions
17
...llet/UnstoppableWallet/Modules/Settings/BlockchainSettings/BlockchainSettingsModule.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
import UIKit | ||
import SwiftUI | ||
|
||
struct BlockchainSettingsModule { | ||
|
||
static func viewController() -> UIViewController { | ||
let service = BlockchainSettingsService( | ||
btcBlockchainManager: App.shared.btcBlockchainManager, | ||
evmBlockchainManager: App.shared.evmBlockchainManager, | ||
evmSyncSourceManager: App.shared.evmSyncSourceManager | ||
static func view() -> some View { | ||
let viewModel = BlockchainSettingsViewModel( | ||
btcBlockchainManager: App.shared.btcBlockchainManager, | ||
evmBlockchainManager: App.shared.evmBlockchainManager, | ||
evmSyncSourceManager: App.shared.evmSyncSourceManager | ||
) | ||
let viewModel = BlockchainSettingsViewModel(service: service) | ||
return BlockchainSettingsViewController(viewModel: viewModel) | ||
return BlockchainSettingsView(viewModel: viewModel) | ||
} | ||
|
||
} |
73 changes: 0 additions & 73 deletions
73
...let/UnstoppableWallet/Modules/Settings/BlockchainSettings/BlockchainSettingsService.swift
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
...Wallet/UnstoppableWallet/Modules/Settings/BlockchainSettings/BlockchainSettingsView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import MarketKit | ||
import SDWebImageSwiftUI | ||
import SwiftUI | ||
|
||
struct BlockchainSettingsView: View { | ||
@ObservedObject var viewModel: BlockchainSettingsViewModel | ||
|
||
@State private var btcSheetBlockchain: Blockchain? | ||
@State private var evmSheetBlockchain: Blockchain? | ||
|
||
var body: some View { | ||
ScrollableThemeView { | ||
VStack(spacing: .margin32) { | ||
ListSection { | ||
ForEach(viewModel.btcItems, id: \.blockchain.uid) { item in | ||
ClickableRow(action: { | ||
btcSheetBlockchain = item.blockchain | ||
}) { | ||
ItemView( | ||
blockchain: item.blockchain, | ||
value: item.restoreMode.title | ||
) | ||
} | ||
} | ||
.sheet(item: $btcSheetBlockchain) { blockchain in | ||
ThemeNavigationView { BtcBlockchainSettingsModule.view(blockchain: blockchain) } | ||
} | ||
} | ||
|
||
ListSection { | ||
ForEach(viewModel.evmItems, id: \.blockchain.uid) { item in | ||
ClickableRow(action: { | ||
evmSheetBlockchain = item.blockchain | ||
}) { | ||
ItemView( | ||
blockchain: item.blockchain, | ||
value: item.syncSource.name | ||
) | ||
} | ||
} | ||
.sheet(item: $evmSheetBlockchain) { _ in | ||
Text("TODO") | ||
} | ||
} | ||
} | ||
.padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin32, trailing: .margin16)) | ||
} | ||
.navigationTitle("blockchain_settings.title".localized) | ||
} | ||
|
||
struct ItemView: View { | ||
let blockchain: Blockchain | ||
let value: String | ||
|
||
var body: some View { | ||
WebImage(url: URL(string: blockchain.type.imageUrl)) | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: .iconSize32, height: .iconSize32) | ||
|
||
VStack(spacing: 1) { | ||
Text(blockchain.name).themeBody() | ||
Text(value).themeSubhead2() | ||
} | ||
|
||
Image.disclosureIcon | ||
} | ||
} | ||
} |
128 changes: 0 additions & 128 deletions
128
...toppableWallet/Modules/Settings/BlockchainSettings/BlockchainSettingsViewController.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.