nozaps: switch to global sheet when zapping
This fixes many popping bugs Changelog-Fixed: Fix zap sheet popping
This commit is contained in:
@@ -96,7 +96,6 @@ struct ProfileView: View {
|
||||
|
||||
static let markdown = Markdown()
|
||||
|
||||
@State var showing_select_wallet: Bool = false
|
||||
@State var is_zoomed: Bool = false
|
||||
@State var show_share_sheet: Bool = false
|
||||
@State var show_qr_code: Bool = false
|
||||
@@ -245,7 +244,7 @@ struct ProfileView: View {
|
||||
func lnButton(lnurl: String, profile: Profile) -> some View {
|
||||
let button_img = profile.reactions == false ? "zap.fill" : "zap"
|
||||
return Button(action: {
|
||||
zap_button_model.showing_zap_customizer = true
|
||||
present_sheet(.zap(target: .profile(self.profile.pubkey), lnurl: lnurl))
|
||||
}) {
|
||||
Image(button_img)
|
||||
.foregroundColor(button_img == "zap.fill" ? .orange : Color.primary)
|
||||
@@ -272,38 +271,6 @@ struct ProfileView: View {
|
||||
|
||||
}
|
||||
.cornerRadius(24)
|
||||
.sheet(isPresented: $zap_button_model.showing_zap_customizer) {
|
||||
CustomizeZapView(state: damus_state, target: ZapTarget.profile(self.profile.pubkey), lnurl: lnurl)
|
||||
}
|
||||
.sheet(isPresented: $zap_button_model.showing_select_wallet, onDismiss: {zap_button_model.showing_select_wallet = false}) {
|
||||
SelectWalletView(default_wallet: damus_state.settings.default_wallet, showingSelectWallet: $zap_button_model.showing_select_wallet, our_pubkey: damus_state.pubkey, invoice: zap_button_model.invoice ?? "")
|
||||
}
|
||||
.onReceive(handle_notify(.zapping)) { notif in
|
||||
let zap_ev = notif.object as! ZappingEvent
|
||||
|
||||
guard zap_ev.target.id == self.profile.pubkey else {
|
||||
return
|
||||
}
|
||||
|
||||
guard !zap_ev.is_custom else {
|
||||
return
|
||||
}
|
||||
|
||||
switch zap_ev.type {
|
||||
case .failed:
|
||||
break
|
||||
case .got_zap_invoice(let inv):
|
||||
if damus_state.settings.show_wallet_selector {
|
||||
zap_button_model.invoice = inv
|
||||
zap_button_model.showing_select_wallet = true
|
||||
} else {
|
||||
let wallet = damus_state.settings.default_wallet.model
|
||||
open_with_wallet(wallet: wallet, invoice: inv)
|
||||
}
|
||||
case .sent_from_nwc:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var dmButton: some View {
|
||||
|
||||
@@ -9,7 +9,7 @@ import SwiftUI
|
||||
|
||||
struct SelectWalletView: View {
|
||||
let default_wallet: Wallet
|
||||
@Binding var showingSelectWallet: Bool
|
||||
@Binding var active_sheet: Sheets?
|
||||
let our_pubkey: String
|
||||
let invoice: String
|
||||
@State var invoice_copied: Bool = false
|
||||
@@ -59,7 +59,7 @@ struct SelectWalletView: View {
|
||||
}.padding(.vertical, 2.5)
|
||||
}
|
||||
}.navigationBarTitle(Text("Pay the Lightning invoice", comment: "Navigation bar title for view to pay Lightning invoice."), displayMode: .inline).navigationBarItems(trailing: Button(action: {
|
||||
self.showingSelectWallet = false
|
||||
self.active_sheet = nil
|
||||
}) {
|
||||
Text("Done", comment: "Button to dismiss wallet selection view for paying Lightning invoice.").bold()
|
||||
})
|
||||
@@ -68,9 +68,9 @@ struct SelectWalletView: View {
|
||||
}
|
||||
|
||||
struct SelectWalletView_Previews: PreviewProvider {
|
||||
@State static var show: Bool = true
|
||||
@State static var active_sheet: Sheets? = nil
|
||||
|
||||
static var previews: some View {
|
||||
SelectWalletView(default_wallet: .lnlink, showingSelectWallet: $show, our_pubkey: "", invoice: "")
|
||||
SelectWalletView(default_wallet: .lnlink, active_sheet: $active_sheet, our_pubkey: "", invoice: "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,12 +216,11 @@ struct CustomizeZapView: View {
|
||||
case .got_zap_invoice(let inv):
|
||||
if state.settings.show_wallet_selector {
|
||||
model.invoice = inv
|
||||
model.showing_wallet_selector = true
|
||||
present_sheet(.select_wallet(invoice: inv))
|
||||
} else {
|
||||
end_editing()
|
||||
let wallet = state.settings.default_wallet.model
|
||||
open_with_wallet(wallet: wallet, invoice: inv)
|
||||
model.showing_wallet_selector = false
|
||||
dismiss()
|
||||
}
|
||||
case .sent_from_nwc:
|
||||
@@ -259,9 +258,6 @@ struct CustomizeZapView: View {
|
||||
ZapPicker
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $model.showing_wallet_selector) {
|
||||
SelectWalletView(default_wallet: state.settings.default_wallet, showingSelectWallet: $model.showing_wallet_selector, our_pubkey: state.pubkey, invoice: model.invoice)
|
||||
}
|
||||
.onAppear {
|
||||
model.set_defaults(settings: state.settings)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ struct ZapUserView: View {
|
||||
var body: some View {
|
||||
HStack(alignment: .center) {
|
||||
Text("Zap")
|
||||
.font(.largeTitle)
|
||||
.font(.title2)
|
||||
|
||||
UserView(damus_state: state, pubkey: pubkey, spacer: false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user