Show our reaction if any in long press menu + remove it if selected again

Fix scrolling for reactionsListTableView
This commit is contained in:
Benoit Martins 2023-09-11 15:13:39 +02:00 committed by QuentinArguillere
parent 43e91ae33d
commit 99445a04c4
3 changed files with 52 additions and 42 deletions

View file

@ -384,20 +384,29 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
cell.myImageView.isHidden = true
cell.optionLabel.isHidden = true
cell.myEmojiButton1.layer.cornerRadius = 10
cell.myEmojiButton1.backgroundColor = VoipTheme.light_grey_color
cell.myEmojiButton2.layer.cornerRadius = 10
cell.myEmojiButton2.backgroundColor = VoipTheme.light_grey_color
cell.myEmojiButton3.layer.cornerRadius = 10
cell.myEmojiButton3.backgroundColor = VoipTheme.light_grey_color
cell.myEmojiButton4.layer.cornerRadius = 10
cell.myEmojiButton4.backgroundColor = VoipTheme.light_grey_color
cell.myEmojiButton5.layer.cornerRadius = 10
cell.myEmojiButton5.backgroundColor = VoipTheme.light_grey_color
switch message.ownReaction?.body {
case "❤️":
cell.myEmojiButton1.layer.cornerRadius = 10
cell.myEmojiButton1.backgroundColor = VoipTheme.light_grey_color
case "👍":
cell.myEmojiButton2.layer.cornerRadius = 10
cell.myEmojiButton2.backgroundColor = VoipTheme.light_grey_color
case "😂":
cell.myEmojiButton3.layer.cornerRadius = 10
cell.myEmojiButton3.backgroundColor = VoipTheme.light_grey_color
case "😮":
cell.myEmojiButton4.layer.cornerRadius = 10
cell.myEmojiButton4.backgroundColor = VoipTheme.light_grey_color
case "😢":
cell.myEmojiButton5.layer.cornerRadius = 10
cell.myEmojiButton5.backgroundColor = VoipTheme.light_grey_color
default:
print("No reaction")
}
cell.myEmojiButton1.onClick {
do {
let messageReaction = try message.createReaction(utf8Reaction: "❤️")
let messageReaction = try message.ownReaction?.body != "❤️" ? message.createReaction(utf8Reaction: "❤️") : message.createReaction(utf8Reaction: "")
messageReaction.send()
self.menu!.clearSelection()
self.menu?.removeFromSuperview()
@ -407,7 +416,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
}
cell.myEmojiButton2.onClick {
do {
let messageReaction = try message.createReaction(utf8Reaction: "👍")
let messageReaction = try message.ownReaction?.body != "👍" ? message.createReaction(utf8Reaction: "👍") : message.createReaction(utf8Reaction: "")
messageReaction.send()
self.menu!.clearSelection()
self.menu?.removeFromSuperview()
@ -417,7 +426,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
}
cell.myEmojiButton3.onClick {
do {
let messageReaction = try message.createReaction(utf8Reaction: "😂")
let messageReaction = try message.ownReaction?.body != "😂" ? message.createReaction(utf8Reaction: "😂") : message.createReaction(utf8Reaction: "")
messageReaction.send()
self.menu!.clearSelection()
self.menu?.removeFromSuperview()
@ -427,7 +436,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
}
cell.myEmojiButton4.onClick {
do {
let messageReaction = try message.createReaction(utf8Reaction: "😮")
let messageReaction = try message.ownReaction?.body != "😮" ? message.createReaction(utf8Reaction: "😮") : message.createReaction(utf8Reaction: "")
messageReaction.send()
self.menu!.clearSelection()
self.menu?.removeFromSuperview()
@ -437,7 +446,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
}
cell.myEmojiButton5.onClick {
do {
let messageReaction = try message.createReaction(utf8Reaction: "😢")
let messageReaction = try message.ownReaction?.body != "😢" ? message.createReaction(utf8Reaction: "😢") : message.createReaction(utf8Reaction: "")
messageReaction.send()
self.menu!.clearSelection()
self.menu?.removeFromSuperview()

View file

@ -112,23 +112,29 @@ final class SheetViewController: UIViewController {
func setHeaderInActiveColor(color: UIColor){
colorHeaderInActive = color
}
func setCurrentPosition(position: Int){
currentPosition = position
let path = IndexPath(item: currentPosition, section: 0)
DispatchQueue.main.async {
if self.tabStyle == .flexible {
self.collectionHeader.scrollToItem(at: path, at: .centeredHorizontally, animated: true)
}
self.collectionHeader.reloadData()
}
DispatchQueue.main.async {
self.collectionPage.scrollToItem(at: path, at: .centeredHorizontally, animated: true)
}
}
func setCurrentPosition(position: Int){
currentPosition = position
let path = IndexPath(item: currentPosition, section: 0)
DispatchQueue.main.async {
if self.tabStyle == .flexible {
self.collectionHeader.scrollToItem(at: path, at: .centeredHorizontally, animated: true)
}
self.collectionHeader.reloadData()
}
DispatchQueue.main.async {
self.collectionPage.isPagingEnabled = false
self.collectionPage.scrollToItem(
at: path,
at: .centeredHorizontally,
animated: true
)
self.collectionPage.isPagingEnabled = true
}
}
func setStyle(style: SlidingTabStyle){
tabStyle = style
@ -337,7 +343,6 @@ class SimpleItemViewController: UIViewController, UITableViewDataSource {
// ParticipantsList
view.addSubview(reactionsListTableView)
//reactionsListTableView.matchParentDimmensions().done()
reactionsListTableView.alignParentTop(withMargin: 10).alignParentBottom().alignParentLeft().alignParentRight().done()
reactionsListTableView.dataSource = self
reactionsListTableView.register(ReactionCell.self, forCellReuseIdentifier: "ReactionCell")

View file

@ -249,11 +249,7 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
bubble.trailingAnchor.constraint(equalTo: contentBubble.trailingAnchor).isActive = true
bubble.layer.cornerRadius = 10.0
contentBubble.addSubview(bubbleReaction)
contentView.addSubview(bubbleReaction)
bubbleReaction.translatesAutoresizingMaskIntoConstraints = false
bubbleReaction.topAnchor.constraint(equalTo: bubble.bottomAnchor, constant: -10).isActive = true
bubbleReaction.layer.cornerRadius = 8.0
@ -1502,12 +1498,9 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
stackViewReactionsItem1.isHidden = false
}
}
let tap = UITapGestureRecognizer(target: self, action: #selector(self.showMyViewControllerInACustomizedSheet(_:)))
bubbleReaction.addGestureRecognizer(tap)
}
}else{
contentBubble.isHidden = true
@ -1672,6 +1665,9 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
onNewMessageReaction: { (message: ChatMessage, messageReaction: ChatMessageReaction) -> Void in
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
},
onReactionRemoved: { (message: ChatMessage, address: Address) -> Void in
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
},
onFileTransferProgressIndication: { (message: ChatMessage, content: Content, offset: Int, total: Int) -> Void in
self.file_transfer_progress_indication_recv(message: message, content: content, offset: offset, total: total)
},