Skip to content

Commit

Permalink
Refactor Appearance module to SwiftUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed Sep 10, 2023
1 parent 3de3efc commit 745f303
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 857 deletions.
42 changes: 12 additions & 30 deletions UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import RxSwift
import MarketKit
import RxRelay
import RxSwift
import StorageKit
import MarketKit

class BalanceConversionManager {
private let tokenQueries = [
TokenQuery(blockchainType: .bitcoin, tokenType: .derived(derivation: .bip84)),
TokenQuery(blockchainType: .ethereum, tokenType: .native),
TokenQuery(blockchainType: .binanceSmartChain, tokenType: .native)
TokenQuery(blockchainType: .binanceSmartChain, tokenType: .native),
]
private let keyBlockchainUid = "conversion-blockchain-uid"

Expand Down Expand Up @@ -46,11 +46,9 @@ class BalanceConversionManager {
conversionToken = conversionTokens.first
}
}

}

extension BalanceConversionManager {

var conversionTokenObservable: Observable<Token?> {
conversionTokenRelay.asObservable()
}
Expand All @@ -65,12 +63,7 @@ extension BalanceConversionManager {
self.conversionToken = conversionTokens[newIndex]
}

func setConversionToken(index: Int) {
guard index < conversionTokens.count else {
return
}

conversionToken = conversionTokens[index]
func set(conversionToken: Token?) {
self.conversionToken = conversionToken
}

}
23 changes: 16 additions & 7 deletions UnstoppableWallet/UnstoppableWallet/Models/AppIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,43 @@ enum AppIcon {
var name: String? {
switch self {
case .main: return nil
case .alternate(let name, _): return name
case let .alternate(name, _): return name
}
}

var title: String {
switch self {
case .main: return "Main"
case .alternate(_, let title): return title
case let .alternate(_, title): return title
}
}

var imageName: String {
switch self {
case .main: return "AppIcon60x60"
case .alternate(let name, _): return "\(name)60x60"
case let .alternate(name, _): return "\(name)60x60"
}
}
}

extension AppIcon: Hashable {
public func hash(into hasher: inout Hasher) {
switch self {
case .main:
hasher.combine("main")
case let .alternate(name, _):
hasher.combine("alternate")
hasher.combine(name)
}
}
}

extension AppIcon: Equatable {

public static func ==(lhs: AppIcon, rhs: AppIcon) -> Bool {
public static func == (lhs: AppIcon, rhs: AppIcon) -> Bool {
switch (lhs, rhs) {
case (.main, .main): return true
case (.alternate(let lhsName, _), .alternate(let rhsName, _)): return lhsName == rhsName
case let (.alternate(lhsName, _), .alternate(rhsName, _)): return lhsName == rhsName
default: return false
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct BtcBlockchainSettingsView: View {
}

if restoreMode == viewModel.selectedRestoreMode {
Image("check_1_20").themeIcon(color: .themeJacob)
Image.checkIcon
}
}
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,40 +1,15 @@
import UIKit
import ThemeKit
import SwiftUI

struct AppearanceModule {

static func viewController() -> UIViewController {
let service = AppearanceService(
themeManager: App.shared.themeManager,
launchScreenManager: App.shared.launchScreenManager,
appIconManager: App.shared.appIconManager,
balancePrimaryValueManager: App.shared.balancePrimaryValueManager,
balanceConversionManager: App.shared.balanceConversionManager,
balanceHiddenManager: App.shared.balanceHiddenManager
static func view() -> some View {
let viewModel = AppearanceViewModel(
themeManager: App.shared.themeManager,
launchScreenManager: App.shared.launchScreenManager,
appIconManager: App.shared.appIconManager,
balancePrimaryValueManager: App.shared.balancePrimaryValueManager,
balanceConversionManager: App.shared.balanceConversionManager,
balanceHiddenManager: App.shared.balanceHiddenManager
)

let viewModel = AppearanceViewModel(service: service)
return AppearanceViewController(viewModel: viewModel)
}

}

extension ThemeMode: CustomStringConvertible {

public var title: String {
switch self {
case .system: return "appearance.theme.system".localized
case .dark: return "appearance.theme.dark".localized
case .light: return "appearance.theme.light".localized
}
return AppearanceView(viewModel: viewModel)
}

public var iconName: String {
switch self {
case .system: return "settings_24"
case .dark: return "dark_24"
case .light: return "light_24"
}
}

}
Loading

0 comments on commit 745f303

Please sign in to comment.