Constrain size

This commit is contained in:
Jed Fox 2022-11-16 22:52:44 -05:00
parent 5d91bcf8b5
commit 23a0943b12
No known key found for this signature in database
GPG Key ID: 0B61D18EA54B47E1
2 changed files with 8 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import MastodonUI
final class ProfileHeaderViewModel {
static let avatarImageMaxSizeInPixel = CGSize(width: 400, height: 400)
static let bannerImageMaxSizeInPixel = CGSize(width: 1500, height: 500)
static let maxProfileFieldCount = 4
var disposeBag = Set<AnyCancellable>()

View File

@ -217,7 +217,13 @@ extension ProfileViewModel {
let authorization = authenticationBox.userAuthorization
// TODO: constrain size?
let _header: UIImage? = headerProfileInfo.header
let _header: UIImage? = {
guard let image = headerProfileInfo.header else { return nil }
guard image.size.width <= ProfileHeaderViewModel.bannerImageMaxSizeInPixel.width else {
return image.af.imageScaled(to: ProfileHeaderViewModel.bannerImageMaxSizeInPixel)
}
return image
}()
let _avatar: UIImage? = {
guard let image = headerProfileInfo.avatar else { return nil }