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