Hello everyone!
I’m trying to implement adding a new comment to a post but I can’t see the TextField nor the ‘paperplane’ button.
This is what I’m supposed to be getting:
But this is what I’m getting:
Any ideas on what might be failing? I’ve check everything in my code but I can’t find the problem
This is the link: https://www.codecademy.com/paths/ios-developer/tracks/firebase-authentication-swiftui/modules/adding-users-and-comments-swiftui/articles/socialcademy-10-swiftui
Thanks in advance for your help.
KB
1 Like
I’m getting the same issue. With the downloaded code too. You ever figure it out?
I figured it out! You need to wrap the group using a NavigationView, then place the toolbar inside. Here is the code:
struct CommentsList: View {
@StateObject var viewModel: CommentsViewModel
@State private var isCommentsListDisabled = true
var body: some View {
NavigationView{
Group {
switch viewModel.comments {
case .loading:
ProgressView()
.onAppear {
viewModel.fetchComments()
}
case let .error(error):
EmptyListView(
title: "Cannot Load Comments",
message: error.localizedDescription,
retryAction: {
viewModel.fetchComments()
}
)
case .empty:
EmptyListView(
title: "No Comments",
message: "Be the first to leave a comment."
)
case let .loaded(comments):
List(comments) { comment in
CommentRow(viewModel: viewModel.makeCommentRowViewModel(for: comment))
}
// .padding(.bottom, 10) // use this for white background
.animation(.default, value: comments)
}
}
.toolbar {
ToolbarItem(placement: .bottomBar) {
NewCommentForm(viewModel: viewModel.makeNewCommentViewModel())
.padding(.bottom, 20)
}
}
}
.navigationTitle("Comments")
.navigationBarTitleDisplayMode(.inline)
}
}
7 Likes
Thanks for sharing! This was driving me insane. I don’t know if any of you encounter this problem too.
My profile pic will never show up. I have tried with simulator and on iPhone, I thought it might be the connection, but nope.