Compare commits

..

1 Commits

Author SHA1 Message Date
Duraid Abdul 80e0aa6168 Fix context menu presentation warning and overlapping modals 2022-10-19 12:12:30 -06:00
+18 -44
View File
@@ -278,11 +278,9 @@ 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
@@ -340,17 +338,13 @@ 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.8)
menuButton.tintColor = UIColor(white: 1, alpha: 0.75)
menuButton.menu = makeMenu()
menuButton.showsMenuAsPrimaryAction = true
consoleView.addSubview(menuButton)
@@ -496,14 +490,8 @@ 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 }
@@ -525,7 +513,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
lumaWidthAnchor.constant = -34
lumaHeightAnchor.constant = 96
UIViewPropertyAnimator(duration: 0.4, dampingRatio: 1) { [self] in
lumaView.layer.cornerRadius = 10
lumaView.layer.cornerRadius = 9
consoleView.layoutIfNeeded()
}.startAnimation(afterDelay: 0.06)
@@ -848,22 +836,13 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
public var showAllUserDefaultsKeys = false
func makeMenu() -> UIMenu {
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 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 resize = UIAction(title: "Resize Console", image: UIImage(systemName: "arrow.up.backward.and.arrow.down.forward")) { _ in
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
@@ -915,9 +894,9 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
}()
if keys.isEmpty {
actions.append(
UIAction(title: "No Entries", attributes: .disabled, handler: { _ in })
)
actions.append(UIAction(title: "No Entries",
image: nil, attributes: .disabled, handler: { _ in }
))
} else {
for key in keys.sorted(by: { $0.lowercased() < $1.lowercased() }) {
@@ -1090,12 +1069,7 @@ 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]))
}