Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

불필요한 기능 숨김 처리 및 스크롤 버그 수정 #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions Sources/LocalConsole/LCManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
consoleView.layer.shadowOffset = CGSize(width: 0, height: 2)
consoleView.alpha = 0

consoleView.layer.cornerRadius = 24
consoleView.layer.cornerRadius = 20
consoleView.layer.cornerCurve = .continuous

let _ = lumaView
Expand All @@ -297,7 +297,9 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
consoleTextView.textContainerInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)

consoleTextView.isSelectable = false
consoleTextView.showsVerticalScrollIndicator = false
consoleTextView.indicatorStyle = .white
consoleTextView.showsVerticalScrollIndicator = true
consoleTextView.scrollIndicatorInsets = UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 0)
consoleTextView.contentInsetAdjustmentBehavior = .never
consoleView.addSubview(consoleTextView)

Expand Down Expand Up @@ -817,8 +819,8 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
if consoleTextView.contentOffset.y > consoleTextView.contentSize.height - consoleTextView.bounds.size.height - 20 {

// Weird, weird fix that makes the scroll view bottom pinning system work.
consoleTextView.isScrollEnabled.toggle()
consoleTextView.isScrollEnabled.toggle()
// consoleTextView.isScrollEnabled.toggle()
// consoleTextView.isScrollEnabled.toggle()

consoleTextView.pendingOffsetChange = true
}
Expand All @@ -841,7 +843,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
.font: UIFont.systemFont(ofSize: fontSize, weight: .semibold, design: .monospaced)
]

consoleTextView.attributedText = NSAttributedString(string: string, attributes: attributes)
consoleTextView.setAttributedText(NSAttributedString(string: string, attributes: attributes))
}

// Displays all UserDefaults keys, including unneeded keys that are included by default.
Expand Down Expand Up @@ -872,6 +874,10 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
}
}

let hide = UIAction(title: "Hide Console", image: UIImage(systemName: "eye.slash")) { [weak self] _ in
self?.isVisible = false
}

// If device is phone in landscape, disable resize controller.
if UIDevice.current.userInterfaceIdiom == .phone && consoleViewController.view.frame.width > consoleViewController.view.frame.height {
resize.attributes = .disabled
Expand Down Expand Up @@ -1074,24 +1080,25 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {

debugActions.append(contentsOf: [viewFrames, systemReport, displayReport])
let destructActions = [terminateApplication , respring]

let debugMenu = UIMenu(
title: "Debug", image: UIImage(systemName: "ant"),
children: [
UIMenu(title: "", options: .displayInline, children: debugActions),
UIMenu(title: "", options: .displayInline, children: destructActions),
]
)

// 디버그 메뉴 숨김 처리
// let debugMenu = UIMenu(
// title: "Debug", image: UIImage(systemName: "ant"),
// children: [
// UIMenu(title: "", options: .displayInline, children: debugActions),
// UIMenu(title: "", options: .displayInline, children: destructActions),
// ]
// )

var menuContent: [UIMenuElement] = []

if consoleTextView.text != "" {
menuContent.append(contentsOf: [UIMenu(title: "", options: .displayInline, children: [share, resize])])
menuContent.append(contentsOf: [UIMenu(title: "", options: .displayInline, children: [share, resize, hide])])
} else {
menuContent.append(UIMenu(title: "", options: .displayInline, children: [resize]))
menuContent.append(UIMenu(title: "", options: .displayInline, children: [resize, hide]))
}

menuContent.append(debugMenu)
// menuContent.append(debugMenu)
if let customMenu = menu {
menuContent.append(customMenu)
}
Expand Down Expand Up @@ -1469,13 +1476,20 @@ class LumaView: UIView {
class InvertedTextView: UITextView {

var pendingOffsetChange = false


func setAttributedText(_ attributedText: NSAttributedString) {
self.attributedText = attributedText
self.layoutIfNeeded()
}

// Thanks to WWDC21 UIKit Lab!
override func layoutSubviews() {
super.layoutSubviews()

if panGestureRecognizer.numberOfTouches == 0 && pendingOffsetChange {
contentOffset.y = contentSize.height - bounds.size.height
DispatchQueue.main.async {
self.contentOffset.y = self.contentSize.height - self.bounds.size.height
}
} else {
pendingOffsetChange = false
}
Expand Down