-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Rename `ShyView` to `SecureContainerView` - Add `ShyView` properyWrapper - Add `runtimeWarning` `IncompatibilityHandler` - Add SwiftUI support - Update example - Add swiftpackageindex docc docs - Update CI workflow - Update podspec
- Loading branch information
1 parent
4ac1d92
commit af4b080
Showing
28 changed files
with
814 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
version: 1 | ||
builder: | ||
- platform: ios | ||
documentation_targets: [ShyView] | ||
swift_version: 5.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
test-ios: | ||
xcodebuild \ | ||
-scheme ShyView \ | ||
-destination platform="iOS Simulator,name=iPhone 14 Pro,OS=16.0" \ | ||
-destination platform="iOS Simulator,name=iPhone 15 Pro,OS=17.0" \ | ||
test | xcpretty && exit 0 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Source: https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Internal/RuntimeWarnings.swift | ||
|
||
import Foundation | ||
|
||
extension Notification.Name { | ||
public static let runtimeWarning = Self("ShyView.runtimeWarning") | ||
} | ||
|
||
@_transparent | ||
@usableFromInline | ||
@inline(__always) | ||
func runtimeWarn( | ||
_ message: @autoclosure () -> String, | ||
category: String? = "ShyView" | ||
) { | ||
#if DEBUG | ||
let message = message() | ||
NotificationCenter.default.post( | ||
name: .runtimeWarning, | ||
object: nil, | ||
userInfo: ["message": message] | ||
) | ||
let category = category ?? "Runtime Warning" | ||
|
||
#if canImport(os) | ||
os_log( | ||
.fault, | ||
dso: dso, | ||
log: OSLog(subsystem: "com.apple.runtime-issues", category: category), | ||
"%@", | ||
message | ||
) | ||
#else | ||
fputs("\(formatter.string(from: Date())) [\(category)] \(message)\n", stderr) | ||
#endif | ||
#endif | ||
} | ||
|
||
#if DEBUG | ||
|
||
#if canImport(os) | ||
import os | ||
|
||
// NB: Xcode runtime warnings offer a much better experience than traditional assertions and | ||
// breakpoints, but Apple provides no means of creating custom runtime warnings ourselves. | ||
// To work around this, we hook into SwiftUI's runtime issue delivery mechanism, instead. | ||
// | ||
// Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc | ||
@usableFromInline | ||
let dso = { () -> UnsafeMutableRawPointer in | ||
let count = _dyld_image_count() | ||
for i in 0..<count { | ||
if let name = _dyld_get_image_name(i) { | ||
let swiftString = String(cString: name) | ||
if swiftString.hasSuffix("/SwiftUI") { | ||
if let header = _dyld_get_image_header(i) { | ||
return UnsafeMutableRawPointer(mutating: UnsafeRawPointer(header)) | ||
} | ||
} | ||
} | ||
} | ||
return UnsafeMutableRawPointer(mutating: #dsohandle) | ||
}() | ||
#else | ||
import Foundation | ||
|
||
@usableFromInline | ||
let formatter: DateFormatter = { | ||
let formatter = DateFormatter() | ||
formatter.dateFormat = "yyyy-MM-dd HH:MM:SS.sssZ" | ||
return formatter | ||
}() | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// UIView+Layout.swift | ||
// ShyView | ||
// | ||
// Created by Maxim Krouk on 01/09/2023. | ||
// | ||
|
||
#if canImport(UIKit) && !os(watchOS) && !os(tvOS) | ||
import UIKit | ||
|
||
extension UIView { | ||
func pinEdgesToSuperview() { | ||
guard let superview else { return } | ||
pinEdges(to: superview) | ||
} | ||
|
||
func pinEdges(to target: UIView) { | ||
translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
topAnchor.constraint(equalTo: target.topAnchor), | ||
bottomAnchor.constraint(equalTo: target.bottomAnchor), | ||
leadingAnchor.constraint(equalTo: target.leadingAnchor), | ||
trailingAnchor.constraint(equalTo: target.trailingAnchor) | ||
]) | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// UIView+SecureView.swift | ||
// ShyView | ||
// | ||
// Created by Maxim Krouk on 01/09/2023. | ||
// | ||
|
||
#if canImport(UIKit) && !os(watchOS) && !os(tvOS) | ||
import UIKit | ||
|
||
extension UIView { | ||
static func makeSecureView() -> UIView? { | ||
let secureView: UIView? | ||
let textField = UITextField() | ||
textField.isSecureTextEntry = true | ||
secureView = textField.layer.sublayers?.first?.delegate as? UIView | ||
secureView?.subviews.forEach { $0.removeFromSuperview() } | ||
secureView?.isUserInteractionEnabled = true | ||
return secureView | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.