View UnconstrainedEnvironmentObject.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
import SwiftUI | |
extension EnvironmentValues { | |
struct UnconstrainedObjectKey<Object>: | |
EnvironmentKey | |
where | |
Object: AnyObject | |
{ | |
static var defaultValue: Object? { | |
nil |
View ReferenceFileDocument_Example.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
import SwiftUI | |
import UniformTypeIdentifiers | |
// DOCUMENT EXAMPLE | |
extension UTType { | |
static var exampleText: UTType { | |
UTType(importedAs: "com.example.plain-text") | |
} | |
} |
View CustomStateObject.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
import SwiftUI | |
import Combine | |
/// The idea is to use State to create a storage object which will be | |
/// cached and restored by the framework. Then during the update phase we | |
/// re-inject the object into a nested ObservableObject and subscribe to the | |
/// ObjectType’s objectWillChange to forward to the _MessageForwarder’s | |
/// objectWillChange which is already subscribed by the framework as it’s an | |
/// inner dynamic property of our custom PW which is also a dynamic property. | |
@propertyWrapper |
View interchangeable_matched_geometry_effect.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
import SwiftUI | |
struct HeroAnimationTest: View { | |
let indices = 0 ..< 3 | |
@State | |
var showsOtherView = false | |
@Namespace | |
var namespaceID: Namespace.ID |
View swiftui_picker_attempt.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
import Combine | |
import SwiftUI | |
// To re-align the cells to the center we use a workaround through debouncing | |
// the nearest cell ID which is computed every time the scroll view moves. | |
// | |
// HOWEVER there is a bug that still needs to be solved: | |
// If you drag the scroll view and hold, the debounce event will still happen | |
// and reposition the cell. | |
// |
View weak_as_type.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
import PlaygroundSupport | |
import Dispatch | |
let page = PlaygroundPage.current | |
page.needsIndefiniteExecution = true | |
struct Weak<T> { | |
struct _ObjectBox { | |
weak var object: AnyObject? | |
} |
View small_but_shiny.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
public protocol MapKey { | |
associatedtype Value | |
static var defaultValue: Value { get } | |
} | |
public struct Map<Base> { | |
typealias _Key = ObjectIdentifier | |
var _values: [_Key: Any] |
View swiftui_alignment_keys.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
import SwiftUI | |
// T.Type -> AlignmentID.Type -> Any.Type -> UInt | |
extension HorizontalAlignment { | |
enum TestH: AlignmentID { | |
static func defaultValue(in context: ViewDimensions) -> CGFloat { | |
0 | |
} | |
} |
View broken_swiftui_layout.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
// BUG: FB7635852 | |
import SwiftUI | |
struct ContentView: View { | |
let count: Int | |
var body: some View { | |
HStack | |
.init(alignment: .top, spacing: 0) { |
View swiftui_update_inconsistency.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
// SOME OBSERVATIONS: | |
// * In Xcode 11.3.1 `V_Struct_Representable_ObservedObject` won't update | |
// which is clearly a bug. This bug is fixed in Xcode 11.4 beta 1. | |
// | |
// * `V_Struct` and `V_Struct_Representable` both never update because | |
// they shouldn't as the framework internal raw-diffing likely won't | |
// identify any change. (EXPECTED BEHAVIOR) | |
// | |
// * `V_Class` and `V_Class_ObservedObject` both produce a runtime crash, | |
// which might be a bug as well. `View` conforming types shouldn't be |
NewerOlder