import SwiftUI import SFSafeSymbols struct TopView: View { let info: TopInfo let style: HeaderStyle var body: some View { GeometryReader { geo in let sideWidth = max(0, (geo.size.width - geo.size.height) / 2) HStack(spacing: 0) { VStack(alignment: .leading, spacing: 0) { Text(info.name) .font(.title) .foregroundColor(.accentColor) Spacer(minLength: 0) Text(info.tagLine) .font(.subheadline) .padding(.trailing, style.imageShadowSize) Spacer(minLength: 0) HStack { RightImageLabel(info.place, systemSymbol: .house) .padding(.leading, -4) RightImageLabel(info.ageText, systemSymbol: .hourglass) }.font(.subheadline) } .frame(width: sideWidth) TopViewImage( image: info.imageName, shadow: style.imageShadowSize, lineWidth: style.imageBorderWidth) VStack(alignment: .trailing) { LeftImageLabel(info.web, systemSymbol: .globe) .frame(maxHeight: style.iconHeight) Spacer() LeftImageLabel(info.email, systemSymbol: .envelope) .frame(maxHeight: style.iconHeight) Spacer() LeftImageLabel(info.phone, systemSymbol: .phone) .frame(maxHeight: style.iconHeight) Spacer() HStack(spacing: 0) { Spacer() Text(info.github) Image("Github") .resizable() .aspectRatio(1.0, contentMode: .fit) .padding(2) .frame(width: style.iconHeight) }.frame(maxHeight: style.iconHeight) } .font(.subheadline) .frame(width: sideWidth) } } } } struct TopView_Previews: PreviewProvider { static var previews: some View { TopView(info: .init( imageName: "Cover", name: "Christoph Hagen", tagLine: "Problem solver and creative mind with a favour for interdisciplinary work.", place: "Würzburg, Germany", ageText: "Age 32", web: "christophhagen.de", email: "jobs@christophhagen.de", phone: "Upon Request", github: "github.com/christophhagen"), style: HeaderStyle()) .previewLayout(.fixed(width: 540, height: 120)) } }