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) {
|
override func buildMenu(with builder: UIMenuBuilder) {
|
||||||
|
super.buildMenu(with: builder)
|
||||||
|
|
||||||
if builder.system == .main {
|
if builder.system == .main {
|
||||||
MenuController.buildMainMenu(builder: builder)
|
MenuController.buildMainMenu(builder: builder)
|
||||||
|
@ -106,11 +107,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
return "compose"
|
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 let prevSubTabCommand = UIKeyCommand(title: "Previous Sub Tab", action: #selector(TabbedPageViewController.selectPrevPage), input: "[", modifierFlags: [.command, .shift])
|
||||||
|
|
||||||
static func buildMainMenu(builder: UIMenuBuilder) {
|
static func buildMainMenu(builder: UIMenuBuilder) {
|
||||||
builder.replace(menu: .file, with: buildFileMenu())
|
builder.insertChild(buildFileMenu(), atStartOfMenu: .file)
|
||||||
builder.insertChild(buildSubTabMenu(), atStartOfMenu: .view)
|
builder.insertChild(buildSubTabMenu(), atStartOfMenu: .view)
|
||||||
builder.insertChild(buildSidebarShortcuts(), atStartOfMenu: .view)
|
builder.insertChild(buildSidebarShortcuts(), atStartOfMenu: .view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func buildFileMenu() -> UIMenu {
|
private static func buildFileMenu() -> UIMenu {
|
||||||
return UIMenu(
|
return UIMenu(
|
||||||
title: "File",
|
title: "",
|
||||||
image: nil,
|
image: nil,
|
||||||
identifier: nil,
|
identifier: nil,
|
||||||
options: [],
|
options: .displayInline,
|
||||||
children: [
|
children: [
|
||||||
composeCommand,
|
composeCommand,
|
||||||
refreshCommand(discoverabilityTitle: nil),
|
refreshCommand(discoverabilityTitle: nil),
|
||||||
UIKeyCommand(title: "Close", action: #selector(AppDelegate.closeWindow), input: "w", modifierFlags: .command),
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,8 +226,6 @@ extension MastodonController {
|
||||||
draft.visibility = visibility
|
draft.visibility = visibility
|
||||||
draft.contentWarning = contentWarning
|
draft.contentWarning = contentWarning
|
||||||
draft.contentWarningEnabled = !contentWarning.isEmpty
|
draft.contentWarningEnabled = !contentWarning.isEmpty
|
||||||
|
|
||||||
DraftsManager.shared.add(draft)
|
|
||||||
return draft
|
return draft
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate {
|
||||||
@MainActor
|
@MainActor
|
||||||
private func fetchSavedHashtags() -> [SavedHashtag] {
|
private func fetchSavedHashtags() -> [SavedHashtag] {
|
||||||
let req = SavedHashtag.fetchRequest()
|
let req = SavedHashtag.fetchRequest()
|
||||||
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true, selector: #selector(NSString.localizedCompare(_:)))]
|
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)]
|
||||||
do {
|
do {
|
||||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -228,7 +228,7 @@ class MainSidebarViewController: UIViewController {
|
||||||
@MainActor
|
@MainActor
|
||||||
private func fetchSavedHashtags() -> [SavedHashtag] {
|
private func fetchSavedHashtags() -> [SavedHashtag] {
|
||||||
let req = SavedHashtag.fetchRequest()
|
let req = SavedHashtag.fetchRequest()
|
||||||
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true, selector: #selector(NSString.localizedCompare(_:)))]
|
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)]
|
||||||
do {
|
do {
|
||||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -78,11 +78,6 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
||||||
mutAttrString.trimTrailingCharactersInSet(.whitespacesAndNewlines)
|
mutAttrString.trimTrailingCharactersInSet(.whitespacesAndNewlines)
|
||||||
mutAttrString.collapseWhitespace()
|
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
|
self.attributedText = mutAttrString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,9 +99,7 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
||||||
|
|
||||||
switch node.tagName() {
|
switch node.tagName() {
|
||||||
case "br":
|
case "br":
|
||||||
// need to specify defaultFont here b/c otherwise it uses the default 12pt Helvetica which
|
attributed.append(NSAttributedString(string: "\n"))
|
||||||
// screws up its determination of the line height making multiple lines of emojis squash together
|
|
||||||
attributed.append(NSAttributedString(string: "\n", attributes: [.font: defaultFont]))
|
|
||||||
case "a":
|
case "a":
|
||||||
if let link = try? node.attr("href"),
|
if let link = try? node.attr("href"),
|
||||||
let webURL = WebURL(link),
|
let webURL = WebURL(link),
|
||||||
|
@ -114,7 +107,7 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
||||||
attributed.addAttribute(.link, value: url, range: attributed.fullRange)
|
attributed.addAttribute(.link, value: url, range: attributed.fullRange)
|
||||||
}
|
}
|
||||||
case "p":
|
case "p":
|
||||||
attributed.append(NSAttributedString(string: "\n\n", attributes: [.font: defaultFont]))
|
attributed.append(NSAttributedString(string: "\n\n"))
|
||||||
case "em", "i":
|
case "em", "i":
|
||||||
let currentFont: UIFont
|
let currentFont: UIFont
|
||||||
if attributed.length == 0 {
|
if attributed.length == 0 {
|
||||||
|
@ -136,11 +129,11 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
||||||
case "code":
|
case "code":
|
||||||
attributed.addAttribute(.font, value: UIFont.monospacedSystemFont(ofSize: defaultFont.pointSize, weight: .regular), range: attributed.fullRange)
|
attributed.addAttribute(.font, value: UIFont.monospacedSystemFont(ofSize: defaultFont.pointSize, weight: .regular), range: attributed.fullRange)
|
||||||
case "pre":
|
case "pre":
|
||||||
attributed.append(NSAttributedString(string: "\n\n"))
|
|
||||||
attributed.addAttribute(.font, value: UIFont.monospacedSystemFont(ofSize: defaultFont.pointSize, weight: .regular), range: attributed.fullRange)
|
attributed.addAttribute(.font, value: UIFont.monospacedSystemFont(ofSize: defaultFont.pointSize, weight: .regular), range: attributed.fullRange)
|
||||||
case "ol", "ul":
|
|
||||||
attributed.append(NSAttributedString(string: "\n\n"))
|
attributed.append(NSAttributedString(string: "\n\n"))
|
||||||
|
case "ol", "ul":
|
||||||
attributed.trimLeadingCharactersInSet(.whitespacesAndNewlines)
|
attributed.trimLeadingCharactersInSet(.whitespacesAndNewlines)
|
||||||
|
attributed.append(NSAttributedString(string: "\n\n"))
|
||||||
case "li":
|
case "li":
|
||||||
let parentEl = node.parent()!
|
let parentEl = node.parent()!
|
||||||
let parentTag = parentEl.tagName()
|
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
|
// 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)])
|
bullet = NSAttributedString(string: "\(index + 1).\t", attributes: [.font: UIFont.monospacedDigitSystemFont(ofSize: defaultFont.pointSize, weight: .regular)])
|
||||||
} else if parentTag == "ul" {
|
} else if parentTag == "ul" {
|
||||||
bullet = NSAttributedString(string: "\u{2022}\t", attributes: [.font: defaultFont])
|
bullet = NSAttributedString(string: "\u{2022}\t")
|
||||||
} else {
|
} else {
|
||||||
bullet = NSAttributedString()
|
bullet = NSAttributedString()
|
||||||
}
|
}
|
||||||
attributed.insert(bullet, at: 0)
|
attributed.insert(bullet, at: 0)
|
||||||
attributed.append(NSAttributedString(string: "\n", attributes: [.font: defaultFont]))
|
attributed.append(NSAttributedString(string: "\n"))
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue