Created
April 23, 2022 13:08
-
-
Save amosgyamfi/3c6ea1484145ba99647fa18b163c2a49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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