Compare commits
No commits in common. "98516e3802b3739177d5d595544cb6e935e0e90c" and "ecab33bdce122dd7dc7a69d7a97c6f8393e9e3ce" have entirely different histories.
98516e3802
...
ecab33bdce
|
@ -67,6 +67,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
}
|
||||
|
||||
override func buildMenu(with builder: UIMenuBuilder) {
|
||||
super.buildMenu(with: builder)
|
||||
|
||||
if builder.system == .main {
|
||||
MenuController.buildMainMenu(builder: builder)
|
||||
|
@ -106,11 +107,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
return "compose"
|
||||
}
|
||||
}
|
||||
|
||||
@objc func closeWindow() {
|
||||
guard let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) else {
|
||||
return
|
||||
}
|
||||
UIApplication.shared.requestSceneSessionDestruction(scene.session, options: nil)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,21 +52,20 @@ struct MenuController {
|
|||
static let prevSubTabCommand = UIKeyCommand(title: "Previous Sub Tab", action: #selector(TabbedPageViewController.selectPrevPage), input: "[", modifierFlags: [.command, .shift])
|
||||
|
||||
static func buildMainMenu(builder: UIMenuBuilder) {
|
||||
builder.replace(menu: .file, with: buildFileMenu())
|
||||
builder.insertChild(buildFileMenu(), atStartOfMenu: .file)
|
||||
builder.insertChild(buildSubTabMenu(), atStartOfMenu: .view)
|
||||
builder.insertChild(buildSidebarShortcuts(), atStartOfMenu: .view)
|
||||
}
|
||||
|
||||
private static func buildFileMenu() -> UIMenu {
|
||||
return UIMenu(
|
||||
title: "File",
|
||||
title: "",
|
||||
image: nil,
|
||||
identifier: nil,
|
||||
options: [],
|
||||
options: .displayInline,
|
||||
children: [
|
||||
composeCommand,
|
||||
refreshCommand(discoverabilityTitle: nil),
|
||||
UIKeyCommand(title: "Close", action: #selector(AppDelegate.closeWindow), input: "w", modifierFlags: .command),
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
|
@ -226,8 +226,6 @@ extension MastodonController {
|
|||
draft.visibility = visibility
|
||||
draft.contentWarning = contentWarning
|
||||
draft.contentWarningEnabled = !contentWarning.isEmpty
|
||||
|
||||
DraftsManager.shared.add(draft)
|
||||
return draft
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate {
|
|||
@MainActor
|
||||
private func fetchSavedHashtags() -> [SavedHashtag] {
|
||||
let req = SavedHashtag.fetchRequest()
|
||||
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true, selector: #selector(NSString.localizedCompare(_:)))]
|
||||
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)]
|
||||
do {
|
||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
||||
} catch {
|
||||
|
|
|
@ -228,7 +228,7 @@ class MainSidebarViewController: UIViewController {
|
|||
@MainActor
|
||||
private func fetchSavedHashtags() -> [SavedHashtag] {
|
||||
let req = SavedHashtag.fetchRequest()
|
||||
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true, selector: #selector(NSString.localizedCompare(_:)))]
|
||||
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)]
|
||||
do {
|
||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
||||
} catch {
|
||||
|
|
|
@ -78,11 +78,6 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
|||
mutAttrString.trimTrailingCharactersInSet(.whitespacesAndNewlines)
|
||||
mutAttrString.collapseWhitespace()
|
||||
|
||||
let style = NSMutableParagraphStyle()
|
||||
// 2 points is enough that it doesn't make things look weirdly spaced out, but leaves a slight gap when there are multiple lines of emojis
|
||||
style.lineSpacing = 2
|
||||
mutAttrString.addAttribute(.paragraphStyle, value: style, range: mutAttrString.fullRange)
|
||||
|
||||
self.attributedText = mutAttrString
|
||||
}
|
||||
|
||||
|
@ -104,9 +99,7 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
|||
|
||||
switch node.tagName() {
|
||||
case "br":
|
||||
// need to specify defaultFont here b/c otherwise it uses the default 12pt Helvetica which
|
||||
// screws up its determination of the line height making multiple lines of emojis squash together
|
||||
attributed.append(NSAttributedString(string: "\n", attributes: [.font: defaultFont]))
|
||||
attributed.append(NSAttributedString(string: "\n"))
|
||||
case "a":
|
||||
if let link = try? node.attr("href"),
|
||||
let webURL = WebURL(link),
|
||||
|
@ -114,7 +107,7 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
|||
attributed.addAttribute(.link, value: url, range: attributed.fullRange)
|
||||
}
|
||||
case "p":
|
||||
attributed.append(NSAttributedString(string: "\n\n", attributes: [.font: defaultFont]))
|
||||
attributed.append(NSAttributedString(string: "\n\n"))
|
||||
case "em", "i":
|
||||
let currentFont: UIFont
|
||||
if attributed.length == 0 {
|
||||
|
@ -136,11 +129,11 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
|||
case "code":
|
||||
attributed.addAttribute(.font, value: UIFont.monospacedSystemFont(ofSize: defaultFont.pointSize, weight: .regular), range: attributed.fullRange)
|
||||
case "pre":
|
||||
attributed.append(NSAttributedString(string: "\n\n"))
|
||||
attributed.addAttribute(.font, value: UIFont.monospacedSystemFont(ofSize: defaultFont.pointSize, weight: .regular), range: attributed.fullRange)
|
||||
case "ol", "ul":
|
||||
attributed.append(NSAttributedString(string: "\n\n"))
|
||||
case "ol", "ul":
|
||||
attributed.trimLeadingCharactersInSet(.whitespacesAndNewlines)
|
||||
attributed.append(NSAttributedString(string: "\n\n"))
|
||||
case "li":
|
||||
let parentEl = node.parent()!
|
||||
let parentTag = parentEl.tagName()
|
||||
|
@ -150,12 +143,12 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
|||
// we use the monospace digit font so that the periods of all the list items line up
|
||||
bullet = NSAttributedString(string: "\(index + 1).\t", attributes: [.font: UIFont.monospacedDigitSystemFont(ofSize: defaultFont.pointSize, weight: .regular)])
|
||||
} else if parentTag == "ul" {
|
||||
bullet = NSAttributedString(string: "\u{2022}\t", attributes: [.font: defaultFont])
|
||||
bullet = NSAttributedString(string: "\u{2022}\t")
|
||||
} else {
|
||||
bullet = NSAttributedString()
|
||||
}
|
||||
attributed.insert(bullet, at: 0)
|
||||
attributed.append(NSAttributedString(string: "\n", attributes: [.font: defaultFont]))
|
||||
attributed.append(NSAttributedString(string: "\n"))
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue