mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
Add leading and trailing SwipeActions for bubbles
This commit is contained in:
parent
afeef1d93c
commit
768f505559
2 changed files with 41 additions and 24 deletions
|
|
@ -22,8 +22,38 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
func compositeViewDescription() -> UICompositeViewDescription! { return type(of: self).compositeDescription }
|
||||
|
||||
var collectionView: UICollectionView = {
|
||||
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
|
||||
return collectionView
|
||||
if #available(iOS 14.0, *) {
|
||||
var listConfiguration = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
|
||||
listConfiguration.leadingSwipeActionsConfigurationProvider = { indexPath in
|
||||
let rep = UIContextualAction(style: .normal, title: "Reply") {
|
||||
action, view, completion in
|
||||
//self?.deleteMessage(at: indexPath)
|
||||
completion(true)
|
||||
}
|
||||
return UISwipeActionsConfiguration(actions: [rep])
|
||||
}
|
||||
|
||||
listConfiguration.trailingSwipeActionsConfigurationProvider = { indexPath in
|
||||
let del = UIContextualAction(style: .destructive, title: "Delete") {
|
||||
action, view, completion in
|
||||
//self?.deleteMessage(at: indexPath)
|
||||
completion(true)
|
||||
}
|
||||
return UISwipeActionsConfiguration(actions: [del])
|
||||
}
|
||||
|
||||
listConfiguration.showsSeparators = false
|
||||
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: listConfiguration)
|
||||
layout.configuration.contentInsetsReference = .layoutMargins
|
||||
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
collectionView.layoutMargins = .init(top: 100, left: 100, bottom: 100, right: 100)
|
||||
return collectionView
|
||||
} else {
|
||||
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
|
||||
return collectionView
|
||||
}
|
||||
}()
|
||||
|
||||
var menu: DropDown? = nil
|
||||
|
|
@ -90,9 +120,12 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
collectionView.delegate = self
|
||||
collectionView.register(MultilineMessageCell.self, forCellWithReuseIdentifier: MultilineMessageCell.reuseId)
|
||||
|
||||
(collectionView.collectionViewLayout as! UICollectionViewFlowLayout).estimatedItemSize = UICollectionViewFlowLayout.automaticSize
|
||||
(collectionView.collectionViewLayout as! UICollectionViewFlowLayout).minimumLineSpacing = 2
|
||||
|
||||
if #available(iOS 14.0, *) {
|
||||
collectionView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
|
||||
} else {
|
||||
(collectionView.collectionViewLayout as! UICollectionViewFlowLayout).estimatedItemSize = UICollectionViewFlowLayout.automaticSize
|
||||
(collectionView.collectionViewLayout as! UICollectionViewFlowLayout).minimumLineSpacing = 2
|
||||
}
|
||||
collectionView.transform = CGAffineTransform(scaleX: 1, y: -1)
|
||||
}
|
||||
|
||||
|
|
@ -234,13 +267,6 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
return ChatConversationTableViewModel.sharedModel.getNBMessages()
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegateFlowLayout -
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
||||
let referenceHeight: CGFloat = 100
|
||||
let referenceWidth: CGFloat = 100
|
||||
return CGSize(width: referenceWidth, height: referenceHeight)
|
||||
}
|
||||
|
||||
func isBasicChatRoom(_ room: OpaquePointer?) -> Bool {
|
||||
if room == nil {
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
|
||||
eventMessageView.isHidden = true
|
||||
|
||||
|
||||
//Message
|
||||
contentView.addSubview(contactDateLabel)
|
||||
|
||||
|
|
@ -204,20 +203,18 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
|
||||
contentBubble.addSubview(bubble)
|
||||
bubble.translatesAutoresizingMaskIntoConstraints = false
|
||||
bubble.topAnchor.constraint(equalTo: contactDateLabel.bottomAnchor).isActive = true
|
||||
bubble.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
|
||||
bubble.topAnchor.constraint(equalTo: contactDateLabel.bottomAnchor, constant: 2).isActive = true
|
||||
bubble.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -2).isActive = true
|
||||
bubble.leadingAnchor.constraint(equalTo: contentBubble.leadingAnchor).isActive = true
|
||||
bubble.trailingAnchor.constraint(equalTo: contentBubble.trailingAnchor).isActive = true
|
||||
bubble.layer.cornerRadius = 10.0
|
||||
|
||||
contentBubble.addSubview(chatRead)
|
||||
chatRead.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -2).isActive = true
|
||||
chatRead.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -4).isActive = true
|
||||
chatRead.trailingAnchor.constraint(equalTo: deleteItemCheckBox.leadingAnchor, constant: -8).isActive = true
|
||||
chatRead.size(w: 10, h: 10).done()
|
||||
chatRead.isHidden = true
|
||||
|
||||
|
||||
|
||||
//PreContentViewBubble
|
||||
bubble.addSubview(preContentViewBubble)
|
||||
preContentViewBubble.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
|
@ -317,8 +314,6 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
|
||||
replyView.isHidden = true
|
||||
|
||||
|
||||
|
||||
//ContentViewBubble
|
||||
bubble.addSubview(contentViewBubble)
|
||||
contentViewBubble.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
|
@ -1004,10 +999,6 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
|
||||
let regex = try! NSRegularExpression(pattern: "sips:(\\S+)")
|
||||
|
||||
|
||||
//matches = detector.matches(in: input, options: [], range: NSRange(location: 0, length: input.utf16.count))
|
||||
//let matchesSips = regex.matches(in: input, options: [], range: NSRange(location: 0, length: input.utf16.count))
|
||||
|
||||
let matchesSips = detector.matches(in: input, options: [], range: NSRange(location: 0, length: input.utf16.count))
|
||||
matches = regex.matches(in: input, options: [], range: NSRange(location: 0, length: input.utf16.count))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue