Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
//
2
//  ProfileView.swift
3
//  twogetskills
4
//
5
//  Created by Efrain Yanez Recanatini on 5/4/22.
6
//
7
 
8
import Foundation
9
 
10
import Foundation
11
import SwiftUI
12
 
13
 
14
struct ProfileView: View {
15
    @Environment(\.presentationMode)
16
       var presentationMode: Binding
17
 
18
 
19
    private var userExtendedPointViewModel : UserExtendedPointViewModel = UserExtendedPointViewModel()
20
 
21
 
22
    private let colorBackgroundTopic = UIColor(hex: Config.COLOR_BACKGROUND_TOPIC)
23
 
24
    private let colorAppTextView = UIColor(hex: Config.COLOR_APP_TEXT_VIEW_TITLE)
25
 
26
    private let colorAppBackground = UIColor(hex: Config.COLOR_APP_BAR)
27
 
28
    let preference = Preference.sharedInstance
29
 
30
 
31
 
32
 
33
    var body: some View {
34
        GeometryReader { geometry in
35
        VStack {
36
            ZStack(alignment: .top) {
37
                Rectangle()
38
                    .foregroundColor(Color(colorAppBackground ?? .systemBlue))
39
                    .edgesIgnoringSafeArea(.top)
40
                    .frame(height: 70)
41
 
42
 
43
                HStack {
44
                    if preference.image.isEmpty {
45
                         Image("logo")
46
                            .resizable()
47
                            .aspectRatio(contentMode: .fit)
48
                            .frame(height: Constants.PROFILE_IMAGE_SIZE)
49
                            .clipShape(Circle())
50
                            .overlay(Circle().stroke(Color.white, lineWidth: 4))
51
                            .shadow(radius: 10)
52
 
53
 
54
 
55
                    } else {
56
                        CustomAsyncImageProfile(
57
                            url: URL(string: preference.image)!,
58
                            placeholder: { Text("Cargando...").font(.footnote).foregroundColor(.black)},
59
                            image: {
60
                                Image(uiImage: $0)
61
                                    .resizable()
62
 
63
                            }
64
                        )
65
                    }
66
                }.padding(10)
67
            }
68
            VStack(spacing: 5) {
69
                VStack(spacing: 5) {
70
                    Text("\(preference.firstName) \(preference.lastName)" )
71
                        .bold()
72
                        .font(.title)
73
                    Text("\(preference.email)")
74
                        .font(.body)
75
                        .foregroundColor(Color(colorAppTextView ?? .blue))
76
                }.padding()
77
 
78
 
79
            }.background(Color(colorBackgroundTopic ?? .gray))
80
 
81
            ScrollView {
82
                ForEach(0..<self.userExtendedPointViewModel.points.count) { i in
83
 
84
                    UserExtendedPointView(userExtendedPoint: self.userExtendedPointViewModel.points[i])
85
                        .listRowInsets(.init()).frame(width: geometry.size.width, height: 70, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
86
 
87
                }
88
            }
89
 
90
            //.listStyle(InsetListStyle())
91
 
92
            .background(Color(colorBackgroundTopic ?? .white))
93
 
94
 
95
            //Spacer()
96
 
97
        }.onAppear {
98
            userExtendedPointViewModel.loadAll()
99
        }
100
        .background(Color(colorBackgroundTopic ?? .gray))
101
        .navigationBarBackButtonHidden(true)
102
        .navigationBarTitleDisplayMode(.inline)
103
        .navigationTitle("Perfil")
104
 
105
 
106
        }
107
    }
108
 
109
 
110
 
111
 
112
}
113
 
114
 
115
struct ProfileView_Previews: PreviewProvider {
116
    static var previews: some View {
117
        ProfileView()
118
    }
119
}