Skip to content

Commit

Permalink
Fix brave/brave-ios#8459: Accounts tab modals reset when returning fr…
Browse files Browse the repository at this point in the history
…om background (brave/brave-ios#8460)

Fix for Accounts modals resetting if KeyringStore changes. Sheet(s) presented from Lists that are redrawn lose their state.
  • Loading branch information
StephenHeaps committed Nov 22, 2023
1 parent b5cc113 commit 026f1f0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
34 changes: 5 additions & 29 deletions Sources/BraveWallet/Crypto/Accounts/AccountsHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ struct AccountsHeaderView: View {
var settingsStore: SettingsStore
var networkStore: NetworkStore

@State private var isPresentingBackup: Bool = false
@State private var isPresentingAddAccount: Bool = false
@Binding var isPresentingBackup: Bool
@Binding var isPresentingAddAccount: Bool

var body: some View {
HStack {
Expand All @@ -27,20 +27,6 @@ struct AccountsHeaderView: View {
.foregroundColor(Color(.braveBlurpleTint))
}
}
.background(
Color.clear
.sheet(isPresented: $isPresentingBackup) {
NavigationView {
BackupWalletView(
password: nil,
keyringStore: keyringStore
)
}
.navigationViewStyle(StackNavigationViewStyle())
.environment(\.modalPresentationMode, $isPresentingBackup)
.accentColor(Color(.braveBlurpleTint))
}
)
Spacer()
HStack(spacing: 16) {
Button(action: {
Expand All @@ -49,18 +35,6 @@ struct AccountsHeaderView: View {
Label(Strings.Wallet.addAccountTitle, systemImage: "plus")
.labelStyle(.iconOnly)
}
.background(
Color.clear
.sheet(isPresented: $isPresentingAddAccount) {
NavigationView {
AddAccountView(
keyringStore: keyringStore,
networkStore: networkStore
)
}
.navigationViewStyle(StackNavigationViewStyle())
}
)
NavigationLink(
destination: Web3SettingsView(
settingsStore: settingsStore,
Expand All @@ -83,7 +57,9 @@ struct AccountsHeaderView_Previews: PreviewProvider {
AccountsHeaderView(
keyringStore: .previewStore,
settingsStore: .previewStore,
networkStore: .previewStore
networkStore: .previewStore,
isPresentingBackup: .constant(false),
isPresentingAddAccount: .constant(false)
)
.previewLayout(.sizeThatFits)
.previewColorSchemes()
Expand Down
32 changes: 31 additions & 1 deletion Sources/BraveWallet/Crypto/Accounts/AccountsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct AccountsView: View {
var cryptoStore: CryptoStore
@ObservedObject var keyringStore: KeyringStore
@State private var selectedAccount: BraveWallet.AccountInfo?
@State private var isPresentingBackup: Bool = false
@State private var isPresentingAddAccount: Bool = false

private var primaryAccounts: [BraveWallet.AccountInfo] {
keyringStore.allAccounts.filter(\.isPrimary)
Expand All @@ -29,7 +31,9 @@ struct AccountsView: View {
header: AccountsHeaderView(
keyringStore: keyringStore,
settingsStore: cryptoStore.settingsStore,
networkStore: cryptoStore.networkStore
networkStore: cryptoStore.networkStore,
isPresentingBackup: $isPresentingBackup,
isPresentingAddAccount: $isPresentingAddAccount
)
.resetListHeaderStyle()
) {
Expand Down Expand Up @@ -106,6 +110,32 @@ struct AccountsView: View {
)
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.background(
Color.clear
.sheet(isPresented: $isPresentingBackup) {
NavigationView {
BackupWalletView(
password: nil,
keyringStore: keyringStore
)
}
.navigationViewStyle(StackNavigationViewStyle())
.environment(\.modalPresentationMode, $isPresentingBackup)
.accentColor(Color(.braveBlurpleTint))
}
)
.background(
Color.clear
.sheet(isPresented: $isPresentingAddAccount) {
NavigationView {
AddAccountView(
keyringStore: keyringStore,
networkStore: cryptoStore.networkStore
)
}
.navigationViewStyle(StackNavigationViewStyle())
}
)
}
}

Expand Down

0 comments on commit 026f1f0

Please sign in to comment.