Revert "Bh updates to improve wallet selector"

This commit is contained in:
Suhail Saqan
2022-12-29 23:30:56 -08:00
committed by GitHub
parent 0bcabc8e08
commit 403a22125a
8 changed files with 177 additions and 162 deletions

View File

@@ -18,8 +18,8 @@ struct ConfigView: View {
@State var privkey_copied: Bool = false
@State var pubkey_copied: Bool = false
@EnvironmentObject var user_settings: UserSettingsStore
@State var allWallets: [Wallet] = Wallet.allCases
let walletItems: [WalletItem] = get_wallet_list()
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)
Picker("Select default wallet",
selection: $user_settings.defaultWallet) {
ForEach(allWallets, id: \.self) { wallet in
Text(wallet.model.displayName)
.tag(wallet.model.tag)
}
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))
}
})
}
}

View File

@@ -150,8 +150,7 @@ 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)
}
}

View File

@@ -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 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) {
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) {
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)
}
}
} 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)
}
}.padding(.vertical, 2.5)
}
}.navigationBarTitle(Text("Pay the lightning invoice"), displayMode: .inline).navigationBarItems(trailing: Button(action: {
self.showingSelectWallet = false
}) {