Skip to content

Instantly share code, notes, and snippets.

d-srd

Block or report user

Report or block d-srd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MessageListView_ScrollView.swift
GeometryReader { geometry in
ScrollView {
ForEach(self.messages) { message in
MessageView(message: message)
.padding(.horizontal, 8)
.padding(EdgeInsets(
top: 0,
leading: message.sender == .me ? geometry.size.width * 0.5 : 0 ,
bottom: 0,
trailing: message.sender == .me ? 0 : geometry.size.width * 0.5))
View MessageListView_Body.swift
GeometryReader { geometry in
ForEach(self.messages) { message in
MessageView(message: message)
.padding(.horizontal, 8)
.padding(EdgeInsets(
top: 0,
leading: message.sender == .me ? geometry.size.width * 0.5 : 0 ,
bottom: 0,
trailing: message.sender == .me ? 0 : geometry.size.width * 0.5))
}
View MessageListView_Padding.swift
.padding(EdgeInsets(
top: 0,
leading: message.sender == .me ? 64 : 0 ,
bottom: 0,
trailing: message.sender == .me ? 0 : 64))
View MessageListView.swift
struct MessageListView: View {
let messages: [Message]
var body: some View {
ForEach(self.messages) { message in
MessageView(message: message)
.padding(.horizontal, 8)
}
}
}
View MessageView_Spacing.swift
struct MessageView: View {
let message: Message
var body: some View {
HStack {
if message.sender == .me {
Spacer()
}
Text(message.content)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
View MessageView.swift
struct MessageView: View {
let message: Message
var body: some View {
Text(message.content)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
.padding(.horizontal, 12)
.padding(.vertical, 4)
.background(message.sender == .me ? Color.blue : Color.gray)
.foregroundColor(message.sender == .me ? Color.white : Color.black)
View Message.swift
struct Message: Hashable, Identifiable {
enum Sender: Hashable {
case me
case other(named: String)
}
let id: Int
let sender: Sender
let content: String
}
View SwiftUI_model_EnvironmentObject.swift
struct HighScoreView: View {
@EnvironmentObject var highScore: HighScore
var body: some View {
Text(highScore.value)
}
}
View SwiftUI_model_ObservedObject.swift
struct UserInputView: View {
@ObservedObject var user: User
var body: some View {
VStack {
Text(user.name)
Text(user.surname)
}
}
}
View SwiftUI_model_Binding.swift
struct UsernameInputView: View {
@Binding var username: String
var body: some View {
TextField(username, text: $username)
}
}
You can’t perform that action at this time.