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
// | |
// Color+Codable.swift | |
// FirestoreCodableSamples | |
// | |
// Created by Peter Friese on 18.03.21. | |
// | |
import SwiftUI | |
// Inspired by https://cocoacasts.com/from-hex-to-uicolor-and-back-in-swift |
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
struct ContentView: View { | |
var body: some View { | |
ScrollViewOffset(onOffsetChange: { (offset) in | |
print("New ScrollView offset: \(offset)") | |
}) { | |
VStack { | |
ForEach(0..<100) { index in | |
Text("\(index)") | |
} | |
} |
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
// | |
// FacebookAuth.swift | |
// GitHub: ethanhuang13 | |
// Twitter: @ethanhuang13 | |
import AuthenticationServices | |
import SafariServices | |
/* | |
Updated: |
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
import UIKit | |
public final class TextView: UITextView { | |
public override init(frame: CGRect, textContainer: NSTextContainer?) { | |
super.init(frame: frame, textContainer: textContainer) | |
layoutManager.delegate = self | |
isScrollEnabled = false | |
} | |
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
extension NSLayoutManager { | |
var numberOfLines: Int { | |
var linesCount: Int = 0 | |
var idx: Int = 0 | |
let lineRange: NSRangePointer = .allocate(capacity: 1) | |
while idx < numberOfGlyphs { | |
lineFragmentRect(forGlyphAt: idx, effectiveRange: lineRange) | |
idx = NSMaxRange(lineRange.pointee) | |
linesCount += 1 | |
} |
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
e print(String(data: JSONSerialization.data(withJSONObject: JSONSerialization.jsonObject(with: data, options: []), options: .prettyPrinted), encoding: .utf8)!) |
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
import Foundation | |
import CommonCrypto | |
internal enum CryptoError: Error { | |
case emptyData | |
case invalidData | |
case invalidKey | |
case fail(status: CCStatus) | |
} |
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
import UIKit | |
public protocol UITableViewHeaderFooterViewIdentifiable: UITableViewHeaderFooterView { | |
static var identifier: String { get } | |
} | |
public extension UITableViewHeaderFooterViewIdentifiable where Self: UITableViewHeaderFooterView { | |
static var identifier: String { | |
return String(describing: self) | |
} |
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
import Foundation | |
public extension UIApplication { | |
class func tryURL(_ urls: [String]) { | |
let application = UIApplication.shared | |
urls.forEach { urlString in | |
guard let url = URL(string: urlString) else { | |
Logger.error?.message("Cannot make url from: \(urlString)") | |
return | |
} |
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
import UIKit | |
import WebKit | |
open class ProgressObservableWebViewController: UIViewController, WKWebViewProgressObservable { | |
@IBOutlet weak public var webView: WKWebView! | |
public var webViewProgressObservation: Any? | |
private let progressView: UIProgressView = { | |
let view = UIProgressView(progressViewStyle: .default) |
NewerOlder