Compare commits
4 Commits
ecab33bdce
...
98516e3802
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 98516e3802 | |
Shadowfacts | 68b03838a2 | |
Shadowfacts | 1f0025b101 | |
Shadowfacts | b46f007f64 |
|
@ -67,7 +67,6 @@ 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)
|
||||||
|
@ -107,4 +106,11 @@ 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,20 +52,21 @@ 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.insertChild(buildFileMenu(), atStartOfMenu: .file)
|
builder.replace(menu: .file, with: buildFileMenu())
|
||||||
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: "",
|
title: "File",
|
||||||
image: nil,
|
image: nil,
|
||||||
identifier: nil,
|
identifier: nil,
|
||||||
options: .displayInline,
|
options: [],
|
||||||
children: [
|
children: [
|
||||||
composeCommand,
|
composeCommand,
|
||||||
refreshCommand(discoverabilityTitle: nil),
|
refreshCommand(discoverabilityTitle: nil),
|
||||||
|
UIKeyCommand(title: "Close", action: #selector(AppDelegate.closeWindow), input: "w", modifierFlags: .command),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,8 @@ 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)]
|
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true, selector: #selector(NSString.localizedCompare(_:)))]
|
||||||
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)]
|
req.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true, selector: #selector(NSString.localizedCompare(_:)))]
|
||||||
do {
|
do {
|
||||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -78,6 +78,11 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +104,9 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
||||||
|
|
||||||
switch node.tagName() {
|
switch node.tagName() {
|
||||||
case "br":
|
case "br":
|
||||||
attributed.append(NSAttributedString(string: "\n"))
|
// 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]))
|
||||||
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),
|
||||||
|
@ -107,7 +114,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"))
|
attributed.append(NSAttributedString(string: "\n\n", attributes: [.font: defaultFont]))
|
||||||
case "em", "i":
|
case "em", "i":
|
||||||
let currentFont: UIFont
|
let currentFont: UIFont
|
||||||
if attributed.length == 0 {
|
if attributed.length == 0 {
|
||||||
|
@ -129,11 +136,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)
|
||||||
attributed.append(NSAttributedString(string: "\n\n"))
|
|
||||||
case "ol", "ul":
|
case "ol", "ul":
|
||||||
attributed.trimLeadingCharactersInSet(.whitespacesAndNewlines)
|
|
||||||
attributed.append(NSAttributedString(string: "\n\n"))
|
attributed.append(NSAttributedString(string: "\n\n"))
|
||||||
|
attributed.trimLeadingCharactersInSet(.whitespacesAndNewlines)
|
||||||
case "li":
|
case "li":
|
||||||
let parentEl = node.parent()!
|
let parentEl = node.parent()!
|
||||||
let parentTag = parentEl.tagName()
|
let parentTag = parentEl.tagName()
|
||||||
|
@ -143,12 +150,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")
|
bullet = NSAttributedString(string: "\u{2022}\t", attributes: [.font: defaultFont])
|
||||||
} else {
|
} else {
|
||||||
bullet = NSAttributedString()
|
bullet = NSAttributedString()
|
||||||
}
|
}
|
||||||
attributed.insert(bullet, at: 0)
|
attributed.insert(bullet, at: 0)
|
||||||
attributed.append(NSAttributedString(string: "\n"))
|
attributed.append(NSAttributedString(string: "\n", attributes: [.font: defaultFont]))
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue