This file contains hidden or 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 SceneKit | |
class ARQLThumbnailGenerator { | |
private let device = MTLCreateSystemDefaultDevice()! | |
/// Create a thumbnail image of the asset with the specified URL at the specified | |
/// animation time. Supports loading of .scn, .usd, .usdz, .obj, and .abc files, | |
/// and other formats supported by ModelIO. |
This file contains hidden or 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 | |
/// A UITextView subclass with placeholder text support. | |
/// It uses another UILabel to show the placeholder, shown when text is empty. | |
class PlaceholderTextView: UITextView { | |
lazy var placeholderLabel: UILabel = { | |
let label = UILabel() | |
label.textColor = UIColor(white: 0.5, alpha: 0.85) | |
label.backgroundColor = .clear |
This file contains hidden or 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 NaturalLanguage | |
let text = "All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood." | |
let tokenizer = NLTokenizer(unit: .word) | |
tokenizer.string = text | |
//let tokenArray = tokenizer.tokens(for: strRange) | |
tokenizer.enumerateTokens(in: text.startIndex..<text.endIndex) { tokenRange, _ in | |
print(text[tokenRange]) | |
return true |
This file contains hidden or 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 Combine | |
enum APIError: Error, LocalizedError { | |
case unknown, apiError(reason: String) | |
var errorDescription: String? { | |
switch self { | |
case .unknown: | |
return "Unknown error" |
This file contains hidden or 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 SwiftUI | |
import Combine | |
struct AdaptsToSoftwareKeyboard: ViewModifier { | |
@State var currentHeight: CGFloat = 0 | |
func body(content: Content) -> some View { | |
content | |
.padding(.bottom, currentHeight) | |
.edgesIgnoringSafeArea(.bottom) |
This file contains hidden or 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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 2 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-2/ | |
import SwiftUI | |
struct MyTextPreferenceData { | |
let viewIdx: Int | |
var topLeading: Anchor<CGPoint>? = nil | |
var bottomTrailing: Anchor<CGPoint>? = nil |
This file contains hidden or 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 RealityKit | |
import UIKit | |
class ViewController: UIViewController { | |
let arView: ARView | |
func addGestures() { | |
// Use any entity. Here we're using a cube with size 0.5m | |
let entity = ModelEntity(mesh: MeshResource.generateBox(size: 0.5)) | |
entity.generateCollisionShapes(recursive: true) |
This file contains hidden or 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 enum ColorSupport { | |
public static var label: UIColor { | |
if #available(iOS 13, *) { | |
return .label | |
} | |
return UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) | |
} |
This file contains hidden or 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
// | |
// PagerView.swift | |
// | |
// Created by Majid Jabrayilov on 12/5/19. | |
// Copyright © 2019 Majid Jabrayilov. All rights reserved. | |
// | |
import SwiftUI | |
struct PagerView<Content: View>: View { | |
let pageCount: Int |
This file contains hidden or 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
// | |
// DeviceConstants.swift | |
// SampleApp | |
// | |
// Created by RoLY roLLs on 12/31/19. | |
// Copyright © 2019 RoLYroLLs Enterprises, LLC. All rights reserved. | |
// | |
/// Taken from https://developer.apple.com/documentation/swiftui/securefield/3289399-previewdevice |