Skip to content

Commit

Permalink
Fix brave/brave-ios#8229: Disable save changes until changes made (br…
Browse files Browse the repository at this point in the history
…ave/brave-ios#8240)

Disable Save Changes button in Filters until changes are made
  • Loading branch information
StephenHeaps authored Oct 13, 2023
1 parent 526b2fb commit 6178028
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 6178028

Please sign in to comment.