Skip to content

Commit

Permalink
Merge pull request #13 from jaesung-0o0/feature/jaesung/update-messag…
Browse files Browse the repository at this point in the history
…e-menu1

Modified `highlightMessagePublisher` to send optional value
  • Loading branch information
x-0o0 authored Mar 8, 2023
2 parents ffa36d5 + 642da06 commit 8295343
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 19 deletions.
35 changes: 26 additions & 9 deletions Documentation/Chat_in_Channel/MessageList.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,35 @@ MessageList(messages) { message in
} menuContent: { highlightMessage in
// menu content
MessageMenu {
Button("Copy", action: copy)
.buttonStyle(MessageMenuButtonStyle(symbol: "doc.on.doc"))
// Copy action
Button(action: copy) {
HStack {
Text("Copy")

Spacer()

Image(systemName: "doc.on.doc")
}
.padding(.horizontal, 16)
.foregroundColor(appearance.primary)
}
.frame(height: 44)

Divider()

Button("Reply", action: reply)
.buttonStyle(MessageMenuButtonStyle(symbol: "arrowshape.turn.up.right"))

Divider()

Button("Delete", action: delete)
.buttonStyle(MessageMenuButtonStyle(symbol: "trash"))
// Delete action
Button(action: delete) {
HStack {
Text("Delete")

Spacer()

Image(systemName: "trash")
}
.padding(.horizontal, 16)
.foregroundColor(appearance.primary)
}
.frame(height: 44)
}
.padding(.top, 12)
}
Expand Down
29 changes: 22 additions & 7 deletions Sources/ChatUI/ChatInChannel/MessageList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,33 @@ public struct MessageList<MessageType: MessageProtocol & Identifiable, RowConten
/// MessageRow(message: message)
/// } menuContent: { highlightMessage in
/// MessageMenu {
/// Button("Copy", action: copy)
/// .buttonStyle(MessageMenuButtonStyle(symbol: "doc.on.doc"))
/// Button(action: copy) {
/// HStack {
/// Text("Copy")
///
/// Divider()
/// Spacer()
///
/// Button("Reply", action: reply)
/// .buttonStyle(MessageMenuButtonStyle(symbol: "arrowshape.turn.up.right"))
/// Image(systemName: "doc.on.doc")
/// }
/// .padding(.horizontal, 16)
/// .foregroundColor(appearance.primary)
/// }
/// .frame(height: 44)
///
/// Divider()
///
/// Button("Delete", action: delete)
/// .buttonStyle(MessageMenuButtonStyle(symbol: "trash"))
/// Button(action: delte) {
/// .HStack {
/// Text("Delete")
///
/// Spacer()
///
/// Image(systemName: "trash")
/// }
/// .padding(.horizontal, 16)
/// .foregroundColor(appearance.primary)
/// }
/// .frame(height: 44)
/// }
/// .padding(.top, 12)
/// }
Expand Down
3 changes: 2 additions & 1 deletion Sources/ChatUI/ChatInChannel/MessageMenu/MessageMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ public struct MessageMenuButtonStyle: ButtonStyle {
public func makeBody(configuration: Configuration) -> some View {
HStack {
configuration.label
.frame(height: 44)

Spacer()
Image(systemName: symbol)
}
.padding(.horizontal, 16)
.foregroundColor(appearance.primary)
.background(configuration.isPressed ? appearance.secondaryBackground : Color.clear)
.frame(height: 44)
}

public init(symbol: String) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ChatUI/ChatInChannel/MessageRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public struct MessageRow<M: MessageProtocol>: View {
}
}
.onReceive(highlightMessagePublisher) { highlightMessage in
isSelected = message.id == highlightMessage.id
isSelected = message.id == highlightMessage?.id
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ChatUI/Publishers/HighlightMessagePublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ import Combine
/**
The publisher that send highlight message.
*/
public var highlightMessagePublisher = PassthroughSubject<any MessageProtocol, Never>()
public var highlightMessagePublisher = PassthroughSubject<(any MessageProtocol)?, Never>()

0 comments on commit 8295343

Please sign in to comment.