diff options
Diffstat (limited to 'Hotline/iOS/ChatView.swift')
| -rw-r--r-- | Hotline/iOS/ChatView.swift | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Hotline/iOS/ChatView.swift b/Hotline/iOS/ChatView.swift index dadd5e6..e5105d0 100644 --- a/Hotline/iOS/ChatView.swift +++ b/Hotline/iOS/ChatView.swift @@ -2,20 +2,21 @@ import SwiftUI extension View { func endEditing() { - UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) + UIApplication.shared.sendAction( + #selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) } } struct ChatView: View { @Environment(Hotline.self) private var model: Hotline @Environment(\.colorScheme) var colorScheme - + @State var input: String = "" @State private var scrollPos: Int? @State private var contentHeight: CGFloat = 0 - + @Namespace var bottomID - + var body: some View { NavigationStack { VStack(spacing: 0) { @@ -24,7 +25,7 @@ struct ChatView: View { LazyVStack(alignment: .leading) { ForEach(model.chat) { msg in if msg.type == .agreement { - + VStack(alignment: .center) { if let bannerImage = self.model.bannerImage { Image(uiImage: bannerImage) @@ -33,7 +34,7 @@ struct ChatView: View { .frame(maxWidth: 468.0) .clipShape(RoundedRectangle(cornerRadius: 5)) } - + VStack(alignment: .leading) { HStack { Text(msg.text) @@ -51,8 +52,7 @@ struct ChatView: View { } .frame(maxWidth: .infinity) .padding() - } - else if msg.type == .status { + } else if msg.type == .status { HStack { Spacer() Text(msg.text) @@ -62,13 +62,11 @@ struct ChatView: View { Spacer() } .padding() - } - else { + } else { HStack(alignment: .firstTextBaseline) { if let username = msg.username { Text("**\(username):** \(msg.text)") - } - else { + } else { Text(msg.text) .textSelection(.enabled) } @@ -96,9 +94,9 @@ struct ChatView: View { self.endEditing() } } - + Divider() - + HStack(alignment: .top) { Image(systemName: "chevron.right").opacity(0.4) TextField("", text: $input, axis: .vertical) @@ -144,7 +142,7 @@ struct ChatView: View { } } } - + } } } |