Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 74556927be | |||
| fee9e30df9 | |||
| 5e2b5feca4 | |||
| 3ffdde8904 | |||
| 63ebc8ed31 | |||
| 64e18b18fc |
@@ -162,7 +162,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
|
||||
/// Gesture endpoints. Each point represents a corner of the screen. TODO: Handle screen rotation.
|
||||
var possibleEndpoints: [CGPoint] {
|
||||
guard let consoleWindow else { return [] }
|
||||
guard let consoleWindow = consoleWindow else { return [] }
|
||||
|
||||
let screenSize = viewController.view.frame.size
|
||||
|
||||
@@ -185,7 +185,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
let leftEndpointX = consoleSize.width / 2 + consoleWindow.safeAreaInsets.left + (isLandscapePhone ? 4 : 12) + (isLandscapeRightNotchedPhone ? -16 : 0)
|
||||
let rightEndpointX = screenSize.width - (consoleSize.width / 2 + consoleWindow.safeAreaInsets.right) - (isLandscapePhone ? 4 : 12) + (isLandscapeLeftNotchedPhone ? 16 : 0)
|
||||
let topEndpointY = consoleSize.height / 2 + consoleWindow.safeAreaInsets.top + 12 + (isPortraitNotchedPhone ? -10 : 0)
|
||||
let bottomEndpointY = screenSize.height - (consoleSize.height / 2 + consoleWindow.safeAreaInsets.bottom) - 12 + (isLandscapePhone ? 10 : 0)
|
||||
let bottomEndpointY = screenSize.height - consoleSize.height / 2 - (keyboardHeight ?? consoleWindow.safeAreaInsets.bottom) - 12 + (isLandscapePhone ? 10 : 0)
|
||||
|
||||
if consoleSize.width < screenSize.width - 112 {
|
||||
// Four endpoints, one for each corner.
|
||||
@@ -280,10 +280,12 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
|
||||
let _ = lumaView
|
||||
|
||||
borderView.frame = CGRect(x: -1, y: -1,
|
||||
width: consoleSize.width + 2,
|
||||
height: consoleSize.height + 2)
|
||||
borderView.layer.borderWidth = 2 - 1 / consoleView.traitCollection.displayScale
|
||||
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.layer.borderWidth = borderWidth
|
||||
borderView.layer.borderColor = UIColor(white: 1, alpha: 0.08).cgColor
|
||||
borderView.layer.cornerRadius = consoleView.layer.cornerRadius + 1
|
||||
borderView.layer.cornerCurve = .continuous
|
||||
@@ -578,10 +580,9 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
// MARK: Handle keyboard show/hide.
|
||||
private var keyboardHeight: CGFloat? = nil {
|
||||
didSet {
|
||||
|
||||
temporaryKeyboardHeightValueTracker = oldValue
|
||||
|
||||
if consoleView.center != possibleEndpoints[0] && consoleView.center != possibleEndpoints[1] {
|
||||
if possibleEndpoints.count > 2, consoleView.center != possibleEndpoints[0] && consoleView.center != possibleEndpoints[1] {
|
||||
let nearestTargetPosition = nearestTargetTo(consoleView.center, possibleTargets: possibleEndpoints.suffix(2))
|
||||
|
||||
UIViewPropertyAnimator(duration: 0.55, dampingRatio: 1) {
|
||||
@@ -1177,28 +1178,19 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
|
||||
// Custom window for the console to appear above other windows while passing touches down.
|
||||
class ConsoleWindow: UIWindow {
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
|
||||
if let hitView = super.hitTest(point, with: event) {
|
||||
return hitView.isKind(of: ConsoleWindow.self) ? nil : hitView
|
||||
}
|
||||
return super.hitTest(point, with: event)
|
||||
}
|
||||
}
|
||||
|
||||
// Custom view for the console to appear above other windows while passing touches down.
|
||||
class PassthroughView: UIView {
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
|
||||
if let hitView = super.hitTest(point, with: event) {
|
||||
return hitView.isKind(of: PassthroughView.self) ? nil : hitView
|
||||
if hitView.isKind(of: PassthroughView.self) {
|
||||
return nil
|
||||
}
|
||||
return hitView
|
||||
}
|
||||
return super.hitTest(point, with: event)
|
||||
}
|
||||
}
|
||||
|
||||
// Custom view that is passed through if it is the returned hitTest for ConsoleWindow.
|
||||
class PassthroughView: UIView { }
|
||||
|
||||
import UIKit.UIGestureRecognizerSubclass
|
||||
|
||||
@@ -1278,41 +1270,56 @@ class SwizzleTool: NSObject {
|
||||
class LumaView: UIView {
|
||||
lazy var visualEffectView: UIView = {
|
||||
Bundle(path: "/Sys" + "tem/Lib" + "rary/Private" + "Framework" + "s/Material" + "Kit." + "framework")!.load()
|
||||
|
||||
let Pill = NSClassFromString("MT" + "Luma" + "Dodge" + "Pill" + "View") as! UIView.Type
|
||||
|
||||
let pillView = Pill.init()
|
||||
|
||||
enum Style: Int {
|
||||
case none = 0
|
||||
case thin = 1
|
||||
case gray = 2
|
||||
case black = 3
|
||||
case white = 4
|
||||
|
||||
if let Pill = NSClassFromString("MT" + "Luma" + "Dodge" + "Pill" + "View") as? UIView.Type {
|
||||
|
||||
let pillView = Pill.init()
|
||||
|
||||
enum Style: Int {
|
||||
case none = 0
|
||||
case thin = 1
|
||||
case gray = 2
|
||||
case black = 3
|
||||
case white = 4
|
||||
}
|
||||
|
||||
enum BackgroundLuminance: Int {
|
||||
case unknown = 0
|
||||
case dark = 1
|
||||
case light = 2
|
||||
}
|
||||
|
||||
pillView.setValue(2, forKey: "style")
|
||||
pillView.setValue(1, forKey: "background" + "Luminance")
|
||||
pillView.perform(NSSelectorFromString("_" + "update" + "Style"))
|
||||
|
||||
addSubview(pillView)
|
||||
|
||||
pillView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
pillView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
pillView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
pillView.topAnchor.constraint(equalTo: topAnchor),
|
||||
pillView.bottomAnchor.constraint(equalTo: bottomAnchor)
|
||||
])
|
||||
|
||||
return pillView
|
||||
} else {
|
||||
let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterialDark))
|
||||
addSubview(visualEffectView)
|
||||
|
||||
visualEffectView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
visualEffectView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
visualEffectView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
visualEffectView.topAnchor.constraint(equalTo: topAnchor),
|
||||
visualEffectView.bottomAnchor.constraint(equalTo: bottomAnchor)
|
||||
])
|
||||
|
||||
return visualEffectView
|
||||
}
|
||||
|
||||
enum BackgroundLuminance: Int {
|
||||
case unknown = 0
|
||||
case dark = 1
|
||||
case light = 2
|
||||
}
|
||||
|
||||
pillView.setValue(2, forKey: "style")
|
||||
pillView.setValue(1, forKey: "background" + "Luminance")
|
||||
pillView.perform(NSSelectorFromString("_" + "update" + "Style"))
|
||||
|
||||
addSubview(pillView)
|
||||
|
||||
pillView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
pillView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
pillView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
pillView.topAnchor.constraint(equalTo: topAnchor),
|
||||
pillView.bottomAnchor.constraint(equalTo: bottomAnchor)
|
||||
])
|
||||
|
||||
return pillView
|
||||
}()
|
||||
|
||||
lazy var foregroundView: UIView = {
|
||||
|
||||
Reference in New Issue
Block a user