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
public struct PageView<Data, ID, Content>: View where Data: RandomAccessCollection, ID: Hashable, Content: View { | |
let data: Data | |
private let id: KeyPath<Data.Element, ID> | |
@Binding private var selection: ID? | |
private let content: (Data.Element) -> Content | |
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
/// A collection that supports moving and sorting of elements. | |
public protocol PermutableCollection: Collection { | |
mutating func swapAt(_ i: Self.Index, _ j: Self.Index) | |
// mutating func move(fromOffsets source: IndexSet, toOffset destination: Int) | |
// mutating func partition(by belongsInSecondPartition: (Element) throws -> Bool) rethrows -> Index | |
} |
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
struct KeyedList<Key, Element> : KeyableCollection { \\ ID or KEY... do I need ID??? | |
private var _elements: [Element] | |
// init?()... if attempting to add elements, make init failable | |
init(id keyPath: KeyPath<Element, Key>) where Key: Hashable { | |
} | |
init() where Element: Hashable, Key == Never { \\ ID == Self?? |
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
struct ChildView: View { | |
let text : String | |
var body: some View { | |
// THERE IS NO ACCESS TO THE PATH DATA! | |
... | |
} |
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
struct ContentView: View { | |
@NavigationState var path | |
var body: some View { | |
NavigationStack($path) { | |
... | |
} | |
struct ChildView: View { |
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
@propertyWrapper | |
class Observed<Value>: ObservableObject { | |
@Published public var wrappedValue: Value | |
public init(wrappedValue: Value) { | |
self.wrappedValue = wrappedValue | |
} | |
} |
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
/// Dictionary-backed storage allowing for for single instantiation and retrieval of an object. | |
struct Singletons { | |
private static var dictionary : [String : AnyObject] = [:] | |
private static func key<T: AnyObject>(for type: T.Type, key: String? = nil) -> String { | |
let type = String(reflecting: T.self) // describing: String; reflecting: Swift.String | |
guard let key else { return type } // returns Swift.String | |
return type + "." + key // returns Swift.String.key | |
} |
NewerOlder