Compare commits
No commits in common. "af2d9e7eb85f3d167566aa008172bd0ecd7dde9c" and "1a767ff9103ae5b7fae2e3a5e78969b41819b786" have entirely different histories.
af2d9e7eb8
...
1a767ff910
|
@ -10,12 +10,11 @@ import Foundation
|
|||
import Pachyderm
|
||||
|
||||
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 version: Version?
|
||||
private(set) var pleromaVersion: Version?
|
||||
private(set) var hometownVersion: Version?
|
||||
private(set) var maxStatusChars = 500
|
||||
|
||||
var localOnlyPosts: Bool {
|
||||
|
@ -31,7 +30,7 @@ struct InstanceFeatures {
|
|||
}
|
||||
|
||||
var boostToOriginalAudience: Bool {
|
||||
instanceType == .pleroma || instanceType.isMastodon
|
||||
instanceType == .pleroma || instanceType == .mastodon
|
||||
}
|
||||
|
||||
var profilePinnedStatuses: Bool {
|
||||
|
@ -39,15 +38,15 @@ struct InstanceFeatures {
|
|||
}
|
||||
|
||||
var trends: Bool {
|
||||
instanceType.isMastodon
|
||||
instanceType == .mastodon
|
||||
}
|
||||
|
||||
var trendingStatusesAndLinks: Bool {
|
||||
instanceType.isMastodon && hasVersion(3, 5, 0)
|
||||
instanceType == .mastodon && hasVersion(3, 5, 0)
|
||||
}
|
||||
|
||||
var reblogVisibility: Bool {
|
||||
(instanceType.isMastodon && hasVersion(2, 8, 0))
|
||||
(instanceType == .mastodon && hasVersion(2, 8, 0))
|
||||
|| (instanceType == .pleroma && hasPleromaVersion(2, 0, 0))
|
||||
}
|
||||
|
||||
|
@ -56,31 +55,24 @@ struct InstanceFeatures {
|
|||
}
|
||||
|
||||
mutating func update(instance: Instance, nodeInfo: NodeInfo?) {
|
||||
var version: Version?
|
||||
|
||||
let ver = instance.version.lowercased()
|
||||
if ver.contains("glitch") {
|
||||
instanceType = .glitch
|
||||
} else if nodeInfo?.software.name == "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") {
|
||||
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") {
|
||||
instanceType = .pixelfed
|
||||
} else {
|
||||
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
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class ReblogService {
|
|||
}
|
||||
} else {
|
||||
image = nil
|
||||
reblogVisibilityActions = nil
|
||||
reblogVisibilityActions = []
|
||||
}
|
||||
|
||||
let preview = ConfirmReblogStatusPreviewView(status: status)
|
||||
|
|
|
@ -76,7 +76,6 @@ class CustomAlertController: UIViewController {
|
|||
let titleLabel = UILabel()
|
||||
titleLabel.text = config.title
|
||||
titleLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0)
|
||||
titleLabel.adjustsFontForContentSizeCategory = true
|
||||
titleLabel.numberOfLines = 0
|
||||
titleLabel.textAlignment = .center
|
||||
stack.addArrangedSubview(titleLabel)
|
||||
|
@ -362,14 +361,13 @@ class CustomAlertActionButton: UIControl {
|
|||
let label = UILabel()
|
||||
label.text = title
|
||||
label.textColor = .tintColor
|
||||
label.adjustsFontForContentSizeCategory = true
|
||||
if case .cancel = action.style {
|
||||
switch action.style {
|
||||
case .cancel:
|
||||
label.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0)
|
||||
} else {
|
||||
label.font = .preferredFont(forTextStyle: .body)
|
||||
}
|
||||
if case .destructive = action.style {
|
||||
case .destructive:
|
||||
label.textColor = .systemRed
|
||||
default:
|
||||
break
|
||||
}
|
||||
titleView.addArrangedSubview(label)
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ class ConfirmReblogStatusPreviewView: UIView {
|
|||
let displayNameLabel = EmojiLabel()
|
||||
displayNameLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .caption1).addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]), size: 0)
|
||||
displayNameLabel.adjustsFontSizeToFitWidth = true
|
||||
displayNameLabel.adjustsFontForContentSizeCategory = true
|
||||
displayNameLabel.updateForAccountDisplayName(account: status.account)
|
||||
vStack.addArrangedSubview(displayNameLabel)
|
||||
|
||||
|
@ -65,7 +64,6 @@ class ConfirmReblogStatusPreviewView: UIView {
|
|||
contentView.isScrollEnabled = false
|
||||
contentView.backgroundColor = nil
|
||||
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
|
||||
contentView.paragraphStyle = .default
|
||||
// TODO: line limit
|
||||
|
|
Loading…
Reference in New Issue