Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #8379: Transaction Details v2 UI #8474

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "tx_details_lines.svg",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Sources/BraveWallet/Crypto/NFT/NFTView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct NFTView: View {
}

private var filtersButton: some View {
AssetButton(braveSystemName: "leo.filter.settings", action: {
WalletIconButton(braveSystemName: "leo.filter.settings", action: {
isPresentingFiltersDisplaySettings = true
})
}
Expand Down Expand Up @@ -150,7 +150,7 @@ struct NFTView: View {
}

private var addCustomAssetButton: some View {
AssetButton(braveSystemName: "leo.plus.add") {
WalletIconButton(braveSystemName: "leo.plus.add") {
isShowingAddCustomNFT = true
}
}
Expand Down
29 changes: 0 additions & 29 deletions Sources/BraveWallet/Crypto/Portfolio/AssetButton.swift

This file was deleted.

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

private var editUserAssetsButton: some View {
AssetButton(braveSystemName: "leo.list.settings", action: {
WalletIconButton(braveSystemName: "leo.list.settings", action: {
isPresentingEditUserAssets = true
})
.sheet(isPresented: $isPresentingEditUserAssets) {
Expand All @@ -98,7 +98,7 @@ struct PortfolioAssetsView: View {
}

private var filtersButton: some View {
AssetButton(braveSystemName: "leo.filter.settings", action: {
WalletIconButton(braveSystemName: "leo.filter.settings", action: {
isPresentingFiltersDisplaySettings = true
})
.sheet(isPresented: $isPresentingFiltersDisplaySettings) {
Expand Down
61 changes: 61 additions & 0 deletions Sources/BraveWallet/Crypto/Portfolio/WalletIconButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* Copyright 2023 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import SwiftUI
import DesignSystem

struct WalletIconButton: View {

enum IconSymbol {
case braveSystemName(String)
case systemName(String)
}

let iconSymbol: IconSymbol
let action: () -> Void

@ScaledMetric var length: CGFloat = 36

init(
braveSystemName: String,
action: @escaping () -> Void,
length: CGFloat = 36
) {
self.iconSymbol = .braveSystemName(braveSystemName)
self.action = action
self._length = .init(wrappedValue: length)
}

init(
systemName: String,
action: @escaping () -> Void,
length: CGFloat = 36
) {
self.iconSymbol = .systemName(systemName)
self.action = action
self._length = .init(wrappedValue: length)
}

var body: some View {
Button(action: action) {
Group {
switch iconSymbol {
case .braveSystemName(let braveSystemName):
Image(braveSystemName: braveSystemName)
case .systemName(let systemName):
Image(systemName: systemName)
}
}
.foregroundColor(Color(braveSystemName: .iconInteractive))
.imageScale(.medium)
.padding(6)
.frame(width: length, height: length)
.background(
Circle()
.strokeBorder(Color(braveSystemName: .dividerInteractive), lineWidth: 1)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,14 @@ class AccountActivityStore: ObservableObject, WalletObserverStore {
func transactionDetailsStore(for transaction: BraveWallet.TransactionInfo) -> TransactionDetailsStore {
TransactionDetailsStore(
transaction: transaction,
parsedTransaction: nil,
keyringService: keyringService,
walletService: walletService,
rpcService: rpcService,
assetRatioService: assetRatioService,
blockchainRegistry: blockchainRegistry,
solanaTxManagerProxy: solTxManagerProxy,
ipfsApi: ipfsApi,
userAssetManager: assetManager
)
}
Expand Down
7 changes: 6 additions & 1 deletion Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class AssetDetailStore: ObservableObject, WalletObserverStore {
private let txService: BraveWalletTxService
private let blockchainRegistry: BraveWalletBlockchainRegistry
private let solTxManagerProxy: BraveWalletSolanaTxManagerProxy
private let ipfsApi: IpfsAPI
private let swapService: BraveWalletSwapService
private let assetManager: WalletUserAssetManagerType
/// A list of tokens that are supported with the current selected network for all supported
Expand Down Expand Up @@ -119,6 +120,7 @@ class AssetDetailStore: ObservableObject, WalletObserverStore {
txService: BraveWalletTxService,
blockchainRegistry: BraveWalletBlockchainRegistry,
solTxManagerProxy: BraveWalletSolanaTxManagerProxy,
ipfsApi: IpfsAPI,
swapService: BraveWalletSwapService,
userAssetManager: WalletUserAssetManagerType,
assetDetailType: AssetDetailType
Expand All @@ -130,6 +132,7 @@ class AssetDetailStore: ObservableObject, WalletObserverStore {
self.txService = txService
self.blockchainRegistry = blockchainRegistry
self.solTxManagerProxy = solTxManagerProxy
self.ipfsApi = ipfsApi
self.swapService = swapService
self.assetManager = userAssetManager
self.assetDetailType = assetDetailType
Expand Down Expand Up @@ -386,12 +389,14 @@ class AssetDetailStore: ObservableObject, WalletObserverStore {
func transactionDetailsStore(for transaction: BraveWallet.TransactionInfo) -> TransactionDetailsStore {
TransactionDetailsStore(
transaction: transaction,
parsedTransaction: nil,
keyringService: keyringService,
walletService: walletService,
rpcService: rpcService,
assetRatioService: assetRatioService,
blockchainRegistry: blockchainRegistry,
solanaTxManagerProxy: solTxManagerProxy,
ipfsApi: ipfsApi,
userAssetManager: assetManager
)
}
Expand Down Expand Up @@ -452,7 +457,7 @@ extension AssetDetailStore: BraveWalletTxServiceObserver {
update()
}
func onTxServiceReset() {
}
}
}

extension AssetDetailStore: BraveWalletBraveWalletServiceObserver {
Expand Down
2 changes: 2 additions & 0 deletions Sources/BraveWallet/Crypto/Stores/CryptoStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ public class CryptoStore: ObservableObject, WalletObserverStore {
txService: txService,
blockchainRegistry: blockchainRegistry,
solTxManagerProxy: solTxManagerProxy,
ipfsApi: ipfsApi,
swapService: swapService,
userAssetManager: userAssetManager,
assetDetailType: assetDetailType
Expand Down Expand Up @@ -499,6 +500,7 @@ public class CryptoStore: ObservableObject, WalletObserverStore {
ethTxManagerProxy: ethTxManagerProxy,
keyringService: keyringService,
solTxManagerProxy: solTxManagerProxy,
ipfsApi: ipfsApi,
userAssetManager: userAssetManager
)
confirmationStore = store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public class TransactionConfirmationStore: ObservableObject, WalletObserverStore
private let ethTxManagerProxy: BraveWalletEthTxManagerProxy
private let keyringService: BraveWalletKeyringService
private let solTxManagerProxy: BraveWalletSolanaTxManagerProxy
private let ipfsApi: IpfsAPI
private let assetManager: WalletUserAssetManagerType
private var selectedChain: BraveWallet.NetworkInfo = .init()
private var txServiceObserver: TxServiceObserver?
Expand All @@ -156,6 +157,7 @@ public class TransactionConfirmationStore: ObservableObject, WalletObserverStore
ethTxManagerProxy: BraveWalletEthTxManagerProxy,
keyringService: BraveWalletKeyringService,
solTxManagerProxy: BraveWalletSolanaTxManagerProxy,
ipfsApi: IpfsAPI,
userAssetManager: WalletUserAssetManagerType
) {
self.assetRatioService = assetRatioService
Expand All @@ -166,6 +168,7 @@ public class TransactionConfirmationStore: ObservableObject, WalletObserverStore
self.ethTxManagerProxy = ethTxManagerProxy
self.keyringService = keyringService
self.solTxManagerProxy = solTxManagerProxy
self.ipfsApi = ipfsApi
self.assetManager = userAssetManager

self.setupObservers()
Expand Down Expand Up @@ -339,14 +342,22 @@ public class TransactionConfirmationStore: ObservableObject, WalletObserverStore

func activeTxDetailsStore() -> TransactionDetailsStore {
let tx = allTxs.first { $0.id == activeTransactionId } ?? activeParsedTransaction.transaction
let parsedTransaction: ParsedTransaction?
if activeParsedTransaction.transaction.id == tx.id {
parsedTransaction = activeParsedTransaction
} else {
parsedTransaction = nil
}
return TransactionDetailsStore(
transaction: tx,
parsedTransaction: parsedTransaction,
keyringService: keyringService,
walletService: walletService,
rpcService: rpcService,
assetRatioService: assetRatioService,
blockchainRegistry: blockchainRegistry,
solanaTxManagerProxy: solTxManagerProxy,
ipfsApi: ipfsApi,
userAssetManager: assetManager
)
}
Expand Down
Loading