Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

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

Rev Autor Línea Nro. Línea
1 efrain 1
//
2
//  CompanyListItemView.swift
3
//  twogetskills
4
//
5
//  Created by Efrain Yanez Recanatini on 7/30/22.
6
//
7
 
8
import Foundation
9
import SwiftUI
10
import HTMLEntities
11
 
12
struct CompanyListItemView: View {
13
    @EnvironmentObject var appNavigation : AppNavigation
14
 
15
 
16
    private var companyModel : CompanyModel
17
    private var companyName : String
21 efrain 18
    private var appData = Environment(\.appData).wrappedValue
1 efrain 19
 
20
    init (companyUuid : String) {
21
 
17 efrain 22
        let companyDao = CompanyDao()
1 efrain 23
        self.companyModel = companyDao.selectByUuid(uuid: companyUuid)
24
 
25
 
26
        if companyModel.name.count > Constants.MYCAPSULE_TITLE_MAX_LENGTH {
27
            self.companyName =  String(Array(companyModel.name)[0...Constants.MYCAPSULE_TITLE_MAX_LENGTH]) + "..."
28
        } else {
29
            self.companyName = companyModel.name
30
        }
31
 
32
 
33
    }
34
 
35
 
36
 
37
    var body: some View {
38
        VStack(spacing: 0 ) {
39
        Group {
40
            HStack {
41
                Group {
42
 
19 efrain 43
                    if companyModel.image.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
1 efrain 44
 
45
 
46
                    Image(uiImage: UIImage(named: "logo") ?? UIImage())
47
                        .resizable()
48
                        .resizable()
49
                        .aspectRatio(contentMode: .fit)
50
 
51
 
52
 
53
                } else {
54
                    CustomAsyncImage(
19 efrain 55
                        url: URL(string: companyModel.image.trimmingCharacters(in: .whitespacesAndNewlines))!,
1 efrain 56
                        placeholder: { Text(Config.LANG_COMMON_LOADING).font(.footnote).foregroundColor(.black)},
57
                        image: {
58
                            Image(uiImage: $0).resizable()
59
 
60
 
61
                        }
62
                    )
63
                }
64
                } .frame(width: 48, height:48, alignment:  .center)
65
                .clipShape(Circle())
66
                .overlay(Circle().stroke(Color.white, lineWidth: 1))
67
                .padding(.top, 5)
68
                .padding(.leading, 5)
69
 
70
 
71
 
72
                VStack(spacing: 0)
73
                {
74
                    HStack {
75
                        Text(self.companyName)
76
                            .font(Font.custom(Config.FONT_NAME_BOLD, size: 14))
77
                            .foregroundColor(Color("color_capsule_list_item_title_foreground"))
78
 
79
                        Spacer()
80
                    }
81
 
82
 
83
 
84
                }
85
 
86
 
87
            }
88
 
89
        }
90
 
91
 
92
        Divider()
93
        } .background(Color("color_capsule_list_item_background"))
94
        .padding(.leading, 5)
95
        .padding(.trailing, 5)
96
 
97
    }
98
}
99
 
100
struct CompanyListItemView_Previews: PreviewProvider {
101
 
102
 
103
 
104
 
105
    static var previews: some View {
106
        CompanyListItemView(companyUuid: "C123")
17 efrain 107
 
1 efrain 108
    }
109
}