mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Pill View rendering, performance improvement part 2 (#1894)
* improvdement * code improvement
This commit is contained in:
@@ -24,7 +24,7 @@ protocol PillAttachmentViewProviderDelegate: AnyObject {
|
||||
var roomContext: RoomScreenViewModel.Context? { get }
|
||||
|
||||
func registerPillView(_ pillView: UIView)
|
||||
func invalidateTextAttachmentsDisplay(update: Bool)
|
||||
func invalidateTextAttachmentsDisplay()
|
||||
}
|
||||
|
||||
final class PillAttachmentViewProvider: NSTextAttachmentViewProvider {
|
||||
@@ -44,7 +44,8 @@ final class PillAttachmentViewProvider: NSTextAttachmentViewProvider {
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
|
||||
guard let textAttachmentData = (textAttachment as? PillTextAttachment)?.pillData else {
|
||||
guard let textAttachment = textAttachment as? PillTextAttachment,
|
||||
let pillData = textAttachment.pillData else {
|
||||
MXLog.failure("[PillAttachmentViewProvider]: attachment is missing data or not of expected class")
|
||||
return
|
||||
}
|
||||
@@ -56,15 +57,16 @@ final class PillAttachmentViewProvider: NSTextAttachmentViewProvider {
|
||||
context = PillContext.mock(type: .loadUser(isOwn: false))
|
||||
imageProvider = MockMediaProvider()
|
||||
} else if let roomContext = delegate?.roomContext {
|
||||
context = PillContext(roomContext: roomContext, data: textAttachmentData)
|
||||
context = PillContext(roomContext: roomContext, data: pillData)
|
||||
imageProvider = roomContext.imageProvider
|
||||
} else {
|
||||
MXLog.failure("[PillAttachmentViewProvider]: missing room context")
|
||||
return
|
||||
}
|
||||
|
||||
let view = PillView(imageProvider: imageProvider, context: context) { [weak self] in
|
||||
self?.delegate?.invalidateTextAttachmentsDisplay(update: true)
|
||||
let view = PillView(imageProvider: imageProvider, context: context) { [weak self, weak textAttachment] in
|
||||
textAttachment?.invalidateLastBounds()
|
||||
self?.delegate?.invalidateTextAttachmentsDisplay()
|
||||
}
|
||||
let controller = UIHostingController(rootView: view)
|
||||
controller.view.backgroundColor = .clear
|
||||
@@ -93,5 +95,5 @@ extension WysiwygTextView: PillAttachmentViewProviderDelegate {
|
||||
(mentionDisplayHelper as? ComposerMentionDisplayHelper)?.roomContext
|
||||
}
|
||||
|
||||
func invalidateTextAttachmentsDisplay(update: Bool) { }
|
||||
func invalidateTextAttachmentsDisplay() { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user