Skip to content
Snippets Groups Projects
Commit 6f77a17f authored by Charles Wright's avatar Charles Wright
Browse files

First rough draft of the new replies view with simple TextField composer

parent fcfa8ace
No related branches found
No related tags found
2 merge requests!210New comments view (previously replies),!209Draft: v1.1.0
......@@ -132,6 +132,7 @@ enum SystemImages: String {
case lockFill = "lock.fill"
case lockRectangle = "lock.rectangle"
case minusCircleFill = "minus.circle.fill"
case paperplaneCircleFill = "paperplane.circle.fill"
case pencil = "pencil"
case pencilCircleFill = "pencil.circle.fill"
case personCropCircleBadgePlus = "person.crop.circle.badge.plus"
......@@ -165,6 +166,7 @@ enum SystemImages: String {
case lockSlashFill = "lock.slash.fill"
case minusMagnifyingglass = "minus.magnifyingglass"
case paperclip = "paperclip"
case paperclipCircleFill = "paperclip.circle.fill"
case person2SquareStack = "person.2.square.stack"
case personCropSquare = "person.crop.square"
case photoBadgePlusFill = "photo.badge.plus.fill"
......
......@@ -11,11 +11,18 @@ import Matrix
struct RepliesView: View {
var room: Matrix.Room
@ObservedObject var parent: Matrix.Message
@State var expanded = false
@State var showReplyComposer = false
@State var newMessageText = ""
func send() async throws -> EventId {
let eventId = try await room.sendText(text: newMessageText, inReplyTo: parent)
await MainActor.run {
self.newMessageText = ""
}
return eventId
}
var body: some View {
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 0) {
let now = Date()
let cutoff = now.addingTimeInterval(300.0)
let allMessages = parent.replies.values
......@@ -27,46 +34,52 @@ struct RepliesView: View {
$0.timestamp < $1.timestamp
}
if messages.isEmpty {
if DebugModel.shared.debugMode {
HStack {
Spacer()
Text("No replies")
}
} else {
EmptyView()
if messages.isEmpty && DebugModel.shared.debugMode {
Text("No replies")
}
ScrollView {
ForEach(messages) { message in
MessageCard(message: message, isThreaded: true)
}
}
else {
if !expanded {
HStack {
Spacer()
Button(action: {
self.expanded = true
room.objectWillChange.send()
}) {
Text("Show \(messages.count) replies")
.font(.footnote)
}
}
} else {
ForEach(messages) { message in
MessageCard(message: message, isThreaded: true)
}
HStack {
Spacer()
Button(action: {
self.expanded = false
room.objectWillChange.send()
}) {
Text("Hide replies")
.font(.footnote)
}
Divider()
HStack(spacing: 4) {
Button(action: {
// Pick media to attach
}) {
Image(systemName: SystemImages.paperclipCircleFill.rawValue)
.resizable()
.frame(width: 32, height: 32)
}
.disabled(true)
TextField(text: $newMessageText) {
Text("Message")
}
.textFieldStyle(.roundedBorder)
.submitLabel(.send)
.onSubmit {
Task {
try await send()
}
}
AsyncButton(action: {
try await send()
}) {
Image(systemName: SystemImages.paperplaneCircleFill.rawValue)
.resizable()
.frame(width: 32, height: 32)
}
.disabled(newMessageText.isEmpty)
}
.padding(4)
}
.padding(.leading)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment