commit c4884eed229e6ea7c613dd00c680e68cd61aa38a
parent 906e4ad9195de6a98fc7cd1d3445151f5eebdebc
Author: William Casarin <jb55@jb55.com>
Date: Sat, 5 Mar 2022 09:55:55 -0800
PayView: pull out confirm_button into its own function
Just to clean things up a bit, the view is getting pretty noisy
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/lightninglink/Views/PayView.swift b/lightninglink/Views/PayView.swift
@@ -132,24 +132,7 @@ struct PayView: View {
Spacer()
- if ready_invoice != nil {
-
- Button("Confirm") {
- let res = confirm_payment(bolt11: ready_invoice!.invoice, lnlink: self.lnlink)
-
- switch res {
- case .left(let err):
- self.error = "Error: \(err)"
-
- case .right(let pay):
- print(pay)
- self.dismiss()
- NotificationCenter.default.post(name: .sentPayment, object: pay)
- }
- }
- .foregroundColor(Color.green)
- .font(.title)
- }
+ confirm_button(ready_invoice)
}
}
.onAppear() {
@@ -161,6 +144,28 @@ struct PayView: View {
}
}
+ func confirm_button(_ ready_invoice: ReadyInvoice?) -> some View {
+ Group {
+ if ready_invoice != nil {
+ Button("Confirm") {
+ let res = confirm_payment(bolt11: ready_invoice!.invoice, lnlink: self.lnlink)
+
+ switch res {
+ case .left(let err):
+ self.error = "Error: \(err)"
+
+ case .right(let pay):
+ print(pay)
+ self.dismiss()
+ NotificationCenter.default.post(name: .sentPayment, object: pay)
+ }
+ }
+ .foregroundColor(Color.green)
+ .font(.title)
+ }
+ }
+ }
+
func switch_state(_ state: PayState) {
self.state = state
handle_state_change()