Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created April 23, 2022 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosgyamfi/3c6ea1484145ba99647fa18b163c2a49 to your computer and use it in GitHub Desktop.
Save amosgyamfi/3c6ea1484145ba99647fa18b163c2a49 to your computer and use it in GitHub Desktop.
//
// 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