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
// by klaytonb | |
// https://forums.developer.apple.com/forums/thread/699111?answerId=740437022#740437022 | |
import Combine | |
import SwiftUI | |
public extension Publishers { | |
static var keyboardHeight: AnyPublisher<CGFloat, Never> { | |
let willShow = NotificationCenter.default.publisher(for: UIApplication.keyboardWillShowNotification) | |
.map { $0.keyboardHeight } | |
let willHide = NotificationCenter.default.publisher(for: UIApplication.keyboardWillHideNotification) |
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 Combine | |
import Foundation | |
import SwiftUI | |
import UIKit | |
extension UIView { | |
fileprivate func findRelevantContainer() -> ContainerType? { | |
var responder: UIResponder? = self | |
while let currentResponder = responder { |
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 SwiftUI | |
import TipKit | |
struct Tip1: ShowTip { | |
var title: Text = Text("Step1 Tips") | |
@Parameter | |
static var show: Bool = false | |
var rules: [Rule] { |
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 SwiftData | |
extension Note { | |
/// 根据给定的筛选条件生成相应的谓词,用于筛选笔记。 | |
public static func predicateFor(_ filter: NotePredicate) -> Predicate<Note>? { | |
var result: Predicate<Note>? | |
switch filter { | |
case let .filterRootNoteByName(name): | |
result = #Predicate<Note> { $0.name == name && $0.parent == nil } |
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 | |
@available(macOS 14, iOS 17, tvOS 17, watchOS 10, *) | |
/// Allows you to use an existing Predicate as a ``StandardPredicateExpression`` | |
struct VariableWrappingExpression<T>: StandardPredicateExpression { | |
let predicate: Predicate<T> | |
let variable: PredicateExpressions.Variable<T> | |
func evaluate(_ bindings: PredicateBindings) throws -> Bool { | |
// resolve the variable |
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
// | |
// InfiniteScrollChart.swift | |
// ChartsGallery | |
// | |
// Created by beader on 2022/11/3. | |
// | |
import SwiftUI | |
import Charts |
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 SwiftUI | |
struct ContentView: View { | |
@State var show = false | |
var body: some View { | |
VStack { | |
Button("Pop Sheet") { show.toggle() } | |
} | |
.adaptiveSheet(isPresent: $show) { SheetView() } | |
} |
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
// | |
// FreeSpaceViewController.swift | |
// Free Space | |
// | |
// Created by Kyle Howells on 04/05/2022. | |
// | |
import UIKit | |
class FreeSpaceViewController: UIViewController { |
NewerOlder