Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c5d5e018a | |||
| 6413eb8a81 |
@@ -278,9 +278,11 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
|
||||
let borderWidth = 2 - 1 / consoleView.traitCollection.displayScale
|
||||
|
||||
borderView.frame = CGRect(x: -borderWidth, y: -borderWidth,
|
||||
width: consoleSize.width + 2 * borderWidth,
|
||||
height: consoleSize.height + 2 * borderWidth)
|
||||
borderView.frame = CGRect(
|
||||
x: -borderWidth, y: -borderWidth,
|
||||
width: consoleSize.width + 2 * borderWidth,
|
||||
height: consoleSize.height + 2 * borderWidth
|
||||
)
|
||||
borderView.layer.borderWidth = borderWidth
|
||||
borderView.layer.borderColor = UIColor(white: 1, alpha: 0.08).cgColor
|
||||
borderView.layer.cornerRadius = consoleView.layer.cornerRadius + 1
|
||||
@@ -338,13 +340,17 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
circle.isUserInteractionEnabled = false
|
||||
menuButton.addSubview(circle)
|
||||
|
||||
let ellipsisImage = UIImageView(image: UIImage(systemName: "ellipsis",
|
||||
withConfiguration: UIImage.SymbolConfiguration(pointSize: 18, weight: .medium)))
|
||||
let ellipsisImage = UIImageView(
|
||||
image: UIImage(
|
||||
systemName: "ellipsis",
|
||||
withConfiguration: UIImage.SymbolConfiguration(pointSize: 18, weight: .medium)
|
||||
)
|
||||
)
|
||||
ellipsisImage.frame.size = circle.bounds.size
|
||||
ellipsisImage.contentMode = .center
|
||||
circle.addSubview(ellipsisImage)
|
||||
|
||||
menuButton.tintColor = UIColor(white: 1, alpha: 0.75)
|
||||
menuButton.tintColor = UIColor(white: 1, alpha: 0.8)
|
||||
menuButton.menu = makeMenu()
|
||||
menuButton.showsMenuAsPrimaryAction = true
|
||||
consoleView.addSubview(menuButton)
|
||||
@@ -490,8 +496,14 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// Specify a UIMenu or UIAction to be included in the console's main menu.
|
||||
public var menu: UIMenuElement? = nil {
|
||||
didSet {
|
||||
menuButton.menu = makeMenu()
|
||||
}
|
||||
}
|
||||
|
||||
var grabberMode: Bool = false {
|
||||
|
||||
didSet {
|
||||
guard oldValue != grabberMode else { return }
|
||||
|
||||
@@ -513,7 +525,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
lumaWidthAnchor.constant = -34
|
||||
lumaHeightAnchor.constant = 96
|
||||
UIViewPropertyAnimator(duration: 0.4, dampingRatio: 1) { [self] in
|
||||
lumaView.layer.cornerRadius = 9
|
||||
lumaView.layer.cornerRadius = 10
|
||||
consoleView.layoutIfNeeded()
|
||||
}.startAnimation(afterDelay: 0.06)
|
||||
|
||||
@@ -836,13 +848,22 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
public var showAllUserDefaultsKeys = false
|
||||
|
||||
func makeMenu() -> UIMenu {
|
||||
let share = UIAction(title: "Share Text...", image: UIImage(systemName: "square.and.arrow.up")) { _ in
|
||||
let activityViewController = UIActivityViewController(
|
||||
activityItems: [self.consoleTextView.text ?? ""],
|
||||
applicationActivities: nil
|
||||
)
|
||||
self.consoleViewController.present(activityViewController, animated: true)
|
||||
}
|
||||
let share: UIAction = {
|
||||
// Something here causes a crash < iOS 15. Fall back to copy text for iOS 15 and below.
|
||||
if #available(iOS 16, *) {
|
||||
return UIAction(title: "Share Text...", image: UIImage(systemName: "square.and.arrow.up")) { _ in
|
||||
let activityViewController = UIActivityViewController(
|
||||
activityItems: [self.consoleTextView.text ?? ""],
|
||||
applicationActivities: nil
|
||||
)
|
||||
self.consoleViewController.present(activityViewController, animated: true)
|
||||
}
|
||||
} else {
|
||||
return UIAction(title: "Copy Text", image: UIImage(systemName: "doc.on.doc")) { _ in
|
||||
UIPasteboard.general.string = self.consoleTextView.text
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
let resize = UIAction(title: "Resize Console", image: UIImage(systemName: "arrow.up.backward.and.arrow.down.forward")) { _ in
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
@@ -894,9 +915,9 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
}()
|
||||
|
||||
if keys.isEmpty {
|
||||
actions.append(UIAction(title: "No Entries",
|
||||
image: nil, attributes: .disabled, handler: { _ in }
|
||||
))
|
||||
actions.append(
|
||||
UIAction(title: "No Entries", attributes: .disabled, handler: { _ in })
|
||||
)
|
||||
} else {
|
||||
for key in keys.sorted(by: { $0.lowercased() < $1.lowercased() }) {
|
||||
|
||||
@@ -1069,7 +1090,12 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
} else {
|
||||
menuContent.append(UIMenu(title: "", options: .displayInline, children: [resize]))
|
||||
}
|
||||
|
||||
menuContent.append(debugMenu)
|
||||
if let customMenu = menu {
|
||||
menuContent.append(customMenu)
|
||||
}
|
||||
|
||||
if consoleTextView.text != "" {
|
||||
menuContent.append(UIMenu(title: "", options: .displayInline, children: [clear]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user