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

Commit

Permalink
Fix #8663: Account Details v2 (#8716)
Browse files Browse the repository at this point in the history
* Account Activity / Details v2 WIP

* Update unit tests for transaction sections, assets sorted by fiat

* Add security row for dapp supported accounts

* Fix cases where currency formatter's `maximumFractionDigits` was not restored in `TransactionParser` (`solEstimatedTxFee` unavailable or `filTxData` unavailable)

* Remove old observer extensions from `AccountActivityStore`.

* Fix for NFTs not being displayed correctly in transactions list (for NFT transactions)

* Update copy for account details rows
  • Loading branch information
StephenHeaps committed Feb 6, 2024
1 parent 0a6fd8b commit 0b023e3
Show file tree
Hide file tree
Showing 14 changed files with 975 additions and 590 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import struct Shared.Strings
import BraveUI

struct AccountTransactionListView: View {
@ObservedObject var keyringStore: KeyringStore
@ObservedObject var activityStore: AccountActivityStore
@ObservedObject var networkStore: NetworkStore

@Environment(\.openURL) private var openWalletURL

@State private var transactionDetails: TransactionDetailsStore?
@State private var query: String = ""

private func emptyTextView(_ message: String) -> some View {
Text(message)
Expand All @@ -26,40 +24,15 @@ struct AccountTransactionListView: View {
}

var body: some View {
List {
Section(
header: WalletListHeaderView(title: Text(Strings.Wallet.transactionsTitle))
) {
Group {
if activityStore.transactionSummaries.isEmpty {
emptyTextView(Strings.Wallet.noTransactions)
} else {
ForEach(activityStore.transactionSummaries) { txSummary in
Button(action: {
self.transactionDetails = activityStore.transactionDetailsStore(for: txSummary.txInfo)
}) {
TransactionSummaryView(summary: txSummary)
}
.contextMenu {
if !txSummary.txHash.isEmpty {
Button(action: {
if let txNetwork = self.networkStore.allChains.first(where: { $0.chainId == txSummary.txInfo.chainId }),
let url = txNetwork.txBlockExplorerLink(txHash: txSummary.txHash, for: txNetwork.coin) {
openWalletURL(url)
}
}) {
Label(Strings.Wallet.viewOnBlockExplorer, systemImage: "arrow.up.forward.square")
}
}
}
}
}
}
.listRowBackground(Color(.secondaryBraveGroupedBackground))
TransactionsListView(
transactionSections: activityStore.transactionSections,
query: $query,
showFilter: false,
filtersButtonTapped: { },
transactionTapped: { transaction in
self.transactionDetails = activityStore.transactionDetailsStore(for: transaction)
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
)
.navigationTitle(Strings.Wallet.transactionsTitle)
.navigationBarTitleDisplayMode(.inline)
.sheet(
Expand All @@ -82,10 +55,8 @@ struct AccountTransactionListView: View {
struct AccountTransactionListView_Previews: PreviewProvider {
static var previews: some View {
AccountTransactionListView(
keyringStore: .previewStore,
activityStore: {
let store: AccountActivityStore = .previewStore
store.previewTransactions()
return store
}(),
networkStore: .previewStore
Expand Down
25 changes: 17 additions & 8 deletions Sources/BraveWallet/Crypto/Accounts/AccountsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ struct AccountsView: View {
@State private var selectedAccountActivity: BraveWallet.AccountInfo?
/// When populated, account info presented modally for given account (rename, export private key)
@State private var selectedAccountForEdit: BraveWallet.AccountInfo?

/// When populated, private key export is presented modally for the given account.
@State private var selectedAccountForExport: BraveWallet.AccountInfo?

@Environment(\.buySendSwapDestination)
private var buySendSwapDestination: Binding<BuySendSwapDestination?>

var body: some View {
ScrollView {
LazyVStack(spacing: 16) {
Expand Down Expand Up @@ -63,25 +66,31 @@ struct AccountsView: View {
}
.navigationTitle(Strings.Wallet.accountsPageTitle)
.navigationBarTitleDisplayMode(.inline)
.background(Color(braveSystemName: .containerBackground))
.background(
NavigationLink(
isActive: Binding(
get: { selectedAccountActivity != nil },
set: { if !$0 { selectedAccountActivity = nil } }
set: {
if !$0 {
selectedAccountActivity = nil
if let selectedAccountActivity {
cryptoStore.closeAccountActivityStore(for: selectedAccountActivity)
}
}
}
),
destination: {
if let account = selectedAccountActivity {
AccountActivityView(
keyringStore: keyringStore,
activityStore: cryptoStore.accountActivityStore(
store: cryptoStore.accountActivityStore(
for: account,
observeAccountUpdates: false
),
networkStore: cryptoStore.networkStore
cryptoStore: cryptoStore,
keyringStore: keyringStore,
buySendSwapDestination: buySendSwapDestination
)
.onDisappear {
cryptoStore.closeAccountActivityStore(for: account)
}
}
},
label: {
Expand Down
Loading

0 comments on commit 0b023e3

Please sign in to comment.