AutorÃa | Ultima modificación | Ver Log |
//// ProfileView.swift// twogetskills//// Created by Efrain Yanez Recanatini on 5/4/22.//import Foundationimport Foundationimport SwiftUIstruct ProfileView: View {@Environment(\.presentationMode)var presentationMode: Bindingprivate var userExtendedPointViewModel : UserExtendedPointViewModel = UserExtendedPointViewModel()private let colorBackgroundTopic = UIColor(hex: Config.COLOR_BACKGROUND_TOPIC)private let colorAppTextView = UIColor(hex: Config.COLOR_APP_TEXT_VIEW_TITLE)private let colorAppBackground = UIColor(hex: Config.COLOR_APP_BAR)let preference = Preference.sharedInstancevar body: some View {GeometryReader { geometry inVStack {ZStack(alignment: .top) {Rectangle().foregroundColor(Color(colorAppBackground ?? .systemBlue)).edgesIgnoringSafeArea(.top).frame(height: 70)HStack {if preference.image.isEmpty {Image("logo").resizable().aspectRatio(contentMode: .fit).frame(height: Constants.PROFILE_IMAGE_SIZE).clipShape(Circle()).overlay(Circle().stroke(Color.white, lineWidth: 4)).shadow(radius: 10)} else {CustomAsyncImageProfile(url: URL(string: preference.image)!,placeholder: { Text("Cargando...").font(.footnote).foregroundColor(.black)},image: {Image(uiImage: $0).resizable()})}}.padding(10)}VStack(spacing: 5) {VStack(spacing: 5) {Text("\(preference.firstName) \(preference.lastName)" ).bold().font(.title)Text("\(preference.email)").font(.body).foregroundColor(Color(colorAppTextView ?? .blue))}.padding()}.background(Color(colorBackgroundTopic ?? .gray))ScrollView {ForEach(0..<self.userExtendedPointViewModel.points.count) { i inUserExtendedPointView(userExtendedPoint: self.userExtendedPointViewModel.points[i]).listRowInsets(.init()).frame(width: geometry.size.width, height: 70, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)}}//.listStyle(InsetListStyle()).background(Color(colorBackgroundTopic ?? .white))//Spacer()}.onAppear {userExtendedPointViewModel.loadAll()}.background(Color(colorBackgroundTopic ?? .gray)).navigationBarBackButtonHidden(true).navigationBarTitleDisplayMode(.inline).navigationTitle("Perfil")}}}struct ProfileView_Previews: PreviewProvider {static var previews: some View {ProfileView()}}