mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
751be7b3a7
* Update the SDK. * Add mockMXC URLs to fix all the crashes during tests. * Refactor Voice Messages to not use a MediaSource for local files.
59 lines
1.6 KiB
Swift
59 lines
1.6 KiB
Swift
//
|
|
// Copyright 2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
// Please see LICENSE in the repository root for full details.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
extension MediaProviderMock {
|
|
struct Configuration { }
|
|
|
|
convenience init(configuration: Configuration) {
|
|
self.init()
|
|
|
|
imageFromSourceSizeClosure = { mediaSource, _ in
|
|
guard mediaSource != nil else {
|
|
return nil
|
|
}
|
|
|
|
// At some stage it would be nice to return different images, but for now they can be the same.
|
|
if mediaSource?.url == .mockMXCImage || mediaSource?.url == .mockMXCAvatar {
|
|
return Asset.Images.appLogo.image
|
|
}
|
|
|
|
return UIImage(systemName: "photo")
|
|
}
|
|
|
|
loadImageFromSourceSizeClosure = { _, _ in
|
|
guard let image = UIImage(systemName: "photo") else {
|
|
fatalError()
|
|
}
|
|
|
|
return .success(image)
|
|
}
|
|
|
|
loadImageDataFromSourceClosure = { _ in
|
|
guard let image = UIImage(systemName: "photo"),
|
|
let data = image.pngData() else {
|
|
fatalError()
|
|
}
|
|
|
|
return .success(data)
|
|
}
|
|
|
|
loadFileFromSourceFilenameReturnValue = .failure(.failedRetrievingFile)
|
|
|
|
loadImageRetryingOnReconnectionSizeClosure = { _, _ in
|
|
Task {
|
|
guard let image = UIImage(systemName: "photo") else {
|
|
fatalError()
|
|
}
|
|
|
|
return image
|
|
}
|
|
}
|
|
}
|
|
}
|