Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 1 | 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
//  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
 
11 efrain 15
    private let appDao = AppDao.sharedInstance
1 efrain 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: {
11 efrain 82
                            var appData = appDao.selectOne()
1 efrain 83
                            appData.companyUuidActive = self.companyModel.uuid
84
 
11 efrain 85
                            print("update query : 17")
86
                            appDao.update(model: appData)
87
 
1 efrain 88
                            withAnimation {
89
                                appNavigation.subpageActive = .progress
90
                            }
91
 
92
 
93
 
94
                        }, label: {
95
                            Image(systemName: "arrowtriangle.right.fill")
96
                                .resizable()
97
                                .aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
98
                                .frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
99
                        }).padding(.trailing, 10)
100
                        .foregroundColor(Color("color_capsule_list_item_title_foreground"))
101
                    }
102
 
103
 
104
 
105
                }
106
 
107
 
108
            }
109
 
110
        }
111
 
112
 
113
        Divider()
114
        } .background(Color("color_capsule_list_item_background"))
115
        .padding(.leading, 5)
116
        .padding(.trailing, 5)
117
 
118
    }
119
}
120
 
121
struct CompanyListItemView_Previews: PreviewProvider {
122
 
123
 
124
 
125
 
126
    static var previews: some View {
127
        CompanyListItemView(companyUuid: "C123")
128
    }
129
}