Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 11 | 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
    private let appData : AppData = AppData.sharedInstance
16
 
17
    private var companyModel : CompanyModel
18
    private var companyName : String
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
 
83
                            appData.companyUuidActive = self.companyModel.uuid
84
                            appData.save()
85
 
86
                            withAnimation {
87
                                appNavigation.subpageActive = .progress
88
                            }
89
 
90
 
91
 
92
                        }, label: {
93
                            Image(systemName: "arrowtriangle.right.fill")
94
                                .resizable()
95
                                .aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
96
                                .frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
97
                        }).padding(.trailing, 10)
98
                        .foregroundColor(Color("color_capsule_list_item_title_foreground"))
99
                    }
100
 
101
 
102
 
103
                }
104
 
105
 
106
            }
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 CompanyListItemView_Previews: PreviewProvider {
120
 
121
 
122
 
123
 
124
    static var previews: some View {
125
        CompanyListItemView(companyUuid: "C123")
126
    }
127
}