diff --git a/Sources/BraveWallet/Crypto/Accounts/AccountsView.swift b/Sources/BraveWallet/Crypto/Accounts/AccountsView.swift index 5940d6b713d..13e4342e9b8 100644 --- a/Sources/BraveWallet/Crypto/Accounts/AccountsView.swift +++ b/Sources/BraveWallet/Crypto/Accounts/AccountsView.swift @@ -182,6 +182,7 @@ private struct AccountCardView: View { let isLoading: Bool let action: (Action) -> Void + @Environment(\.colorScheme) private var colorScheme: ColorScheme @ScaledMetric private var avatarSize = 40.0 private let maxAvatarSize: CGFloat = 80.0 private let contentPadding: CGFloat = 16 @@ -195,11 +196,14 @@ private struct AccountCardView: View { .frame(width: min(avatarSize, maxAvatarSize), height: min(avatarSize, maxAvatarSize)) VStack(alignment: .leading) { AddressView(address: account.address) { - Text(account.name) - .font(.headline.weight(.semibold)) - .foregroundColor(Color(braveSystemName: .textPrimary)) - Text(account.address.truncatedAddress) - .font(.footnote) + // VStack keeps views together when showing context menu w/ address + VStack(alignment: .leading) { + Text(account.name) + .font(.headline.weight(.semibold)) + .foregroundColor(Color(braveSystemName: .textPrimary)) + Text(account.address.truncatedAddress) + .font(.footnote) + } } Text(account.accountSupportDisplayString) .font(.footnote) @@ -314,14 +318,17 @@ private struct AccountCardView: View { }) { VStack(spacing: 0) { topSectionContent() - .background(Color.white.opacity(0.5)) + .background(colorScheme == .dark ? Color.black.opacity(0.5) : Color.white.opacity(0.5)) bottomSectionContent + .background( + colorScheme == .dark ? Color.black.opacity(0.4) : Color.clear + ) } .background( RoundedRectangle(cornerRadius: 8) .stroke(Color(braveSystemName: .dividerInteractive), lineWidth: 1) - .background(RoundedRectangle(cornerRadius: 8).fill(Color(white: 0.95))) + .background(cardBackground) ) .clipShape(RoundedRectangle(cornerRadius: 8)) .frame(maxWidth: .infinity) @@ -331,6 +338,13 @@ private struct AccountCardView: View { topSectionContent(hidingButtons: false) } } + + private var cardBackground: some View { + BlockieMaterial(address: account.address) + .blur(radius: 25, opaque: true) + .opacity(0.3) + .clipShape(RoundedRectangle(cornerRadius: 8)) + } } private extension BraveWallet.AccountInfo { diff --git a/Sources/BraveWallet/Crypto/Accounts/Details/AccountDetailsView.swift b/Sources/BraveWallet/Crypto/Accounts/Details/AccountDetailsView.swift index 966d5fc6ae5..32ffabfd072 100644 --- a/Sources/BraveWallet/Crypto/Accounts/Details/AccountDetailsView.swift +++ b/Sources/BraveWallet/Crypto/Accounts/Details/AccountDetailsView.swift @@ -101,7 +101,6 @@ struct AccountDetailsView: View { } .listStyle(InsetGroupedListStyle()) .listBackgroundColor(Color(UIColor.braveGroupedBackground)) - .navigationTitle(Strings.Wallet.accountDetailsTitle) .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItemGroup(placement: .cancellationAction) { diff --git a/Sources/BraveWallet/Crypto/Stores/AccountsStore.swift b/Sources/BraveWallet/Crypto/Stores/AccountsStore.swift index c5f76fa774a..16d6c7f8576 100644 --- a/Sources/BraveWallet/Crypto/Stores/AccountsStore.swift +++ b/Sources/BraveWallet/Crypto/Stores/AccountsStore.swift @@ -5,6 +5,7 @@ import BraveCore import SwiftUI +import Preferences struct AccountDetails: Equatable, Identifiable { var id: String { account.id } @@ -39,10 +40,12 @@ class AccountsStore: ObservableObject, WalletObserverStore { private let keyringService: BraveWalletKeyringService private let rpcService: BraveWalletJsonRpcService + private let walletService: BraveWalletBraveWalletService private let assetRatioService: BraveWalletAssetRatioService private let userAssetManager: WalletUserAssetManagerType private var keyringServiceObserver: KeyringServiceObserver? + private var walletServiceObserver: WalletServiceObserver? var isObserving: Bool { keyringServiceObserver != nil @@ -51,11 +54,13 @@ class AccountsStore: ObservableObject, WalletObserverStore { init( keyringService: BraveWalletKeyringService, rpcService: BraveWalletJsonRpcService, + walletService: BraveWalletBraveWalletService, assetRatioService: BraveWalletAssetRatioService, userAssetManager: WalletUserAssetManagerType ) { self.keyringService = keyringService self.rpcService = rpcService + self.walletService = walletService self.assetRatioService = assetRatioService self.userAssetManager = userAssetManager self.setupObservers() @@ -69,6 +74,13 @@ class AccountsStore: ObservableObject, WalletObserverStore { self?.update() } ) + self.walletServiceObserver = WalletServiceObserver( + walletService: walletService, + _onNetworkListChanged: { [weak self] in + self?.update() + } + ) + Preferences.Wallet.showTestNetworks.observe(from: self) } func tearDown() { @@ -240,3 +252,10 @@ class AccountsStore: ObservableObject, WalletObserverStore { tokenBalancesCache[account.address]?[tokenId] } } + +extension AccountsStore: PreferencesObserver { + public func preferencesDidChange(for key: String) { + guard key == Preferences.Wallet.showTestNetworks.key else { return } + update() + } +} diff --git a/Sources/BraveWallet/Crypto/Stores/CryptoStore.swift b/Sources/BraveWallet/Crypto/Stores/CryptoStore.swift index 6e2d838116f..772febfdf90 100644 --- a/Sources/BraveWallet/Crypto/Stores/CryptoStore.swift +++ b/Sources/BraveWallet/Crypto/Stores/CryptoStore.swift @@ -197,6 +197,7 @@ public class CryptoStore: ObservableObject, WalletObserverStore { self.accountsStore = .init( keyringService: keyringService, rpcService: rpcService, + walletService: walletService, assetRatioService: assetRatioService, userAssetManager: userAssetManager ) diff --git a/Sources/BraveWallet/Preview Content/MockStores.swift b/Sources/BraveWallet/Preview Content/MockStores.swift index 9e2cfed431f..1ebe6171021 100644 --- a/Sources/BraveWallet/Preview Content/MockStores.swift +++ b/Sources/BraveWallet/Preview Content/MockStores.swift @@ -260,6 +260,7 @@ extension AccountsStore { .init( keyringService: MockKeyringService(), rpcService: MockJsonRpcService(), + walletService: MockBraveWalletService(), assetRatioService: MockAssetRatioService(), userAssetManager: TestableWalletUserAssetManager() ) diff --git a/Tests/BraveWalletTests/AccountsStoreTests.swift b/Tests/BraveWalletTests/AccountsStoreTests.swift index 957fddca9fe..8e47eb8da54 100644 --- a/Tests/BraveWalletTests/AccountsStoreTests.swift +++ b/Tests/BraveWalletTests/AccountsStoreTests.swift @@ -155,6 +155,9 @@ import Preferences } } + let walletService = BraveWallet.TestBraveWalletService() + walletService._addObserver = { _ in } + let assetRatioService = BraveWallet.TestAssetRatioService() assetRatioService._price = { priceIds, _, _, completion in completion(true, [self.mockETHAssetPrice, @@ -190,6 +193,7 @@ import Preferences let store = AccountsStore( keyringService: keyringService, rpcService: rpcService, + walletService: walletService, assetRatioService: assetRatioService, userAssetManager: userAssetManager )