Animate avatars by default

This commit is contained in:
Justin Mazzocchi 2021-02-03 17:50:25 -08:00
parent 11e27d20d9
commit a566babe3a
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
5 changed files with 19 additions and 8 deletions

View File

@ -70,7 +70,7 @@ public extension AppPreferences {
return value
}
return .profiles
return .everywhere
}
set { self[.animateAvatars] = newValue.rawValue }
}

View File

@ -64,7 +64,7 @@ public extension AccountViewModel {
func avatarURL(profile: Bool = false) -> URL {
if !identityContext.appPreferences.shouldReduceMotion,
(identityContext.appPreferences.animateAvatars == .everywhere
|| identityContext.appPreferences.animateAvatars == .profiles && profile) {
|| (identityContext.appPreferences.animateAvatars == .profiles && profile)) {
return accountService.account.avatar
} else {
return accountService.account.avatarStatic

View File

@ -4,12 +4,13 @@ import Kingfisher
import UIKit
import ViewModels
// swiftlint:disable file_length
final class AccountHeaderView: UIView {
let headerImageBackgroundView = UIView()
let headerImageView = AnimatedImageView()
let headerButton = UIButton()
let avatarBackgroundView = UIView()
let avatarImageView = UIImageView()
let avatarImageView = AnimatedImageView()
let avatarButton = UIButton()
let relationshipButtonsStackView = UIStackView()
let followButton = UIButton(type: .system)
@ -405,3 +406,4 @@ private extension AccountHeaderView {
])
}
}
// swiftlint:enable file_length

View File

@ -187,12 +187,17 @@ private extension CompositionView {
}
.store(in: &cancellables)
parentViewModel.$identityContext.map(\.identity)
parentViewModel.$identityContext
.sink { [weak self] in
guard let self = self else { return }
self.avatarImageView.kf.setImage(with: $0.image)
self.changeIdentityButton.accessibilityLabel = $0.handle
let avatarURL = $0.appPreferences.animateAvatars == .everywhere
&& !$0.appPreferences.shouldReduceMotion
? $0.identity.account?.avatar
: $0.identity.account?.avatarStatic
self.avatarImageView.kf.setImage(with: avatarURL)
self.changeIdentityButton.accessibilityLabel = $0.identity.handle
self.changeIdentityButton.accessibilityHint =
NSLocalizedString("compose.change-identity-button.accessibility-hint", comment: "")
}

View File

@ -65,8 +65,12 @@ private extension SecondaryNavigationTitleView {
}
func applyViewModel() {
avatarImageView.kf.setImage(with: viewModel.identityContext.identity.image)
avatarImageView.autoPlayAnimatedImage = viewModel.identityContext.appPreferences.animateAvatars == .everywhere
let avatarURL = viewModel.identityContext.appPreferences.animateAvatars == .everywhere
&& !viewModel.identityContext.appPreferences.shouldReduceMotion
? viewModel.identityContext.identity.account?.avatar
: viewModel.identityContext.identity.account?.avatarStatic
avatarImageView.kf.setImage(with: avatarURL)
if let displayName = viewModel.identityContext.identity.account?.displayName,
!displayName.isEmpty {