Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

Rev 17 | Ir a la última revisión | | 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
18
    private var appData = AppData.sharedInstance
19
 
20
    init (companyUuid : String) {
21
 
22
        let companyDao = CompanyDao.sharedInstance
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
 
43
                    if companyModel.image.isEmpty {
44
 
45
 
46
                    Image(uiImage: UIImage(named: "logo") ?? UIImage())
47
                        .resizable()
48
                        .resizable()
49
                        .aspectRatio(contentMode: .fit)
50
 
51
 
52
 
53
                } else {
54
                    CustomAsyncImage(
55
                        url: URL(string: companyModel.image)!,
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
                        Button(action: {
82
                            self.appData.companyUuidActive = self.companyModel.uuid
83
                            self.appData.save()
84
 
85
                            withAnimation {
86
                                appNavigation.subpageActive = .progress
87
                            }
88
 
89
 
90
 
91
                        }, label: {
92
                            Image(systemName: "arrowtriangle.right.fill")
93
                                .resizable()
94
                                .aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
95
                                .frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
96
                        }).padding(.trailing, 10)
97
                        .foregroundColor(Color("color_capsule_list_item_title_foreground"))
98
                    }
99
 
100
 
101
 
102
                }
103
 
104
 
105
            }
106
 
107
        }
108
 
109
 
110
        Divider()
111
        } .background(Color("color_capsule_list_item_background"))
112
        .padding(.leading, 5)
113
        .padding(.trailing, 5)
114
 
115
    }
116
}
117
 
118
struct CompanyListItemView_Previews: PreviewProvider {
119
 
120
 
121
 
122
 
123
    static var previews: some View {
124
        CompanyListItemView(companyUuid: "C123")
125
    }
126
}