* Update copyright holding and dates * compound IDE Macros updated * update copyright * update copyrights done * update templates and README
59 lines
2.4 KiB
Swift
59 lines
2.4 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2023-2025 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Compound
|
|
import SwiftUI
|
|
|
|
struct AudioMediaEventsTimelineView: View {
|
|
let timelineItem: AudioRoomTimelineItem
|
|
|
|
var body: some View {
|
|
MediaFileRoomTimelineContent(filename: timelineItem.content.filename,
|
|
fileSize: timelineItem.content.fileSize,
|
|
caption: timelineItem.content.caption,
|
|
formattedCaption: timelineItem.content.formattedCaption,
|
|
additionalWhitespaces: timelineItem.additionalWhitespaces(),
|
|
isAudioFile: true)
|
|
.accessibilityLabel(L10n.commonAudio)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.bubbleBackground(isOutgoing: timelineItem.isOutgoing)
|
|
}
|
|
}
|
|
|
|
struct AudioMediaEventsTimelineView_Previews: PreviewProvider, TestablePreview {
|
|
static let viewModel = TimelineViewModel.mock
|
|
|
|
static var previews: some View {
|
|
VStack(spacing: 20) {
|
|
AudioMediaEventsTimelineView(timelineItem: makeItem(filename: "audio.ogg",
|
|
fileSize: 2 * 1024 * 1024))
|
|
|
|
AudioMediaEventsTimelineView(timelineItem: makeItem(filename: "Best Song Ever.mp3",
|
|
fileSize: 7 * 1024 * 1024,
|
|
caption: "This song rocks!"))
|
|
}
|
|
.environmentObject(viewModel.context)
|
|
}
|
|
|
|
static func makeItem(filename: String, fileSize: UInt, caption: String? = nil) -> AudioRoomTimelineItem {
|
|
.init(id: .randomEvent,
|
|
timestamp: .mock,
|
|
isOutgoing: false,
|
|
isEditable: false,
|
|
canBeRepliedTo: true,
|
|
sender: .init(id: "Bob"),
|
|
content: .init(filename: filename,
|
|
caption: caption,
|
|
duration: 300,
|
|
waveform: nil,
|
|
source: nil,
|
|
fileSize: fileSize,
|
|
contentType: nil))
|
|
}
|
|
}
|