Compare commits

..

No commits in common. "f825760fe93d6db6ef6de2a670996a8a9075b23c" and "c3cf38b0c90aec227ffc6ea65a11781a31326aff" have entirely different histories.

6 changed files with 15 additions and 66 deletions

View File

@ -17,6 +17,7 @@ class ReblogService {
private let status: StatusMO private let status: StatusMO
var hapticFeedback = true var hapticFeedback = true
var visibility: Visibility? = nil
var requireConfirmation = Preferences.shared.confirmBeforeReblog var requireConfirmation = Preferences.shared.confirmBeforeReblog
init(status: StatusMO, mastodonController: MastodonController, presenter: any TuskerNavigationDelegate) { init(status: StatusMO, mastodonController: MastodonController, presenter: any TuskerNavigationDelegate) {
@ -30,30 +31,26 @@ class ReblogService {
requireConfirmation { requireConfirmation {
presentConfirmationAlert() presentConfirmationAlert()
} else { } else {
await doToggleReblog(visibility: nil) await doToggleReblog()
} }
} }
private func presentConfirmationAlert() { private func presentConfirmationAlert() {
let image: UIImage? let image: UIImage?
let reblogVisibilityActions: [CustomAlertController.MenuAction] let reblogVisibilityActions: [CustomAlertController.MenuAction]?
let maximumVisibility = status.visibility
if mastodonController.instanceFeatures.reblogVisibility { if mastodonController.instanceFeatures.reblogVisibility {
image = UIImage(systemName: maximumVisibility.unfilledImageName) image = UIImage(systemName: Visibility.public.unfilledImageName)
reblogVisibilityActions = [Visibility.unlisted, .private].compactMap { visibility in reblogVisibilityActions = [Visibility.unlisted, .private].map { visibility in
guard visibility < maximumVisibility else { CustomAlertController.MenuAction(title: "Reblog as \(visibility.displayName)", subtitle: visibility.subtitle, image: UIImage(systemName: visibility.unfilledImageName)) {
return nil
}
return CustomAlertController.MenuAction(title: "Reblog as \(visibility.displayName)", subtitle: visibility.subtitle, image: UIImage(systemName: visibility.unfilledImageName)) {
// deliberately retain a strong reference to self // deliberately retain a strong reference to self
Task { Task {
await self.doToggleReblog(visibility: visibility) await self.doToggleReblog()
} }
} }
} }
} else { } else {
image = nil image = nil
reblogVisibilityActions = [] reblogVisibilityActions = nil
} }
let preview = ConfirmReblogStatusPreviewView(status: status) let preview = ConfirmReblogStatusPreviewView(status: status)
@ -62,11 +59,11 @@ class ReblogService {
CustomAlertController.Action(title: "Reblog", image: image, style: .default, handler: { CustomAlertController.Action(title: "Reblog", image: image, style: .default, handler: {
// deliberately retain a strong reference to self // deliberately retain a strong reference to self
Task { Task {
await self.doToggleReblog(visibility: nil) await self.doToggleReblog()
} }
}) })
]) ])
if !reblogVisibilityActions.isEmpty { if let reblogVisibilityActions {
var menuAction = CustomAlertController.Action(title: nil, image: UIImage(systemName: "chevron.down"), style: .menu(reblogVisibilityActions), handler: nil) var menuAction = CustomAlertController.Action(title: nil, image: UIImage(systemName: "chevron.down"), style: .menu(reblogVisibilityActions), handler: nil)
menuAction.isSecondaryMenu = true menuAction.isSecondaryMenu = true
config.actions.append(menuAction) config.actions.append(menuAction)
@ -75,7 +72,7 @@ class ReblogService {
presenter.present(alert, animated: true) presenter.present(alert, animated: true)
} }
private func doToggleReblog(visibility: Visibility?) async { private func doToggleReblog() async {
let oldValue = status.reblogged let oldValue = status.reblogged
status.reblogged.toggle() status.reblogged.toggle()
mastodonController.persistentContainer.statusSubject.send(status.id) mastodonController.persistentContainer.statusSubject.send(status.id)

View File

@ -518,7 +518,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
if let centerStatusID, if let centerStatusID,
let index = statusIDs.firstIndex(of: centerStatusID) { let index = statusIDs.firstIndex(of: centerStatusID) {
self.scrollToItem(item: items[index]) self.scrollToItem(item: items[index])
stateRestorationLogger.info("TimelineViewController: restored statuses with center ID \(centerStatusID)") stateRestorationLogger.fault("TimelineViewController: restored statuses with center ID \(centerStatusID)")
} else { } else {
stateRestorationLogger.fault("TimelineViewController: restored statuses, but couldn't find center ID") stateRestorationLogger.fault("TimelineViewController: restored statuses, but couldn't find center ID")
} }

View File

@ -46,13 +46,6 @@ class CachedImageView: UIImageView {
} }
} }
func showOnlyBlurHash(_ blurhash: String, for url: URL) {
if url != self.url {
self.url = url
updateBlurhash(blurhash, for: url)
}
}
@objc private func preferencesChanged() { @objc private func preferencesChanged() {
if isGrayscale != Preferences.shared.grayscaleImages { if isGrayscale != Preferences.shared.grayscaleImages {
updateImage() updateImage()

View File

@ -19,7 +19,6 @@ class ProfileHeaderButton: UIButton {
var backgroundConfig = UIBackgroundConfiguration.clear() var backgroundConfig = UIBackgroundConfiguration.clear()
backgroundConfig.visualEffect = UIBlurEffect(style: .systemThickMaterial) backgroundConfig.visualEffect = UIBlurEffect(style: .systemThickMaterial)
config.background = backgroundConfig config.background = backgroundConfig
config.imagePadding = 4
self.configuration = config self.configuration = config
} }

View File

@ -75,13 +75,6 @@ class ScrollingSegmentedControl<Value: Hashable>: UIScrollView, UIGestureRecogni
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if traitCollection.preferredContentSizeCategory != previousTraitCollection?.preferredContentSizeCategory {
invalidateIntrinsicContentSize()
}
}
private func createOptionViews() { private func createOptionViews() {
optionsStack.arrangedSubviews.forEach { $0.removeFromSuperview() } optionsStack.arrangedSubviews.forEach { $0.removeFromSuperview() }

View File

@ -30,7 +30,7 @@ class StatusCardView: UIView {
private var titleLabel: UILabel! private var titleLabel: UILabel!
private var descriptionLabel: UILabel! private var descriptionLabel: UILabel!
private var domainLabel: UILabel! private var domainLabel: UILabel!
private var imageView: StatusCardImageView! private var imageView: CachedImageView!
private var placeholderImageView: UIImageView! private var placeholderImageView: UIImageView!
private var leadingSpacer: UIView! private var leadingSpacer: UIView!
private var trailingSpacer: UIView! private var trailingSpacer: UIView!
@ -80,7 +80,7 @@ class StatusCardView: UIView {
vStack.alignment = .leading vStack.alignment = .leading
vStack.spacing = 0 vStack.spacing = 0
imageView = StatusCardImageView(cache: .attachments) imageView = CachedImageView(cache: .attachments)
imageView.contentMode = .scaleAspectFill imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true imageView.clipsToBounds = true
@ -167,18 +167,7 @@ class StatusCardView: UIView {
} }
if let image = card.image { if let image = card.image {
if status.sensitive { imageView.update(for: URL(image), blurhash: card.blurhash)
if let blurhash = card.blurhash {
imageView.blurImage = false
imageView.showOnlyBlurHash(blurhash, for: URL(image)!)
} else {
// if we don't have a blurhash, load the image and show it behind a blur
imageView.blurImage = true
imageView.update(for: URL(image), blurhash: nil)
}
} else {
imageView.update(for: URL(image), blurhash: card.blurhash)
}
imageView.isHidden = false imageView.isHidden = false
leadingSpacer.isHidden = true leadingSpacer.isHidden = true
} else { } else {
@ -268,25 +257,3 @@ extension StatusCardView: UIContextMenuInteractionDelegate {
} }
} }
} }
private class StatusCardImageView: CachedImageView {
@Lazy private var blurView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
var blurImage = false {
didSet {
if blurImage {
if !_blurView.isInitialized {
blurView.translatesAutoresizingMaskIntoConstraints = false
addSubview(blurView)
NSLayoutConstraint.activate([
blurView.leadingAnchor.constraint(equalTo: leadingAnchor),
blurView.trailingAnchor.constraint(equalTo: trailingAnchor),
blurView.topAnchor.constraint(equalTo: topAnchor),
blurView.bottomAnchor.constraint(equalTo: bottomAnchor),
])
}
} else {
_blurView.valueIfInitialized?.removeFromSuperview()
}
}
}
}