fix: paging still enabled issue when blocking/blocked in profile scene

This commit is contained in:
CMK 2021-06-24 15:14:50 +08:00
parent d8be41fd33
commit 48c7ffe20e
2 changed files with 19 additions and 2 deletions

View File

@ -452,7 +452,7 @@ extension ProfileViewController {
viewModel.isEditing
.handleEvents(receiveOutput: { [weak self] isEditing in
guard let self = self else { return }
// set firset responder for key command
// set first responder for key command
if !isEditing {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.profileSegmentedViewController.pagingViewController.becomeFirstResponder()
@ -520,6 +520,14 @@ extension ProfileViewController {
self.profileHeaderViewController.profileHeaderView.statusDashboardView.followersDashboardMeterView.accessibilityLabel = L10n.Scene.Profile.Dashboard.Accessibility.countFollowers(count ?? 0)
}
.store(in: &disposeBag)
viewModel.needsPaingEnabled
.receive(on: RunLoop.main)
.sink { [weak self] needsPaingEnabled in
guard let self = self else { return }
self.profileSegmentedViewController.pagingViewController.isScrollEnabled = needsPaingEnabled
}
.store(in: &disposeBag)
profileHeaderViewController.profileHeaderView.delegate = self
}

View File

@ -58,8 +58,9 @@ class ProfileViewModel: NSObject {
let isReplyBarButtonItemHidden = CurrentValueSubject<Bool, Never>(true)
let isMoreMenuBarButtonItemHidden = CurrentValueSubject<Bool, Never>(true)
let isMeBarButtonItemsHidden = CurrentValueSubject<Bool, Never>(true)
let needsPagePinToTop = CurrentValueSubject<Bool, Never>(false)
let needsPaingEnabled = CurrentValueSubject<Bool, Never>(true)
init(context: AppContext, optionalMastodonUser mastodonUser: MastodonUser?) {
self.context = context
@ -147,6 +148,14 @@ class ProfileViewModel: NSObject {
}
.store(in: &disposeBag)
Publishers.CombineLatest(
isBlocking,
isBlockedBy
)
.map { !($0 || $1) }
.assign(to: \.value, on: needsPaingEnabled)
.store(in: &disposeBag)
setup()
}