import SwiftUI

struct EventPostHeaderView: View {
    var summary: PostSummary
    
    var body: some View {
        VStack(alignment: .leading, spacing: 6) {
            HStack {
                Text(summary.title)
                    .textStyle(.title3)
                    .multilineTextAlignment(.leading)
                
                Spacer()
            }
            
            if let author = summary.authorStringNoPrefix, let authorId = summary.author.first?.id {
                NavigationLink {
                    AuthorView(authorId: authorId)
                } label: {
                    HStack(alignment: .center) {
                        Text(author)
                            .textStyle(.caption1)
                            .multilineTextAlignment(.leading)
                        
                        Spacer()
                    }
                }
                .buttonStyle(FlatButtonStyle())
            }
        }
    }
}

#if DEBUG
struct EventPostHeaderView_Previews: PreviewProvider {
    static var previews: some View {
        EventPostHeaderView(summary: Post.previewContent[0].summary)
    }
}
#endif
