fix: make report-status can be revealed
This commit is contained in:
parent
1356e3755f
commit
1b05d787df
@ -21,7 +21,7 @@ enum ReportSection: Equatable, Hashable {
|
|||||||
extension ReportSection {
|
extension ReportSection {
|
||||||
static func tableViewDiffableDataSource(
|
static func tableViewDiffableDataSource(
|
||||||
for tableView: UITableView,
|
for tableView: UITableView,
|
||||||
dependency: NeedsDependency,
|
dependency: ReportViewController,
|
||||||
managedObjectContext: NSManagedObjectContext,
|
managedObjectContext: NSManagedObjectContext,
|
||||||
timestampUpdatePublisher: AnyPublisher<Date, Never>
|
timestampUpdatePublisher: AnyPublisher<Date, Never>
|
||||||
) -> UITableViewDiffableDataSource<ReportSection, Item> {
|
) -> UITableViewDiffableDataSource<ReportSection, Item> {
|
||||||
@ -33,6 +33,7 @@ extension ReportSection {
|
|||||||
switch item {
|
switch item {
|
||||||
case .reportStatus(let objectID, let attribute):
|
case .reportStatus(let objectID, let attribute):
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportedStatusTableViewCell.self), for: indexPath) as! ReportedStatusTableViewCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ReportedStatusTableViewCell.self), for: indexPath) as! ReportedStatusTableViewCell
|
||||||
|
cell.dependency = dependency
|
||||||
let activeMastodonAuthenticationBox = dependency.context.authenticationService.activeMastodonAuthenticationBox.value
|
let activeMastodonAuthenticationBox = dependency.context.authenticationService.activeMastodonAuthenticationBox.value
|
||||||
let requestUserID = activeMastodonAuthenticationBox?.userID ?? ""
|
let requestUserID = activeMastodonAuthenticationBox?.userID ?? ""
|
||||||
managedObjectContext.performAndWait {
|
managedObjectContext.performAndWait {
|
||||||
|
@ -498,6 +498,34 @@ extension StatusProviderFacade {
|
|||||||
.store(in: &dependency.context.disposeBag)
|
.store(in: &dependency.context.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func responseToStatusContentWarningRevealAction(dependency: ReportViewController, cell: UITableViewCell) {
|
||||||
|
let status = Future<Status?, Never> { promise in
|
||||||
|
guard let diffableDataSource = dependency.viewModel.diffableDataSource,
|
||||||
|
let indexPath = dependency.tableView.indexPath(for: cell),
|
||||||
|
let item = diffableDataSource.itemIdentifier(for: indexPath) else {
|
||||||
|
promise(.success(nil))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let managedObjectContext = dependency.viewModel.statusFetchedResultsController
|
||||||
|
.fetchedResultsController
|
||||||
|
.managedObjectContext
|
||||||
|
|
||||||
|
switch item {
|
||||||
|
case .reportStatus(let objectID, _):
|
||||||
|
managedObjectContext.perform {
|
||||||
|
let status = managedObjectContext.object(with: objectID) as! Status
|
||||||
|
promise(.success(status))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
promise(.success(nil))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_responseToStatusContentWarningRevealAction(
|
||||||
|
dependency: dependency,
|
||||||
|
status: status
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension StatusProviderFacade {
|
extension StatusProviderFacade {
|
||||||
|
@ -13,7 +13,7 @@ import CoreDataStack
|
|||||||
extension ReportViewModel {
|
extension ReportViewModel {
|
||||||
func setupDiffableDataSource(
|
func setupDiffableDataSource(
|
||||||
for tableView: UITableView,
|
for tableView: UITableView,
|
||||||
dependency: NeedsDependency
|
dependency: ReportViewController
|
||||||
) {
|
) {
|
||||||
let timestampUpdatePublisher = Timer.publish(every: 1.0, on: .main, in: .common)
|
let timestampUpdatePublisher = Timer.publish(every: 1.0, on: .main, in: .common)
|
||||||
.autoconnect()
|
.autoconnect()
|
||||||
|
@ -17,6 +17,7 @@ final class ReportedStatusTableViewCell: UITableViewCell, StatusCell {
|
|||||||
|
|
||||||
static let bottomPaddingHeight: CGFloat = 10
|
static let bottomPaddingHeight: CGFloat = 10
|
||||||
|
|
||||||
|
var dependency: ReportViewController?
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
var pollCountdownSubscription: AnyCancellable?
|
var pollCountdownSubscription: AnyCancellable?
|
||||||
var observations = Set<NSKeyValueObservation>()
|
var observations = Set<NSKeyValueObservation>()
|
||||||
@ -63,6 +64,9 @@ final class ReportedStatusTableViewCell: UITableViewCell, StatusCell {
|
|||||||
|
|
||||||
override func layoutSubviews() {
|
override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
// precondition: app is active
|
||||||
|
guard UIApplication.shared.applicationState == .active else { return }
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.statusView.drawContentWarningImageView()
|
self.statusView.drawContentWarningImageView()
|
||||||
}
|
}
|
||||||
@ -127,8 +131,10 @@ extension ReportedStatusTableViewCell {
|
|||||||
resetSeparatorLineLayout()
|
resetSeparatorLineLayout()
|
||||||
|
|
||||||
selectionStyle = .none
|
selectionStyle = .none
|
||||||
|
statusView.delegate = self
|
||||||
|
statusView.statusMosaicImageViewContainer.delegate = self
|
||||||
statusView.actionToolbarContainer.isHidden = true
|
statusView.actionToolbarContainer.isHidden = true
|
||||||
statusView.isUserInteractionEnabled = false
|
statusView.contentWarningOverlayView.blurContentImageView.backgroundColor = backgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
@ -168,3 +174,44 @@ extension ReportedStatusTableViewCell {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ReportedStatusTableViewCell: MosaicImageViewContainerDelegate {
|
||||||
|
func mosaicImageViewContainer(_ mosaicImageViewContainer: MosaicImageViewContainer, didTapImageView imageView: UIImageView, atIndex index: Int) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func mosaicImageViewContainer(_ mosaicImageViewContainer: MosaicImageViewContainer, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView) {
|
||||||
|
|
||||||
|
guard let dependency = self.dependency else { return }
|
||||||
|
StatusProviderFacade.responseToStatusContentWarningRevealAction(dependency: dependency, cell: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ReportedStatusTableViewCell: StatusViewDelegate {
|
||||||
|
func statusView(_ statusView: StatusView, headerInfoLabelDidPressed label: UILabel) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func statusView(_ statusView: StatusView, avatarButtonDidPressed button: UIButton) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func statusView(_ statusView: StatusView, revealContentWarningButtonDidPressed button: UIButton) {
|
||||||
|
guard let dependency = self.dependency else { return }
|
||||||
|
StatusProviderFacade.responseToStatusContentWarningRevealAction(dependency: dependency, cell: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
func statusView(_ statusView: StatusView, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView) {
|
||||||
|
guard let dependency = self.dependency else { return }
|
||||||
|
StatusProviderFacade.responseToStatusContentWarningRevealAction(dependency: dependency, cell: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
func statusView(_ statusView: StatusView, playerContainerView: PlayerContainerView, contentWarningOverlayViewDidPressed contentWarningOverlayView: ContentWarningOverlayView) {
|
||||||
|
guard let dependency = self.dependency else { return }
|
||||||
|
StatusProviderFacade.responseToStatusContentWarningRevealAction(dependency: dependency, cell: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
func statusView(_ statusView: StatusView, pollVoteButtonPressed button: UIButton) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func statusView(_ statusView: StatusView, activeLabel: ActiveLabel, didSelectActiveEntity entity: ActiveEntity) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user