Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 8 | Rev 17 | Ir a la última revisión | | 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 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
                        .aspectRatio(contentMode: .fit)
27
 
28
 
29
 
30
                } else {
31
                    CustomAsyncImage(
8 efrain 32
                        url: URL(string: comment.image)!,
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
                }
11 efrain 42
                .frame(width: Config.COMMENT_IMAGE_SIZE_WIDTH, height: Config.COMMENT_IMAGE_SIZE_HEIGHT)
43
                .clipShape(Circle())
1 efrain 44
                    .overlay(Circle().stroke(Color.white, lineWidth: 1))
45
 
46
 
47
 
48
 
49
                VStack(spacing: 0)
50
                {
51
                    HStack {
8 efrain 52
                        Text(comment.fullname)
1 efrain 53
                            .font(Font.custom(Config.FONT_NAME_BOLD, size: 14))
54
                            .foregroundColor(Color("color_capsule_list_item_title_foreground"))
55
 
56
                        Spacer()
57
 
8 efrain 58
                        if !comment.link_delete.isEmpty {
1 efrain 59
 
11 efrain 60
                            Button(action: {
61
 
62
                                NotificationCenter.default.post(
63
                                    name:Constants.NOTIFICATION_NAME_COMMAND_DELETE_COMMENT,
64
                                    object: nil,
65
                                    userInfo: ["id" : comment.id, "link_delete" : comment.link_delete])
66
 
67
                            }, label: {
68
                                Image(systemName: "trash")
69
                                    .resizable()
70
                                    .aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
71
                                    .frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
72
                            }).padding(.trailing, 10)
73
                            .foregroundColor(Color("color_capsule_list_item_title_foreground"))
74
 
75
                            }
1 efrain 76
                    }
77
                    HStack {
8 efrain 78
                        Text(comment.comment)
1 efrain 79
                            .font(Font.custom(Config.FONT_NAME_REGULAR, size: 12))
80
                            .foregroundColor(Color("color_capsule_list_item_description_foreground"))
81
 
82
 
83
                        Spacer()
84
                    }.padding(.top, 3)
85
                    .padding(.bottom, 10)
86
 
87
 
88
 
89
 
90
 
91
 
92
 
93
                    HStack {
8 efrain 94
                        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 95
                            .padding(.leading, 8)
96
 
97
                        Spacer()
98
 
8 efrain 99
                        Text(comment.date)
1 efrain 100
                            .font(Font.custom(Config.FONT_NAME_REGULAR, size: 12))
101
                            .foregroundColor(Color("color_capsule_list_item_description_foreground"))
102
                            .padding(.trailing, 10)
103
 
104
 
105
 
106
 
107
                    }
108
 
109
 
110
                }.padding(.top, 10)
111
                .padding(.bottom, 10)
112
 
113
        }
114
 
115
 
116
        Divider()
117
        } .background(Color("color_capsule_list_item_background"))
118
        .padding(.leading, 5)
119
        .padding(.trailing, 5)
120
        }
121
    }
122
}
123
 
124
struct CommentAndRatingCommentListItem_Previews: PreviewProvider {
8 efrain 125
 
126
    static var comment = CommentAndRatingComment(
127
        date: "2022-07-28T10:00:00", image: "", fullname: "Santiago Olivera", rating: 3.8, comment: "Comentario de prueba", link_delete: "LINK"
128
    )
129
 
1 efrain 130
    static var previews: some View {
8 efrain 131
        CommentAndRatingCommentListItem(comment: comment)
1 efrain 132
    }
133
}