mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 16:21:00 +00:00
Animate avatars by default
This commit is contained in:
parent
11e27d20d9
commit
a566babe3a
5 changed files with 19 additions and 8 deletions
|
@ -70,7 +70,7 @@ public extension AppPreferences {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
return .profiles
|
return .everywhere
|
||||||
}
|
}
|
||||||
set { self[.animateAvatars] = newValue.rawValue }
|
set { self[.animateAvatars] = newValue.rawValue }
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public extension AccountViewModel {
|
||||||
func avatarURL(profile: Bool = false) -> URL {
|
func avatarURL(profile: Bool = false) -> URL {
|
||||||
if !identityContext.appPreferences.shouldReduceMotion,
|
if !identityContext.appPreferences.shouldReduceMotion,
|
||||||
(identityContext.appPreferences.animateAvatars == .everywhere
|
(identityContext.appPreferences.animateAvatars == .everywhere
|
||||||
|| identityContext.appPreferences.animateAvatars == .profiles && profile) {
|
|| (identityContext.appPreferences.animateAvatars == .profiles && profile)) {
|
||||||
return accountService.account.avatar
|
return accountService.account.avatar
|
||||||
} else {
|
} else {
|
||||||
return accountService.account.avatarStatic
|
return accountService.account.avatarStatic
|
||||||
|
|
|
@ -4,12 +4,13 @@ import Kingfisher
|
||||||
import UIKit
|
import UIKit
|
||||||
import ViewModels
|
import ViewModels
|
||||||
|
|
||||||
|
// swiftlint:disable file_length
|
||||||
final class AccountHeaderView: UIView {
|
final class AccountHeaderView: UIView {
|
||||||
let headerImageBackgroundView = UIView()
|
let headerImageBackgroundView = UIView()
|
||||||
let headerImageView = AnimatedImageView()
|
let headerImageView = AnimatedImageView()
|
||||||
let headerButton = UIButton()
|
let headerButton = UIButton()
|
||||||
let avatarBackgroundView = UIView()
|
let avatarBackgroundView = UIView()
|
||||||
let avatarImageView = UIImageView()
|
let avatarImageView = AnimatedImageView()
|
||||||
let avatarButton = UIButton()
|
let avatarButton = UIButton()
|
||||||
let relationshipButtonsStackView = UIStackView()
|
let relationshipButtonsStackView = UIStackView()
|
||||||
let followButton = UIButton(type: .system)
|
let followButton = UIButton(type: .system)
|
||||||
|
@ -405,3 +406,4 @@ private extension AccountHeaderView {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// swiftlint:enable file_length
|
||||||
|
|
|
@ -187,12 +187,17 @@ private extension CompositionView {
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
parentViewModel.$identityContext.map(\.identity)
|
parentViewModel.$identityContext
|
||||||
.sink { [weak self] in
|
.sink { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
||||||
self.avatarImageView.kf.setImage(with: $0.image)
|
let avatarURL = $0.appPreferences.animateAvatars == .everywhere
|
||||||
self.changeIdentityButton.accessibilityLabel = $0.handle
|
&& !$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 =
|
self.changeIdentityButton.accessibilityHint =
|
||||||
NSLocalizedString("compose.change-identity-button.accessibility-hint", comment: "")
|
NSLocalizedString("compose.change-identity-button.accessibility-hint", comment: "")
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,12 @@ private extension SecondaryNavigationTitleView {
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyViewModel() {
|
func applyViewModel() {
|
||||||
avatarImageView.kf.setImage(with: viewModel.identityContext.identity.image)
|
let avatarURL = viewModel.identityContext.appPreferences.animateAvatars == .everywhere
|
||||||
avatarImageView.autoPlayAnimatedImage = 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,
|
if let displayName = viewModel.identityContext.identity.account?.displayName,
|
||||||
!displayName.isEmpty {
|
!displayName.isEmpty {
|
||||||
|
|
Loading…
Reference in a new issue