London Escorts sunderland escorts 1v1.lol unblocked yohoho 76 https://www.symbaloo.com/mix/yohoho?lang=EN yohoho https://www.symbaloo.com/mix/agariounblockedpvp https://yohoho-io.app/ https://www.symbaloo.com/mix/agariounblockedschool1?lang=EN
-1.2 C
New York
Sunday, February 2, 2025

ios – The best way to add a submit


I’m attempting to add a submit with simply textwords however my code solely uploads the submit that has a picture connected to it and the submit with simply phrases do not present up in firebase

How do I repair this code to permit my person add their submit with out photographs to firebase

That is the uploadPostViewModel I’ve the textual content as a string however but the information just isn’t being uploaded as if it not listed however the picture is what am I lacking from this code that is not permitting my textual content knowledge to be uploaded to firebase

class UploadPostViewModel: ObservableObject {
    @Revealed var didUploadPost = false
    @Revealed var error: Error?
    @Revealed var profileImage: Picture?
    @Revealed var caption = ""
    @Revealed var textual content = ""
    @Revealed var selectedImage: PhotosPickerItem? {
        didSet { Activity { await loadImage(fromItem: selectedImage) } }
    }
    
    non-public var uiImage: UIImage?
    
    func uploadPost() async throws {
        guard let uid = Auth.auth().currentUser?.uid else { return }
        guard let picture = uiImage else { return }
        
        do {
            guard let picture = strive await ImageUploader.uploadImage(picture: picture, kind: .submit) else { return }
            let submit = Put up(ownerUid: uid,textual content: textual content, caption: caption, likes: 0, replyCount: 67, picture: picture, timestamp: Timestamp())

            
            strive await PostService.uploadPost(submit)
            self.didUploadPost = true
        } catch {
            print("DEBUG: Did not add picture with error (error.localizedDescription)")
            self.error = error
        }
    }
    
    func loadImage(fromItem merchandise: PhotosPickerItem?) async {
        guard let merchandise = merchandise else { return }
        
        guard let knowledge = strive? await merchandise.loadTransferable(kind: Information.self) else { return }
        guard let uiImage = UIImage(knowledge: knowledge) else { return }
        self.uiImage = uiImage
        self.profileImage = Picture(uiImage: uiImage)
    }
}
 @State var captionText = ""
       
       @StateObject var viewModel = UploadPostViewModel()
       @Setting(.dismiss) var dismiss
      
       @Binding var tabIndex: Int
       
       non-public var person: Userss? {
           return ThirdUserService.shared.currentUser
       }
       var physique: some View {
           NavigationStack {
               VStack {
                   HStack(alignment: .high) {
                       RectangularImageSize(person: person, measurement: .small)
                       
                       VStack(alignment: .main, spacing: 4) {
                           Textual content(person?.username ?? "")
                               .fontWeight(.semibold)
                           
                           TextField("Sort One thing", textual content: $viewModel.textual content, axis: .vertical)
                       }
                       .font(.footnote)
                       
                       Spacer()
                       
                       if !viewModel.textual content.isEmpty {
                           Button {
                               viewModel.textual content = ""
                           } label: {
                               Picture(systemName: "xmark")
                                   .resizable()
                                   .body(width: 12, peak: 12)
                                   .foregroundColor(.grey)
                           }
                       }
                   }
                   
                   Spacer()
               }
               .padding()
               .toolbar {
                   ToolbarItem(placement: .navigationBarLeading) {
                       Button("Cancel") {
                           dismiss()
                       }
                       .font(.subheadline)
                       .foregroundStyle(Shade.black)
                   }
                   
                   ToolbarItem(placement: .navigationBarTrailing) {
                       Button("Put up") {
                           Activity {
                               strive await viewModel.uploadPost()
                               dismiss()
                           }
                       }
                       .opacity(viewModel.textual content.isEmpty ? 0.5 : 1.0)
                       .disabled(viewModel.textual content.isEmpty)
                       .font(.subheadline)
                       .fontWeight(.semibold)
                       .foregroundStyle(Shade.inexperienced)
                   }
               }
               .onDisappear { tabIndex = 0 }
               
           }
       }
   }

Related Articles

Social Media Auto Publish Powered By : XYZScripts.com