Revert "@bhakes: Bh updates to improve wallet selector" (#6)
This commit is contained in:
@@ -18,8 +18,8 @@ struct ConfigView: View {
|
||||
@State var privkey_copied: Bool = false
|
||||
@State var pubkey_copied: Bool = false
|
||||
@EnvironmentObject var user_settings: UserSettingsStore
|
||||
|
||||
let walletItems: [WalletItem] = get_wallet_list()
|
||||
|
||||
@State var allWallets: [Wallet] = Wallet.allCases
|
||||
|
||||
let generator = UIImpactFeedbackGenerator(style: .light)
|
||||
|
||||
@@ -82,13 +82,13 @@ struct ConfigView: View {
|
||||
}
|
||||
|
||||
Section("Wallet Selector") {
|
||||
Toggle("Show wallet selector", isOn: $user_settings.showwalletselector).toggleStyle(.switch)
|
||||
if walletItems != [] {
|
||||
Picker(selection: $user_settings.defaultwallet, label: Text("Select default wallet"), content: {
|
||||
ForEach(walletItems, id: \.self) { wallet in
|
||||
Text(wallet.name).tag(get_wallet_tag(wallet.tag))
|
||||
}
|
||||
})
|
||||
Toggle("Show wallet selector", isOn: $user_settings.showWalletSelector).toggleStyle(.switch)
|
||||
Picker("Select default wallet",
|
||||
selection: $user_settings.defaultWallet) {
|
||||
ForEach(allWallets, id: \.self) { wallet in
|
||||
Text(wallet.model.displayName)
|
||||
.tag(wallet.model.tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,8 @@ struct ProfileView: View {
|
||||
}
|
||||
}
|
||||
}.sheet(isPresented: $showingSelectWallet, onDismiss: {showingSelectWallet = false}) {
|
||||
SelectWalletView(showingSelectWallet: $showingSelectWallet, invoice: $inv).environmentObject(user_settings)
|
||||
SelectWalletView(showingSelectWallet: $showingSelectWallet, invoice: $inv)
|
||||
.environmentObject(user_settings)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ struct SelectWalletView: View {
|
||||
@State var invoice_copied: Bool = false
|
||||
@EnvironmentObject var user_settings: UserSettingsStore
|
||||
|
||||
@State var allWalletModels: [Wallet.Model] = Wallet.allModels
|
||||
let generator = UIImpactFeedbackGenerator(style: .light)
|
||||
let walletItems: [WalletItem] = get_wallet_list()
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
@@ -35,42 +35,42 @@ struct SelectWalletView: View {
|
||||
generator.impactOccurred()
|
||||
}
|
||||
}
|
||||
Section("Select a lightning wallet"){
|
||||
List{
|
||||
Button() {
|
||||
let wallet = get_default_wallet(user_settings.defaultwallet.rawValue)
|
||||
if let url = URL(string: "\(wallet.link)\(invoice)"), UIApplication.shared.canOpenURL(url) {
|
||||
Section("Select a lightning wallet"){
|
||||
List{
|
||||
Button() {
|
||||
let walletModel = user_settings.defaultWallet.model
|
||||
if let url = URL(string: "\(walletModel.link)\(invoice)"), UIApplication.shared.canOpenURL(url) {
|
||||
openURL(url)
|
||||
} else {
|
||||
if let url = URL(string: walletModel.appStoreLink), UIApplication.shared.canOpenURL(url) {
|
||||
openURL(url)
|
||||
} else {
|
||||
if let url = URL(string: wallet.appStoreLink), UIApplication.shared.canOpenURL(url) {
|
||||
openURL(url)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
HStack {
|
||||
Text("Default Wallet").font(.body).foregroundColor(.blue)
|
||||
}
|
||||
}.buttonStyle(.plain)
|
||||
ForEach(walletItems, id: \.self) { wallet in
|
||||
if (wallet.id >= 0){
|
||||
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)
|
||||
}
|
||||
}.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
}.padding(.vertical, 2.5)
|
||||
}
|
||||
} label: {
|
||||
HStack {
|
||||
Text("Default Wallet").font(.body).foregroundColor(.blue)
|
||||
}
|
||||
}.buttonStyle(.plain)
|
||||
List($allWalletModels) { $wallet in
|
||||
if wallet.index >= 0 {
|
||||
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.displayName).font(.body)
|
||||
}
|
||||
}.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
}.padding(.vertical, 2.5)
|
||||
}
|
||||
}.navigationBarTitle(Text("Pay the lightning invoice"), displayMode: .inline).navigationBarItems(trailing: Button(action: {
|
||||
self.showingSelectWallet = false
|
||||
}) {
|
||||
|
||||
Reference in New Issue
Block a user