use UIIimage to generate the local thumbnail for the avatar image so that snapshotting works fine and performance are improved

This commit is contained in:
Mauro Romito
2026-01-15 17:06:27 +01:00
committed by Mauro
parent 648caa4e82
commit 2f11eb7b65
10 changed files with 44 additions and 36 deletions
@@ -6,7 +6,7 @@
// Please see LICENSE files in the repository root for full details.
//
import Foundation
import SwiftUI
enum CreateRoomScreenErrorType: Error {
case failedCreatingRoom
@@ -31,7 +31,19 @@ struct CreateRoomScreenViewState: BindableState {
let isKnockingFeatureEnabled: Bool
var aliasLocalPart: String
var bindings: CreateRoomScreenViewStateBindings
var avatarMediaInfo: MediaInfo?
var avatarMediaInfo: MediaInfo? {
didSet {
switch avatarMediaInfo {
case .image(_, let thumbnailURL, _):
avatarImage = UIImage(contentsOfFile: thumbnailURL.path(percentEncoded: false))
default:
avatarImage = nil
}
}
}
var avatarImage: UIImage?
var canCreateRoom: Bool {
!roomName.isEmpty && aliasErrors.isEmpty
}