aboutsummaryrefslogtreecommitdiff
path: root/Hotline/macOS/MessageView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hotline/macOS/MessageView.swift')
-rw-r--r--Hotline/macOS/MessageView.swift34
1 files changed, 22 insertions, 12 deletions
diff --git a/Hotline/macOS/MessageView.swift b/Hotline/macOS/MessageView.swift
index 0a8b071..f62f922 100644
--- a/Hotline/macOS/MessageView.swift
+++ b/Hotline/macOS/MessageView.swift
@@ -3,19 +3,19 @@ import SwiftUI
struct MessageView: View {
@Environment(Hotline.self) private var model: Hotline
@Environment(\.colorScheme) private var colorScheme
-
+
@State private var input: String = ""
@State private var scrollPos: Int?
@State private var contentHeight: CGFloat = 0
@Namespace private var bottomID
@FocusState private var focusedField: FocusedField?
-
+
var userID: UInt16
-
+
var body: some View {
ScrollViewReader { reader in
VStack(alignment: .leading, spacing: 0) {
-
+
// MARK: Scroll View
GeometryReader { gm in
ScrollView(.vertical) {
@@ -25,17 +25,27 @@ struct MessageView: View {
if msg.direction == .outgoing {
Spacer()
}
-
+
Text(LocalizedStringKey(msg.text))
.lineSpacing(4)
.multilineTextAlignment(.leading)
.textSelection(.enabled)
- .tint(msg.direction == .outgoing ? Color("Outgoing Message Link") : Color("Link Color"))
- .foregroundStyle(msg.direction == .outgoing ? Color("Outgoing Message Text") : Color("Incoming Message Text"))
+ .tint(
+ msg.direction == .outgoing
+ ? Color("Outgoing Message Link") : Color("Link Color")
+ )
+ .foregroundStyle(
+ msg.direction == .outgoing
+ ? Color("Outgoing Message Text") : Color("Incoming Message Text")
+ )
.padding(EdgeInsets(top: 10, leading: 14, bottom: 10, trailing: 14))
- .background(msg.direction == .outgoing ? Color("Outgoing Message Background") : Color("Incoming Message Background"))
+ .background(
+ msg.direction == .outgoing
+ ? Color("Outgoing Message Background")
+ : Color("Incoming Message Background")
+ )
.clipShape(RoundedRectangle(cornerRadius: 16))
-
+
if msg.direction == .incoming {
Spacer()
}
@@ -44,7 +54,7 @@ struct MessageView: View {
}
}
.padding()
-
+
VStack(spacing: 0) {}.id(bottomID)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -61,10 +71,10 @@ struct MessageView: View {
reader.scrollTo(bottomID, anchor: .bottom)
}
}
-
+
// MARK: Input Divider
Divider()
-
+
// MARK: Input Bar
HStack(alignment: .lastTextBaseline, spacing: 0) {
let user = model.users.first(where: { $0.id == userID })