Skip to content

Commit 8512624

Browse files
authored
Expose MediaAttachment properties and initializer (#1000)
* Expose `MediaAttachment` properties and init * Update CHANGELOG with new features and fixes Updated CHANGELOG to include recent feature additions and bug fixes.
1 parent 7a7130c commit 8512624

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
99
- Add participant actions in channel info view [#982](https://github.com/GetStream/stream-chat-swiftui/pull/982)
1010
- Add support for overriding `onImageTap` in `LinkAttachmentView` [#986](https://github.com/GetStream/stream-chat-swiftui/pull/986)
1111
- Add support for customizing text colors in `LinkAttachmentView` [#992](https://github.com/GetStream/stream-chat-swiftui/pull/992)
12+
- Expose `MediaAttachment` properties and initializer [#1000](https://github.com/GetStream/stream-chat-swiftui/pull/1000)
1213

1314
### 🐞 Fixed
1415
- Fix openChannel not working when searching or another chat shown [#975](https://github.com/GetStream/stream-chat-swiftui/pull/975)

Sources/StreamChatSwiftUI/ChatChannel/MessageList/ImageAttachmentView.swift

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,15 @@ extension ChatMessage {
425425
public struct MediaAttachment: Identifiable, Equatable {
426426
@Injected(\.utils) var utils
427427

428-
let url: URL
429-
let type: MediaAttachmentType
430-
var uploadingState: AttachmentUploadingState?
428+
public let url: URL
429+
public let type: MediaAttachmentType
430+
public var uploadingState: AttachmentUploadingState?
431+
432+
public init(url: URL, type: MediaAttachmentType, uploadingState: AttachmentUploadingState? = nil) {
433+
self.url = url
434+
self.type = type
435+
self.uploadingState = uploadingState
436+
}
431437

432438
public var id: String {
433439
url.absoluteString
@@ -477,9 +483,14 @@ extension MediaAttachment {
477483
}
478484
}
479485

480-
enum MediaAttachmentType {
481-
case image
482-
case video
486+
public struct MediaAttachmentType: RawRepresentable {
487+
public let rawValue: String
488+
public init(rawValue: String) {
489+
self.rawValue = rawValue
490+
}
491+
492+
public static let image = Self(rawValue: "image")
493+
public static let video = Self(rawValue: "video")
483494
}
484495

485496
/// Options for the gallery view.

0 commit comments

Comments
 (0)