Compare commits

...

89 Commits

Author SHA1 Message Date
Duraid Abdul 74556927be Fix crash when invoking keyboard early 2022-10-15 12:49:16 -06:00
Duraid Abdul fee9e30df9 Fix simulator crash 2022-10-15 12:48:52 -06:00
Duraid Abdul 5e2b5feca4 Fix blocked touches on iPad 2022-10-15 12:48:23 -06:00
Duraid Abdul 3ffdde8904 Fix Xcode 13 build failure 2022-09-20 10:39:18 -06:00
Duraid Abdul 63ebc8ed31 Fix border view frame 2022-09-18 23:39:48 -06:00
Duraid Abdul 64e18b18fc Fix keybaord avoidance 2022-09-18 23:31:00 -06:00
Duraid Abdul 9dcfa5accd iPhone 14 Pro support 2022-09-18 21:05:11 -06:00
Duraid Abdul adbb2d763f Update README.md 2022-05-14 19:15:47 -07:00
Duraid Abdul c08c26f4a7 Update README.md 2022-05-14 19:15:18 -07:00
Duraid Abdul d995119198 Update LCManager.swift 2022-02-01 12:26:52 -08:00
Duraid Abdul b4d7c06432 Update LCManager.swift 2022-01-26 21:02:54 -08:00
Duraid Abdul a7b95a4379 Update LCManager.swift 2022-01-26 02:18:26 -08:00
Duraid Abdul 3efe25f804 Update LCManager.swift 2022-01-25 17:15:30 -08:00
Duraid Abdul 0a3e28b28f Animation Improvements 2022-01-24 23:09:49 -08:00
Duraid Abdul 009fab95be UserDefaults Support
Signed-off-by: Duraid Abdul <duraidabdul@users.noreply.github.com>
2022-01-24 19:06:49 -08:00
Duraid Abdul a1275a7f49 Update LCManager.swift 2022-01-22 00:09:49 -08:00
Duraid Abdul e08d439d2b Various Improvements 2022-01-22 00:06:35 -08:00
Duraid Abdul da9d78f559 Merge branch 'main' of https://github.com/duraidabdul/LocalConsole 2022-01-21 12:47:53 -08:00
Duraid Abdul 50e4ce4e03 Update LCManager.swift 2022-01-21 12:47:50 -08:00
Duraid Abdul ae73be37b4 Update README.md 2022-01-17 12:08:39 -08:00
Duraid Abdul eeece2fda8 Update LCManager.swift
Fix for touch passthrough.
2021-12-26 00:39:38 -08:00
Duraid Abdul 01ee69b8c5 iPad Support, Landscape Support on iPhone
Full support for iPad screen sizes and screen rotation on all devices.
2021-12-26 00:27:32 -08:00
Duraid Abdul 72d9b1fbd5 Update LCManager.swift 2021-11-20 01:06:15 -07:00
Duraid Abdul b435de87a2 Add FrameRateRequest 2021-11-11 20:28:16 -08:00
Duraid Abdul 372c8ce90b Update LCManager.swift 2021-10-16 17:40:08 -06:00
Duraid Abdul 0d36867f6b Reduced top endpoint padding 2021-09-12 12:58:57 -06:00
Duraid Abdul 3fff6edff0 Revert to cached position on resize 2021-09-12 12:29:03 -06:00
Duraid Abdul 485126dcf7 Update LCManager.swift 2021-09-11 10:02:25 -06:00
Duraid Abdul 245d69679d Merge branch 'main' of https://github.com/duraidabdul/LocalConsole into main 2021-09-06 16:50:03 -06:00
Duraid Abdul 7920272bff Update LCManager.swift 2021-09-06 16:49:56 -06:00
Duraid Abdul 6892a19b0e Update README.md 2021-09-05 12:22:18 -06:00
Duraid Abdul d2d45f8e03 Update LCManager.swift 2021-09-05 12:00:49 -06:00
Duraid Abdul d5a06c013e Update LCManager.swift 2021-09-05 11:49:50 -06:00
Duraid Abdul 3c2683c6bf Update LCManager.swift 2021-09-01 19:04:56 -06:00
Duraid Abdul fd1114802f Update LCManager.swift 2021-09-01 18:53:40 -06:00
Duraid Abdul afe572f4e3 Merge branch 'main' of https://github.com/duraidabdul/LocalConsole into main 2021-09-01 18:35:57 -06:00
Duraid Abdul ceb5ed0a0c Update LCManager.swift 2021-09-01 18:35:54 -06:00
Duraid Abdul 9189fa4173 Update README.md 2021-08-28 18:24:03 -07:00
Duraid Abdul 1e39b362cc Update LCManager.swift 2021-08-28 02:02:22 -07:00
Duraid Abdul 265eaeadad Update LCManager.swift
Code maintenance, fix for grabber long press bug.
2021-08-28 01:49:03 -07:00
Duraid Abdul cf0d3beb76 Update ResizeController.swift 2021-08-27 14:15:28 -07:00
Duraid Abdul ec386069a2 Update LCManager.swift 2021-08-27 14:04:56 -07:00
Duraid Abdul ab36ae5bb8 Update LCManager.swift
Fix keyboard avoidance, improve view states throughout interaction.
2021-08-27 12:39:48 -07:00
Duraid Abdul e6846048d0 Console hiding animation refinements 2021-08-27 01:58:06 -07:00
Duraid Abdul d6d9aad082 @available fix 2021-08-26 23:59:12 -07:00
Duraid Abdul 6723947fe6 Update LCManager.swift 2021-08-26 23:42:41 -07:00
Duraid Abdul 24a7a197b0 Hide Console Interaction
Added interaction and animations for hiding console away
2021-08-26 23:41:53 -07:00
Duraid Abdul ab79c1200f Update LCManager.swift
Fix for some potential issues that could be caused by initializing LCManager off the main queue, and improved the console text view's ability to stick to the bottom if it is scrolled to the bottom.
2021-08-16 11:40:35 -07:00
Duraid Abdul 0ae97b8162 Update LCManager.swift 2021-08-02 12:39:49 -07:00
Duraid Abdul 4b79e2744d Update LCManager.swift 2021-08-01 20:30:11 -07:00
Duraid Abdul 641e20bb01 Update LCManager.swift 2021-08-01 20:19:15 -07:00
Duraid Abdul bc6c4a91ba Merge branch 'main' of https://github.com/duraidabdul/LocalConsole into main 2021-08-01 20:14:08 -07:00
Duraid Abdul 82605fcfbb Improve systemReport() 2021-08-01 20:14:05 -07:00
Duraid Abdul 27876dfba9 Update README.md 2021-07-27 01:05:06 -07:00
Duraid Abdul 1a2da892ac Merge pull request #6 from NoahFetz/main
Fix Xcode 13 beta 3 extension error
2021-07-27 00:57:51 -07:00
Noah Fetz c9bfed3373 Merge pull request #1 from NoahFetz/fix
[Fix] Xcode 13B3 Extension unavailable
2021-07-26 08:57:06 +02:00
Noah Fetz 3f732f5054 [Fix] Xcode 13B3 Extension unavailable 2021-07-26 08:49:51 +02:00
Duraid Abdul 33de7eb54a Merge pull request #5 from duraidabdul/add-license-1
Create LICENSE
2021-07-24 18:17:45 -07:00
Duraid Abdul bad02ce90b Create LICENSE 2021-07-24 18:17:27 -07:00
Duraid Abdul c2cdc1c822 Split Strings 2021-07-20 13:24:34 -07:00
Duraid Abdul 61ed2d92db Performance improvements 2021-07-20 13:02:41 -07:00
Duraid Abdul a522748e3c Merge branch 'main' of https://github.com/duraidabdul/LocalConsole into main 2021-06-22 10:56:58 -07:00
Duraid Abdul 58aecf3a9d Update LCManager.swift 2021-06-22 10:56:56 -07:00
Duraid Abdul 971de252bf Delete Additional Files directory 2021-06-15 12:14:04 -07:00
Duraid Abdul ef0bd6cd8a Offload Demo files 2021-06-15 12:13:45 -07:00
Duraid Abdul 5f8c210c62 Update LCManager.swift
Improved debug border implementation.
2021-06-12 14:36:27 -07:00
Duraid Abdul 0bbfabc568 Reverse text in console, brand new debug. 2021-06-10 11:48:37 -07:00
Duraid Abdul 157ab2153f Delete Demo_Test.gif 2021-06-04 13:09:21 -07:00
Duraid Abdul 51ddd6c2c2 Delete Demo_test2.gif 2021-06-04 13:09:14 -07:00
Duraid Abdul c5a5641906 Update README.md 2021-06-04 13:08:59 -07:00
Duraid Abdul cbbbf2c6db Update README.md 2021-06-04 13:08:25 -07:00
Duraid Abdul a75c5763a4 Update README.md 2021-06-04 13:06:53 -07:00
Duraid Abdul a66afaef04 Update README.md 2021-06-04 13:04:54 -07:00
Duraid Abdul 7ca52868ff Add files via upload 2021-06-04 13:04:38 -07:00
Duraid Abdul 417bdf2fb3 Add files via upload 2021-06-04 13:02:41 -07:00
Duraid Abdul 92299c62de Delete Demo_Test.gif 2021-06-04 13:01:30 -07:00
Duraid Abdul 22cd8d12ff Update README.md 2021-06-04 12:59:44 -07:00
Duraid Abdul de62ed79af Add files via upload 2021-06-04 12:58:32 -07:00
Duraid Abdul 261ba2a83b Update README.md 2021-06-04 12:43:30 -07:00
Duraid Abdul 697d636cbc Update README.md 2021-06-04 12:42:59 -07:00
Duraid Abdul cdbb4fef4d Update README.md 2021-06-04 12:42:32 -07:00
Duraid Abdul dea5e6e4e0 Update README.md 2021-06-04 12:40:55 -07:00
Duraid Abdul b28605e52e Merge branch 'main' of https://github.com/duraidabdul/LocalConsole into main 2021-06-03 16:27:47 -07:00
Duraid Abdul 35a5350f17 Update LCManager.swift 2021-06-03 16:27:43 -07:00
Duraid Abdul b319499056 Merge pull request #3 from hxperl/add-uicolor-context
🎨 Add UIColor context to fix CI Build compile
2021-06-02 22:12:51 -07:00
hxperl 17d30ad554 🎨 Add UIColor context to fix CI Build compile 2021-06-03 13:09:15 +09:00
Duraid Abdul b56d27ff26 Add OS Compile Date to System Report 2021-06-01 14:46:05 -07:00
Duraid Abdul c7fe1daf26 Update System Report
Reorganized system report code for readability. Added some more valued to the system report.
2021-06-01 14:17:25 -07:00
Duraid Abdul 6db60e25b2 Asynchronous System Report 2021-05-31 21:24:23 -07:00
8 changed files with 1410 additions and 282 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 MiB

