Post

Replies

Boosts

Views

Activity

Reply to Help with "Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure."
Hello Claude 31, I have two MainView files: This is MainView.swift import SwiftUI struct MainView: View { @StateObject var viewModel = MainView_ViewModel() var body: some View { if viewModel.isSignedIn, !viewModel.currentUserId.isEmpty { // signed in state ToDoListView() } else { LoginView() } } } struct MainView_Previews: PreviewProvider { static var previews: some View { MainView() } } This is MainView_ViewModel.swift import FirebaseAuth import Foundation class MainView_ViewModel: ObservableObject { @Published var currentUserId: String = "" private var handler: AuthStateDidChangeListenerHandle? // when user signs in or out this published will be triggered and update oru view // if we have a user it means they are signed in // nil = not signed in init() { self.handler = Auth.auth().addStateDidChangeListener { [weak self] _, user in DispatchQueue.main.async { self?.currentUserId = user?.uid ?? "" } } } public var isSignedIn: Bool { return Auth.auth().currentUser != nil } } Thank you. Lorna
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’23
Reply to Help with "Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure."
Hello Claude31, The error is on the same line as Form { All the code and curly braces are included. I am not sure if I understood exactly what you had in mind. I tried this but had the same issue. Not sure why the error message does not copy here, but it is exactly the same as before immediately after Form { Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure In the box at the bottom left: I see : Exception NSException * "The default FirebaseApp instance must be configured before the default Authinstance can be initialized. One way to ensure this is to call FirebaseApp.configure() in the App Delegate's application(_:didFinishLaunchingWithOptions:) (or the @main struct's initializer in SwiftUI)." 0x0000600003837810 and self @thin TODO.TODOApp.Type TODO.TODOApp FYI I have another file called RegisterView_ViewModel import SwiftUI struct RegisterView: View { //@StateObject var viewModel = RegisterView_ViewModel() @State var viewModel = RegisterView_ViewModel() var body: some View { VStack { //Header HeaderView(title: "Register", subtitle: "Start organizing", angle: -15, background: .blue) Form { TextField("Full Name", text: $viewModel.name) //TextField("Full Name", text: $viewModel.name) .textFieldStyle(DefaultTextFieldStyle()) .autocorrectionDisabled() TextField("Email Address", text: $viewModel.email) //TextField("Email Address", text: $viewModel.email) .textFieldStyle(DefaultTextFieldStyle()) .autocapitalization(.none) .autocorrectionDisabled() SecureField("Password", text: $viewModel.password) //SecureField("Password", text: $viewModel.password) .textFieldStyle(DefaultTextFieldStyle()) TLButton( title: "Create Account", background: .green ) { viewModel.register() } .padding() } .offset(y: -50) Spacer() } } } struct RegisterView_Previews: PreviewProvider { static var previews: some View { RegisterView() } } Is this what is was supposed to look like or did I mess up? Lorna
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’23
Reply to Help with "Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure."
Thank you so much for taking your time to try to help. I really appreciate it. The code is part of a bigger project with a number of pages. I'm on Lesson 6. Everything was perfect up until now. So, I'm stuck. I commented out sections of what I sent but still not working. Re YouTube, thank you!! Great! I did not include TLButton because there were no errors indicated. Here it is. import SwiftUI struct TLButton: View { let title: String let background: Color let action: () -> Void var body: some View { Button { action() } label: { ZStack { RoundedRectangle(cornerRadius: 10) .foregroundColor(background) Text(title) .foregroundColor(Color.white) .bold() } } } } struct TLButton_Previews: PreviewProvider { static var previews: some View { TLButton(title: "Value", background: .red) { // Action } } } When I comment out a section of the view. The build is successful but then it will not show what it should show. Instead, I see this. TODO`static TODOApp.$main(): 0x1055097a0 <+0>: pushq %rbp 0x1055097a1 <+1>: movq %rsp, %rbp 0x1055097a4 <+4>: pushq %r13 0x1055097a6 <+6>: pushq %rax 0x1055097a7 <+7>: callq 0x1055097d0 ; lazy protocol witness table accessor for type TODO.TODOApp and conformance TODO.TODOApp : SwiftUI.App in TODO at 0x1055097ac <+12>: movq %rax, %rsi 0x1055097af <+15>: leaq 0x8995b2(%rip), %r13 ; type metadata for TODO.TODOApp 0x1055097b6 <+22>: movq %r13, %rdi 0x1055097b9 <+25>: callq 0x105badae4 ; symbol stub for: static SwiftUI.App.main() -> () -> 0x1055097be <+30>: addq $0x8, %rsp 0x1055097c2 <+34>: popq %r13 0x1055097c4 <+36>: popq %rbp 0x1055097c5 <+37>: retq What is not visible here is what is printed in red is the following: "Thread 1: "The default FirebaseApp instance must be configured before the default Authinstance can be initialized. One way to ensure this is to call FirebaseApp.configure() in the App Delegate's application(_:didFinishLaunchingWithOptions:) (or the @main struct's initializer in SwiftUI)."
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’23