add wallet modal

This commit is contained in:
Suhail Saqan
2022-12-22 04:20:37 -06:00
parent 205b1ba731
commit bb6d1b2522
4 changed files with 74 additions and 4 deletions

View File

@@ -0,0 +1,51 @@
//
// SelectWalletView.swift
// damus
//
// Created by Suhail Saqan on 12/22/22.
//
import SwiftUI
struct WalletItem : Decodable, Identifiable {
var id: Int
var name : String
var link : String
var appStoreLink : String
}
struct SelectWalletView: View {
@Binding var show_select_wallet: Bool
@Binding var invoice: String
@Environment(\.openURL) private var openURL
let walletItems = try! JSONDecoder().decode([WalletItem].self, from: Constants.WALLETS)
var body: some View {
VStack(alignment: .leading) {
ForEach(walletItems) { wallet in
HStack(spacing: 20) {
Button("\(wallet.name)"){
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)
}
}
}.buttonStyle(.borderedProminent)
.contentShape(Rectangle())
}
}
}
}
}
struct SelectWalletView_Previews: PreviewProvider {
@State static var show: Bool = true
@State static var invoice: String = ""
static var previews: some View {
SelectWalletView(show_select_wallet: $show, invoice: $invoice)
}
}