+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Duraid Abdul
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+13 -19
View File
@@ -3,8 +3,8 @@
Welcome to LocalConsole! This Swift Package makes on-device debugging easy with a convenient PiP-style console that can display items in the same way ```print()``` will in Xcode. This tool can also dynamically display view frames and restart SpringBoard right from your live app.
<div>
<img src="https://github.com/duraidabdul/LocalConsole/blob/main/Additional%20Files/Demo_Pan.gif?raw=true" width="320">
<img src="https://github.com/duraidabdul/LocalConsole/blob/main/Additional%20Files/Demo_Resize.gif?raw=true" width="320">
<img src="https://github.com/duraidabdul/Demos/blob/main/Demo_Pan.gif?raw=true" width="320">
<img src="https://github.com/duraidabdul/Demos/blob/main/Demo_Resize.gif?raw=true" width="320">
</div>
## **Setup**
@@ -13,42 +13,36 @@ Welcome to LocalConsole! This Swift Package makes on-device debugging easy with
2. Paste the following into the URL field: https://github.com/duraidabdul/LocalConsole/
3. Once the package dependancy has been added, import LocalConsole and create an easily accessible global instance of ```Console.shared```.
3. Once the package dependancy has been added, import LocalConsole and create an easily accessible global instance of ```LCManager.shared```.
```swift
import LocalConsole
let localConsoleManager = LCManager.shared
let consoleManager = LCManager.shared
```
## **Usage**
Once prepared, the localConsole can be used throughout your project.
Once prepared, the consoleManager can be used throughout your project.
```swift
// Show the console view.
localConsoleManager.isVisible = true
// Activate the console view.
consoleManager.isVisible = true
// Hide the console view.
localConsoleManager.isVisible = false
// Deactivate the console view.
consoleManager.isVisible = false
```
```swift
// Print items to the console view.
localConsoleManager.print("Hello, world!")
consoleManager.print("Hello, world!")
// Clear console text.
localConsoleManager.clear()
consoleManager.clear()
// Copy console text.
localConsoleManager.copy()
consoleManager.copy()
```
```swift
// Change the console view font size.
localConsoleManager.fontSize = 5
consoleManager.fontSize = 5
```
## **To-Do**
* Support for iOS 13
* Screen edge console hiding
* Make console view reactive to landscape/portrait switch
+1
View File
@@ -22,6 +22,7 @@ extension UIScreen {
static var hasRoundedCorners = UIScreen.main.value(forKey: "_" + "display" + "Corner" + "Radius") as! CGFloat > 0
}
@available(iOSApplicationExtension, unavailable)
extension UIApplication {
var statusBarHeight: CGFloat {
if let window = UIApplication.shared.windows.first {
File diff suppressed because it is too large Load Diff
+126 -38
View File
@@ -7,15 +7,20 @@
import UIKit
@available(iOSApplicationExtension, unavailable)
class ResizeController {
public static let shared = ResizeController()
lazy var platterView = PlatterView(frame: .zero)
lazy var consoleCenterPoint = CGPoint(x: (UIScreen.main.nativeBounds.width / 2).rounded() / UIScreen.main.scale,
y: (UIScreen.main.nativeBounds.height / 2).rounded() / UIScreen.main.scale
+ (UIScreen.hasRoundedCorners ? 0 : 24))
var consoleCenterPoint: CGPoint {
let containerViewSize = LCManager.shared.viewController.view.frame.size
return CGPoint(x: (containerViewSize.width * UIScreen.main.scale / 2).rounded() / UIScreen.main.scale,
y: (containerViewSize.height * UIScreen.main.scale / 2).rounded() / UIScreen.main.scale
+ (UIScreen.hasRoundedCorners ? 0 : 24))
}
lazy var consoleOutlineView: UIView = {
@@ -114,8 +119,20 @@ class ResizeController {
// Ensure initial autolayout is performed unanimated.
LCManager.shared.consoleWindow?.layoutIfNeeded()
if #available(iOS 15, *) {
FrameRateRequest.shared.perform(duration: 1.5)
}
if isActive {
UIViewPropertyAnimator(duration: 0.75, dampingRatio: 1) {
let textView = LCManager.shared.consoleTextView
textView.contentOffset.y = textView.contentSize.height - textView.bounds.size.height
}.startAnimation()
if LCManager.shared.consoleView.traitCollection.userInterfaceStyle == .light {
LCManager.shared.consoleView.layer.shadowOpacity = 0.25
}
@@ -161,7 +178,7 @@ class ResizeController {
LCManager.shared.consoleView.layer.shadowOpacity = 0.5
UIViewPropertyAnimator(duration: 0.6, dampingRatio: 1) {
LCManager.shared.consoleView.center = LCManager.shared.possibleEndpoints.first!
LCManager.shared.snapToCachedEndpoint()
// Update grabbers (layout constraints)
LCManager.shared.consoleWindow?.layoutIfNeeded()
@@ -189,15 +206,25 @@ class ResizeController {
var initialHeight = CGFloat.zero
static let kMinConsoleHeight: CGFloat = 108
static let kMaxConsoleHeight: CGFloat = 346
var verticalPanner_frameRateRequestID: UUID?
@objc func verticalPanner(recognizer: UIPanGestureRecognizer) {
let translation = recognizer.translation(in: bottomGrabber.superview)
let maxHeight: CGFloat = 346
let minHeight: CGFloat = 108
let minHeight = Self.kMinConsoleHeight
let maxHeight = Self.kMaxConsoleHeight
switch recognizer.state {
case .began:
if #available(iOS 15, *) {
verticalPanner_frameRateRequestID = UUID()
FrameRateRequest.shared.activate(id: verticalPanner_frameRateRequestID!)
}
initialHeight = LCManager.shared.consoleSize.height
UIViewPropertyAnimator(duration: 0.4, dampingRatio: 1) { [self] in
@@ -224,16 +251,27 @@ class ResizeController {
}
}()
LCManager.shared.lumaHeightAnchor.constant = resolvedHeight
LCManager.shared.consoleSize.height = resolvedHeight
LCManager.shared.consoleView.center.y = consoleCenterPoint.y
case .ended, .cancelled:
if #available(iOS 15, *), let id = verticalPanner_frameRateRequestID {
verticalPanner_frameRateRequestID = nil
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
FrameRateRequest.shared.deactivate(id: id)
}
}
UIViewPropertyAnimator(duration: 0.4, dampingRatio: 0.7) {
if LCManager.shared.consoleSize.height > maxHeight {
LCManager.shared.consoleSize.height = maxHeight
LCManager.shared.lumaHeightAnchor.constant = maxHeight
}
if LCManager.shared.consoleSize.height < minHeight {
LCManager.shared.consoleSize.height = minHeight
LCManager.shared.lumaHeightAnchor.constant = minHeight
}
LCManager.shared.consoleView.center.y = self.consoleCenterPoint.y
@@ -252,17 +290,25 @@ class ResizeController {
var initialWidth = CGFloat.zero
static let kMaxConsoleWidth: CGFloat = UIScreen.portraitSize.width - 56
static let kMinConsoleWidth: CGFloat = 112
static let kMaxConsoleWidth: CGFloat = [UIScreen.portraitSize.width, UIScreen.portraitSize.height].min()! - 56
var horizontalPanner_frameRateRequestID: UUID?
@objc func horizontalPanner(recognizer: UIPanGestureRecognizer) {
let translation = recognizer.translation(in: bottomGrabber.superview)
let maxWidth: CGFloat = Self.kMaxConsoleWidth
let minWidth: CGFloat = 112
let minWidth = Self.kMinConsoleWidth
let maxWidth = Self.kMaxConsoleWidth
switch recognizer.state {
case .began:
if #available(iOS 15, *) {
horizontalPanner_frameRateRequestID = UUID()
FrameRateRequest.shared.activate(id: horizontalPanner_frameRateRequestID!)
}
initialWidth = LCManager.shared.consoleSize.width
UIViewPropertyAnimator(duration: 0.4, dampingRatio: 1) { [self] in
@@ -294,6 +340,13 @@ class ResizeController {
case .ended, .cancelled:
if #available(iOS 15, *), let id = horizontalPanner_frameRateRequestID {
horizontalPanner_frameRateRequestID = nil
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
FrameRateRequest.shared.deactivate(id: id)
}
}
UIViewPropertyAnimator(duration: 0.4, dampingRatio: 0.7) {
if LCManager.shared.consoleSize.width > maxWidth {
LCManager.shared.consoleSize.width = maxWidth
@@ -317,17 +370,12 @@ class ResizeController {
}
}
@available(iOSApplicationExtension, unavailable)
class PlatterView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.frame.size = UIScreen.portraitSize
// Make sure bottom doesn't show on upwards pan.
self.frame.size.height += 50
self.frame.origin = possibleEndpoints[1]
autoresizingMask = [.flexibleWidth, .flexibleHeight]
layer.shadowRadius = 10
layer.shadowOpacity = 0.125
layer.shadowOffset = CGSize(width: 0, height: 0)
@@ -344,11 +392,12 @@ class PlatterView: UIView {
blurView.clipsToBounds = true
blurView.frame = bounds
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
addSubview(blurView)
LCManager.shared.consoleWindow?.addSubview(self)
LCManager.shared.consoleWindow?.sendSubviewToBack(self)
LCManager.shared.viewController.view.addSubview(self)
LCManager.shared.viewController.view.sendSubviewToBack(self)
_ = backgroundButton
@@ -359,7 +408,7 @@ class PlatterView: UIView {
let grabber = UIView()
grabber.frame.size = CGSize(width: 36, height: 5)
grabber.frame.origin.y = 10
grabber.center.x = bounds.width / 2
grabber.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin]
grabber.backgroundColor = .label
grabber.alpha = 0.1
grabber.layer.cornerRadius = 2.5
@@ -370,29 +419,45 @@ class PlatterView: UIView {
titleLabel.text = "Resize Console"
titleLabel.font = .systemFont(ofSize: 30, weight: .bold)
titleLabel.sizeToFit()
titleLabel.center.x = bounds.width / 2
titleLabel.frame.origin.y = 28
titleLabel.roundOriginToPixel()
titleLabel.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin]
addSubview(titleLabel)
let subtitleLabel = UILabel()
subtitleLabel.text = "Use the grabbers to resize the console."
subtitleLabel.font = .systemFont(ofSize: 17, weight: .medium)
subtitleLabel.sizeToFit()
subtitleLabel.alpha = 0.5
subtitleLabel.center.x = bounds.width / 2
subtitleLabel.frame.origin.y = titleLabel.frame.maxY + 8
subtitleLabel.roundOriginToPixel()
subtitleLabel.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin]
addSubview(subtitleLabel)
addSubview(resetButton)
resetButton.center = CGPoint(x: UIScreen.portraitSize.width / 2 - 74,
y: UIScreen.portraitSize.height - possibleEndpoints[0].y * 2)
resetButton.roundOriginToPixel()
let buttonContainerView = UIView()
buttonContainerView.addSubview(resetButton)
buttonContainerView.addSubview(doneButton)
addSubview(buttonContainerView)
addSubview(doneButton)
doneButton.center = CGPoint(x: UIScreen.portraitSize.width / 2 + 74,
y: UIScreen.portraitSize.height - possibleEndpoints[0].y * 2)
doneButton.roundOriginToPixel()
buttonContainerView.translatesAutoresizingMaskIntoConstraints = false
resetButton.translatesAutoresizingMaskIntoConstraints = false
doneButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
buttonContainerView.widthAnchor.constraint(equalToConstant: 264),
buttonContainerView.heightAnchor.constraint(equalToConstant: 52),
buttonContainerView.centerXAnchor.constraint(equalTo: centerXAnchor),
buttonContainerView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -possibleEndpoints[0].y * 2),
resetButton.widthAnchor.constraint(equalToConstant: 116),
resetButton.heightAnchor.constraint(equalToConstant: 52),
resetButton.leadingAnchor.constraint(equalTo: buttonContainerView.leadingAnchor),
resetButton.topAnchor.constraint(equalTo: buttonContainerView.topAnchor),
doneButton.widthAnchor.constraint(equalToConstant: 116),
doneButton.heightAnchor.constraint(equalToConstant: 52),
doneButton.trailingAnchor.constraint(equalTo: buttonContainerView.trailingAnchor),
doneButton.topAnchor.constraint(equalTo: buttonContainerView.topAnchor)
])
}
lazy var backgroundButton: UIButton = {
@@ -408,11 +473,10 @@ class PlatterView: UIView {
lazy var doneButton: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = .systemBlue.resolvedColor(with: UITraitCollection(userInterfaceStyle: .dark))
button.backgroundColor = UIColor.systemBlue.resolvedColor(with: UITraitCollection(userInterfaceStyle: .dark))
button.setTitle("Done", for: .normal)
button.setTitleColor(.white, for: .normal)
button.titleLabel?.font = .systemFont(ofSize: 17, weight: .medium)
button.frame.size = CGSize(width: 116, height: 52)
button.layer.cornerRadius = 20
button.layer.cornerCurve = .continuous
@@ -447,7 +511,6 @@ class PlatterView: UIView {
button.setTitle("Reset", for: .normal)
button.setTitleColor(.label, for: .normal)
button.titleLabel?.font = .systemFont(ofSize: 17, weight: .medium)
button.frame.size = CGSize(width: 116, height: 52)
button.layer.cornerRadius = 20
button.layer.cornerCurve = .continuous
@@ -455,11 +518,12 @@ class PlatterView: UIView {
// Resolves a text view frame animation bug that occurs when *decreasing* text view width.
if LCManager.shared.consoleSize.width > LCManager.shared.defaultConsoleSize.width {
LCManager.shared.consoleTextView.frame.size.width = LCManager.shared.defaultConsoleSize.width
LCManager.shared.consoleTextView.frame.size.width = LCManager.shared.defaultConsoleSize.width - 4
}
UIViewPropertyAnimator(duration: 0.4, dampingRatio: 1) {
LCManager.shared.consoleSize = LCManager.shared.defaultConsoleSize
LCManager.shared.lumaHeightAnchor.constant = LCManager.shared.defaultConsoleSize.height
LCManager.shared.consoleView.center = ResizeController.shared.consoleCenterPoint
LCManager.shared.consoleWindow?.layoutIfNeeded()
}.startAnimation()
@@ -479,18 +543,35 @@ class PlatterView: UIView {
return button
}()
func configureFrame() {
self.frame.size = LCManager.shared.viewController.view.frame.size
// Make sure bottom doesn't show on upwards pan.
self.frame.size.height += 50
self.frame.origin = possibleEndpoints[1]
autoresizingMask = [.flexibleWidth, .flexibleHeight]
}
func reveal() {
configureFrame()
UIViewPropertyAnimator(duration: 0.6, dampingRatio: 1) {
self.frame.origin = self.possibleEndpoints[0]
}.startAnimation()
backgroundButton.isHidden = false
isHidden = false
}
func dismiss() {
UIViewPropertyAnimator(duration: 0.6, dampingRatio: 1) {
let animator = UIViewPropertyAnimator(duration: 0.6, dampingRatio: 1) {
self.frame.origin = self.possibleEndpoints[1]
}.startAnimation()
}
animator.addCompletion { _ in
self.isHidden = true
}
animator.startAnimation()
backgroundButton.isHidden = true
}
@@ -511,7 +592,9 @@ class PlatterView: UIView {
fatalError("init(coder:) has not been implemented")
}
lazy var possibleEndpoints = [CGPoint(x: 0, y: (UIScreen.hasRoundedCorners ? 44 : -8) + 63), CGPoint(x: 0, y: UIScreen.portraitSize.height + 5)]
var possibleEndpoints: [CGPoint] { return [CGPoint(x: 0, y: (UIScreen.hasRoundedCorners ? 44 : -8) + 63),
CGPoint(x: 0, y: LCManager.shared.viewController.view.frame.size.height + 5)]
}
var initialPlatterOriginY = CGFloat.zero
@@ -593,15 +676,20 @@ class PlatterView: UIView {
$0.transform = .identity
}
}
positionAnimator.startAnimation()
if nearestTargetPosition == possibleEndpoints[1] {
ResizeController.shared.isActive = false
backgroundButton.isHidden = true
positionAnimator.addCompletion { _ in
self.isHidden = true
}
} else {
ResizeController.shared.isActive = true
}
positionAnimator.startAnimation()
default: break
}
}
+108
View File
@@ -0,0 +1,108 @@
//
// SystemReport.swift
// LocalConsole
//
// Created by Duraid Abdul on 2021-06-01.
//
import Foundation
import MachO
class SystemReport {
static let shared = SystemReport()
var versionString: String {
ProcessInfo.processInfo.operatingSystemVersionString
.replacingOccurrences(of: "Build ", with: "")
.replacingOccurrences(of: "Version ", with: "")
}
// Current device thermal state.
var thermalState: String {
let state = ProcessInfo.processInfo.thermalState
switch state {
case .nominal: return "Nominal"
case .fair : return "Fair"
case .serious : return "Serious"
case .critical : return "Critical"
default: return "Unknown"
}
}
// Retrieve device mobile gestalt cache.
lazy var gestaltCacheExtra: NSDictionary? = {
let url = URL(fileURLWithPath: "/pri" + "vate/va" + "r/containe" + "rs/Shared/Sys" + "temGroup/sys" + "temgroup.com.apple.mobilegestal" + "tcache/Libr" + "ary/Ca" + "ches/com.app" + "le.MobileGes" + "talt.plist")
let dictionary = NSDictionary(contentsOf: url)
return dictionary?.value(forKey: "CacheE" + "xtra") as? NSDictionary
}()
// Device marketing name.
lazy var gestaltMarketingName: Any = gestaltCacheExtra?.value(forKey: "Z/dqyWS6OZ" + "TRy10UcmUAhw") ?? "Unknown"
// iBoot (second-stage loader) version.
lazy var gestaltFirmwareVersion: Any = gestaltCacheExtra?.value(forKey: "LeSRsiLoJC" + "Mhjn6nd6GWbQ") ?? "Unknown"
// CPU architecture.
lazy var gestaltArchitecture: Any = gestaltCacheExtra?.value(forKey: "k7QIBwZJJO" + "Vw+Sej/8h8VA") ?? deviceArchitecture
// Fallback in case gestaltArchitecture doesn't return a value.
var deviceArchitecture: String {
let info = NXGetLocalArchInfo()
return String(utf8String: (info?.pointee.description)!) ?? "Unknown"
}
lazy var gestaltModelIdentifier: Any = gestaltCacheExtra?.value(forKey: "h9jDsbgj7xI" + "VeIQ8S3/X3Q") ?? modelIdentifier
// Fallback in case gestaltModelIdentifier doesn't return a value.
var modelIdentifier: String {
if let simulatorModelIdentifier = ProcessInfo().environment["SIMULATOR_MO" + "DEL_IDENTIFIER"] { return simulatorModelIdentifier }
var sysinfo = utsname()
uname(&sysinfo) // ignore return value
return String(bytes: Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)), encoding: .ascii)?.trimmingCharacters(in: .controlCharacters) ?? "Unknown"
}
var kernel: String {
var size = 0
sysctlbyname("ker" + "n.os" + "type", nil, &size, nil, 0)
var string = [CChar](repeating: 0, count: Int(size))
sysctlbyname("ker" + "n.os" + "type", &string, &size, nil, 0)
return String(cString: string)
}
var kernelVersion: String {
var size = 0
sysctlbyname("ker" + "n.os" + "release", nil, &size, nil, 0)
var string = [CChar](repeating: 0, count: Int(size))
sysctlbyname("ker" + "n.os" + "release", &string, &size, nil, 0)
return String(cString: string)
}
var compileDate: String {
var size = 0
sysctlbyname("ker" + "n.ve" + "rsion", nil, &size, nil, 0)
var string = [CChar](repeating: 0, count: Int(size))
sysctlbyname("ker" + "n.ve" + "rsion", &string, &size, nil, 0)
let fullString = String(cString: string) /// Ex: Darwin Kernel Version 20.6.0: Mon May 10 03:15:29 PDT 2021; root:xnu-7195.140.13.0.1~20/RELEASE_ARM64_T8101
let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.date.rawValue)
if let matches = detector?.matches(in: fullString, options: [], range: NSRange(location: 0, length: fullString.utf16.count)) {
for match in matches {
if let date = match.date {
let dateformatter = DateFormatter()
dateformatter.dateStyle = .medium
return dateformatter.string(from: date)
}
}
}
return "Unknown"
}
}