diff --git a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/Aggregator/CryptoSolanaAccountsAggregator.swift b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/Aggregator/CryptoSolanaAccountsAggregator.swift index fb4c8f95a9..e71b223d42 100644 --- a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/Aggregator/CryptoSolanaAccountsAggregator.swift +++ b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/Aggregator/CryptoSolanaAccountsAggregator.swift @@ -30,10 +30,13 @@ struct CryptoSolanaAccountsAggregator: DataAggregator { } else if hideZeroBalance, account.lamports == 0 { tags.insert(.ignore) } + + let canBeHidden = account.token.keyAppExtensions.canBeHidden ?? true + let extraAction: AccountExtraAction? = canBeHidden ? .showHide : nil return RenderableSolanaAccount( account: account, - extraAction: .visiable, + extraAction: extraAction, tags: tags ) } diff --git a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/CryptoAccountsView.swift b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/CryptoAccountsView.swift index 5b81fa57f2..2acd7631f5 100644 --- a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/CryptoAccountsView.swift +++ b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/CryptoAccountsView.swift @@ -65,13 +65,13 @@ struct CryptoAccountsView: View { if !viewModel.transferAccounts.isEmpty { wrappedList(itemsCount: viewModel.transferAccounts.count) { ForEach(viewModel.transferAccounts, id: \.id) { - tokenCell(rendableAccount: $0, isVisiable: true) + tokenCell(rendableAccount: $0, isVisible: true) } } } wrappedList(itemsCount: viewModel.accounts.count) { ForEach(viewModel.accounts, id: \.id) { - tokenCell(rendableAccount: $0, isVisiable: true) + tokenCell(rendableAccount: $0, isVisible: true) } } .padding(.top, 12) @@ -100,7 +100,7 @@ struct CryptoAccountsView: View { if !isHiddenSectionDisabled { wrappedList(itemsCount: viewModel.hiddenAccounts.count) { ForEach(viewModel.hiddenAccounts, id: \.id) { - tokenCell(rendableAccount: $0, isVisiable: false) + tokenCell(rendableAccount: $0, isVisible: false) } .transition(AnyTransition.opacity.animation(.linear(duration: 0.3))) } @@ -111,7 +111,7 @@ struct CryptoAccountsView: View { .background(Color(Asset.Colors.smoke.color)) } - private func tokenCell(rendableAccount: any RenderableAccount, isVisiable: Bool) -> some View { + private func tokenCell(rendableAccount: any RenderableAccount, isVisible: Bool) -> some View { CryptoAccountCellView(rendable: rendableAccount) { viewModel.invoke(for: rendableAccount, event: .tap) } onButtonTap: { @@ -119,10 +119,10 @@ struct CryptoAccountsView: View { } .do { view in switch rendableAccount.extraAction { - case .visiable: + case .showHide: return AnyView( view.swipeActions( - isVisible: isVisiable, + isVisible: isVisible, currentUserInteractionCellID: $currentUserInteractionCellID ) { viewModel.invoke(for: rendableAccount, event: .visibleToggle) diff --git a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Actions Panel/CryptoActionsPanelViewModel.swift b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Actions Panel/CryptoActionsPanelViewModel.swift index f2a2219e42..8de0852164 100644 --- a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Actions Panel/CryptoActionsPanelViewModel.swift +++ b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Actions Panel/CryptoActionsPanelViewModel.swift @@ -42,7 +42,13 @@ final class CryptoActionsPanelViewModel: BaseViewModel, ObservableObject { .map { (state: AsyncValueState<[SolanaAccountsService.Account]>) -> String in let equityValue: Double = state.value .filter { !$0.isUSDC } - .reduce(0) { $0 + $1.amountInFiatDouble } + .reduce(0) { + if $1.token.keyAppExtensions.ruleOfProcessingTokenPriceWS == .byCountOfTokensValue { + return $0 + $1.amount + } else { + return $0 + $1.amountInFiatDouble + } + } return "\(Defaults.fiat.symbol)\(equityValue.toString(maximumFractionDigits: 2))" } .receive(on: RunLoop.main) diff --git a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Aggregator/HomeSolanaAccountsAggregator.swift b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Aggregator/HomeSolanaAccountsAggregator.swift index b21abe093d..5a36d2ee54 100644 --- a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Aggregator/HomeSolanaAccountsAggregator.swift +++ b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Aggregator/HomeSolanaAccountsAggregator.swift @@ -40,7 +40,7 @@ struct HomeSolanaAccountsAggregator: DataAggregator { return RenderableSolanaAccount( account: account, - extraAction: .visiable, + extraAction: .showHide, tags: tags ) } diff --git a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/HomeAccountsView.swift b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/HomeAccountsView.swift index 152aac49f6..41b2f13e41 100644 --- a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/HomeAccountsView.swift +++ b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/HomeAccountsView.swift @@ -57,107 +57,4 @@ struct HomeAccountsView: View { } ) } - - private var content: some View { - VStack(alignment: .leading, spacing: 0) { - Text(L10n.tokens) - .font(uiFont: .font(of: .title3, weight: .semibold)) - .foregroundColor(Color(Asset.Colors.night.color)) - .padding(.horizontal, 16) - .padding(.bottom, 8) - wrappedList(itemsCount: viewModel.accounts.count) { - ForEach(viewModel.accounts, id: \.id) { - tokenCell(rendableAccount: $0, isVisiable: true) - } - } - if !viewModel.hiddenAccounts.isEmpty { - Button( - action: { - viewModel.hiddenTokensTapped() - let generator = UIImpactFeedbackGenerator(style: .light) - generator.impactOccurred() - withAnimation { - isHiddenSectionDisabled.toggle() - } - }, - label: { - HStack(spacing: 8) { - Image(uiImage: isHiddenSectionDisabled ? .eyeHiddenTokens : .eyeHiddenTokensHide) - Text(L10n.hiddenTokens) - .foregroundColor(Color(Asset.Colors.mountain.color)) - .font(.system(size: 16)) - .padding(.vertical, 12) - Spacer() - } - .frame(maxWidth: .infinity) - .padding(.horizontal, 16) - } - ) - if !isHiddenSectionDisabled { - wrappedList(itemsCount: viewModel.hiddenAccounts.count) { - ForEach(viewModel.hiddenAccounts, id: \.id) { - tokenCell(rendableAccount: $0, isVisiable: false) - } - .transition(AnyTransition.opacity.animation(.linear(duration: 0.3))) - } - } - } - } - .padding(.top, 32) - .background(Color(Asset.Colors.snow.color)) - } - - private func tokenCell(rendableAccount: any RenderableAccount, isVisiable: Bool) -> some View { - HomeAccountView(rendable: rendableAccount) { - viewModel.invoke(for: rendableAccount, event: .tap) - } onButtonTap: { - viewModel.invoke(for: rendableAccount, event: .extraButtonTap) - } - .do { view in - switch rendableAccount.extraAction { - case .visiable: - return AnyView( - view.swipeActions( - isVisible: isVisiable, - currentUserInteractionCellID: $currentUserInteractionCellID - ) { - viewModel.invoke(for: rendableAccount, event: .visibleToggle) - } - ) - case .none: - return AnyView(view) - } - } - .frame(height: 72) - .padding(.horizontal, 16) - } - - @ViewBuilder - private func wrappedList( - itemsCount: Int, - @ViewBuilder content: @escaping () -> Content - ) -> some View { - List { - content() - .listRowSeparator(.hidden) - .listRowInsets(EdgeInsets()) - } - .listStyle(.plain) - .frame(height: CGFloat(itemsCount) * 72) - } -} - -private extension View { - @ViewBuilder func swipeActions( - isVisible: Bool, - currentUserInteractionCellID _: Binding, - action: @escaping () -> Void - ) -> some View { - swipeActions(allowsFullSwipe: true) { - Button(action: action) { - Image(uiImage: isVisible ? .eyeHide : .eyeShow) - } - .tint(.clear) - } - } } diff --git a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/HomeAccountsViewModel.swift b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/HomeAccountsViewModel.swift index c45f7a7272..b061d9a263 100644 --- a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/HomeAccountsViewModel.swift +++ b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/HomeAccountsViewModel.swift @@ -104,8 +104,13 @@ final class HomeAccountsViewModel: BaseViewModel, ObservableObject { .map { (state: AsyncValueState<[SolanaAccountsService.Account]>) -> String in let equityValue: Double = state.value .filter { $0.isUSDC } + .filter { $0.token.keyAppExtensions.calculationOfFinalBalanceOnWS ?? true } .reduce(0) { - $0 + $1.amountInFiatDouble + if $1.token.keyAppExtensions.ruleOfProcessingTokenPriceWS == .byCountOfTokensValue { + return $0 + $1.amount + } else { + return $0 + $1.amountInFiatDouble + } } return "\(Defaults.fiat.symbol)\(equityValue.toString(maximumFractionDigits: 2))" } diff --git a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Model/RenderableAccount.swift b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Model/RenderableAccount.swift index 91c7b43f36..f9e86d05ac 100644 --- a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Model/RenderableAccount.swift +++ b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Model/RenderableAccount.swift @@ -44,7 +44,7 @@ struct AccountTags: OptionSet { } enum AccountExtraAction { - case visiable + case showHide } enum AccountDetail { diff --git a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Subview/HomeAccountView.swift b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Subview/HomeAccountView.swift index 84ee87e031..44a7556cfd 100644 --- a/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Subview/HomeAccountView.swift +++ b/p2p_wallet/Scenes/Main/NewHome/Subview/AccountList/Subview/HomeAccountView.swift @@ -86,7 +86,7 @@ struct HomeAccountView_Previews: PreviewProvider { title: "Solana", subtitle: "0.1747 SOL", detail: .text("$ 3.67"), - extraAction: .visiable, + extraAction: .showHide, tags: [] ) ) {} onButtonTap: {}