Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions BDKSwiftExampleWallet/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@
}
}
}
},
"Get sats from faucet" : {

},
"HomeView Error" : {
"localizations" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ import Foundation
@Observable
class TransactionListViewModel {
let bdkClient: BDKClient
let keyClient: KeyClient

var showingWalletTransactionsViewErrorAlert = false
var walletTransactionsViewError: AppError?

init(
bdkClient: BDKClient = .live
bdkClient: BDKClient = .live,
keyClient: KeyClient = .live
) {
self.bdkClient = bdkClient
self.keyClient = keyClient
}

func getSentAndReceived(tx: BitcoinDevKit.Transaction) -> SentAndReceivedValues? {
Expand All @@ -35,4 +38,9 @@ class TransactionListViewModel {
}
}

func getEsploraURL() -> String? {
let savedEsploraURL = try? keyClient.getEsploraURL()
return savedEsploraURL
}

}
47 changes: 43 additions & 4 deletions BDKSwiftExampleWallet/View/Activity/TransactionListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,40 @@ struct TransactionListView: View {
.listRowInsets(EdgeInsets())
.listRowSeparator(.hidden)
} else if transactions.isEmpty {
Text("No Transactions")
.font(.subheadline)
.listRowInsets(EdgeInsets())
.listRowSeparator(.hidden)

VStack(alignment: .leading) {

Text("No Transactions")
.font(.subheadline)

let mutinyFaucetURL = URL(string: "https://faucet.mutinynet.com")
let signetFaucetURL = URL(string: "https://signetfaucet.com")

if let mutinyFaucetURL, let signetFaucetURL {

Button {
UIApplication.shared.open(
viewModel.getEsploraURL()
== Constants.Config.EsploraServerURLNetwork.Signet.mutiny
? mutinyFaucetURL : signetFaucetURL
)
} label: {
HStack(spacing: 2) {
Text("Get sats from faucet")
Image(systemName: "arrow.right")
}
.font(.caption)
.foregroundStyle(.secondary)
.underline()
}
.buttonStyle(.plain)

}

}
.listRowInsets(EdgeInsets())
.listRowSeparator(.hidden)

} else {

ForEach(
Expand Down Expand Up @@ -99,4 +129,13 @@ struct TransactionListView: View {
walletSyncState: .synced
)
}
#Preview {
TransactionListView(
viewModel: .init(
bdkClient: .mock
),
transactions: [],
walletSyncState: .synced
)
}
#endif
Loading