lnlink

iOS app for connecting to lightning nodes
git clone git://jb55.com/lnlink
Log | Files | Refs | Submodules | README | LICENSE

SettingsView.swift (1497B)


      1 //
      2 //  SettingsView.swift
      3 //  lightninglink
      4 //
      5 //  Created by William Casarin on 2022-03-05.
      6 //
      7 
      8 import SwiftUI
      9 
     10 
     11 
     12 struct SettingsView: View {
     13     @State var is_reset: Bool = false
     14     @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
     15 
     16     func main_view() -> some View {
     17         VStack {
     18             HStack {
     19                 Text("Settings")
     20                     .font(.largeTitle)
     21                     .fontWeight(.bold)
     22                 Spacer()
     23             }
     24 
     25             Form {
     26                 Section(header: Text("Connection settings")) {
     27                     Button("Disconnect LNLink") {
     28                         reset_lnlink()
     29                         self.presentationMode.wrappedValue.dismiss()
     30                         NotificationCenter.default.post(name: .reset, object: ())
     31                     }
     32                 }
     33 
     34                 Section(header: Text("Support")) {
     35                     Button("Buy me a 🍺") {
     36                         self.presentationMode.wrappedValue.dismiss()
     37                         NotificationCenter.default.post(name: .donate, object: ())
     38                     }
     39                 }
     40 
     41             }
     42             .frame(height: 200)
     43 
     44             Spacer()
     45         }
     46         .padding()
     47     }
     48 
     49     var body: some View {
     50         if is_reset {
     51             SetupView()
     52         } else {
     53             main_view()
     54         }
     55     }
     56 }
     57 
     58 struct SettingsView_Previews: PreviewProvider {
     59     static var previews: some View {
     60         SettingsView()
     61     }
     62 }