//
//  ProfileView.swift
//  Comedores Sociales
//
//  Created by Hector Carrion on 12/16/20.
//

import SwiftUI

struct ProfileSummary: View {
    @State var profile: Profile

    var body: some View {
        VStack(alignment: .leading, spacing: 10) {
            HStack {
                Image(systemName: "person.crop.circle")
                    .font(.system(size: 100))
                VStack(alignment: .leading, spacing: 5) {
                    Text(profile.name)
                        .bold()
                        .font(.title)
                    Text(profile.membership)
                        .font(.headline)
                    
                }
                
            }.padding()
            .frame(width: 350, height: 125, alignment: .topLeading)
            .offset(x: -10, y: 10.0)
            
            HStack {
                Image(systemName: "envelope")
                    .font(.system(size: 20))
                    .foregroundColor(.gray)
                Text(profile.email)
                    .font(.headline)
                    .foregroundColor(.gray)
            }.padding()
            .offset(x: 0, y: 10.0)
            HStack {
                Image(systemName: "phone")
                    .font(.system(size: 20))
                    .foregroundColor(.gray)
                Text(profile.phone)
                    .font(.headline)
                    .foregroundColor(.gray)
            }.padding()
            
            HStack() {
                VStack {
                    Text(String(profile.hoursWorked))
                        .font(.title)
                        .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
                    Text(NSLocalizedString("hours_donated", comment:""))
                        .foregroundColor(.gray)
                }.padding()
                
                Spacer()
                VStack {
                    if profile.membershipStatus == .expired {
                        Text(NSLocalizedString("expired", comment:""))
                            .font(.title)
                            .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
                            .foregroundColor(.red)
                    } else if profile.membershipStatus == .valid {
                        Text(NSLocalizedString("valid", comment:""))
                            .font(.title)
                            .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
                            .foregroundColor(.green)
                    } else {
                        Text(NSLocalizedString("unknown", comment:""))
                            .font(.title)
                            .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
                            .foregroundColor(.orange)
                    }
                    
                    Text(NSLocalizedString("membership", comment:""))
                        .foregroundColor(.gray)
                }.padding()
            }.padding()
            .offset(x: 0, y: -10)
            Spacer()
        }
    }
}

struct ProfileSummary_Previews: PreviewProvider {
    static var previews: some View {
        ProfileSummary(profile: Profile.default)
    }
}
