Skip to content

Instantly share code, notes, and snippets.

@plskz
Last active September 19, 2023 02:05
Show Gist options
  • Save plskz/2fad7e3221114e134d808460dfc2ae95 to your computer and use it in GitHub Desktop.
Save plskz/2fad7e3221114e134d808460dfc2ae95 to your computer and use it in GitHub Desktop.
Swift Playground - Discord Chat UI
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View {
VStack {
HStack {
Image(uiImage: #imageLiteral(resourceName: "Fif9dcDXEAAJ1Ul.jpeg"))
.resizable()
.scaledToFit()
.clipShape(Circle())
.frame(width: 64, height: 64)
VStack (alignment: .leading, spacing: 10) {
HStack {
Text("Aai")
.font(.title)
.foregroundColor(.blue)
Text("Today at 6:25 AM")
.foregroundColor(.gray)
}
Text("Hello, World!")
}
}
}
}
}
PlaygroundPage.current.setLiveView(ContentView())
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View {
VStack {
DiscordChat(time: "6:25 AM", msg: "Hello, world!")
DiscordChat(time: "7:30 AM", msg: "Swiftyy")
DiscordChat(time: "9:17 AM", msg: "Raawr")
}
}
}
struct DiscordChat: View {
var name: String = "Aai"
var time: String
var msg: String
var body: some View {
VStack {
HStack {
Image(uiImage: #imageLiteral(resourceName: "Fif9dcDXEAAJ1Ul.jpeg"))
.resizable()
.scaledToFit()
.clipShape(Circle())
.frame(width: 64, height: 64)
VStack (alignment: .leading, spacing: 10) {
HStack {
Text(name)
.font(.title)
.foregroundColor(.blue)
Text("Today at \(time)")
.foregroundColor(.gray)
}
Text(msg)
}
}
}
// .background(.pink)
}
}
PlaygroundPage.current.setLiveView(ContentView())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment