1
0
mirror of git://jb55.com/damus synced 2024-09-19 11:43:44 +00:00

make wallet items a List

This commit is contained in:
Suhail Saqan 2022-12-22 16:15:34 -06:00
parent 21db49b6dd
commit ed9e60ffb6
No known key found for this signature in database
GPG Key ID: C3E8D33BFD16C6E6
5 changed files with 55 additions and 74 deletions

View File

@ -1025,7 +1025,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\"";
DEVELOPMENT_TEAM = XK7H4JAB3D;
DEVELOPMENT_TEAM = XL4476DR2X;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = damus/Info.plist;
@ -1064,7 +1064,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\"";
DEVELOPMENT_TEAM = XK7H4JAB3D;
DEVELOPMENT_TEAM = XL4476DR2X;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = damus/Info.plist;

View File

@ -1,21 +0,0 @@
{
"images" : [
{
"filename" : "breez.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -25,14 +25,13 @@ public class Constants {
static let WALLETS = """
[
{"id": 0, "name": "Strike", "link": "strike:lightning", "appStoreLink": "https://apps.apple.com/us/app/strike-bitcoin-payments/id1488724463", "image": "strike"},
{"id": 0, "name": "Strike", "link": "strike:", "appStoreLink": "https://apps.apple.com/us/app/strike-bitcoin-payments/id1488724463", "image": "strike"},
{"id": 1, "name": "Cash App", "link": "squarecash://", "appStoreLink": "https://apps.apple.com/us/app/cash-app/id711923939", "image": "cashapp"},
{"id": 2, "name": "Muun", "link": "muun:", "appStoreLink": "https://apps.apple.com/us/app/muun-wallet/id1482037683", "image": "muun"},
{"id": 3, "name": "Blue Wallet", "link": "bluewallet:lightning", "appStoreLink": "https://apps.apple.com/us/app/bluewallet-bitcoin-wallet/id1376878040", "image": "bluewallet"},
{"id": 4, "name": "Wallet Of Satoshi", "link": "walletofsatoshi:lightning", "appStoreLink": "https://apps.apple.com/us/app/wallet-of-satoshi/id1438599608", "image": "walletofsatoshi"},
{"id": 5, "name": "Breez", "link": "breez:lightning", "appStoreLink": "https://testflight.apple.com/join/wPju2Du7", "image": "breez"},
{"id": 6, "name": "Zebedee", "link": "zebedee:lightning", "appStoreLink": "https://apps.apple.com/us/app/zebedee-wallet/id1484394401", "image": "zebedee"},
{"id": 7, "name": "Zeus LN", "link": "zeusln:lightning", "appStoreLink": "https://apps.apple.com/us/app/zeus-ln/id1456038895", "image": "zeusln"},
{"id": 3, "name": "Blue Wallet", "link": "bluewallet:lightning:", "appStoreLink": "https://apps.apple.com/us/app/bluewallet-bitcoin-wallet/id1376878040", "image": "bluewallet"},
{"id": 4, "name": "Wallet Of Satoshi", "link": "walletofsatoshi:lightning:", "appStoreLink": "https://apps.apple.com/us/app/wallet-of-satoshi/id1438599608", "image": "walletofsatoshi"},
{"id": 5, "name": "Zebedee", "link": "zebedee:lightning:", "appStoreLink": "https://apps.apple.com/us/app/zebedee-wallet/id1484394401", "image": "zebedee"},
{"id": 6, "name": "Zeus LN", "link": "zeusln:lightning:", "appStoreLink": "https://apps.apple.com/us/app/zeus-ln/id1456038895", "image": "zeusln"},
]
""".data(using: .utf8)!
}

View File

@ -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()
})
}
}
}