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

Commit

Permalink
Fix #8229: Disable save changes until changes made (#8240)
Browse files Browse the repository at this point in the history
Disable Save Changes button in Filters until changes are made
  • Loading branch information
StephenHeaps authored Oct 13, 2023
1 parent ca3ed63 commit cdd4078
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ struct FiltersDisplaySettingsView: View {
let networkStore: NetworkStore
let save: (Filters) -> Void

private let originalFilters: Filters

/// Returns true if all accounts are selected
var allAccountsSelected: Bool {
accounts.allSatisfy(\.isSelected)
Expand Down Expand Up @@ -157,6 +159,7 @@ struct FiltersDisplaySettingsView: View {
self.isNFTFilters = isNFTFilters
self.networkStore = networkStore
self.save = save
self.originalFilters = filters
}

var body: some View {
Expand Down Expand Up @@ -341,6 +344,16 @@ struct FiltersDisplaySettingsView: View {
.buttonStyle(FadeButtonStyle())
}

private var isSaveChangesDisabled: Bool {
originalFilters.groupBy == groupBy &&
originalFilters.sortOrder == sortOrder &&
originalFilters.isHidingSmallBalances == isHidingSmallBalances &&
originalFilters.isHidingUnownedNFTs == isHidingUnownedNFTs &&
originalFilters.isShowingNFTNetworkLogo == isShowingNFTNetworkLogo &&
originalFilters.accounts == accounts &&
originalFilters.networks == networks
}

private var saveChangesContainer: some View {
VStack {
Button(action: {
Expand All @@ -362,6 +375,7 @@ struct FiltersDisplaySettingsView: View {
.padding(.vertical, 4)
}
.buttonStyle(BraveFilledButtonStyle(size: .large))
.disabled(isSaveChangesDisabled)

Button(action: { dismiss() }) {
Text(Strings.CancelString)
Expand Down

0 comments on commit cdd4078

Please sign in to comment.