Compare commits

..

No commits in common. "af2d9e7eb85f3d167566aa008172bd0ecd7dde9c" and "1a767ff9103ae5b7fae2e3a5e78969b41819b786" have entirely different histories.

4 changed files with 16 additions and 28 deletions

View File

@ -10,12 +10,11 @@ import Foundation
import Pachyderm import Pachyderm
struct InstanceFeatures { struct InstanceFeatures {
private static let pleromaVersionRegex = try! NSRegularExpression(pattern: "\\(compatible; pleroma (.*)\\)", options: .caseInsensitive) private static let pleromaVersionRegex = try! NSRegularExpression(pattern: "\\(compatible; Pleroma (.*)\\)")
private(set) var instanceType = InstanceType.mastodon private(set) var instanceType = InstanceType.mastodon
private(set) var version: Version? private(set) var version: Version?
private(set) var pleromaVersion: Version? private(set) var pleromaVersion: Version?
private(set) var hometownVersion: Version?
private(set) var maxStatusChars = 500 private(set) var maxStatusChars = 500
var localOnlyPosts: Bool { var localOnlyPosts: Bool {
@ -31,7 +30,7 @@ struct InstanceFeatures {
} }
var boostToOriginalAudience: Bool { var boostToOriginalAudience: Bool {
instanceType == .pleroma || instanceType.isMastodon instanceType == .pleroma || instanceType == .mastodon
} }
var profilePinnedStatuses: Bool { var profilePinnedStatuses: Bool {
@ -39,15 +38,15 @@ struct InstanceFeatures {
} }
var trends: Bool { var trends: Bool {
instanceType.isMastodon instanceType == .mastodon
} }
var trendingStatusesAndLinks: Bool { var trendingStatusesAndLinks: Bool {
instanceType.isMastodon && hasVersion(3, 5, 0) instanceType == .mastodon && hasVersion(3, 5, 0)
} }
var reblogVisibility: Bool { var reblogVisibility: Bool {
(instanceType.isMastodon && hasVersion(2, 8, 0)) (instanceType == .mastodon && hasVersion(2, 8, 0))
|| (instanceType == .pleroma && hasPleromaVersion(2, 0, 0)) || (instanceType == .pleroma && hasPleromaVersion(2, 0, 0))
} }
@ -56,31 +55,24 @@ struct InstanceFeatures {
} }
mutating func update(instance: Instance, nodeInfo: NodeInfo?) { mutating func update(instance: Instance, nodeInfo: NodeInfo?) {
var version: Version?
let ver = instance.version.lowercased() let ver = instance.version.lowercased()
if ver.contains("glitch") { if ver.contains("glitch") {
instanceType = .glitch instanceType = .glitch
} else if nodeInfo?.software.name == "hometown" { } else if nodeInfo?.software.name == "hometown" {
instanceType = .hometown instanceType = .hometown
// like "1.0.6+3.5.2"
let parts = ver.split(separator: "+")
if parts.count == 2 {
version = Version(string: String(parts[1]))
hometownVersion = Version(string: String(parts[0]))
}
} else if ver.contains("pleroma") { } else if ver.contains("pleroma") {
instanceType = .pleroma instanceType = .pleroma
if let match = InstanceFeatures.pleromaVersionRegex.firstMatch(in: ver, range: NSRange(location: 0, length: ver.utf16.count)) {
pleromaVersion = Version(string: (ver as NSString).substring(with: match.range(at: 1)))
}
} else if ver.contains("pixelfed") { } else if ver.contains("pixelfed") {
instanceType = .pixelfed instanceType = .pixelfed
} else { } else {
instanceType = .mastodon instanceType = .mastodon
} }
self.version = version ?? Version(string: ver) version = Version(string: ver)
if let match = InstanceFeatures.pleromaVersionRegex.firstMatch(in: ver, range: NSRange(location: 0, length: ver.utf16.count)) {
pleromaVersion = Version(string: (ver as NSString).substring(with: match.range(at: 1)))
}
maxStatusChars = instance.maxStatusCharacters ?? 500 maxStatusChars = instance.maxStatusCharacters ?? 500
} }

View File

@ -50,7 +50,7 @@ class ReblogService {
} }
} else { } else {
image = nil image = nil
reblogVisibilityActions = nil reblogVisibilityActions = []
} }
let preview = ConfirmReblogStatusPreviewView(status: status) let preview = ConfirmReblogStatusPreviewView(status: status)

View File

@ -76,7 +76,6 @@ class CustomAlertController: UIViewController {
let titleLabel = UILabel() let titleLabel = UILabel()
titleLabel.text = config.title titleLabel.text = config.title
titleLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0) titleLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0)
titleLabel.adjustsFontForContentSizeCategory = true
titleLabel.numberOfLines = 0 titleLabel.numberOfLines = 0
titleLabel.textAlignment = .center titleLabel.textAlignment = .center
stack.addArrangedSubview(titleLabel) stack.addArrangedSubview(titleLabel)
@ -362,14 +361,13 @@ class CustomAlertActionButton: UIControl {
let label = UILabel() let label = UILabel()
label.text = title label.text = title
label.textColor = .tintColor label.textColor = .tintColor
label.adjustsFontForContentSizeCategory = true switch action.style {
if case .cancel = action.style { case .cancel:
label.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0) label.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0)
} else { case .destructive:
label.font = .preferredFont(forTextStyle: .body)
}
if case .destructive = action.style {
label.textColor = .systemRed label.textColor = .systemRed
default:
break
} }
titleView.addArrangedSubview(label) titleView.addArrangedSubview(label)
} }

View File

@ -55,7 +55,6 @@ class ConfirmReblogStatusPreviewView: UIView {
let displayNameLabel = EmojiLabel() let displayNameLabel = EmojiLabel()
displayNameLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .caption1).addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]), size: 0) displayNameLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .caption1).addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]), size: 0)
displayNameLabel.adjustsFontSizeToFitWidth = true displayNameLabel.adjustsFontSizeToFitWidth = true
displayNameLabel.adjustsFontForContentSizeCategory = true
displayNameLabel.updateForAccountDisplayName(account: status.account) displayNameLabel.updateForAccountDisplayName(account: status.account)
vStack.addArrangedSubview(displayNameLabel) vStack.addArrangedSubview(displayNameLabel)
@ -65,7 +64,6 @@ class ConfirmReblogStatusPreviewView: UIView {
contentView.isScrollEnabled = false contentView.isScrollEnabled = false
contentView.backgroundColor = nil contentView.backgroundColor = nil
contentView.textContainerInset = .zero contentView.textContainerInset = .zero
contentView.adjustsFontForContentSizeCategory = true
// remove the extra line spacing applied by StatusContentTextView because, since we're using a smaller font, the regular 2pt looks big // remove the extra line spacing applied by StatusContentTextView because, since we're using a smaller font, the regular 2pt looks big
contentView.paragraphStyle = .default contentView.paragraphStyle = .default
// TODO: line limit // TODO: line limit