@ -7,7 +7,7 @@
import SwiftUI
struct WalletItem : Decodable , Identifiable {
struct WalletItem : Decodable , Identifiable , Hashable {
var id : Int
var name : String
var link : String
@ -29,56 +29,59 @@ struct SelectWalletView: View {
NavigationView {
Form {
VStack ( alignment : . leading ) {
Text ( " Copy invoice " )
. bold ( )
. font ( . title3 )
. multilineTextAlignment ( . center )
. padding ( [ . bottom , . top ] , 8 )
HStack {
Text ( invoice ) . font ( . body )
. multilineTextAlignment ( . center )
. lineLimit ( 3 )
. truncationMode ( . tail )
Image ( systemName : self . invoice_copied ? " checkmark.circle " : " doc.on.doc " )
}
. clipShape ( RoundedRectangle ( cornerRadius : 5 ) ) . onTapGesture {
UIPasteboard . general . string = invoice
self . invoice_copied = true
generator . impactOccurred ( )
}
Text ( " Copy invoice " )
. bold ( )
. font ( . title3 )
. multilineTextAlignment ( . center )
. padding ( [ . bottom , . top ] , 8 )
HStack {
Text ( invoice ) . font ( . body )
. lineLimit ( 2 )
. truncationMode ( . tail )
Image ( systemName : self . invoice_copied ? " checkmark.circle " : " doc.on.doc " )
}
. clipShape ( RoundedRectangle ( cornerRadius : 5 ) ) . onTapGesture {
UIPasteboard . general . string = invoice
self . invoice_copied = true
generator . impactOccurred ( )
}
Spacer ( )
Text ( " Select a lightning wallet " )
. bold ( )
. font ( . title3 )
. multilineTextAlignment ( . center )
. padding ( [ . bottom ] , 8 )
ForEach ( walletItems ) { wallet in
HStack ( spacing : 20 ) {
Image ( wallet . image )
. resizable ( )
. frame ( width : 32.0 , height : 32.0 , alignment : . center )
. cornerRadius ( 5 )
Text ( " \( wallet . name ) " )
} . onTapGesture {
if let url = URL ( string : " \( wallet . link ) \( invoice ) " ) , UIApplication . shared . canOpenURL ( url ) {
openURL ( url )
} else {
if let url = URL ( string : wallet . appStoreLink ) , UIApplication . shared . canOpenURL ( url ) {
List {
Section {
ForEach ( walletItems , id : \ . self ) { wallet in
Button ( ) {
if let url = URL ( string : " \( wallet . link ) \( invoice ) " ) , UIApplication . shared . canOpenURL ( url ) {
openURL ( url )
} else {
if let url = URL ( string : wallet . appStoreLink ) , UIApplication . shared . canOpenURL ( url ) {
openURL ( url )
}
}
}
} label : {
HStack {
Image ( wallet . image ) . resizable ( ) . frame ( width : 32.0 , height : 32.0 , alignment : . center ) . cornerRadius ( 5 )
Text ( wallet . name ) . font ( . body )
. lineLimit ( 2 )
. truncationMode ( . tail )
} . padding ( [ . bottom ] , 4 )
} . buttonStyle ( . plain )
wallet . id != 6 ? Divider ( ) . padding ( [ . bottom ] , - 6 ) : nil
}
Divider ( )
} header : {
Text ( " Select a lightning wallet " )
. bold ( )
. font ( . title3 )
. multilineTextAlignment ( . center )
. padding ( [ . bottom , . top ] , 8 )
}
}
}
. navigationBarTitle ( Text ( " Pay the lightning invoice " ) , displayMode : . inline )
. navigationBarItems ( trailing : Button ( action : {
self . show_select_wallet = false
} ) {
Text ( " Done " ) . bold ( )
} )
}
} . navigationBarTitle ( Text ( " Pay the lightning invoice " ) , displayMode : . inline ) . navigationBarItems ( trailing : Button ( action : {
self . show_select_wallet = false
} ) {
Text ( " Done " ) . bold ( )
} )
}
}
}