diff --git a/Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift b/Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift index c24e734f4b3..532b407eb5f 100644 --- a/Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift +++ b/Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift @@ -199,11 +199,11 @@ struct FiltersDisplaySettingsView: View { .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { - Button(action: restoreToDefaults) { + Button(action: resetToDefaults) { Text(Strings.Wallet.settingsResetTransactionAlertButtonTitle) .fontWeight(.semibold) - .foregroundColor(Color(uiColor: WalletV2Design.textInteractive)) } + .disabled(isResetDisabled) } } } @@ -380,12 +380,27 @@ struct FiltersDisplaySettingsView: View { .shadow(color: Color.black.opacity(0.04), radius: 16, x: 0, y: -8) } - func restoreToDefaults() { - self.groupBy = .none + private var isResetDisabled: Bool { + groupBy == GroupBy(rawValue: Preferences.Wallet.groupByFilter.defaultValue) ?? .none + && sortOrder == SortOrder(rawValue: Preferences.Wallet.sortOrderFilter.defaultValue) ?? .valueDesc + && isHidingSmallBalances == Preferences.Wallet.isHidingSmallBalancesFilter.defaultValue + && isHidingUnownedNFTs == Preferences.Wallet.isHidingUnownedNFTsFilter.defaultValue + && isShowingNFTNetworkLogo == Preferences.Wallet.isShowingNFTNetworkLogoFilter.defaultValue + && accounts.allSatisfy(\.isSelected) + && networks.allSatisfy { selectableNetwork in + let isTestnet = WalletConstants.supportedTestNetworkChainIds.contains(selectableNetwork.model.chainId) + return selectableNetwork.isSelected == !isTestnet + } + } + + func resetToDefaults() { + /// Assets are not grouped by default + self.groupBy = GroupBy(rawValue: Preferences.Wallet.groupByFilter.defaultValue) ?? .none // Fiat value in descending order (largest fiat to smallest) by default - self.sortOrder = .valueDesc - // Small balances shown by default - self.isHidingSmallBalances = false + self.sortOrder = SortOrder(rawValue: Preferences.Wallet.sortOrderFilter.defaultValue) ?? .valueDesc + self.isHidingSmallBalances = Preferences.Wallet.isHidingSmallBalancesFilter.defaultValue + self.isHidingUnownedNFTs = Preferences.Wallet.isHidingUnownedNFTsFilter.defaultValue + self.isShowingNFTNetworkLogo = Preferences.Wallet.isShowingNFTNetworkLogoFilter.defaultValue // All accounts selected by default self.accounts = self.accounts.map { @@ -554,7 +569,21 @@ struct FilterPickerRowView