Skip to content

Commit 58653d8

Browse files
committed
Demo App new Static Location integration
1 parent d4de8f8 commit 58653d8

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

DemoApp/StreamChat/Components/CustomAttachments/DemoAttachmentViewCatalog.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import StreamChatUI
88
class DemoAttachmentViewCatalog: AttachmentViewCatalog {
99
override class func attachmentViewInjectorClassFor(message: ChatMessage, components: Components) -> AttachmentViewInjector.Type? {
1010
let hasMultipleAttachmentTypes = message.attachmentCounts.keys.count > 1
11-
let hasStaticLocationAttachment = message.attachmentCounts.keys.contains(.staticLocation)
12-
let hasLiveLocationAttachment = message.attachmentCounts.keys.contains(.liveLocation)
13-
let hasLocationAttachment = hasStaticLocationAttachment || hasLiveLocationAttachment
11+
let hasLocationAttachment = message.sharedLocation != nil
1412
if AppConfig.shared.demoAppConfig.isLocationAttachmentsEnabled && hasLocationAttachment {
1513
if hasMultipleAttachmentTypes {
1614
return MixedAttachmentViewInjector.self

DemoApp/StreamChat/Components/CustomAttachments/DemoQuotedChatMessageView.swift

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ import StreamChatUI
77
import UIKit
88

99
class DemoQuotedChatMessageView: QuotedChatMessageView {
10-
override func setAttachmentPreview(for message: ChatMessage) {
11-
if message.sharedLocation?.isLive == false {
12-
attachmentPreviewView.contentMode = .scaleAspectFit
13-
attachmentPreviewView.image = UIImage(systemName: "mappin.circle.fill")
14-
attachmentPreviewView.tintColor = .systemRed
15-
textView.text = "Location"
16-
return
17-
}
10+
override func updateContent() {
11+
super.updateContent()
1812

19-
if message.sharedLocation?.isLive == true {
20-
attachmentPreviewView.contentMode = .scaleAspectFit
21-
attachmentPreviewView.image = UIImage(systemName: "location.fill")
22-
attachmentPreviewView.tintColor = .systemBlue
23-
textView.text = "Live Location"
24-
return
13+
if let sharedLocation = content?.message.sharedLocation {
14+
if sharedLocation.isLive {
15+
attachmentPreviewView.contentMode = .scaleAspectFit
16+
attachmentPreviewView.image = UIImage(systemName: "location.fill")
17+
attachmentPreviewView.tintColor = .systemBlue
18+
textView.text = "Live Location"
19+
} else {
20+
attachmentPreviewView.contentMode = .scaleAspectFit
21+
attachmentPreviewView.image = UIImage(systemName: "mappin.circle.fill")
22+
attachmentPreviewView.tintColor = .systemRed
23+
textView.text = "Location"
24+
}
2525
}
26-
27-
super.setAttachmentPreview(for: message)
2826
}
2927
}

Sources/StreamChat/Models/Attachments/AttachmentTypes.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ public extension AttachmentType {
136136
static let audio = Self(rawValue: "audio")
137137
static let voiceRecording = Self(rawValue: "voiceRecording")
138138
static let linkPreview = Self(rawValue: "linkPreview")
139-
static let staticLocation = Self(rawValue: "static_location")
140-
static let liveLocation = Self(rawValue: "live_location")
141139
static let unknown = Self(rawValue: "unknown")
142140
}
143141

0 commit comments

Comments
 (0)