Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//
// MessagesView.swift
// iMessageClone
//
//
import SwiftUI
struct MessagesView: View {
var messages: [MessagesStructure] = []
let readIndicator = Color(#colorLiteral(red: 0.3098039329, green: 0.01568627544, blue: 0.1294117719, alpha: 0))
var body: some View {
VStack {
HeaderView()
List(messages) { item in
HStack {
ZStack {
readIndicator
.frame(width: 11, height: 11)
Image(item.unreadIndicator)
}
Image(item.avatar)
.resizable()
.clipShape(Circle())
.frame(width: 45, height: 45)
VStack(alignment: .leading){
HStack{
Text("\(item.name)")
Spacer()
Text("\(item.timestamp)")
.font(.headline)
.foregroundColor(.secondary)
Image(systemName: "chevron.forward")
.font(.headline)
.foregroundColor(.secondary)
}
Text("\(item.messageSummary)")
.font(.headline)
.foregroundColor(.secondary)
}
}
}
.listStyle(.plain)
} // Vertical container for the list and header
}
}
struct MessagesView_Previews: PreviewProvider {
static var previews: some View {
MessagesView(messages: MessageData)
.preferredColorScheme(.dark)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment