Compare commits

...

3 Commits

6 changed files with 21 additions and 11 deletions

View File

@ -25,6 +25,7 @@ public class Draft: NSManagedObject, Identifiable {
@NSManaged public var contentWarningEnabled: Bool
@NSManaged public var editedStatusID: String?
@NSManaged public var id: UUID
@NSManaged public var initialContentWarning: String?
@NSManaged public var initialText: String
@NSManaged public var inReplyToID: String?
@NSManaged public var language: String? // ISO 639 language code
@ -65,7 +66,7 @@ public class Draft: NSManagedObject, Identifiable {
extension Draft {
public var hasContent: Bool {
(!text.isEmpty && text != initialText) ||
(contentWarningEnabled && !contentWarning.isEmpty) ||
(contentWarningEnabled && !contentWarning.isEmpty && contentWarning != initialContentWarning) ||
attachments.count > 0 ||
poll?.hasContent == true
}

View File

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22221.1" systemVersion="22G74" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22222" systemVersion="22G91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Draft" representedClassName="ComposeUI.Draft" syncable="YES">
<attribute name="accountID" attributeType="String"/>
<attribute name="contentWarning" attributeType="String" defaultValueString=""/>
<attribute name="contentWarningEnabled" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="editedStatusID" optional="YES" attributeType="String"/>
<attribute name="id" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="initialContentWarning" optional="YES" attributeType="String"/>
<attribute name="initialText" attributeType="String"/>
<attribute name="inReplyToID" optional="YES" attributeType="String"/>
<attribute name="language" optional="YES" attributeType="String"/>

View File

@ -88,6 +88,7 @@ public class DraftsPersistentContainer: NSPersistentContainer {
draft.text = text
draft.initialText = text
draft.contentWarning = contentWarning
draft.initialContentWarning = contentWarning
draft.contentWarningEnabled = !contentWarning.isEmpty
draft.inReplyToID = inReplyToID
draft.visibility = visibility
@ -112,6 +113,7 @@ public class DraftsPersistentContainer: NSPersistentContainer {
draft.initialText = source.text
draft.contentWarning = source.spoilerText
draft.contentWarningEnabled = !source.spoilerText.isEmpty
draft.initialContentWarning = source.spoilerText
draft.inReplyToID = inReplyToID
draft.visibility = visibility
draft.localOnly = localOnly

View File

@ -91,7 +91,10 @@ class ComposeSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDeleg
}
private func updateTitle(draft: Draft) {
guard let scene = window?.windowScene,
// Don't set the scene title on macOS since it shows both that and the VC title in the window titlebar
#if !targetEnvironment(macCatalyst)
guard !ProcessInfo.processInfo.isiOSAppOnMac,
let scene = window?.windowScene,
let mastodonController = scene.session.mastodonController else {
return
}
@ -101,6 +104,7 @@ class ComposeSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDeleg
} else {
scene.title = "New Post"
}
#endif
}
@objc private func themePrefChanged() {

View File

@ -16,7 +16,7 @@ protocol LargeImageContentView: UIView {
var animationImage: UIImage? { get }
var activityItemsForSharing: [Any] { get }
var owner: LargeImageViewController? { get set }
func setControlsVisible(_ controlsVisible: Bool)
func setControlsVisible(_ controlsVisible: Bool, animated: Bool)
func grayscaleStateChanged()
}
@ -75,13 +75,11 @@ class LargeImageImageContentView: UIImageView, LargeImageContentView {
fatalError("init(coder:) has not been implemented")
}
func setControlsVisible(_ controlsVisible: Bool) {
func setControlsVisible(_ controlsVisible: Bool, animated: Bool) {
#if !targetEnvironment(macCatalyst)
if #available(iOS 16.0, *),
let analysisInteraction {
// note: passing animated: true here doesn't seem to do anything by itself as of iOS 16.2 (20C5032e)
// so the LargeImageViewController handles animating, but we still need to pass true here otherwise it doesn't animate
analysisInteraction.setSupplementaryInterfaceHidden(!controlsVisible, animated: true)
analysisInteraction.setSupplementaryInterfaceHidden(!controlsVisible, animated: animated)
}
#endif
}
@ -138,7 +136,7 @@ class LargeImageGifContentView: GIFImageView, LargeImageContentView {
fatalError("init(coder:) has not been implemented")
}
func setControlsVisible(_ controlsVisible: Bool) {
func setControlsVisible(_ controlsVisible: Bool, animated: Bool) {
}
func grayscaleStateChanged() {
@ -189,7 +187,7 @@ class LargeImageGifvContentView: GifvAttachmentView, LargeImageContentView {
fatalError("init(coder:) has not been implemented")
}
func setControlsVisible(_ controlsVisible: Bool) {
func setControlsVisible(_ controlsVisible: Bool, animated: Bool) {
}
func grayscaleStateChanged() {

View File

@ -282,13 +282,17 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate, LargeIma
self.controlsVisible = controlsVisible
if animated {
UIView.animate(withDuration: 0.2) {
self.contentView.setControlsVisible(controlsVisible)
// note: the value of animated: is passed to ImageAnalysisInteractino.setSupplementaryInterfaceHidden which (as of iOS 17.0.2 (21A350)):
// - does not animate with animated:false when wrapped in a UIView.animate block
// - does not animate with animated:true unless also wrapped in a UIView.animate block
self.contentView.setControlsVisible(controlsVisible, animated: true)
self.updateControlsView()
}
if controlsVisible && !descriptionTextView.isHidden {
descriptionTextView.flashScrollIndicators()
}
} else {
contentView.setControlsVisible(controlsVisible, animated: false)
updateControlsView()
}
}