diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index fa8b06c3d..0f7d85276 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -179,12 +179,12 @@ 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 */; }; DB023295267F0AB800031745 /* ASMetaEditableTextNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB023294267F0AB800031745 /* ASMetaEditableTextNode.swift */; }; 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 */; }; - DB03F7EB268976B5007B274C /* MastodonMeta in Frameworks */ = {isa = PBXBuildFile; productRef = DB03F7EA268976B5007B274C /* MastodonMeta */; }; - DB03F7ED268976B5007B274C /* MetaTextView in Frameworks */ = {isa = PBXBuildFile; productRef = DB03F7EC268976B5007B274C /* MetaTextView */; }; DB03F7F32689AEA3007B274C /* ComposeRepliedToStatusContentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB03F7F22689AEA3007B274C /* ComposeRepliedToStatusContentTableViewCell.swift */; }; DB03F7F52689B782007B274C /* ComposeTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB03F7F42689B782007B274C /* ComposeTableView.swift */; }; DB040ED126538E3D00BEE9D8 /* Trie.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB040ED026538E3C00BEE9D8 /* Trie.swift */; }; @@ -196,6 +196,7 @@ DB0C946F26A7D2A80088FB11 /* AvatarImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0C946E26A7D2A80088FB11 /* AvatarImageView.swift */; }; DB0C947226A7D2D70088FB11 /* AvatarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0C947126A7D2D70088FB11 /* AvatarButton.swift */; }; DB0C947726A7FE840088FB11 /* NotificationAvatarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0C947626A7FE840088FB11 /* NotificationAvatarButton.swift */; }; + DB0E91EA26A9675100BD2ACC /* MetaLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0E91E926A9675100BD2ACC /* MetaLabel.swift */; }; DB0F8150264D1E2500F2A12B /* PickServerLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0F814F264D1E2500F2A12B /* PickServerLoaderTableViewCell.swift */; }; DB118A8225E4B6E600FAB162 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DB118A8125E4B6E600FAB162 /* Preview Assets.xcassets */; }; DB1D186C25EF5BA7003F1F23 /* PollTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1D186B25EF5BA7003F1F23 /* PollTableView.swift */; }; @@ -227,8 +228,6 @@ DB3667A8268AE2900027D07F /* ComposeStatusPollItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB3667A7268AE2900027D07F /* ComposeStatusPollItem.swift */; }; DB3D0FF325BAA61700EAA174 /* AlamofireImage in Frameworks */ = {isa = PBXBuildFile; productRef = DB3D0FF225BAA61700EAA174 /* AlamofireImage */; }; DB3D100D25BAA75E00EAA174 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = DB3D100F25BAA75E00EAA174 /* Localizable.strings */; }; - DB41ED8226A54D8A00F58330 /* MastodonMeta in Frameworks */ = {isa = PBXBuildFile; productRef = DB41ED8126A54D8A00F58330 /* MastodonMeta */; }; - DB41ED8426A54D8A00F58330 /* MetaTextView in Frameworks */ = {isa = PBXBuildFile; productRef = DB41ED8326A54D8A00F58330 /* MetaTextView */; }; DB427DD625BAA00100D1B89D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB427DD525BAA00100D1B89D /* AppDelegate.swift */; }; DB427DD825BAA00100D1B89D /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB427DD725BAA00100D1B89D /* SceneDelegate.swift */; }; DB427DDD25BAA00100D1B89D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DB427DDB25BAA00100D1B89D /* Main.storyboard */; }; @@ -896,6 +895,7 @@ DB0C946E26A7D2A80088FB11 /* AvatarImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarImageView.swift; sourceTree = ""; }; DB0C947126A7D2D70088FB11 /* AvatarButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarButton.swift; sourceTree = ""; }; DB0C947626A7FE840088FB11 /* NotificationAvatarButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationAvatarButton.swift; sourceTree = ""; }; + DB0E91E926A9675100BD2ACC /* MetaLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetaLabel.swift; sourceTree = ""; }; DB0F814D264CFFD300F2A12B /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = ""; }; DB0F814E264CFFD300F2A12B /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/InfoPlist.strings; sourceTree = ""; }; DB0F814F264D1E2500F2A12B /* PickServerLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerLoaderTableViewCell.swift; sourceTree = ""; }; @@ -1257,7 +1257,6 @@ buildActionMask = 2147483647; files = ( DB0140BD25C40D7500F9F3CF /* CommonOSLog in Frameworks */, - DB03F7ED268976B5007B274C /* MetaTextView in Frameworks */, DB89BA0325C10FD0008580ED /* CoreDataStack.framework in Frameworks */, DBC6462B26A1738900B0E31B /* MastodonUI in Frameworks */, 2D42FF6125C8177C004A627A /* ActiveLabel in Frameworks */, @@ -1269,14 +1268,15 @@ DBF96326262EC0A6001D8D25 /* AuthenticationServices.framework in Frameworks */, DBAC6483267D0B21007FE9FD /* DifferenceKit in Frameworks */, 2D61336925C18A4F00CAE157 /* AlamofireNetworkActivityIndicator in Frameworks */, + DB01E23326A98F0900C3965B /* MastodonMeta in Frameworks */, DBAC64A1267E6D02007FE9FD /* Fuzi in Frameworks */, DB3D0FF325BAA61700EAA174 /* AlamofireImage in Frameworks */, DBAC649E267DFE43007FE9FD /* DiffableDataSources in Frameworks */, 2D5981BA25E4D7F8000FB903 /* ThirdPartyMailer in Frameworks */, 87FFDA5D898A5C42ADCB35E7 /* Pods_Mastodon.framework in Frameworks */, DB6804C82637CE2F00430867 /* AppShared.framework in Frameworks */, - DB03F7EB268976B5007B274C /* MastodonMeta in Frameworks */, DBF7A0FC26830C33004176A2 /* FPSIndicator in Frameworks */, + DB01E23526A98F0900C3965B /* MetaTextKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1329,8 +1329,6 @@ DBBC24B826A5421800398BB9 /* CommonOSLog in Frameworks */, DBC6462526A1720B00B0E31B /* MastodonUI in Frameworks */, DBC6463726A195DB00B0E31B /* CoreDataStack.framework in Frameworks */, - DB41ED8426A54D8A00F58330 /* MetaTextView in Frameworks */, - DB41ED8226A54D8A00F58330 /* MastodonMeta in Frameworks */, DBBC24D126A5484F00398BB9 /* UITextView+Placeholder in Frameworks */, DBBC24AA26A5301B00398BB9 /* MastodonSDK in Frameworks */, DB0C946526A6FD4D0088FB11 /* AlamofireImage in Frameworks */, @@ -2502,6 +2500,7 @@ DB6C8C0525F0921200AAA452 /* MastodonSDK */, DB44384E25E8C1FA008912A2 /* CALayer.swift */, 2DF123A625C3B0210020F248 /* ActiveLabel.swift */, + DB0E91E926A9675100BD2ACC /* MetaLabel.swift */, DB68586325E619B700F0A850 /* NSKeyValueObservation.swift */, DB0140CE25C42AEE00F9F3CF /* OSLog.swift */, DB68A06225E905E000CFDF14 /* UIApplication.swift */, @@ -2999,9 +2998,9 @@ DBAC649D267DFE43007FE9FD /* DiffableDataSources */, DBAC64A0267E6D02007FE9FD /* Fuzi */, DBF7A0FB26830C33004176A2 /* FPSIndicator */, - DB03F7EA268976B5007B274C /* MastodonMeta */, - DB03F7EC268976B5007B274C /* MetaTextView */, DBC6462A26A1738900B0E31B /* MastodonUI */, + DB01E23226A98F0900C3965B /* MastodonMeta */, + DB01E23426A98F0900C3965B /* MetaTextKit */, ); productName = Mastodon; productReference = DB427DD225BAA00100D1B89D /* Mastodon.app */; @@ -3127,8 +3126,6 @@ DBBC24A926A5301B00398BB9 /* MastodonSDK */, DBBC24B726A5421800398BB9 /* CommonOSLog */, DBBC24D026A5484F00398BB9 /* UITextView+Placeholder */, - DB41ED8126A54D8A00F58330 /* MastodonMeta */, - DB41ED8326A54D8A00F58330 /* MetaTextView */, DB0C946426A6FD4D0088FB11 /* AlamofireImage */, ); productName = ShareActionExtension; @@ -3226,7 +3223,7 @@ DBAC649F267E6D01007FE9FD /* XCRemoteSwiftPackageReference "Fuzi" */, DBF7A0FA26830C33004176A2 /* XCRemoteSwiftPackageReference "FPSIndicator" */, DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */, - DB03F7E9268976B5007B274C /* XCRemoteSwiftPackageReference "MetaTextView" */, + DB01E23126A98F0900C3965B /* XCRemoteSwiftPackageReference "MetaTextKit" */, ); productRefGroup = DB427DD325BAA00100D1B89D /* Products */; projectDirPath = ""; @@ -3752,6 +3749,7 @@ DB4F096C269EFA2000D62E92 /* SearchResultViewController+StatusProvider.swift in Sources */, DB87D4452609BE0500D12C0D /* ComposeStatusPollOptionCollectionViewCell.swift in Sources */, DB6D9F7D26358ED4008423CD /* SettingsSection.swift in Sources */, + DB0E91EA26A9675100BD2ACC /* MetaLabel.swift in Sources */, DB8AF55025C13703002E6C99 /* MainTabBarController.swift in Sources */, DB9D6BE925E4F5340051B173 /* SearchViewController.swift in Sources */, 2D38F1C625CD37F400561493 /* ContentOffsetAdjustableTimelineViewControllerDelegate.swift in Sources */, @@ -5349,12 +5347,12 @@ minimumVersion = 0.1.1; }; }; - DB03F7E9268976B5007B274C /* XCRemoteSwiftPackageReference "MetaTextView" */ = { + DB01E23126A98F0900C3965B /* XCRemoteSwiftPackageReference "MetaTextKit" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/TwidereProject/MetaTextView.git"; + repositoryURL = "https://github.com/TwidereProject/MetaTextKit.git"; requirement = { kind = exactVersion; - version = 1.4.0; + version = 2.0.0; }; }; DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */ = { @@ -5474,15 +5472,15 @@ package = DB0140BB25C40D7500F9F3CF /* XCRemoteSwiftPackageReference "CommonOSLog" */; productName = CommonOSLog; }; - DB03F7EA268976B5007B274C /* MastodonMeta */ = { + DB01E23226A98F0900C3965B /* MastodonMeta */ = { isa = XCSwiftPackageProductDependency; - package = DB03F7E9268976B5007B274C /* XCRemoteSwiftPackageReference "MetaTextView" */; + package = DB01E23126A98F0900C3965B /* XCRemoteSwiftPackageReference "MetaTextKit" */; productName = MastodonMeta; }; - DB03F7EC268976B5007B274C /* MetaTextView */ = { + DB01E23426A98F0900C3965B /* MetaTextKit */ = { isa = XCSwiftPackageProductDependency; - package = DB03F7E9268976B5007B274C /* XCRemoteSwiftPackageReference "MetaTextView" */; - productName = MetaTextView; + package = DB01E23126A98F0900C3965B /* XCRemoteSwiftPackageReference "MetaTextKit" */; + productName = MetaTextKit; }; DB0C946426A6FD4D0088FB11 /* AlamofireImage */ = { isa = XCSwiftPackageProductDependency; @@ -5494,16 +5492,6 @@ package = DB3D0FF125BAA61700EAA174 /* XCRemoteSwiftPackageReference "AlamofireImage" */; productName = AlamofireImage; }; - DB41ED8126A54D8A00F58330 /* MastodonMeta */ = { - isa = XCSwiftPackageProductDependency; - package = DB03F7E9268976B5007B274C /* XCRemoteSwiftPackageReference "MetaTextView" */; - productName = MastodonMeta; - }; - DB41ED8326A54D8A00F58330 /* MetaTextView */ = { - isa = XCSwiftPackageProductDependency; - package = DB03F7E9268976B5007B274C /* XCRemoteSwiftPackageReference "MetaTextView" */; - productName = MetaTextView; - }; DB68050F2637D0F800430867 /* KeychainAccess */ = { isa = XCSwiftPackageProductDependency; package = DB6804722637CC1200430867 /* XCRemoteSwiftPackageReference "KeychainAccess" */; diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index fd09596bc..1220300f7 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,7 +12,7 @@ CoreDataStack.xcscheme_^#shared#^_ orderHint - 22 + 24 Mastodon - ASDK.xcscheme_^#shared#^_ @@ -22,7 +22,7 @@ Mastodon - RTL.xcscheme_^#shared#^_ orderHint - 3 + 4 Mastodon - Release.xcscheme_^#shared#^_ @@ -37,12 +37,12 @@ NotificationService.xcscheme_^#shared#^_ orderHint - 23 + 22 ShareActionExtension.xcscheme_^#shared#^_ orderHint - 21 + 23 SuppressBuildableAutocreation diff --git a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved index 55f7d7113..45f1697c9 100644 --- a/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Mastodon.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/Alamofire/Alamofire.git", "state": { "branch": null, - "revision": "4d19ad82f80cc71ff829b941ded114c56f4f604c", - "version": "5.4.2" + "revision": "f96b619bcb2383b43d898402283924b80e2c4bae", + "version": "5.4.3" } }, { @@ -110,12 +110,12 @@ } }, { - "package": "MetaTextView", - "repositoryURL": "https://github.com/TwidereProject/MetaTextView.git", + "package": "MetaTextKit", + "repositoryURL": "https://github.com/TwidereProject/MetaTextKit.git", "state": { "branch": null, - "revision": "4c16bc639652a7e1bff4f75e1eba2fcf40213974", - "version": "1.4.0" + "revision": "44fc5111269d9862369348870835e17907062115", + "version": "2.0.0" } }, { @@ -145,6 +145,15 @@ "version": "3.6.2" } }, + { + "package": "SDWebImage", + "repositoryURL": "https://github.com/SDWebImage/SDWebImage.git", + "state": { + "branch": null, + "revision": "76dd4b49110b8624317fc128e7fa0d8a252018bc", + "version": "5.11.1" + } + }, { "package": "swift-nio", "repositoryURL": "https://github.com/apple/swift-nio.git", diff --git a/Mastodon/Diffiable/Section/Compose/ComposeStatusSection.swift b/Mastodon/Diffiable/Section/Compose/ComposeStatusSection.swift index 6a9dd2b3b..bacc5097c 100644 --- a/Mastodon/Diffiable/Section/Compose/ComposeStatusSection.swift +++ b/Mastodon/Diffiable/Section/Compose/ComposeStatusSection.swift @@ -9,7 +9,7 @@ import UIKit import Combine import CoreData import CoreDataStack -import MetaTextView +import MetaTextKit import MastodonMeta import AlamofireImage diff --git a/Mastodon/Diffiable/Section/Status/StatusSection.swift b/Mastodon/Diffiable/Section/Status/StatusSection.swift index 18406da66..9bb34466e 100644 --- a/Mastodon/Diffiable/Section/Status/StatusSection.swift +++ b/Mastodon/Diffiable/Section/Status/StatusSection.swift @@ -113,7 +113,7 @@ extension StatusSection { accessibilityViews.append(cell.statusView.headerInfoLabel) } accessibilityViews.append(contentsOf: [ - cell.statusView.nameLabel, + cell.statusView.nameMetaLabel, cell.statusView.dateLabel, cell.statusView.contentMetaText.textView, ]) @@ -171,7 +171,7 @@ extension StatusSection { cell.statusView.contentMetaText.textView.isAccessibilityElement = false var accessibilityElements: [Any] = [] accessibilityElements.append(cell.statusView.avatarView) - accessibilityElements.append(cell.statusView.nameLabel) + accessibilityElements.append(cell.statusView.nameMetaLabel) accessibilityElements.append(cell.statusView.dateLabel) // TODO: a11y accessibilityElements.append(cell.statusView.contentMetaText.textView) @@ -652,7 +652,13 @@ extension StatusSection { return L10n.Common.Controls.Status.userReblogged(name) }() // sync set display name to avoid layout issue - cell.statusView.headerInfoLabel.configure(content: headerText, emojiDict: status.author.emojiDict) + do { + let mastodonContent = MastodonContent(content: headerText, emojis: status.author.emojiMeta) + let metaContent = try MastodonMetaContent.convert(document: mastodonContent) + cell.statusView.headerInfoLabel.configure(content: metaContent) + } catch { + cell.statusView.headerInfoLabel.reset() + } cell.statusView.headerInfoLabel.accessibilityLabel = headerText cell.statusView.headerInfoLabel.isAccessibilityElement = true } else if status.inReplyToID != nil { @@ -666,7 +672,13 @@ extension StatusSection { let name = author.displayName.isEmpty ? author.username : author.displayName return L10n.Common.Controls.Status.userRepliedTo(name) }() - cell.statusView.headerInfoLabel.configure(content: headerText, emojiDict: status.replyTo?.author.emojiDict ?? [:]) + do { + let mastodonContent = MastodonContent(content: headerText, emojis: status.replyTo?.author.emojiMeta ?? [:]) + let metaContent = try MastodonMetaContent.convert(document: mastodonContent) + cell.statusView.headerInfoLabel.configure(content: metaContent) + } catch { + cell.statusView.headerInfoLabel.reset() + } cell.statusView.headerInfoLabel.accessibilityLabel = headerText cell.statusView.headerInfoLabel.isAccessibilityElement = status.replyTo != nil } else { @@ -682,8 +694,15 @@ extension StatusSection { // name let author = (status.reblog ?? status).author let nameContent = author.displayNameWithFallback - cell.statusView.nameLabel.configure(content: nameContent, emojiDict: author.emojiDict) - cell.statusView.nameLabel.accessibilityLabel = nameContent + do { + let mastodonContent = MastodonContent(content: nameContent, emojis: author.emojiMeta) + let metaContent = try MastodonMetaContent.convert(document: mastodonContent) + cell.statusView.nameMetaLabel.configure(content: metaContent) + cell.statusView.nameMetaLabel.accessibilityLabel = metaContent.trimmed + } catch { + cell.statusView.nameMetaLabel.reset() + cell.statusView.nameMetaLabel.accessibilityLabel = "" + } // username cell.statusView.usernameLabel.text = "@" + author.acct // avatar diff --git a/Mastodon/Extension/MetaLabel.swift b/Mastodon/Extension/MetaLabel.swift new file mode 100644 index 000000000..67200874b --- /dev/null +++ b/Mastodon/Extension/MetaLabel.swift @@ -0,0 +1,53 @@ +// +// MetaText.swift +// Mastodon +// +// Created by MainasuK Cirno on 2021-7-22. +// + +import UIKit +import MetaTextKit + +extension MetaLabel { + enum Style { + case statusHeader + case statusName +// case profileFieldName +// case profileFieldValue + } + + convenience init(style: Style) { + self.init() + + layer.masksToBounds = true + textContainer.lineBreakMode = .byTruncatingTail + + let font: UIFont + let textColor: UIColor + + switch style { + case .statusHeader: + font = UIFontMetrics(forTextStyle: .footnote).scaledFont(for: .systemFont(ofSize: 13, weight: .medium), maximumPointSize: 17) + textColor = Asset.Colors.Label.secondary.color + + case .statusName: + font = .systemFont(ofSize: 17, weight: .semibold) + textColor = Asset.Colors.Label.primary.color +// case .profileFieldName: +// font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 20) +// textColor = Asset.Colors.Label.primary.color +// numberOfLines = 1 +// case .profileFieldValue: +// font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .regular), maximumPointSize: 20) +// textColor = Asset.Colors.Label.primary.color +// numberOfLines = 1 + } + + self.font = font + self.textColor = textColor + + textAttributes = [ + .font: font, + .foregroundColor: textColor + ] + }} diff --git a/Mastodon/Protocol/StatusProvider/StatusProvider+StatusTableViewCellDelegate.swift b/Mastodon/Protocol/StatusProvider/StatusProvider+StatusTableViewCellDelegate.swift index a752f2180..544de8893 100644 --- a/Mastodon/Protocol/StatusProvider/StatusProvider+StatusTableViewCellDelegate.swift +++ b/Mastodon/Protocol/StatusProvider/StatusProvider+StatusTableViewCellDelegate.swift @@ -13,7 +13,7 @@ import CoreDataStack import MastodonSDK import ActiveLabel import Meta -import MetaTextView +import MetaTextKit // MARK: - StatusViewDelegate extension StatusTableViewCellDelegate where Self: StatusProvider { diff --git a/Mastodon/Protocol/StatusProvider/StatusProviderFacade.swift b/Mastodon/Protocol/StatusProvider/StatusProviderFacade.swift index 40f0f6bb8..e5bb15a80 100644 --- a/Mastodon/Protocol/StatusProvider/StatusProviderFacade.swift +++ b/Mastodon/Protocol/StatusProvider/StatusProviderFacade.swift @@ -13,7 +13,7 @@ import CoreDataStack import MastodonSDK import ActiveLabel import Meta -import MetaTextView +import MetaTextKit #if ASDK import AsyncDisplayKit diff --git a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusContentTableViewCell.swift b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusContentTableViewCell.swift index 7dbda5b36..d970b6734 100644 --- a/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusContentTableViewCell.swift +++ b/Mastodon/Scene/Compose/CollectionViewCell/ComposeStatusContentTableViewCell.swift @@ -8,7 +8,7 @@ import os.log import UIKit import Combine -import MetaTextView +import MetaTextKit import UITextView_Placeholder final class ComposeStatusContentTableViewCell: UITableViewCell { diff --git a/Mastodon/Scene/Compose/ComposeViewController.swift b/Mastodon/Scene/Compose/ComposeViewController.swift index 4ce020837..156680496 100644 --- a/Mastodon/Scene/Compose/ComposeViewController.swift +++ b/Mastodon/Scene/Compose/ComposeViewController.swift @@ -10,7 +10,7 @@ import UIKit import Combine import PhotosUI import MastodonSDK -import MetaTextView +import MetaTextKit import MastodonMeta import Meta import MastodonUI diff --git a/Mastodon/Scene/Compose/ComposeViewModel+DataSource.swift b/Mastodon/Scene/Compose/ComposeViewModel+DataSource.swift index 4b4e80c52..2642808d1 100644 --- a/Mastodon/Scene/Compose/ComposeViewModel+DataSource.swift +++ b/Mastodon/Scene/Compose/ComposeViewModel+DataSource.swift @@ -12,7 +12,7 @@ import CoreDataStack import TwitterTextEditor import MastodonSDK import MastodonMeta -import MetaTextView +import MetaTextKit extension ComposeViewModel { diff --git a/Mastodon/Scene/Compose/View/CustomEmojiPickerInputViewModel.swift b/Mastodon/Scene/Compose/View/CustomEmojiPickerInputViewModel.swift index d421759b1..d258ff7b8 100644 --- a/Mastodon/Scene/Compose/View/CustomEmojiPickerInputViewModel.swift +++ b/Mastodon/Scene/Compose/View/CustomEmojiPickerInputViewModel.swift @@ -7,7 +7,7 @@ import UIKit import Combine -import MetaTextView +import MetaTextKit final class CustomEmojiPickerInputViewModel { diff --git a/Mastodon/Scene/Compose/View/ReplicaStatusView.swift b/Mastodon/Scene/Compose/View/ReplicaStatusView.swift index 609e4bcc6..8e6d46878 100644 --- a/Mastodon/Scene/Compose/View/ReplicaStatusView.swift +++ b/Mastodon/Scene/Compose/View/ReplicaStatusView.swift @@ -9,7 +9,7 @@ import os.log import UIKit import ActiveLabel import FLAnimatedImage -import MetaTextView +import MetaTextKit final class ReplicaStatusView: UIView { diff --git a/Mastodon/Scene/Notification/NotificationViewController.swift b/Mastodon/Scene/Notification/NotificationViewController.swift index 658c5fcab..5528adf68 100644 --- a/Mastodon/Scene/Notification/NotificationViewController.swift +++ b/Mastodon/Scene/Notification/NotificationViewController.swift @@ -14,7 +14,7 @@ import OSLog import UIKit import ActiveLabel import Meta -import MetaTextView +import MetaTextKit final class NotificationViewController: UIViewController, NeedsDependency { weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } diff --git a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift index 684d9187c..6afc61e9a 100644 --- a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift +++ b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift @@ -11,7 +11,7 @@ import Foundation import CoreDataStack import UIKit import ActiveLabel -import MetaTextView +import MetaTextKit import Meta import FLAnimatedImage diff --git a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift index 95a91b994..043e1b665 100644 --- a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift +++ b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift @@ -11,7 +11,7 @@ import Combine import ActiveLabel import TwitterTextEditor import FLAnimatedImage -import MetaTextView +import MetaTextKit protocol ProfileHeaderViewDelegate: AnyObject { func profileHeaderView(_ profileHeaderView: ProfileHeaderView, avatarImageViewDidPressed imageView: UIImageView) diff --git a/Mastodon/Scene/Report/ReportedStatusTableviewCell.swift b/Mastodon/Scene/Report/ReportedStatusTableviewCell.swift index 639167684..32d096a33 100644 --- a/Mastodon/Scene/Report/ReportedStatusTableviewCell.swift +++ b/Mastodon/Scene/Report/ReportedStatusTableviewCell.swift @@ -13,7 +13,7 @@ import CoreData import CoreDataStack import ActiveLabel import Meta -import MetaTextView +import MetaTextKit final class ReportedStatusTableViewCell: UITableViewCell, StatusCell { diff --git a/Mastodon/Scene/Share/View/Content/StatusView.swift b/Mastodon/Scene/Share/View/Content/StatusView.swift index a12a7bd28..0964ee3ba 100644 --- a/Mastodon/Scene/Share/View/Content/StatusView.swift +++ b/Mastodon/Scene/Share/View/Content/StatusView.swift @@ -12,7 +12,7 @@ import AVKit import ActiveLabel import AlamofireImage import FLAnimatedImage -import MetaTextView +import MetaTextKit import Meta import MastodonSDK @@ -81,12 +81,7 @@ final class StatusView: UIView { return label }() - let headerInfoLabel: ActiveLabel = { - let label = ActiveLabel(style: .statusHeader) - label.text = "Bob reblogged" - label.layer.masksToBounds = false - return label - }() + let headerInfoLabel = MetaLabel(style: .statusHeader) let avatarView: UIView = { let view = UIView() @@ -98,8 +93,8 @@ final class StatusView: UIView { let avatarButton = AvatarButton() let avatarStackedContainerButton: AvatarStackContainerButton = AvatarStackContainerButton() - let nameLabel: ActiveLabel = { - let label = ActiveLabel(style: .statusName) + let nameMetaLabel: MetaLabel = { + let label = MetaLabel(style: .statusName) return label }() @@ -343,24 +338,27 @@ extension StatusView { titleContainerStackView.axis = .horizontal titleContainerStackView.alignment = .center titleContainerStackView.spacing = 4 - nameLabel.translatesAutoresizingMaskIntoConstraints = false - titleContainerStackView.addArrangedSubview(nameLabel) + nameMetaLabel.translatesAutoresizingMaskIntoConstraints = false + titleContainerStackView.addArrangedSubview(nameMetaLabel) NSLayoutConstraint.activate([ - nameLabel.heightAnchor.constraint(equalToConstant: 22).priority(.defaultHigh), + nameMetaLabel.heightAnchor.constraint(equalToConstant: 22).priority(.defaultHigh), ]) - titleContainerStackView.alignment = .firstBaseline titleContainerStackView.addArrangedSubview(nameTrialingDotLabel) titleContainerStackView.addArrangedSubview(dateLabel) - titleContainerStackView.addArrangedSubview(UIView()) // padding + let padding = UIView() + padding.translatesAutoresizingMaskIntoConstraints = false + titleContainerStackView.addArrangedSubview(padding) // padding titleContainerStackView.addArrangedSubview(visibilityImageView) - nameLabel.setContentHuggingPriority(.defaultHigh + 1, for: .horizontal) + nameMetaLabel.setContentHuggingPriority(.defaultHigh + 1, for: .horizontal) nameTrialingDotLabel.setContentHuggingPriority(.defaultHigh + 2, for: .horizontal) nameTrialingDotLabel.setContentCompressionResistancePriority(.required - 2, for: .horizontal) dateLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) - dateLabel.setContentCompressionResistancePriority(.required - 1, for: .horizontal) - visibilityImageView.setContentHuggingPriority(.required - 1, for: .horizontal) + dateLabel.setContentCompressionResistancePriority(.required - 10, for: .horizontal) + padding.setContentHuggingPriority(.defaultLow, for: .horizontal) + padding.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + visibilityImageView.setContentHuggingPriority(.required - 9, for: .horizontal) + visibilityImageView.setContentCompressionResistancePriority(.required - 9, for: .horizontal) visibilityImageView.setContentHuggingPriority(.required - 1, for: .vertical) - visibilityImageView.setContentCompressionResistancePriority(.required - 1, for: .horizontal) // subtitle container: [username] let subtitleContainerStackView = UIStackView() diff --git a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift index 508d928e1..3a186f00b 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift @@ -13,7 +13,7 @@ import CoreData import CoreDataStack import ActiveLabel import Meta -import MetaTextView +import MetaTextKit protocol StatusTableViewCellDelegate: AnyObject { var context: AppContext! { get }