Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
//
2
//  CommentAndRatingCommentsListItem.swift
3
//  twogetskills
4
//
5
//  Created by Efrain Yanez Recanatini on 7/28/22.
6
//
7
 
8
import SwiftUI
9
 
10
struct CommentAndRatingCommentListItemView: View {
11
 
12
    var comment : CommentAndRatingComment
13
    let onDelete: () -> Void
14
 
15
    var body: some View {
16
        VStack(spacing: 0 ) {
17
        Group {
18
            HStack {
19
                Group {
20
 
19 efrain 21
                    if comment.image.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
1 efrain 22
 
23
 
24
                    Image(uiImage: UIImage(named: "logo") ?? UIImage())
25
                        .resizable()
26
                        .aspectRatio(contentMode: .fit)
27
 
28
 
29
 
30
                } else {
31
                    CustomAsyncImage(
19 efrain 32
                        url: URL(string: comment.image.trimmingCharacters(in: .whitespacesAndNewlines))!,
1 efrain 33
                        placeholder: { Text(Config.LANG_COMMON_LOADING).font(.footnote).foregroundColor(.black)},
34
                        image: {
35
                            Image(uiImage: $0).resizable()
36
 
37
 
38
                        }
39
                    )
40
                }
41
                }
42
                .frame(width: Config.COMMENT_IMAGE_SIZE_WIDTH, height: Config.COMMENT_IMAGE_SIZE_HEIGHT)
43
                .clipShape(Circle())
44
                    .overlay(Circle().stroke(Color.white, lineWidth: 1))
45
 
46
 
47
 
48
 
49
                VStack(spacing: 0)
50
                {
51
                    HStack {
52
                        Text(comment.fullname)
53
                            .font(Font.custom(Config.FONT_NAME_BOLD, size: 14))
54
                            .foregroundColor(Color("color_capsule_list_item_title_foreground"))
55
 
56
                        Spacer()
57
 
58
                        if !comment.link_delete.isEmpty {
59
 
60
                            Button(action:  onDelete, label: {
61
                                Image(systemName: "trash")
62
                                    .resizable()
63
                                    .aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
64
                                    .frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
65
                            }).padding(.trailing, 10)
66
                            .foregroundColor(Color("color_capsule_list_item_title_foreground"))
67
 
68
                            }
69
                    }
70
                    HStack {
71
                        Text(comment.comment)
72
                            .font(Font.custom(Config.FONT_NAME_REGULAR, size: 12))
73
                            .foregroundColor(Color("color_capsule_list_item_description_foreground"))
74
 
75
 
76
                        Spacer()
77
                    }.padding(.top, 3)
78
                    .padding(.bottom, 10)
79
 
80
 
81
 
82
 
83
 
84
 
85
 
86
                    HStack {
87
                        FiveStarView(rating: comment.rating, color: Color("color_capsule_list_item_star_foreground"), backgroundColor: Color("color_capsule_list_item_star_background"))               .frame(width: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
88
                            .padding(.leading, 8)
89
 
90
                        Spacer()
91
 
92
                        Text(comment.date)
93
                            .font(Font.custom(Config.FONT_NAME_REGULAR, size: 12))
94
                            .foregroundColor(Color("color_capsule_list_item_description_foreground"))
95
                            .padding(.trailing, 10)
96
 
97
 
98
 
99
 
100
                    }
101
 
102
 
103
                }.padding(.top, 10)
104
                .padding(.bottom, 10)
105
 
106
        }
107
 
108
 
109
        Divider()
110
        } .background(Color("color_capsule_list_item_background"))
111
        .padding(.leading, 5)
112
        .padding(.trailing, 5)
113
        }
114
    }
115
}
116
 
117
struct CommentAndRatingCommentListItemView_Previews: PreviewProvider {
118
 
119
    static var comment = CommentAndRatingComment(
120
        date: "2022-07-28T10:00:00", image: "", fullname: "Santiago Olivera", rating: 3.8, comment: "Comentario de prueba", link_delete: "LINK"
121
    )
122
 
123
    static var previews: some View {
124
        CommentAndRatingCommentListItemView(comment: comment) {
125
 
126
        }
127
    }
128
}