forked from zelo72/mastodon-ios
fix: status sensitive toggle logic issue
This commit is contained in:
parent
c57c3b4304
commit
c4ab4f68c6
|
@ -115,9 +115,7 @@
|
|||
DB0009A626AEE5DC009B9D2D /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = DB0009A926AEE5DC009B9D2D /* Intents.intentdefinition */; settings = {ATTRIBUTES = (no_codegen, ); }; };
|
||||
DB0009A726AEE5DC009B9D2D /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = DB0009A926AEE5DC009B9D2D /* Intents.intentdefinition */; };
|
||||
DB00CA972632DDB600A54956 /* CommonOSLog in Frameworks */ = {isa = PBXBuildFile; productRef = DB00CA962632DDB600A54956 /* CommonOSLog */; };
|
||||
DB0140BD25C40D7500F9F3CF /* CommonOSLog in Frameworks */ = {isa = PBXBuildFile; productRef = DB0140BC25C40D7500F9F3CF /* CommonOSLog */; };
|
||||
DB0140CF25C42AEE00F9F3CF /* OSLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0140CE25C42AEE00F9F3CF /* OSLog.swift */; };
|
||||
DB01E23326A98F0900C3965B /* MastodonMeta in Frameworks */ = {isa = PBXBuildFile; productRef = DB01E23226A98F0900C3965B /* MastodonMeta */; };
|
||||
DB01E23526A98F0900C3965B /* MetaTextKit in Frameworks */ = {isa = PBXBuildFile; productRef = DB01E23426A98F0900C3965B /* MetaTextKit */; };
|
||||
DB023D26279FFB0A005AC798 /* ShareActivityProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB023D25279FFB0A005AC798 /* ShareActivityProvider.swift */; };
|
||||
DB023D2827A0FABD005AC798 /* NotificationTableViewCellDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB023D2727A0FABD005AC798 /* NotificationTableViewCellDelegate.swift */; };
|
||||
|
@ -130,6 +128,8 @@
|
|||
DB029E95266A20430062874E /* MastodonAuthenticationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB029E94266A20430062874E /* MastodonAuthenticationController.swift */; };
|
||||
DB02CDAB26256A9500D0A2AF /* ThreadReplyLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB02CDAA26256A9500D0A2AF /* ThreadReplyLoaderTableViewCell.swift */; };
|
||||
DB02CDBF2625AE5000D0A2AF /* AdaptiveUserInterfaceStyleBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB02CDBE2625AE5000D0A2AF /* AdaptiveUserInterfaceStyleBarButtonItem.swift */; };
|
||||
DB02EA0B280D180D00E751C5 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = DB02EA0A280D180D00E751C5 /* KeychainAccess */; };
|
||||
DB02EA0D280D184B00E751C5 /* CommonOSLog in Frameworks */ = {isa = PBXBuildFile; productRef = DB02EA0C280D184B00E751C5 /* CommonOSLog */; };
|
||||
DB03A793272A7E5700EE37C5 /* SidebarListHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB03A792272A7E5700EE37C5 /* SidebarListHeaderView.swift */; };
|
||||
DB03A795272A981400EE37C5 /* ContentSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB03A794272A981400EE37C5 /* ContentSplitViewController.swift */; };
|
||||
DB03F7F32689AEA3007B274C /* ComposeRepliedToStatusContentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB03F7F22689AEA3007B274C /* ComposeRepliedToStatusContentTableViewCell.swift */; };
|
||||
|
@ -347,7 +347,6 @@
|
|||
DB6804872637CD4C00430867 /* AppShared.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DB68047F2637CD4C00430867 /* AppShared.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
DB6804D12637CE4700430867 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB6804D02637CE4700430867 /* UserDefaults.swift */; };
|
||||
DB6804FD2637CFEC00430867 /* AppSecret.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB6804FC2637CFEC00430867 /* AppSecret.swift */; };
|
||||
DB6805102637D0F800430867 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = DB68050F2637D0F800430867 /* KeychainAccess */; };
|
||||
DB68586425E619B700F0A850 /* NSKeyValueObservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB68586325E619B700F0A850 /* NSKeyValueObservation.swift */; };
|
||||
DB68A04A25E9027700CFDF14 /* AdaptiveStatusBarStyleNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB68A04925E9027700CFDF14 /* AdaptiveStatusBarStyleNavigationController.swift */; };
|
||||
DB68A05D25E9055900CFDF14 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DB68A05C25E9055900CFDF14 /* Settings.bundle */; };
|
||||
|
@ -1372,7 +1371,6 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
DB0140BD25C40D7500F9F3CF /* CommonOSLog in Frameworks */,
|
||||
DB9A487E2603456B008B817C /* UITextView+Placeholder in Frameworks */,
|
||||
2D939AC825EE14620076FA61 /* CropViewController in Frameworks */,
|
||||
DBB525082611EAC0002F1F29 /* Tabman in Frameworks */,
|
||||
|
@ -1382,10 +1380,10 @@
|
|||
DBAC6483267D0B21007FE9FD /* DifferenceKit in Frameworks */,
|
||||
DB552D4F26BBD10C00E481F6 /* OrderedCollections in Frameworks */,
|
||||
2D61336925C18A4F00CAE157 /* AlamofireNetworkActivityIndicator in Frameworks */,
|
||||
DB01E23326A98F0900C3965B /* MastodonMeta in Frameworks */,
|
||||
DBAC64A1267E6D02007FE9FD /* Fuzi in Frameworks */,
|
||||
DB3D0FF325BAA61700EAA174 /* AlamofireImage in Frameworks */,
|
||||
DBAC649E267DFE43007FE9FD /* DiffableDataSources in Frameworks */,
|
||||
DB02EA0D280D184B00E751C5 /* CommonOSLog in Frameworks */,
|
||||
2D5981BA25E4D7F8000FB903 /* ThirdPartyMailer in Frameworks */,
|
||||
87FFDA5D898A5C42ADCB35E7 /* Pods_Mastodon.framework in Frameworks */,
|
||||
DBF7A0FC26830C33004176A2 /* FPSIndicator in Frameworks */,
|
||||
|
@ -1415,7 +1413,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
DB6805102637D0F800430867 /* KeychainAccess in Frameworks */,
|
||||
DB02EA0B280D180D00E751C5 /* KeychainAccess in Frameworks */,
|
||||
EE93E8E8F9E0C39EAAEBD92F /* Pods_AppShared.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -3303,7 +3301,6 @@
|
|||
DB3D0FF225BAA61700EAA174 /* AlamofireImage */,
|
||||
5D526FE125BE9AC400460CB9 /* MastodonSDK */,
|
||||
2D61336825C18A4F00CAE157 /* AlamofireNetworkActivityIndicator */,
|
||||
DB0140BC25C40D7500F9F3CF /* CommonOSLog */,
|
||||
2D5981B925E4D7F8000FB903 /* ThirdPartyMailer */,
|
||||
2D939AC725EE14620076FA61 /* CropViewController */,
|
||||
DB9A487D2603456B008B817C /* UITextView+Placeholder */,
|
||||
|
@ -3312,10 +3309,10 @@
|
|||
DBAC649D267DFE43007FE9FD /* DiffableDataSources */,
|
||||
DBAC64A0267E6D02007FE9FD /* Fuzi */,
|
||||
DBF7A0FB26830C33004176A2 /* FPSIndicator */,
|
||||
DB01E23226A98F0900C3965B /* MastodonMeta */,
|
||||
DB01E23426A98F0900C3965B /* MetaTextKit */,
|
||||
DB552D4E26BBD10C00E481F6 /* OrderedCollections */,
|
||||
DBA5A52E26F07ED800CACBAA /* PanModal */,
|
||||
DB02EA0C280D184B00E751C5 /* CommonOSLog */,
|
||||
);
|
||||
productName = Mastodon;
|
||||
productReference = DB427DD225BAA00100D1B89D /* Mastodon.app */;
|
||||
|
@ -3376,7 +3373,7 @@
|
|||
);
|
||||
name = AppShared;
|
||||
packageProductDependencies = (
|
||||
DB68050F2637D0F800430867 /* KeychainAccess */,
|
||||
DB02EA0A280D180D00E751C5 /* KeychainAccess */,
|
||||
);
|
||||
productName = AppShared;
|
||||
productReference = DB68047F2637CD4C00430867 /* AppShared.framework */;
|
||||
|
@ -5421,7 +5418,7 @@
|
|||
repositoryURL = "https://github.com/TwidereProject/MetaTextKit.git";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 2.2.1;
|
||||
version = 2.2.2;
|
||||
};
|
||||
};
|
||||
DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */ = {
|
||||
|
@ -5539,21 +5536,21 @@
|
|||
package = DB0140BB25C40D7500F9F3CF /* XCRemoteSwiftPackageReference "CommonOSLog" */;
|
||||
productName = CommonOSLog;
|
||||
};
|
||||
DB0140BC25C40D7500F9F3CF /* CommonOSLog */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DB0140BB25C40D7500F9F3CF /* XCRemoteSwiftPackageReference "CommonOSLog" */;
|
||||
productName = CommonOSLog;
|
||||
};
|
||||
DB01E23226A98F0900C3965B /* MastodonMeta */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DB01E23126A98F0900C3965B /* XCRemoteSwiftPackageReference "MetaTextKit" */;
|
||||
productName = MastodonMeta;
|
||||
};
|
||||
DB01E23426A98F0900C3965B /* MetaTextKit */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DB01E23126A98F0900C3965B /* XCRemoteSwiftPackageReference "MetaTextKit" */;
|
||||
productName = MetaTextKit;
|
||||
};
|
||||
DB02EA0A280D180D00E751C5 /* KeychainAccess */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DB6804722637CC1200430867 /* XCRemoteSwiftPackageReference "KeychainAccess" */;
|
||||
productName = KeychainAccess;
|
||||
};
|
||||
DB02EA0C280D184B00E751C5 /* CommonOSLog */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DB0140BB25C40D7500F9F3CF /* XCRemoteSwiftPackageReference "CommonOSLog" */;
|
||||
productName = CommonOSLog;
|
||||
};
|
||||
DB0C946426A6FD4D0088FB11 /* AlamofireImage */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DB3D0FF125BAA61700EAA174 /* XCRemoteSwiftPackageReference "AlamofireImage" */;
|
||||
|
@ -5573,11 +5570,6 @@
|
|||
package = DB552D4D26BBD10C00E481F6 /* XCRemoteSwiftPackageReference "swift-collections" */;
|
||||
productName = OrderedCollections;
|
||||
};
|
||||
DB68050F2637D0F800430867 /* KeychainAccess */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DB6804722637CC1200430867 /* XCRemoteSwiftPackageReference "KeychainAccess" */;
|
||||
productName = KeychainAccess;
|
||||
};
|
||||
DB6D9F41263527CE008423CD /* AlamofireImage */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = DB3D0FF125BAA61700EAA174 /* XCRemoteSwiftPackageReference "AlamofireImage" */;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<key>isShown</key>
|
||||
<true/>
|
||||
<key>orderHint</key>
|
||||
<integer>4</integer>
|
||||
<integer>5</integer>
|
||||
</dict>
|
||||
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -19,7 +19,7 @@
|
|||
<key>Mastodon - RTL.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>19</integer>
|
||||
<integer>20</integer>
|
||||
</dict>
|
||||
<key>Mastodon - Release.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -29,12 +29,12 @@
|
|||
<key>Mastodon - Snapshot.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
<key>Mastodon - ar.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>3</integer>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
<key>Mastodon - ar.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -109,7 +109,7 @@
|
|||
<key>MastodonIntent.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>33</integer>
|
||||
<integer>26</integer>
|
||||
</dict>
|
||||
<key>MastodonIntents.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -124,12 +124,12 @@
|
|||
<key>NotificationService.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>32</integer>
|
||||
<integer>23</integer>
|
||||
</dict>
|
||||
<key>ShareActionExtension.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>31</integer>
|
||||
<integer>24</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "f82c23a8a7ef8dc1a49a8bfc6a96883e79121864",
|
||||
"version": "5.5.0"
|
||||
"revision": "354dda32d89fc8cd4f5c46487f64957d355f53d8",
|
||||
"version": "5.6.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -96,8 +96,8 @@
|
|||
"repositoryURL": "https://github.com/TwidereProject/MetaTextKit.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "3ea336d3de7938dc112084c596a646e697b0feee",
|
||||
"version": "2.2.1"
|
||||
"revision": "8074400b3819ef0395550082e6e8e960ef22e1f3",
|
||||
"version": "2.2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -105,8 +105,8 @@
|
|||
"repositoryURL": "https://github.com/kean/Nuke.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "0db18dd34998cca18e9a28bcee136f84518007a0",
|
||||
"version": "10.4.1"
|
||||
"revision": "78fa963b8491fc520791d8c2a509f1b8593d8aae",
|
||||
"version": "10.7.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -141,8 +141,8 @@
|
|||
"repositoryURL": "https://github.com/SDWebImage/SDWebImage.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "2c53f531f1bedd253f55d85105409c28ed4a922c",
|
||||
"version": "5.12.3"
|
||||
"revision": "2e63d0061da449ad0ed130768d05dceb1496de44",
|
||||
"version": "5.12.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -177,8 +177,8 @@
|
|||
"repositoryURL": "https://github.com/siteline/SwiftUI-Introspect.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "2e09be8af614401bc9f87d40093ec19ce56ccaf2",
|
||||
"version": "0.1.3"
|
||||
"revision": "f2616860a41f9d9932da412a8978fec79c06fe24",
|
||||
"version": "0.1.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -286,24 +286,8 @@ extension DataSourceFacade {
|
|||
try await dependency.context.managedObjectContext.perform {
|
||||
guard let _status = status.object(in: dependency.context.managedObjectContext) else { return }
|
||||
let status = _status.reblog ?? _status
|
||||
|
||||
let allToggled = status.isContentSensitiveToggled && status.isMediaSensitiveToggled
|
||||
|
||||
status.update(isContentSensitiveToggled: !allToggled)
|
||||
status.update(isMediaSensitiveToggled: !allToggled)
|
||||
status.update(isSensitiveToggled: !status.isSensitiveToggled)
|
||||
}
|
||||
}
|
||||
|
||||
// static func responseToToggleMediaSensitiveAction(
|
||||
// dependency: NeedsDependency,
|
||||
// status: ManagedObjectRecord<Status>
|
||||
// ) 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)
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Med
|
|||
let status = _status.reblog ?? _status
|
||||
return NotificationMediaTransitionContext(
|
||||
status: .init(objectID: status.objectID),
|
||||
needsToggleMediaSensitive: status.isMediaSensitiveToggled ? !status.sensitive : status.sensitive
|
||||
needsToggleMediaSensitive: status.isSensitiveToggled ? !status.sensitive : status.sensitive
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Med
|
|||
let status = _status.reblog ?? _status
|
||||
return NotificationMediaTransitionContext(
|
||||
status: .init(objectID: status.objectID),
|
||||
needsToggleMediaSensitive: status.isMediaSensitiveToggled ? !status.sensitive : status.sensitive
|
||||
needsToggleMediaSensitive: status.isMediaSensitive ? !status.isSensitiveToggled : false
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -143,12 +143,7 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & MediaPrev
|
|||
return
|
||||
}
|
||||
|
||||
let managedObjectContext = self.context.managedObjectContext
|
||||
let needsToggleMediaSensitive: Bool = try await managedObjectContext.perform {
|
||||
guard let _status = status.object(in: managedObjectContext) else { return false }
|
||||
let status = _status.reblog ?? _status
|
||||
return status.isMediaSensitiveToggled ? !status.sensitive : status.sensitive
|
||||
}
|
||||
let needsToggleMediaSensitive = await !statusView.viewModel.isMediaReveal
|
||||
|
||||
guard !needsToggleMediaSensitive else {
|
||||
try await DataSourceFacade.responseToToggleSensitiveAction(
|
||||
|
|
|
@ -62,14 +62,14 @@ extension MediaView {
|
|||
{
|
||||
let placeholder = UIImage.placeholder(color: .systemGray6)
|
||||
let request = URLRequest(url: url)
|
||||
ImageDownloader.default.download(request) { response in
|
||||
ImageDownloader.default.download(request, completion: { response in
|
||||
switch response.result {
|
||||
case .success(let image):
|
||||
configuration.previewImage = image
|
||||
case .failure(let error):
|
||||
case .failure:
|
||||
configuration.previewImage = placeholder
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if let assetURL = configuration.assetURL,
|
||||
|
@ -84,7 +84,7 @@ extension MediaView {
|
|||
.store(in: &configuration.blurhashImageDisposeBag)
|
||||
}
|
||||
|
||||
configuration.isReveal = status.sensitive ? status.isMediaSensitiveToggled : true
|
||||
configuration.isReveal = status.isMediaSensitive ? status.isSensitiveToggled : true
|
||||
|
||||
return configuration
|
||||
}
|
||||
|
|
|
@ -156,7 +156,6 @@ extension StatusView {
|
|||
.map { _ in author.avatarImageURL() }
|
||||
.assign(to: \.authorAvatarImageURL, on: viewModel)
|
||||
.store(in: &disposeBag)
|
||||
|
||||
// author name
|
||||
Publishers.CombineLatest(
|
||||
author.publisher(for: \.displayName),
|
||||
|
@ -268,25 +267,19 @@ extension StatusView {
|
|||
.assign(to: \.visibility, on: viewModel)
|
||||
.store(in: &disposeBag)
|
||||
// sensitive
|
||||
status.publisher(for: \.isContentSensitiveToggled)
|
||||
.assign(to: \.isContentSensitiveToggled, on: viewModel)
|
||||
viewModel.isContentSensitive = status.isContentSensitive
|
||||
status.publisher(for: \.isSensitiveToggled)
|
||||
.assign(to: \.isSensitiveToggled, on: viewModel)
|
||||
.store(in: &disposeBag)
|
||||
|
||||
|
||||
// viewModel.source = status.source
|
||||
}
|
||||
|
||||
private func configureMedia(status: Status) {
|
||||
let status = status.reblog ?? status
|
||||
|
||||
viewModel.isMediaSensitive = status.sensitive && !status.attachments.isEmpty // some servers set media sensitive even empty attachments
|
||||
viewModel.isMediaSensitive = status.isMediaSensitive
|
||||
|
||||
let configurations = MediaView.configuration(status: status)
|
||||
viewModel.mediaViewConfigurations = configurations
|
||||
|
||||
status.publisher(for: \.isMediaSensitiveToggled)
|
||||
.assign(to: \.isMediaSensitiveToggled, on: viewModel)
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
||||
private func configurePoll(status: Status) {
|
||||
|
|
|
@ -61,7 +61,7 @@ extension StatusTableViewCell {
|
|||
statusView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 16),
|
||||
containerViewLeadingLayoutConstraint,
|
||||
containerViewTrailingLayoutConstraint,
|
||||
statusView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
||||
contentView.bottomAnchor.constraint(equalTo: statusView.bottomAnchor, constant: 10),
|
||||
])
|
||||
statusView.setup(style: .inline)
|
||||
updateContainerViewMarginConstraints()
|
||||
|
|
|
@ -112,7 +112,7 @@ extension StatusThreadRootTableViewCell {
|
|||
statusView.statusMetricView
|
||||
]
|
||||
|
||||
if !statusView.viewModel.isSensitive {
|
||||
if !statusView.viewModel.isMediaSensitive {
|
||||
elements.removeAll(where: { $0 === statusView.contentSensitiveeToggleButton })
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ let package = Package(
|
|||
.package(url: "https://github.com/apple/swift-nio.git", from: "1.0.0"),
|
||||
.package(url: "https://github.com/kean/Nuke.git", from: "10.3.1"),
|
||||
.package(url: "https://github.com/Flipboard/FLAnimatedImage.git", from: "1.0.0"),
|
||||
.package(url: "https://github.com/TwidereProject/MetaTextKit.git", .exact("2.2.1")),
|
||||
.package(url: "https://github.com/TwidereProject/MetaTextKit.git", .exact("2.2.2")),
|
||||
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.4.0"),
|
||||
.package(url: "https://github.com/Alamofire/AlamofireImage.git", from: "4.1.0"),
|
||||
.package(name: "NukeFLAnimatedImagePlugin", url: "https://github.com/kean/Nuke-FLAnimatedImage-Plugin.git", from: "8.0.0"),
|
||||
|
@ -94,7 +94,6 @@ let package = Package(
|
|||
.product(name: "Alamofire", package: "Alamofire"),
|
||||
.product(name: "AlamofireImage", package: "AlamofireImage"),
|
||||
.product(name: "MetaTextKit", package: "MetaTextKit"),
|
||||
.product(name: "MastodonMeta", package: "MetaTextKit"),
|
||||
.product(name: "FLAnimatedImage", package: "FLAnimatedImage"),
|
||||
]
|
||||
),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="19574" systemVersion="21D62" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="20086" systemVersion="21E258" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<entity name="Application" representedClassName="CoreDataStack.Application" syncable="YES">
|
||||
<attribute name="identifier" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
|
||||
<attribute name="name" attributeType="String"/>
|
||||
|
@ -185,8 +185,7 @@
|
|||
<attribute name="identifier" attributeType="String"/>
|
||||
<attribute name="inReplyToAccountID" optional="YES" attributeType="String"/>
|
||||
<attribute name="inReplyToID" optional="YES" attributeType="String"/>
|
||||
<attribute name="isContentSensitiveToggled" transient="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="isMediaSensitiveToggled" transient="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="isSensitiveToggled" transient="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="language" optional="YES" attributeType="String"/>
|
||||
<attribute name="mentions" optional="YES" attributeType="Binary"/>
|
||||
<attribute name="reblogsCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
|
@ -262,7 +261,7 @@
|
|||
<element name="PrivateNote" positionX="0" positionY="0" width="128" height="89"/>
|
||||
<element name="SearchHistory" positionX="0" positionY="0" width="128" height="149"/>
|
||||
<element name="Setting" positionX="72" positionY="162" width="128" height="164"/>
|
||||
<element name="Status" positionX="0" positionY="0" width="128" height="629"/>
|
||||
<element name="Status" positionX="0" positionY="0" width="128" height="614"/>
|
||||
<element name="Subscription" positionX="81" positionY="171" width="128" height="179"/>
|
||||
<element name="SubscriptionAlerts" positionX="72" positionY="162" width="128" height="164"/>
|
||||
<element name="Tag" positionX="0" positionY="0" width="128" height="149"/>
|
||||
|
|
|
@ -42,9 +42,7 @@ public final class Status: NSManagedObject {
|
|||
@NSManaged public private(set) var spoilerText: String?
|
||||
|
||||
// sourcery: autoUpdatableObject
|
||||
@NSManaged public private(set) var isContentSensitiveToggled: Bool
|
||||
// sourcery: autoUpdatableObject
|
||||
@NSManaged public private(set) var isMediaSensitiveToggled: Bool
|
||||
@NSManaged public private(set) var isSensitiveToggled: Bool
|
||||
|
||||
@NSManaged public private(set) var application: Application?
|
||||
|
||||
|
@ -432,14 +430,9 @@ extension Status: AutoUpdatableObject {
|
|||
self.spoilerText = spoilerText
|
||||
}
|
||||
}
|
||||
public func update(isContentSensitiveToggled: Bool) {
|
||||
if self.isContentSensitiveToggled != isContentSensitiveToggled {
|
||||
self.isContentSensitiveToggled = isContentSensitiveToggled
|
||||
}
|
||||
}
|
||||
public func update(isMediaSensitiveToggled: Bool) {
|
||||
if self.isMediaSensitiveToggled != isMediaSensitiveToggled {
|
||||
self.isMediaSensitiveToggled = isMediaSensitiveToggled
|
||||
public func update(isSensitiveToggled: Bool) {
|
||||
if self.isSensitiveToggled != isSensitiveToggled {
|
||||
self.isSensitiveToggled = isSensitiveToggled
|
||||
}
|
||||
}
|
||||
public func update(reblogsCount: Int64) {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// MastodonStatus.swift
|
||||
//
|
||||
//
|
||||
// Created by MainasuK on 2022-4-18.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreDataStack
|
||||
|
||||
extension Status {
|
||||
|
||||
// mark content sensitive when status contains spoilerText
|
||||
public var isContentSensitive: Bool {
|
||||
if let spoilerText = spoilerText, !spoilerText.isEmpty {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// mark media sensitive when `isContentSensitive` or media marked sensitive
|
||||
public var isMediaSensitive: Bool {
|
||||
// some servers set media sensitive even empty attachments
|
||||
return isContentSensitive || (sensitive && !attachments.isEmpty)
|
||||
}
|
||||
|
||||
}
|
|
@ -74,11 +74,9 @@ extension StatusView {
|
|||
|
||||
// Sensitive
|
||||
@Published public var isContentSensitive: Bool = false
|
||||
@Published public var isContentSensitiveToggled: Bool = false
|
||||
@Published public var isMediaSensitive: Bool = false
|
||||
@Published public var isMediaSensitiveToggled: Bool = false
|
||||
|
||||
@Published public var isSensitive: Bool = false // isContentSensitive || isMediaSensitive
|
||||
@Published public var isSensitiveToggled = false
|
||||
|
||||
@Published public var isContentReveal: Bool = true
|
||||
@Published public var isMediaReveal: Bool = true
|
||||
|
||||
|
@ -130,9 +128,8 @@ extension StatusView {
|
|||
authorAvatarImageURL = nil
|
||||
|
||||
isContentSensitive = false
|
||||
isContentSensitiveToggled = false
|
||||
isMediaSensitive = false
|
||||
isMediaSensitiveToggled = false
|
||||
isSensitiveToggled = false
|
||||
|
||||
activeFilters = []
|
||||
filterContext = nil
|
||||
|
@ -161,28 +158,18 @@ extension StatusView {
|
|||
$spoilerContent
|
||||
.map { $0 != nil }
|
||||
.assign(to: &$isContentSensitive)
|
||||
// isSensitive
|
||||
Publishers.CombineLatest(
|
||||
// isReveal
|
||||
Publishers.CombineLatest3(
|
||||
$isContentSensitive,
|
||||
$isMediaSensitive
|
||||
)
|
||||
.map { $0 || $1 }
|
||||
.assign(to: &$isSensitive)
|
||||
// $isContentReveal
|
||||
Publishers.CombineLatest(
|
||||
$isContentSensitive,
|
||||
$isContentSensitiveToggled
|
||||
)
|
||||
.map { $0 ? $1 : true }
|
||||
.assign(to: &$isContentReveal)
|
||||
// $isMediaReveal
|
||||
Publishers.CombineLatest(
|
||||
$isMediaSensitive,
|
||||
$isMediaSensitiveToggled
|
||||
$isSensitiveToggled
|
||||
)
|
||||
.map { $1 ? !$0 : $0 }
|
||||
.map { !$0 }
|
||||
.assign(to: &$isMediaReveal)
|
||||
.sink { [weak self] isContentSensitive, isMediaSensitive, isSensitiveToggled in
|
||||
guard let self = self else { return }
|
||||
self.isContentReveal = isContentSensitive ? isSensitiveToggled : true
|
||||
self.isMediaReveal = isMediaSensitive ? isSensitiveToggled : true
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -326,29 +313,22 @@ extension StatusView.ViewModel {
|
|||
}
|
||||
.store(in: &disposeBag)
|
||||
|
||||
$isSensitive
|
||||
$isMediaSensitive
|
||||
.sink { isSensitive in
|
||||
guard isSensitive else { return }
|
||||
statusView.setContentSensitiveeToggleButtonDisplay()
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
|
||||
// There are 2 conditions:
|
||||
// 1. The content may non-sensitive with sensitive media
|
||||
// 2. The content and media both senstivie
|
||||
Publishers.CombineLatest(
|
||||
$isContentSensitiveToggled,
|
||||
$isMediaSensitiveToggled
|
||||
)
|
||||
.map { $0 || $1 }
|
||||
.sink { isSensitiveToggled in
|
||||
// The button indicator go-to state for button action direction
|
||||
// eye: when media is hidden
|
||||
// eye-slash: when media display
|
||||
let image = isSensitiveToggled ? UIImage(systemName: "eye.slash.fill") : UIImage(systemName: "eye.fill")
|
||||
statusView.contentSensitiveeToggleButton.setImage(image, for: .normal)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
$isSensitiveToggled
|
||||
.sink { isSensitiveToggled in
|
||||
// The button indicator go-to state for button action direction
|
||||
// eye: when media is hidden
|
||||
// eye-slash: when media display
|
||||
let image = isSensitiveToggled ? UIImage(systemName: "eye.slash.fill") : UIImage(systemName: "eye.fill")
|
||||
statusView.contentSensitiveeToggleButton.setImage(image, for: .normal)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
||||
private func bindMedia(statusView: StatusView) {
|
||||
|
|
|
@ -508,6 +508,7 @@ extension StatusView.Style {
|
|||
|
||||
// status content
|
||||
statusView.contentContainer.addArrangedSubview(statusView.contentMetaText.textView)
|
||||
statusView.containerStackView.setCustomSpacing(16, after: statusView.contentMetaText.textView)
|
||||
|
||||
statusView.spoilerOverlayView.translatesAutoresizingMaskIntoConstraints = false
|
||||
statusView.containerStackView.addSubview(statusView.spoilerOverlayView)
|
||||
|
|
|
@ -114,7 +114,7 @@ extension ActionToolbarContainer {
|
|||
container.addArrangedSubview(favoriteButton)
|
||||
container.addArrangedSubview(shareButton)
|
||||
NSLayoutConstraint.activate([
|
||||
replyButton.heightAnchor.constraint(equalToConstant: 44).priority(.defaultHigh),
|
||||
replyButton.heightAnchor.constraint(equalToConstant: 36).priority(.defaultHigh),
|
||||
replyButton.heightAnchor.constraint(equalTo: reblogButton.heightAnchor).priority(.defaultHigh),
|
||||
replyButton.heightAnchor.constraint(equalTo: favoriteButton.heightAnchor).priority(.defaultHigh),
|
||||
replyButton.heightAnchor.constraint(equalTo: shareButton.heightAnchor).priority(.defaultHigh),
|
||||
|
|
|
@ -75,9 +75,9 @@ extension ProfileStatusDashboardView {
|
|||
tapGestureRecognizer.addTarget(self, action: #selector(ProfileStatusDashboardView.tapGestureRecognizerHandler(_:)))
|
||||
meterView.addGestureRecognizer(tapGestureRecognizer)
|
||||
}
|
||||
|
||||
followingDashboardMeterView.accessibilityHint = "Double tap to open the list" // TODO: i18n
|
||||
followersDashboardMeterView.accessibilityHint = "Double tap to open the list"
|
||||
|
||||
followingDashboardMeterView.accessibilityHint = L10n.Scene.Profile.Accessibility.doubleTapToOpenTheList
|
||||
followersDashboardMeterView.accessibilityHint = L10n.Scene.Profile.Accessibility.doubleTapToOpenTheList
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue