From 0bc128ba795675370dc113515bc7391ba00f702b Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 11 Feb 2022 20:21:28 +0800 Subject: [PATCH] feat: add content warning toggle button --- .../Provider/DataSourceFacade+Status.swift | 30 ++--- ...er+NotificationTableViewCellDelegate.swift | 39 +++++- ...Provider+StatusTableViewCellDelegate.swift | 69 ++++++---- .../NotificationTableViewCellDelegate.swift | 10 -- .../NotificationTimelineViewController.swift | 44 +------ .../StatusTableViewCellDelegate.swift | 10 +- .../Arrow/repeat.small.imageset/Contents.json | 15 +++ .../repeat.small.imageset/repeat.small.pdf | 121 ++++++++++++++++++ .../MastodonAsset/Generated/Assets.swift | 1 + .../MediaGridContainerView+ViewModel.swift | 2 +- .../Container/MediaGridContainerView.swift | 97 +++++++------- .../View/Content/NotificationView.swift | 28 ++-- .../View/Content/StatusView+ViewModel.swift | 17 ++- .../MastodonUI/View/Content/StatusView.swift | 75 ++++++++--- 14 files changed, 374 insertions(+), 184 deletions(-) create mode 100644 MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Arrow/repeat.small.imageset/Contents.json create mode 100644 MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Arrow/repeat.small.imageset/repeat.small.pdf diff --git a/Mastodon/Protocol/Provider/DataSourceFacade+Status.swift b/Mastodon/Protocol/Provider/DataSourceFacade+Status.swift index 41c967b8..a98d34f3 100644 --- a/Mastodon/Protocol/Provider/DataSourceFacade+Status.swift +++ b/Mastodon/Protocol/Provider/DataSourceFacade+Status.swift @@ -283,23 +283,23 @@ extension DataSourceFacade { guard let _status = status.object(in: dependency.context.managedObjectContext) else { return } let status = _status.reblog ?? _status - let isToggled = status.isContentSensitiveToggled || status.isMediaSensitiveToggled - - status.update(isContentSensitiveToggled: !isToggled) - status.update(isMediaSensitiveToggled: !isToggled) + let allToggled = status.isContentSensitiveToggled && status.isMediaSensitiveToggled + + status.update(isContentSensitiveToggled: !allToggled) + status.update(isMediaSensitiveToggled: !allToggled) } } - static func responseToToggleMediaSensitiveAction( - dependency: NeedsDependency, - status: ManagedObjectRecord - ) async throws { - try await dependency.context.managedObjectContext.perform { - guard let _status = status.object(in: dependency.context.managedObjectContext) else { return } - let status = _status.reblog ?? _status - - status.update(isMediaSensitiveToggled: !status.isMediaSensitiveToggled) - } - } +// static func responseToToggleMediaSensitiveAction( +// dependency: NeedsDependency, +// status: ManagedObjectRecord +// ) async throws { +// try await dependency.context.managedObjectContext.perform { +// guard let _status = status.object(in: dependency.context.managedObjectContext) else { return } +// let status = _status.reblog ?? _status +// +// status.update(isMediaSensitiveToggled: !status.isMediaSensitiveToggled) +// } +// } } diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift index 56b5cf2b..f062f01d 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift @@ -222,12 +222,11 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider { ) } - - func tableViewCell( - _ cell: UITableViewCell, notificationView: NotificationView, + _ cell: UITableViewCell, + notificationView: NotificationView, statusView: StatusView, - spoilerBannerViewDidPressed bannerView: SpoilerBannerView + spoilerOverlayViewDidPressed overlayView: SpoilerOverlayView ) { Task { let source = DataSourceItem.Source(tableViewCell: cell, indexPath: nil) @@ -256,6 +255,38 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider { } +// func tableViewCell( +// _ cell: UITableViewCell, notificationView: NotificationView, +// statusView: StatusView, +// spoilerBannerViewDidPressed bannerView: SpoilerBannerView +// ) { +// Task { +// let source = DataSourceItem.Source(tableViewCell: cell, indexPath: nil) +// guard let item = await item(from: source) else { +// assertionFailure() +// return +// } +// guard case let .notification(notification) = item else { +// assertionFailure("only works for notification item") +// return +// } +// let _status: ManagedObjectRecord? = try await self.context.managedObjectContext.perform { +// guard let notification = notification.object(in: self.context.managedObjectContext) else { return nil } +// guard let status = notification.status else { return nil } +// return .init(objectID: status.objectID) +// } +// guard let status = _status else { +// assertionFailure() +// return +// } +// try await DataSourceFacade.responseToToggleSensitiveAction( +// dependency: self, +// status: status +// ) +// } // end Task +// } + + func tableViewCell( _ cell: UITableViewCell, notificationView: NotificationView, diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift index da15b66d..a7afca8c 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift @@ -126,7 +126,7 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & MediaPrev } guard !needsToggleMediaSensitive else { - try await DataSourceFacade.responseToToggleMediaSensitiveAction( + try await DataSourceFacade.responseToToggleSensitiveAction( dependency: self, status: status ) @@ -362,6 +362,29 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider { // MARK: - content warning extension StatusTableViewCellDelegate where Self: DataSourceProvider { + + func tableViewCell( + _ cell: UITableViewCell, + statusView: StatusView, + contentSensitiveeToggleButtonDidPressed button: UIButton + ) { + Task { + let source = DataSourceItem.Source(tableViewCell: cell, indexPath: nil) + guard let item = await item(from: source) else { + assertionFailure() + return + } + guard case let .status(status) = item else { + assertionFailure("only works for status data provider") + return + } + try await DataSourceFacade.responseToToggleSensitiveAction( + dependency: self, + status: status + ) + } // end Task + } + func tableViewCell( _ cell: UITableViewCell, statusView: StatusView, @@ -384,27 +407,27 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider { } // end Task } - func tableViewCell( - _ cell: UITableViewCell, - statusView: StatusView, - spoilerBannerViewDidPressed bannerView: SpoilerBannerView - ) { - Task { - let source = DataSourceItem.Source(tableViewCell: cell, indexPath: nil) - guard let item = await item(from: source) else { - assertionFailure() - return - } - guard case let .status(status) = item else { - assertionFailure("only works for status data provider") - return - } - try await DataSourceFacade.responseToToggleSensitiveAction( - dependency: self, - status: status - ) - } // end Task - } +// func tableViewCell( +// _ cell: UITableViewCell, +// statusView: StatusView, +// spoilerBannerViewDidPressed bannerView: SpoilerBannerView +// ) { +// Task { +// let source = DataSourceItem.Source(tableViewCell: cell, indexPath: nil) +// guard let item = await item(from: source) else { +// assertionFailure() +// return +// } +// guard case let .status(status) = item else { +// assertionFailure("only works for status data provider") +// return +// } +// try await DataSourceFacade.responseToToggleSensitiveAction( +// dependency: self, +// status: status +// ) +// } // end Task +// } func tableViewCell( _ cell: UITableViewCell, @@ -422,7 +445,7 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider { assertionFailure("only works for status data provider") return } - try await DataSourceFacade.responseToToggleMediaSensitiveAction( + try await DataSourceFacade.responseToToggleSensitiveAction( dependency: self, status: status ) diff --git a/Mastodon/Scene/Notification/Cell/NotificationTableViewCellDelegate.swift b/Mastodon/Scene/Notification/Cell/NotificationTableViewCellDelegate.swift index 31370f74..07bc5ff9 100644 --- a/Mastodon/Scene/Notification/Cell/NotificationTableViewCellDelegate.swift +++ b/Mastodon/Scene/Notification/Cell/NotificationTableViewCellDelegate.swift @@ -27,12 +27,10 @@ protocol NotificationTableViewCellDelegate: AnyObject, AutoGenerateProtocolDeleg func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, menuButton button: UIButton, didSelectAction action: MastodonMenu.Action) func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, statusView: StatusView, metaText: MetaText, didSelectMeta meta: Meta) func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, statusView: StatusView, spoilerOverlayViewDidPressed overlayView: SpoilerOverlayView) - func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, statusView: StatusView, spoilerBannerViewDidPressed bannerView: SpoilerBannerView) func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, statusView: StatusView, actionToolbarContainer: ActionToolbarContainer, buttonDidPressed button: UIButton, action: ActionToolbarContainer.Action) func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, quoteStatusView: StatusView, authorAvatarButtonDidPressed button: AvatarButton) func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, quoteStatusView: StatusView, metaText: MetaText, didSelectMeta meta: Meta) func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, quoteStatusView: StatusView, spoilerOverlayViewDidPressed overlayView: SpoilerOverlayView) - func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, quoteStatusView: StatusView, spoilerBannerViewDidPressed bannerView: SpoilerBannerView) func tableViewCell(_ cell: UITableViewCell, notificationView: NotificationView, accessibilityActivate: Void) // sourcery:end } @@ -57,10 +55,6 @@ extension NotificationViewDelegate where Self: NotificationViewContainerTableVie delegate?.tableViewCell(self, notificationView: notificationView, statusView: statusView, spoilerOverlayViewDidPressed: overlayView) } - func notificationView(_ notificationView: NotificationView, statusView: StatusView, spoilerBannerViewDidPressed bannerView: SpoilerBannerView) { - delegate?.tableViewCell(self, notificationView: notificationView, statusView: statusView, spoilerBannerViewDidPressed: bannerView) - } - func notificationView(_ notificationView: NotificationView, statusView: StatusView, actionToolbarContainer: ActionToolbarContainer, buttonDidPressed button: UIButton, action: ActionToolbarContainer.Action) { delegate?.tableViewCell(self, notificationView: notificationView, statusView: statusView, actionToolbarContainer: actionToolbarContainer, buttonDidPressed: button, action: action) } @@ -77,10 +71,6 @@ extension NotificationViewDelegate where Self: NotificationViewContainerTableVie delegate?.tableViewCell(self, notificationView: notificationView, quoteStatusView: quoteStatusView, spoilerOverlayViewDidPressed: overlayView) } - func notificationView(_ notificationView: NotificationView, quoteStatusView: StatusView, spoilerBannerViewDidPressed bannerView: SpoilerBannerView) { - delegate?.tableViewCell(self, notificationView: notificationView, quoteStatusView: quoteStatusView, spoilerBannerViewDidPressed: bannerView) - } - func notificationView(_ notificationView: NotificationView, accessibilityActivate: Void) { delegate?.tableViewCell(self, notificationView: notificationView, accessibilityActivate: accessibilityActivate) } diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift index 44d165ba..301b2f37 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift @@ -175,46 +175,4 @@ extension NotificationTimelineViewController: UITableViewDelegate, AutoGenerateT } // MARK: - NotificationTableViewCellDelegate -extension NotificationTimelineViewController: NotificationTableViewCellDelegate { - - func tableViewCell( - _ cell: UITableViewCell, - notificationView: NotificationView, - statusView: StatusView, - spoilerOverlayViewDidPressed overlayView: SpoilerOverlayView - ) { - guard let diffableDataSource = viewModel.diffableDataSource else { return } - guard let indexPath = tableView.indexPath(for: cell) else { return } - guard let reloadItem = diffableDataSource.itemIdentifier(for: indexPath) else { return } - - Task { - let source = DataSourceItem.Source(tableViewCell: cell, indexPath: nil) - guard let item = await item(from: source) else { - assertionFailure() - return - } - guard case let .notification(notification) = item else { - assertionFailure("only works for notification item") - return - } - let _status: ManagedObjectRecord? = try await self.context.managedObjectContext.perform { - guard let notification = notification.object(in: self.context.managedObjectContext) else { return nil } - guard let status = notification.status else { return nil } - return .init(objectID: status.objectID) - } - guard let status = _status else { - assertionFailure() - return - } - try await DataSourceFacade.responseToToggleSensitiveAction( - dependency: self, - status: status - ) - -// var snapshot = diffableDataSource.snapshot() -// snapshot.reloadItems([reloadItem]) -// diffableDataSource.apply(snapshot, animatingDifferences: false) - } // end Task - } - -} +extension NotificationTimelineViewController: NotificationTableViewCellDelegate { } diff --git a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCellDelegate.swift b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCellDelegate.swift index 0f879de0..b4dbef43 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCellDelegate.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCellDelegate.swift @@ -25,6 +25,7 @@ protocol StatusTableViewCellDelegate: AnyObject, AutoGenerateProtocolDelegate { // sourcery:inline:StatusTableViewCellDelegate.AutoGenerateProtocolDelegate func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, headerDidPressed header: UIView) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, authorAvatarButtonDidPressed button: AvatarButton) + func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, contentSensitiveeToggleButtonDidPressed button: UIButton) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, metaText: MetaText, didSelectMeta meta: Meta) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, mediaGridContainerView: MediaGridContainerView, mediaView: MediaView, didSelectMediaViewAt index: Int) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, pollTableView tableView: UITableView, didSelectRowAt indexPath: IndexPath) @@ -32,7 +33,6 @@ protocol StatusTableViewCellDelegate: AnyObject, AutoGenerateProtocolDelegate { func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, actionToolbarContainer: ActionToolbarContainer, buttonDidPressed button: UIButton, action: ActionToolbarContainer.Action) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, menuButton button: UIButton, didSelectAction action: MastodonMenu.Action) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, spoilerOverlayViewDidPressed overlayView: SpoilerOverlayView) - func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, spoilerBannerViewDidPressed bannerView: SpoilerBannerView) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, mediaGridContainerView: MediaGridContainerView, mediaSensitiveButtonDidPressed button: UIButton) func tableViewCell(_ cell: UITableViewCell, statusView: StatusView, accessibilityActivate: Void) // sourcery:end @@ -51,6 +51,10 @@ extension StatusViewDelegate where Self: StatusViewContainerTableViewCell { delegate?.tableViewCell(self, statusView: statusView, authorAvatarButtonDidPressed: button) } + func statusView(_ statusView: StatusView, contentSensitiveeToggleButtonDidPressed button: UIButton) { + delegate?.tableViewCell(self, statusView: statusView, contentSensitiveeToggleButtonDidPressed: button) + } + func statusView(_ statusView: StatusView, metaText: MetaText, didSelectMeta meta: Meta) { delegate?.tableViewCell(self, statusView: statusView, metaText: metaText, didSelectMeta: meta) } @@ -79,10 +83,6 @@ extension StatusViewDelegate where Self: StatusViewContainerTableViewCell { delegate?.tableViewCell(self, statusView: statusView, spoilerOverlayViewDidPressed: overlayView) } - func statusView(_ statusView: StatusView, spoilerBannerViewDidPressed bannerView: SpoilerBannerView) { - delegate?.tableViewCell(self, statusView: statusView, spoilerBannerViewDidPressed: bannerView) - } - func statusView(_ statusView: StatusView, mediaGridContainerView: MediaGridContainerView, mediaSensitiveButtonDidPressed button: UIButton) { delegate?.tableViewCell(self, statusView: statusView, mediaGridContainerView: mediaGridContainerView, mediaSensitiveButtonDidPressed: button) } diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Arrow/repeat.small.imageset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Arrow/repeat.small.imageset/Contents.json new file mode 100644 index 00000000..61b0d4b4 --- /dev/null +++ b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Arrow/repeat.small.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "repeat.small.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true + } +} diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Arrow/repeat.small.imageset/repeat.small.pdf b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Arrow/repeat.small.imageset/repeat.small.pdf new file mode 100644 index 00000000..be8467d2 --- /dev/null +++ b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Arrow/repeat.small.imageset/repeat.small.pdf @@ -0,0 +1,121 @@ +%PDF-1.7 + +1 0 obj + << >> +endobj + +2 0 obj + << /Length 3 0 R >> +stream +/DeviceRGB CS +/DeviceRGB cs +q +1.000000 0.000000 -0.000000 1.000000 1.997589 2.358398 cm +0.000000 0.000000 0.000000 scn +13.752419 11.631601 m +13.931720 11.631601 14.096325 11.568684 14.225361 11.463720 c +15.313271 10.549767 16.004837 9.176446 16.004837 7.641602 c +16.004837 4.952847 13.882531 2.759784 11.221727 2.646221 c +11.004837 2.641602 l +6.563000 2.641602 l +7.782749 1.421932 l +8.049015 1.155665 8.073221 0.739002 7.855367 0.445391 c +7.782749 0.361271 l +7.516482 0.095004 7.099819 0.070798 6.806207 0.288652 c +6.722089 0.361271 l +4.222089 2.861272 l +3.955822 3.127539 3.931616 3.544202 4.149471 3.837813 c +4.222089 3.921931 l +6.722089 6.421931 l +7.014983 6.714825 7.489855 6.714825 7.782749 6.421931 c +8.049015 6.155664 8.073221 5.739001 7.855367 5.445390 c +7.782749 5.361272 l +6.563000 4.141602 l +11.004837 4.141602 l +12.873401 4.141602 14.399964 5.605879 14.499659 7.449566 c +14.504837 7.641602 l +14.504837 8.722754 14.014629 9.689410 13.244354 10.331430 c +13.095952 10.466222 13.002419 10.662989 13.002419 10.881601 c +13.002419 11.295815 13.338205 11.631601 13.752419 11.631601 c +h +8.222090 14.921932 m +8.488357 15.188198 8.905020 15.212404 9.198631 14.994550 c +9.282749 14.921932 l +11.782749 12.421932 l +11.855368 12.337813 l +12.049016 12.076825 12.051406 11.718611 11.862539 11.455222 c +11.782749 11.361271 l +9.282749 8.861272 l +9.198631 8.788653 l +8.937643 8.595005 8.579429 8.592613 8.316040 8.781481 c +8.222090 8.861272 l +8.149471 8.945390 l +7.955823 9.206378 7.953431 9.564592 8.142298 9.827981 c +8.222090 9.921932 l +9.441000 11.141602 l +5.000000 11.141602 l +3.131437 11.141602 1.604874 9.677324 1.505179 7.833637 c +1.500000 7.641602 l +1.500000 6.558465 1.992010 5.590244 2.764729 4.948239 c +2.910926 4.812664 3.002419 4.617817 3.002419 4.401602 c +3.002419 3.987389 2.666633 3.651602 2.252419 3.651602 c +2.061133 3.651602 1.886572 3.723213 1.754084 3.841089 c +0.681080 4.754352 0.000000 6.118439 0.000000 7.641602 c +0.000000 10.330357 2.122307 12.523419 4.783111 12.636982 c +5.000000 12.641602 l +9.441000 12.641602 l +8.222090 13.861271 l +8.149471 13.945390 l +7.931617 14.239001 7.955823 14.655665 8.222090 14.921932 c +h +f +n +Q + +endstream +endobj + +3 0 obj + 2140 +endobj + +4 0 obj + << /Annots [] + /Type /Page + /MediaBox [ 0.000000 0.000000 20.000000 20.000000 ] + /Resources 1 0 R + /Contents 2 0 R + /Parent 5 0 R + >> +endobj + +5 0 obj + << /Kids [ 4 0 R ] + /Count 1 + /Type /Pages + >> +endobj + +6 0 obj + << /Pages 5 0 R + /Type /Catalog + >> +endobj + +xref +0 7 +0000000000 65535 f +0000000010 00000 n +0000000034 00000 n +0000002230 00000 n +0000002253 00000 n +0000002426 00000 n +0000002500 00000 n +trailer +<< /ID [ (some) (id) ] + /Root 6 0 R + /Size 7 +>> +startxref +2559 +%%EOF \ No newline at end of file diff --git a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift index 5e7ae79c..23aa940d 100644 --- a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift +++ b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift @@ -23,6 +23,7 @@ public typealias AssetImageTypeAlias = ImageAsset.Image public enum Asset { public enum Arrow { public static let `repeat` = ImageAsset(name: "Arrow/repeat") + public static let repeatSmall = ImageAsset(name: "Arrow/repeat.small") } public enum Asset { public static let email = ImageAsset(name: "Asset/email") diff --git a/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView+ViewModel.swift index 92c5972b..c48ed3ca 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView+ViewModel.swift @@ -21,7 +21,7 @@ extension MediaGridContainerView.ViewModel { func bind(view: MediaGridContainerView) { $isSensitiveToggleButtonDisplay .sink { isDisplay in - view.sensitiveToggleButtonBlurVisualEffectView.isHidden = !isDisplay + // view.sensitiveToggleButtonBlurVisualEffectView.isHidden = !isDisplay } .store(in: &disposeBag) } diff --git a/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift b/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift index a461dd9c..41d97c0f 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift @@ -49,21 +49,21 @@ public final class MediaGridContainerView: UIView { }() - let sensitiveToggleButtonBlurVisualEffectView: UIVisualEffectView = { - let visualEffectView = UIVisualEffectView(effect: ContentWarningOverlayView.blurVisualEffect) - visualEffectView.layer.masksToBounds = true - visualEffectView.layer.cornerRadius = MediaGridContainerView.sensitiveToggleButtonSize.width / 2 - visualEffectView.layer.cornerCurve = .continuous - return visualEffectView - }() - let sensitiveToggleButtonVibrancyVisualEffectView = UIVisualEffectView(effect: UIVibrancyEffect(blurEffect: ContentWarningOverlayView.blurVisualEffect)) - let sensitiveToggleButton: HitTestExpandedButton = { - let button = HitTestExpandedButton(type: .system) - button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 4, bottom: 4, right: 4) - button.imageView?.contentMode = .scaleAspectFit - button.setImage(UIImage(systemName: "eye.slash.fill"), for: .normal) - return button - }() +// let sensitiveToggleButtonBlurVisualEffectView: UIVisualEffectView = { +// let visualEffectView = UIVisualEffectView(effect: ContentWarningOverlayView.blurVisualEffect) +// visualEffectView.layer.masksToBounds = true +// visualEffectView.layer.cornerRadius = MediaGridContainerView.sensitiveToggleButtonSize.width / 2 +// visualEffectView.layer.cornerCurve = .continuous +// return visualEffectView +// }() +// let sensitiveToggleButtonVibrancyVisualEffectView = UIVisualEffectView(effect: UIVibrancyEffect(blurEffect: ContentWarningOverlayView.blurVisualEffect)) +// let sensitiveToggleButton: HitTestExpandedButton = { +// let button = HitTestExpandedButton(type: .system) +// button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 4, bottom: 4, right: 4) +// button.imageView?.contentMode = .scaleAspectFit +// button.setImage(UIImage(systemName: "eye.slash.fill"), for: .normal) +// return button +// }() public override init(frame: CGRect) { super.init(frame: frame) @@ -79,7 +79,7 @@ public final class MediaGridContainerView: UIView { extension MediaGridContainerView { private func _init() { - sensitiveToggleButton.addTarget(self, action: #selector(MediaGridContainerView.sensitiveToggleButtonDidPressed(_:)), for: .touchUpInside) +// sensitiveToggleButton.addTarget(self, action: #selector(MediaGridContainerView.sensitiveToggleButtonDidPressed(_:)), for: .touchUpInside) } } @@ -105,8 +105,8 @@ extension MediaGridContainerView { let mediaView = _mediaViews[0] layout.layout(in: self, mediaView: mediaView) - layoutSensitiveToggleButton() - bringSubviewToFront(sensitiveToggleButtonBlurVisualEffectView) +// layoutSensitiveToggleButton() +// bringSubviewToFront(sensitiveToggleButtonBlurVisualEffectView) return mediaView } @@ -117,8 +117,8 @@ extension MediaGridContainerView { let mediaViews = Array(_mediaViews[0..