Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 8 | Ir a la última revisión | | 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 appData = AppData.sharedInstance
23
 
24
 
25
 
26
 
27
    var body: some View {
28
        GeometryReader { geometry in
29
            VStack(spacing: 0) {
30
                HStack {
31
                    Image("logo")
32
                    .resizable()
33
                    .frame(width: 32, height: 32, alignment: .center)
34
                    .aspectRatio(contentMode: .fit)
35
                    .foregroundColor(Color("color_app_bar_foreground"))
36
                    .padding(.leading, 16)
37
 
38
 
39
                    Text(Config.LANG_TAB_BAR_BUTTON_PROFILE)
40
                    .font(Font.custom(Config.FONT_NAME_REGULAR, size: Config.FONT_SIZE_APP_BAR_HEAD1 ))
41
                    .foregroundColor(Color("color_app_bar_foreground"))
42
                    .padding(.leading, 4)
43
 
44
                    Spacer()
45
 
46
 
47
                }
48
                .background(Color("color_app_bar_background"))
49
                .edgesIgnoringSafeArea(.top)
50
                .frame(height: 50)
51
                Divider()
52
 
53
            ZStack(alignment: .top) {
54
 
55
 
56
                Rectangle()
57
                    .foregroundColor(Color("color_app_bar_background"))
58
                    .edgesIgnoringSafeArea(.top)
59
                    .frame(height: 70)
60
 
61
 
62
                HStack {
63
                    if appData.image.isEmpty {
64
                         Image("logo")
65
                            .resizable()
66
                            .aspectRatio(contentMode: .fit)
67
                            .frame(height: Config.PROFILE_IMAGE_SIZE)
68
                            .clipShape(Circle())
69
                            .overlay(Circle().stroke(Color.white, lineWidth: 4))
70
                            .shadow(radius: 10)
71
 
72
 
73
 
74
                    } else {
75
                        CustomAsyncImageProfile(
76
                            url: URL(string: appData.image)!,
77
                            placeholder: { Text(Config.LANG_COMMON_LOADING).font(.footnote).foregroundColor(.black)},
78
                            image: {
79
                                Image(uiImage: $0)
80
                                    .resizable()
81
 
82
                            }
83
                        )
84
                    }
85
                }.padding(10)
86
            }
87
            VStack(spacing: 5) {
88
                VStack(spacing: 5) {
89
                    Text("\(appData.firstName) \(appData.lastName)" )
90
                        .bold()
91
                        .font(.title)
92
                    Text("\(appData.email)")
93
                        .font(.body)
94
                        .foregroundColor(Color("color_texview"))
95
                }.padding()
96
 
97
 
98
            }.background(Color("color_card_view_background"))
99
 
100
            ScrollView {
101
                ForEach(0..<self.userExtendedPointViewModel.points.count) { i in
102
 
103
 
104
                    UserExtendedPointView(userExtendedPoint: self.userExtendedPointViewModel.points[i])
105
                        .listRowInsets(.init()).frame(width: geometry.size.width, height: 70, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
106
 
107
                }
108
            }
109
 
110
            //.listStyle(InsetListStyle())
111
 
112
            .background(Color("color_card_view_background"))
113
 
114
 
115
            //Spacer()
116
 
117
        }.onAppear {
118
            userExtendedPointViewModel.loadAll()
119
        }
120
        .navigationTitle("Perfil")
121
        .navigationBarBackButtonHidden(true)
122
        .navigationBarTitleDisplayMode(.inline)
123
        .navigationBarItems(
124
 
125
 
126
            trailing:
127
            Button(action: {
128
                print("Dismissing sheet view...")
129
            }, label: {
130
                HStack {
131
                    Image(systemName: "arrow.clockwise")
132
                    .aspectRatio(contentMode: .fit)
133
                    //.foregroundColor(Color("color_app_bar_foreground"))
134
                    //.background(Color("color_app_bar_background"))
135
                }
136
            })
137
        )
138
 
139
 
140
        }
141
    }
142
 
143
 
144
 
145
 
146
}
147
 
148
 
149
struct ProfileView_Previews: PreviewProvider {
150
    static var previews: some View {
151
        ProfileView()
152
    }
153
}