Implement the save action when previewing media. (#3630)

* Implement the save action on the media preview.

* Update Compound and use the correct icon.

Also fixes an icon that has been renamed.

* Update the add to photo library usage description to match the designs.

* PR comments.
This commit is contained in:
Doug
2024-12-17 16:35:51 +00:00
committed by GitHub
parent 2b82b94500
commit 2a865ce5bf
23 changed files with 403 additions and 68 deletions
@@ -8,6 +8,7 @@ import Combine
import Foundation
import LocalAuthentication
import MatrixRustSDK
import Photos
import SwiftUI
class AnalyticsClientMock: AnalyticsClientProtocol {
var isRunning: Bool {
@@ -12327,6 +12328,79 @@ class PHGPostHogMock: PHGPostHogProtocol {
screenPropertiesClosure?(screenTitle, properties)
}
}
class PhotoLibraryManagerMock: PhotoLibraryManagerProtocol {
//MARK: - addResource
var addResourceAtUnderlyingCallsCount = 0
var addResourceAtCallsCount: Int {
get {
if Thread.isMainThread {
return addResourceAtUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = addResourceAtUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
addResourceAtUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
addResourceAtUnderlyingCallsCount = newValue
}
}
}
}
var addResourceAtCalled: Bool {
return addResourceAtCallsCount > 0
}
var addResourceAtReceivedArguments: (type: PHAssetResourceType, url: URL)?
var addResourceAtReceivedInvocations: [(type: PHAssetResourceType, url: URL)] = []
var addResourceAtUnderlyingReturnValue: Result<Void, PhotoLibraryManagerError>!
var addResourceAtReturnValue: Result<Void, PhotoLibraryManagerError>! {
get {
if Thread.isMainThread {
return addResourceAtUnderlyingReturnValue
} else {
var returnValue: Result<Void, PhotoLibraryManagerError>? = nil
DispatchQueue.main.sync {
returnValue = addResourceAtUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
addResourceAtUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
addResourceAtUnderlyingReturnValue = newValue
}
}
}
}
var addResourceAtClosure: ((PHAssetResourceType, URL) async -> Result<Void, PhotoLibraryManagerError>)?
func addResource(_ type: PHAssetResourceType, at url: URL) async -> Result<Void, PhotoLibraryManagerError> {
addResourceAtCallsCount += 1
addResourceAtReceivedArguments = (type: type, url: url)
DispatchQueue.main.async {
self.addResourceAtReceivedInvocations.append((type: type, url: url))
}
if let addResourceAtClosure = addResourceAtClosure {
return await addResourceAtClosure(type, url)
} else {
return addResourceAtReturnValue
}
}
}
class PollInteractionHandlerMock: PollInteractionHandlerProtocol {
//MARK: - sendPollResponse