allow opening wallet selector for profile LN button
This commit is contained in:
@@ -9,13 +9,13 @@ import SwiftUI
|
||||
|
||||
struct InvoiceView: View {
|
||||
let invoice: Invoice
|
||||
@State var show_select_wallet: Bool = false
|
||||
@State var showingSelectWallet: Bool = false
|
||||
@State var inv: String = ""
|
||||
|
||||
var PayButton: some View {
|
||||
Button("Pay") {
|
||||
inv = invoice.string
|
||||
show_select_wallet = true
|
||||
showingSelectWallet = true
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
}
|
||||
@@ -39,8 +39,8 @@ struct InvoiceView: View {
|
||||
.zIndex(5.0)
|
||||
}
|
||||
.padding()
|
||||
} .sheet(isPresented: $show_select_wallet, onDismiss: {show_select_wallet = false}) {
|
||||
SelectWalletView(show_select_wallet: $show_select_wallet, invoice: $inv)
|
||||
}.sheet(isPresented: $showingSelectWallet, onDismiss: {showingSelectWallet = false}) {
|
||||
SelectWalletView(showingSelectWallet: $showingSelectWallet, invoice: $inv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,20 +118,29 @@ struct ProfileView: View {
|
||||
@StateObject var profile: ProfileModel
|
||||
@StateObject var followers: FollowersModel
|
||||
@State private var showingEditProfile = false
|
||||
@State var showingSelectWallet: Bool = false
|
||||
@State var inv: String = ""
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
//@EnvironmentObject var profile: ProfileModel
|
||||
|
||||
func LNButton(_ url: URL) -> some View {
|
||||
func LNButton(lud06: String?, lud16: String?) -> some View {
|
||||
Button(action: {
|
||||
UIApplication.shared.open(url)
|
||||
if let l = lud06 {
|
||||
inv = l
|
||||
} else {
|
||||
inv = lud16 ?? ""
|
||||
}
|
||||
showingSelectWallet = true
|
||||
}) {
|
||||
Image(systemName: "bolt.circle")
|
||||
.symbolRenderingMode(.palette)
|
||||
.font(.system(size: 34).weight(.thin))
|
||||
.foregroundStyle(colorScheme == .light ? .black : .white, colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.2))
|
||||
}.sheet(isPresented: $showingSelectWallet, onDismiss: {showingSelectWallet = false}) {
|
||||
SelectWalletView(showingSelectWallet: $showingSelectWallet, invoice: $inv)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +165,8 @@ struct ProfileView: View {
|
||||
|
||||
Spacer()
|
||||
|
||||
if let lnuri = data?.lightning_uri {
|
||||
LNButton(lnuri)
|
||||
if (data != nil) && (data?.lud06 != nil || data?.lud16 != nil) {
|
||||
LNButton(lud06: data?.lud06, lud16: data?.lud16)
|
||||
}
|
||||
|
||||
DMButton
|
||||
|
||||
@@ -16,7 +16,7 @@ struct WalletItem : Decodable, Identifiable, Hashable {
|
||||
}
|
||||
|
||||
struct SelectWalletView: View {
|
||||
@Binding var show_select_wallet: Bool
|
||||
@Binding var showingSelectWallet: Bool
|
||||
@Binding var invoice: String
|
||||
@Environment(\.openURL) private var openURL
|
||||
@State var invoice_copied: Bool = false
|
||||
@@ -78,7 +78,7 @@ struct SelectWalletView: View {
|
||||
}
|
||||
}
|
||||
}.navigationBarTitle(Text("Pay the lightning invoice"), displayMode: .inline).navigationBarItems(trailing: Button(action: {
|
||||
self.show_select_wallet = false
|
||||
self.showingSelectWallet = false
|
||||
}) {
|
||||
Text("Done").bold()
|
||||
})
|
||||
@@ -91,6 +91,6 @@ struct SelectWalletView_Previews: PreviewProvider {
|
||||
@State static var invoice: String = ""
|
||||
|
||||
static var previews: some View {
|
||||
SelectWalletView(show_select_wallet: $show, invoice: $invoice)
|
||||
SelectWalletView(showingSelectWallet: $show, invoice: $invoice)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user