post edit
This commit is contained in:
		
							parent
							
								
									f5e5d1f72f
								
							
						
					
					
						commit
						478020f6f2
					
				@ -10,7 +10,7 @@ struct Post: Identifiable, Codable {
 | 
			
		||||
    let description: String?               // Описание поста
 | 
			
		||||
    let media: [MediaItem]                 // Массив медиафайлов
 | 
			
		||||
    let mediaOrder: [UUID]?                // Порядок отображения медиа
 | 
			
		||||
    let thumbnailID: UUID?                 // Превью для видео
 | 
			
		||||
    let thumbnailID: UUID                  // Превью
 | 
			
		||||
    let duration: Double?                  // Длительность видео/аудио
 | 
			
		||||
    let createdAt: Date                    // Дата создания
 | 
			
		||||
    let updatedAt: Date                    // Дата обновления
 | 
			
		||||
@ -20,7 +20,7 @@ struct Post: Identifiable, Codable {
 | 
			
		||||
    let commentsCount: Int                 // Кол-во комментариев
 | 
			
		||||
    let isLikedByCurrentUser: Bool         // Лайк текущим юзером
 | 
			
		||||
    let isSavedByCurrentUser: Bool         // Сохранено текущим юзером
 | 
			
		||||
    let authorID: String                   // Автор
 | 
			
		||||
    let authorID: UUID                     // Автор
 | 
			
		||||
    let authorUsername: String             // Имя пользователя автора
 | 
			
		||||
    let hashtags: [String]?                // Хэштеги
 | 
			
		||||
    let location: String?                  // Гео
 | 
			
		||||
@ -30,6 +30,7 @@ struct Post: Identifiable, Codable {
 | 
			
		||||
 | 
			
		||||
enum MediaType: String, Codable {
 | 
			
		||||
    case photo
 | 
			
		||||
    case live
 | 
			
		||||
    case video
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -96,10 +96,13 @@ class PostService {
 | 
			
		||||
 | 
			
		||||
        for i in 0..<32 {
 | 
			
		||||
            let mediaID = UUID()
 | 
			
		||||
            let thumbID = Bool.random() ? UUID() : nil
 | 
			
		||||
//            let thumbID = Bool.random() ? UUID() : nil
 | 
			
		||||
            let thumbID = UUID()
 | 
			
		||||
            let postID = UUID()
 | 
			
		||||
            
 | 
			
		||||
            let authorId = "user_\(Int.random(in: 1...5))"
 | 
			
		||||
            let authorId = UUID()
 | 
			
		||||
            let authorUserName = "username_\(Int.random(in: 1...5))"
 | 
			
		||||
//            let authorId = "user_\(Int.random(in: 1...5))"
 | 
			
		||||
            let post = Post(
 | 
			
		||||
                id: postID,
 | 
			
		||||
                title: sampleTitles[i],
 | 
			
		||||
@ -119,7 +122,7 @@ class PostService {
 | 
			
		||||
                isLikedByCurrentUser: Bool.random(),
 | 
			
		||||
                isSavedByCurrentUser: Bool.random(),
 | 
			
		||||
                authorID: authorId,
 | 
			
		||||
                authorUsername: "username_\(authorId.split(separator: "_").last ?? "")",
 | 
			
		||||
                authorUsername: authorUserName,
 | 
			
		||||
                hashtags: ["#тест", "#видео", "#swiftui", "#ui"].shuffled().prefix(2).map { $0 },
 | 
			
		||||
                location: Bool.random() ? "Москва" : nil,
 | 
			
		||||
                languageCode: Bool.random() ? ["ru", "en"] : ["ru"],
 | 
			
		||||
 | 
			
		||||
@ -70,7 +70,11 @@ struct PostGridItem: View {
 | 
			
		||||
                
 | 
			
		||||
                // 3. Информация об авторе и лайки
 | 
			
		||||
                HStack {
 | 
			
		||||
                    HStack(spacing: 4) {
 | 
			
		||||
                    
 | 
			
		||||
                    Button(action: {
 | 
			
		||||
                        // пока ничего не делаем
 | 
			
		||||
                    }) {
 | 
			
		||||
                        HStack(spacing: 4) {
 | 
			
		||||
                        Image(systemName: "person.circle.fill")
 | 
			
		||||
                            .resizable()
 | 
			
		||||
                            .frame(width: 20, height: 20)
 | 
			
		||||
@ -78,16 +82,26 @@ struct PostGridItem: View {
 | 
			
		||||
                        Text(post.authorUsername)
 | 
			
		||||
                            .font(.footnote)
 | 
			
		||||
                            .lineLimit(1)
 | 
			
		||||
                            .foregroundColor(.primary)
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    }
 | 
			
		||||
                    .contentShape(Rectangle())
 | 
			
		||||
 | 
			
		||||
                    Spacer()
 | 
			
		||||
                    
 | 
			
		||||
                    HStack(spacing: 4) {
 | 
			
		||||
 | 
			
		||||
                    Button(action: {
 | 
			
		||||
                        // пока ничего не делаем
 | 
			
		||||
                    }) {
 | 
			
		||||
                        HStack(spacing: 4) {
 | 
			
		||||
                        Image(systemName: post.isLikedByCurrentUser ? "heart.fill" : "heart")
 | 
			
		||||
                            .foregroundColor(post.isLikedByCurrentUser ? .red : .primary)
 | 
			
		||||
                        Text("\(post.likes)")
 | 
			
		||||
                            .font(.subheadline)
 | 
			
		||||
                            .foregroundColor(.primary)
 | 
			
		||||
                    }
 | 
			
		||||
                    }
 | 
			
		||||
                    .contentShape(Rectangle())
 | 
			
		||||
                    
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            .padding(8)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user