fix: profile fields not set hidden when blocked issue. resolve #195
This commit is contained in:
parent
dae423f28f
commit
31a79cbef0
|
@ -222,13 +222,18 @@ extension ProfileHeaderViewController {
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
Publishers.CombineLatest(
|
Publishers.CombineLatest3(
|
||||||
viewModel.isEditing,
|
viewModel.isEditing,
|
||||||
viewModel.displayProfileInfo.fields
|
viewModel.displayProfileInfo.fields,
|
||||||
|
viewModel.needsFiledCollectionViewHidden
|
||||||
)
|
)
|
||||||
.receive(on: RunLoop.main)
|
.receive(on: RunLoop.main)
|
||||||
.sink { [weak self] isEditing, fields in
|
.sink { [weak self] isEditing, fields, needsHidden in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
guard !needsHidden else {
|
||||||
|
self.profileHeaderView.fieldCollectionView.isHidden = true
|
||||||
|
return
|
||||||
|
}
|
||||||
self.profileHeaderView.fieldCollectionView.isHidden = isEditing ? false : fields.isEmpty
|
self.profileHeaderView.fieldCollectionView.isHidden = isEditing ? false : fields.isEmpty
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
|
@ -22,6 +22,7 @@ final class ProfileHeaderViewModel {
|
||||||
let isEditing = CurrentValueSubject<Bool, Never>(false)
|
let isEditing = CurrentValueSubject<Bool, Never>(false)
|
||||||
let viewDidAppear = CurrentValueSubject<Bool, Never>(false)
|
let viewDidAppear = CurrentValueSubject<Bool, Never>(false)
|
||||||
let needsSetupBottomShadow = CurrentValueSubject<Bool, Never>(true)
|
let needsSetupBottomShadow = CurrentValueSubject<Bool, Never>(true)
|
||||||
|
let needsFiledCollectionViewHidden = CurrentValueSubject<Bool, Never>(false)
|
||||||
let isTitleViewContentOffsetSet = CurrentValueSubject<Bool, Never>(false)
|
let isTitleViewContentOffsetSet = CurrentValueSubject<Bool, Never>(false)
|
||||||
let emojiDict = CurrentValueSubject<MastodonStatusContent.EmojiDict, Never>([:])
|
let emojiDict = CurrentValueSubject<MastodonStatusContent.EmojiDict, Never>([:])
|
||||||
let accountForEdit = CurrentValueSubject<Mastodon.Entity.Account?, Never>(nil)
|
let accountForEdit = CurrentValueSubject<Mastodon.Entity.Account?, Never>(nil)
|
||||||
|
|
|
@ -218,7 +218,7 @@ final class ProfileHeaderView: UIView {
|
||||||
collectionView.isScrollEnabled = false
|
collectionView.isScrollEnabled = false
|
||||||
return collectionView
|
return collectionView
|
||||||
}()
|
}()
|
||||||
var fieldCollectionViewHeightLaoutConstraint: NSLayoutConstraint!
|
var fieldCollectionViewHeightLayoutConstraint: NSLayoutConstraint!
|
||||||
var fieldCollectionViewHeightObservation: NSKeyValueObservation?
|
var fieldCollectionViewHeightObservation: NSKeyValueObservation?
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
|
@ -239,6 +239,8 @@ final class ProfileHeaderView: UIView {
|
||||||
|
|
||||||
extension ProfileHeaderView {
|
extension ProfileHeaderView {
|
||||||
private func _init() {
|
private func _init() {
|
||||||
|
backgroundColor = ThemeService.shared.currentTheme.value.systemGroupedBackgroundColor
|
||||||
|
fieldCollectionView.backgroundColor = ThemeService.shared.currentTheme.value.profileFieldCollectionViewBackgroundColor
|
||||||
ThemeService.shared.currentTheme
|
ThemeService.shared.currentTheme
|
||||||
.receive(on: RunLoop.main)
|
.receive(on: RunLoop.main)
|
||||||
.sink { [weak self] theme in
|
.sink { [weak self] theme in
|
||||||
|
@ -427,17 +429,17 @@ extension ProfileHeaderView {
|
||||||
|
|
||||||
fieldCollectionView.translatesAutoresizingMaskIntoConstraints = false
|
fieldCollectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
metaContainerStackView.addArrangedSubview(fieldCollectionView)
|
metaContainerStackView.addArrangedSubview(fieldCollectionView)
|
||||||
fieldCollectionViewHeightLaoutConstraint = fieldCollectionView.heightAnchor.constraint(equalToConstant: 44).priority(.defaultHigh)
|
fieldCollectionViewHeightLayoutConstraint = fieldCollectionView.heightAnchor.constraint(equalToConstant: 44).priority(.defaultHigh)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
fieldCollectionViewHeightLaoutConstraint,
|
fieldCollectionViewHeightLayoutConstraint,
|
||||||
])
|
])
|
||||||
fieldCollectionViewHeightObservation = fieldCollectionView.observe(\.contentSize, options: .new, changeHandler: { [weak self] tableView, _ in
|
fieldCollectionViewHeightObservation = fieldCollectionView.observe(\.contentSize, options: .new, changeHandler: { [weak self] tableView, _ in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
guard self.fieldCollectionView.contentSize.height != .zero else {
|
guard self.fieldCollectionView.contentSize.height != .zero else {
|
||||||
self.fieldCollectionViewHeightLaoutConstraint.constant = 44
|
self.fieldCollectionViewHeightLayoutConstraint.constant = 44
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.fieldCollectionViewHeightLaoutConstraint.constant = self.fieldCollectionView.contentSize.height
|
self.fieldCollectionViewHeightLayoutConstraint.constant = self.fieldCollectionView.contentSize.height
|
||||||
})
|
})
|
||||||
|
|
||||||
bringSubviewToFront(bannerContainerView)
|
bringSubviewToFront(bannerContainerView)
|
||||||
|
|
|
@ -495,7 +495,8 @@ extension ProfileViewController {
|
||||||
let isNeedSetHidden = isBlocking || isBlockedBy || suspended
|
let isNeedSetHidden = isBlocking || isBlockedBy || suspended
|
||||||
self.profileHeaderViewController.viewModel.needsSetupBottomShadow.value = !isNeedSetHidden
|
self.profileHeaderViewController.viewModel.needsSetupBottomShadow.value = !isNeedSetHidden
|
||||||
self.profileHeaderViewController.profileHeaderView.bioContainerView.isHidden = isNeedSetHidden
|
self.profileHeaderViewController.profileHeaderView.bioContainerView.isHidden = isNeedSetHidden
|
||||||
self.profileHeaderViewController.pageSegmentedControl.isHidden = isNeedSetHidden
|
self.profileHeaderViewController.viewModel.needsFiledCollectionViewHidden.value = isNeedSetHidden
|
||||||
|
self.profileHeaderViewController.pageSegmentedControl.isEnabled = !isNeedSetHidden
|
||||||
self.viewModel.needsPagePinToTop.value = isNeedSetHidden
|
self.viewModel.needsPagePinToTop.value = isNeedSetHidden
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
@ -530,7 +531,7 @@ extension ProfileViewController {
|
||||||
self.profileHeaderViewController.profileHeaderView.statusDashboardView.followersDashboardMeterView.accessibilityLabel = L10n.Scene.Profile.Dashboard.Accessibility.countFollowers(count ?? 0)
|
self.profileHeaderViewController.profileHeaderView.statusDashboardView.followersDashboardMeterView.accessibilityLabel = L10n.Scene.Profile.Dashboard.Accessibility.countFollowers(count ?? 0)
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
viewModel.needsPaingEnabled
|
viewModel.needsPagingEnabled
|
||||||
.receive(on: RunLoop.main)
|
.receive(on: RunLoop.main)
|
||||||
.sink { [weak self] needsPaingEnabled in
|
.sink { [weak self] needsPaingEnabled in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
|
|
@ -63,7 +63,7 @@ class ProfileViewModel: NSObject {
|
||||||
let isMeBarButtonItemsHidden = CurrentValueSubject<Bool, Never>(true)
|
let isMeBarButtonItemsHidden = CurrentValueSubject<Bool, Never>(true)
|
||||||
|
|
||||||
let needsPagePinToTop = CurrentValueSubject<Bool, Never>(false)
|
let needsPagePinToTop = CurrentValueSubject<Bool, Never>(false)
|
||||||
let needsPaingEnabled = CurrentValueSubject<Bool, Never>(true)
|
let needsPagingEnabled = CurrentValueSubject<Bool, Never>(true)
|
||||||
let needsImageOverlayBlurred = CurrentValueSubject<Bool, Never>(false)
|
let needsImageOverlayBlurred = CurrentValueSubject<Bool, Never>(false)
|
||||||
|
|
||||||
init(context: AppContext, optionalMastodonUser mastodonUser: MastodonUser?) {
|
init(context: AppContext, optionalMastodonUser mastodonUser: MastodonUser?) {
|
||||||
|
@ -161,7 +161,7 @@ class ProfileViewModel: NSObject {
|
||||||
|
|
||||||
isBlockingOrBlocked
|
isBlockingOrBlocked
|
||||||
.map { !$0 }
|
.map { !$0 }
|
||||||
.assign(to: \.value, on: needsPaingEnabled)
|
.assign(to: \.value, on: needsPagingEnabled)
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
isBlockingOrBlocked
|
isBlockingOrBlocked
|
||||||
|
|
Loading…
Reference in New Issue