Post

Replies

Boosts

Views

Activity

Reply to Unable to pass down returned value from one view to another
// //  ListView.swift //  Notes10 // //  Created by Mansidak Singh on 6/15/22. // import SwiftUI import FirebaseFirestore import Firebase import FirebaseAuth   struct ListView: View {     @StateObject var dataManager = DataManager()     @State var isPresented = false     var body: some View {         NavigationView {             ZStack{                              List(dataManager.notes) { note in                 NavigationLink(destination: NoteView(newNote: note.content, idd: note.id)) {                     EmptyView()                                     Text(note.content)}.buttonStyle(PlainButtonStyle())                              .frame(height: 0)                            .navigationTitle("Notes")                              .navigationBarItems(                 trailing: Button (action: {},                                   label: {                                          NavigationLink(destination: NoteView(newNote: "", idd: "") )                                                       {Image(systemName: "plus")}                       .simultaneousGesture(TapGesture().onEnded{                           dataManager.addNote()                       })}                      ))                     .listStyle(.plain)                     .buttonStyle(PlainButtonStyle())                                                                       }.environment(\.defaultMinListRowHeight, 55)                 .listStyle(.plain)                 .buttonStyle(PlainButtonStyle())         .padding(.trailing, -80.0) //             }         }.accentColor(.black)     } } Here is the Data Manager code that runs the addNote function import Foundation import FirebaseFirestore import SwiftUI import Firebase import FirebaseDatabase import FirebaseAuth class DataManager : ObservableObject {          @Published var notes: [Note] = []     @Published var idd = ""     func addNote()-> String{         let user = Auth.auth().currentUser         let uid = Auth.auth().currentUser!.uid         let db = Firestore.firestore()         var ref: DocumentReference? = nil         ref = db.collection("userslist").document(uid).collection("actualnotes").addDocument(data: ["content":"New Note","time": [".sv": "timestamp"]])         {error in         if let error = error{             print(error.localizedDescription)         }             else {                     print("Document added with ID: \(ref!.documentID)")               }         } //        @Binding var idd: String                let  idd = ref!.documentID                   return idd         }           Here is the NotesView code that accepts the idd import Foundation import SwiftUI struct NoteView: View {          @State var newNote: String = ""     @State var idd: String = "" @StateObject var dataManager = DataManager()     var body: some View {         TextEditor(text: $newNote)         TextEditor(text: $idd)                 .padding(EdgeInsets(top: -10, leading: 10, bottom: 40, trailing: 0))                                .font(.system(size: 16, design: .monospaced))                           Button (action: {                              dataManager.updateNote(idd: idd, noteContent: newNote)                              }, label: {Text("Update")}) .listStyle(.plain)                     .buttonStyle(PlainButtonStyle())     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Source view disappearing when interrupting a zoom navigation transition
apple fix this pls thx
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jan ’26
Reply to FinanceKit - authorization process is not entitled error
Hi folks, @dtroupe I recenlty got the entitlement approval. My code is still crashing. any updates on this? : /
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to FinanceKit requestAuthorization denied
Any updates on this? I'm still getting the same error as OP despite using NSFinancialDataUsageDescription
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Unable to pass down returned value from one view to another
hi @Claude31, so sorry for my ignorance. I just formatted the code properly and added that in one of the replies below. I couldn't edit the original post for some reason.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Unable to pass down returned value from one view to another
// //  ListView.swift //  Notes10 // //  Created by Mansidak Singh on 6/15/22. // import SwiftUI import FirebaseFirestore import Firebase import FirebaseAuth   struct ListView: View {     @StateObject var dataManager = DataManager()     @State var isPresented = false     var body: some View {         NavigationView {             ZStack{                              List(dataManager.notes) { note in                 NavigationLink(destination: NoteView(newNote: note.content, idd: note.id)) {                     EmptyView()                                     Text(note.content)}.buttonStyle(PlainButtonStyle())                              .frame(height: 0)                            .navigationTitle("Notes")                              .navigationBarItems(                 trailing: Button (action: {},                                   label: {                                          NavigationLink(destination: NoteView(newNote: "", idd: "") )                                                       {Image(systemName: "plus")}                       .simultaneousGesture(TapGesture().onEnded{                           dataManager.addNote()                       })}                      ))                     .listStyle(.plain)                     .buttonStyle(PlainButtonStyle())                                                                       }.environment(\.defaultMinListRowHeight, 55)                 .listStyle(.plain)                 .buttonStyle(PlainButtonStyle())         .padding(.trailing, -80.0) //             }         }.accentColor(.black)     } } Here is the Data Manager code that runs the addNote function import Foundation import FirebaseFirestore import SwiftUI import Firebase import FirebaseDatabase import FirebaseAuth class DataManager : ObservableObject {          @Published var notes: [Note] = []     @Published var idd = ""     func addNote()-> String{         let user = Auth.auth().currentUser         let uid = Auth.auth().currentUser!.uid         let db = Firestore.firestore()         var ref: DocumentReference? = nil         ref = db.collection("userslist").document(uid).collection("actualnotes").addDocument(data: ["content":"New Note","time": [".sv": "timestamp"]])         {error in         if let error = error{             print(error.localizedDescription)         }             else {                     print("Document added with ID: \(ref!.documentID)")               }         } //        @Binding var idd: String                let  idd = ref!.documentID                   return idd         }           Here is the NotesView code that accepts the idd import Foundation import SwiftUI struct NoteView: View {          @State var newNote: String = ""     @State var idd: String = "" @StateObject var dataManager = DataManager()     var body: some View {         TextEditor(text: $newNote)         TextEditor(text: $idd)                 .padding(EdgeInsets(top: -10, leading: 10, bottom: 40, trailing: 0))                                .font(.system(size: 16, design: .monospaced))                           Button (action: {                              dataManager.updateNote(idd: idd, noteContent: newNote)                              }, label: {Text("Update")}) .listStyle(.plain)                     .buttonStyle(PlainButtonStyle())     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22