Skip to content

Commit

Permalink
Remove balance conversion from appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
ant013 committed Jun 3, 2024
1 parent 162811a commit 9ea81b0
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class BalanceConversionManager {
private let tokenQueries = [
TokenQuery(blockchainType: .bitcoin, tokenType: .derived(derivation: .bip84)),
TokenQuery(blockchainType: .ethereum, tokenType: .native),
TokenQuery(blockchainType: .binanceSmartChain, tokenType: .native),
]
private let keyBlockchainUid = "conversion-blockchain-uid"

Expand Down Expand Up @@ -66,6 +65,7 @@ extension BalanceConversionManager {
func set(tokenQueryId: String?) {
conversionToken = tokenQueryId
.flatMap { TokenQuery(id: $0) }
.flatMap { tokenQueries.contains($0) ? $0 : nil }
.flatMap { try? marketKit.token(query: $0) } ??
conversionTokens.first
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ struct AppearanceView: View {
@State private var priceChangeSelectorPresented = false
@State private var launchScreenSelectorPresented = false
@State private var balanceValueSelectorPresented = false
@State private var conversionSelectorPresented = false

var body: some View {
ScrollableThemeView {
Expand Down Expand Up @@ -125,27 +124,6 @@ struct AppearanceView: View {
viewModel.balancePrimaryValue = BalancePrimaryValue.allCases[index]
}
)

ClickableRow(spacing: .margin8) {
conversionSelectorPresented = true
} content: {
Text("appearance.balance_conversion".localized).textBody()
Spacer()
Text(viewModel.conversionToken?.coin.code ?? "").textSubhead1()
Image("arrow_small_down_20").themeIcon()
}
.alert(
isPresented: $conversionSelectorPresented,
title: "appearance.balance_conversion".localized,
viewItems: viewModel.conversionTokens.map { .init(text: $0.coin.code, selected: viewModel.conversionToken == $0) },
onTap: { index in
guard let index else {
return
}

viewModel.conversionToken = viewModel.conversionTokens[index]
}
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ import SwiftUI
import ThemeKit

class AppearanceViewModel: ObservableObject {
private var cancellables = Set<AnyCancellable>()

private let themeManager = App.shared.themeManager
private let launchScreenManager = App.shared.launchScreenManager
private let appIconManager = App.shared.appIconManager
private let balancePrimaryValueManager = App.shared.balancePrimaryValueManager
private let balanceConversionManager = App.shared.balanceConversionManager
private let walletButtonHiddenManager = App.shared.walletButtonHiddenManager
private let priceChangeModeManager = App.shared.priceChangeModeManager

let themeModes: [ThemeMode] = [.system, .dark, .light]
let conversionTokens: [Token]

@Published var themeMode: ThemeMode {
didSet {
Expand Down Expand Up @@ -77,18 +73,6 @@ class AppearanceViewModel: ObservableObject {
}
}

@Published var conversionToken: Token? {
didSet {
guard balanceConversionManager.conversionToken != conversionToken else {
return
}
if let conversionToken {
stat(page: .appearance, event: .selectBalanceConversion(coinUid: conversionToken.coin.uid))
}
balanceConversionManager.set(conversionToken: conversionToken)
}
}

@Published var appIcon: AppIcon {
didSet {
guard appIconManager.appIcon != appIcon else {
Expand All @@ -100,17 +84,12 @@ class AppearanceViewModel: ObservableObject {
}

init() {
conversionTokens = balanceConversionManager.conversionTokens

themeMode = themeManager.themeMode
hideMarkets = !launchScreenManager.showMarket
priceChangeMode = priceChangeModeManager.priceChangeMode
launchScreen = launchScreenManager.launchScreen
hideBalanceButtons = walletButtonHiddenManager.buttonHidden
balancePrimaryValue = balancePrimaryValueManager.balancePrimaryValue
conversionToken = balanceConversionManager.conversionToken
appIcon = appIconManager.appIcon

balanceConversionManager.$conversionToken.sink { [weak self] in self?.conversionToken = $0 }.store(in: &cancellables)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,6 @@
"appearance.balance_value" = "Balance Value";
"appearance.balance_value.coin_fiat" = "Coin / Fiat";
"appearance.balance_value.fiat_coin" = "Fiat / Coin";
"appearance.balance_conversion" = "Balance Conversion";

"appearance.app_icon" = "App Icon";

Expand Down

0 comments on commit 9ea81b0

Please sign in to comment.