├── .gitignore ├── LICENSE ├── Package.swift ├── README.md ├── Sources └── OpenSwiftUI │ ├── Animatable.swift │ ├── Binding.swift │ ├── Graph │ └── Graph.swift │ ├── Layout │ ├── Alignment.swift │ ├── Axis.swift │ ├── Edge.swift │ ├── EdgeInsets.swift │ ├── Point.swift │ ├── Size.swift │ └── ViewDimensions.swift │ ├── LocalizedStringKey.swift │ ├── Modifiers │ ├── BackgroundModifier.swift │ ├── EmptyModifier.swift │ ├── EnvironmentKeyWritingModifier.swift │ ├── EnvironmentalModifier.swift │ ├── PaddingModifier.swift │ ├── ViewModifier.swift │ └── ViewModifier_Content.swift │ ├── PropertyList.swift │ ├── State.swift │ ├── Transaction.swift │ ├── UnaryViewAdaptor.swift │ ├── ViewBuilder.swift │ ├── Views │ ├── AnyView.swift │ ├── Button.swift │ ├── Color.swift │ ├── ConditionalContent.swift │ ├── Divider.swift │ ├── EmptyView.swift │ ├── Font.swift │ ├── ForEach.swift │ ├── Group.swift │ ├── HStack.swift │ ├── HStackLayout.swift │ ├── Image.swift │ ├── ModifiedContent.swift │ ├── Never.swift │ ├── Optional.swift │ ├── Picker.swift │ ├── Shape.swift │ ├── ShapeView.swift │ ├── Shapes │ │ ├── Angle.swift │ │ ├── Circle.swift │ │ ├── Path.swift │ │ └── Rectangle.swift │ ├── Spacer.swift │ ├── Stepper.swift │ ├── Text.swift │ ├── Toggle.swift │ ├── TupleView.swift │ ├── VStack.swift │ ├── VStackLayout.swift │ ├── View.swift │ ├── ZStack.swift │ └── ZStackLayout.swift │ ├── _VariadicView │ ├── VariadicView.swift │ ├── VariadicView_Children.swift │ ├── VariadicView_MultiViewRoot.swift │ ├── VariadicView_Root.swift │ ├── VariadicView_UnaryViewRoot.swift │ └── VariadicView_ViewRoot.swift │ └── _ViewTraitKey.swift └── Tests ├── LinuxMain.swift └── OpenSwiftUITests ├── OpenSwiftUITests.swift └── XCTestManifests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | # 51 | # Add this line if you want to avoid checking in source code from the Xcode workspace 52 | # *.xcworkspace 53 | 54 | # Carthage 55 | # 56 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 57 | # Carthage/Checkouts 58 | 59 | Carthage/Build 60 | 61 | # Accio dependency management 62 | Dependencies/ 63 | .accio/ 64 | 65 | # fastlane 66 | # 67 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 68 | # screenshots whenever they are needed. 69 | # For more information about the recommended setup visit: 70 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 71 | 72 | fastlane/report.xml 73 | fastlane/Preview.html 74 | fastlane/screenshots/**/*.png 75 | fastlane/test_output 76 | 77 | # Code Injection 78 | # 79 | # After new code Injection tools there's a generated folder /iOSInjectionProject 80 | # https://github.com/johnno1962/injectionforxcode 81 | 82 | iOSInjectionProject/ 83 | .DS_Store 84 | .swiftpm 85 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Devran "Cosmo" Uenal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "OpenSwiftUI", 8 | platforms: [ 9 | .macOS(.v10_15), .iOS(.v13) 10 | ], 11 | products: [ 12 | // Products define the executables and libraries produced by a package, and make them visible to other packages. 13 | .library( 14 | name: "OpenSwiftUI", 15 | targets: ["OpenSwiftUI"]), 16 | ], 17 | dependencies: [ 18 | // Dependencies declare other packages that this package depends on. 19 | // .package(url: /* package url */, from: "1.0.0"), 20 | .package(url: "https://github.com/Cosmo/CoreGraphicsShim.git", .branch("master")), 21 | ], 22 | targets: [ 23 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 24 | // Targets can depend on other targets in this package, and on products in packages which this package depends on. 25 | .target( 26 | name: "OpenSwiftUI", 27 | dependencies: ["CoreGraphicsShim"]), 28 | .testTarget( 29 | name: "OpenSwiftUITests", 30 | dependencies: ["OpenSwiftUI"]), 31 | ] 32 | ) 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenSwiftUI 2 | 3 | OpenSwiftUI is an OpenSource implementation of Apple's [SwiftUI](https://developer.apple.com/documentation/swiftui) [DSL (Domain-specific language)](https://en.wikipedia.org/wiki/Domain-specific_language). 4 | 5 | The project's goal is to stay close to the original API as possible. 6 | 7 | Currently, this project is in early development. 8 | 9 | ## Background 10 | 11 | Apple introduced SwiftUI at WWDC 19. Since then, developing applications with graphical user interfaces became more comfortable to read, write, and maintain. Unfortunately, the principle "Learn once, apply anywhere" works on Apple platforms, only. 12 | 13 | Swift runs on Apple platforms, the web, Linux, Windows, and even on embedded devices. 14 | Wouldn't it be great if you could write GUI based applications with SwiftUI on platforms that run Swift? 15 | 16 | ## SwiftUI on your platform 17 | 18 | OpenSwiftUI provides the API — other projects can implement the actual rendering of UI elements for different platforms like Linux, Windows, Embedded, and many more. 19 | 20 | [SwiftUIEmbedded](https://github.com/Cosmo/SwiftUIEmbedded) is one of the first projects that make use of OpenSwiftUI ([Demo](https://github.com/Cosmo/SwiftUIEmbedded-Demo)). 21 | 22 | [![Demo](https://img.youtube.com/vi/bE1bqOhXcY4/0.jpg)](https://www.youtube.com/watch?v=bE1bqOhXcY4) 23 | 24 | ## Contributing 25 | 26 | Over time and collective guesswork, it should be possible to re-create the complete SwiftUI API from Apple. 27 | Check the [Status](#status) overview to see what's missing or needs to be completed. 28 | 29 | A good starting point is to get familiar with the [SwiftUI interface](#swiftui-interface), focus on certain functionality, and try to re-implement it. 30 | A helpful tool is to use reflection (`Mirror(reflecting: …)`) to peek into SwiftUI types and instances. This reveals the internal structure of instances (properties, types, names and inheritance). 31 | 32 | Once you implemented a missing piece, please feel free to contribute a pull request. 33 | 34 | *Please note:* 35 | 36 | Private methods and properties of SwiftUI should be prefixed by an `_` (underscore) and marked as public in OpenSwiftUI. 37 | Doing this is necessary because the frontend might need access. 38 | 39 | 40 | Xcode 11.2 or higher is required. 41 | 42 | 43 | ## Status 44 | 45 | 46 | 47 | ### Views and Controls 48 | 49 | #### Essentials 50 | 51 | | Status | Name | Notes | 52 | | --- | --- | --- | 53 | | ✅ | `protocol View` | 54 | 55 | #### Text 56 | 57 | | Status | Name | Notes | 58 | | --- | --- | --- | 59 | | ✅ | `struct Text` | | 60 | | ❌ | `struct TextField` | | 61 | | ❌ | `struct SecureField` | | 62 | | ✅ | `struct Font` | | 63 | 64 | #### Images 65 | 66 | | Status | Name | Notes | 67 | | --- | --- | --- | 68 | | ⚠️ | `struct Image` | CGImage not supported | 69 | 70 | #### Buttons 71 | 72 | | Status | Name | Notes | 73 | | --- | --- | --- | 74 | | ✅ | `struct Button` | | 75 | | ❌ | `struct NavigationLink` | | 76 | | ❌ | `struct MenuButton` | | 77 | | ❌ | `struct EditButton` | | 78 | | ❌ | `struct PasteButton` | | 79 | 80 | #### Value Selectors 81 | 82 | | Status | Name | Notes | 83 | | --- | --- | --- | 84 | | ❌ | `struct Toggle` | | 85 | | ⚠️ | `struct Picker` | | 86 | | ❌ | `struct DatePicker` | | 87 | | ❌ | `struct Slider` | | 88 | | ⚠️ | `struct Stepper` | | 89 | 90 | #### Supporting Types 91 | 92 | | Status | Name | Notes | 93 | | --- | --- | --- | 94 | | ✅ | `struct ViewBuilder` | | 95 | | ✅ | `protocol ViewModifier` | | 96 | 97 | 98 | ### View Layout and Presentation 99 | 100 | #### Stacks 101 | 102 | | Status | Name | Notes | 103 | | --- | --- | --- | 104 | | ✅ | `struct HStack` | | 105 | | ✅ | `struct VStack` | | 106 | | ✅ | `struct ZStack` | | 107 | 108 | #### Lists and Scroll Views 109 | 110 | | Status | Name | Notes | 111 | | --- | --- | --- | 112 | | ❌ | `struct List` | | 113 | | ❌ | `protocol DynamicViewContent` | | 114 | | ✅ | `protocol Identifiable` | Provided by Swift. | 115 | | ✅ | `struct ForEach` | | 116 | | ❌ | `struct ScrollView` | | 117 | | ⚠️ | `enum Axis` | | 118 | 119 | #### Container Views 120 | 121 | | Status | Name | Notes | 122 | | --- | --- | --- | 123 | | ❌ | `struct Form` | | 124 | | ⚠️ | `struct Group` | | 125 | | ❌ | `struct GroupBox` | | 126 | | ❌ | `struct Section` | | 127 | 128 | #### Spacer and Dividers 129 | 130 | | Status | Name | Notes | 131 | | --- | --- | --- | 132 | | ✅ | `struct Spacer` | | 133 | | ✅ | `struct Divider` | | 134 | 135 | #### Architectural Views 136 | 137 | | Status | Name | Notes | 138 | | --- | --- | --- | 139 | | ❌ | `struct NavigationView` | | 140 | | ❌ | `struct TabView` | | 141 | | ❌ | `struct HSplitView` | | 142 | | ❌ | `struct VSplitView` | | 143 | 144 | #### Presentations 145 | 146 | | Status | Name | Notes | 147 | | --- | --- | --- | 148 | | ❌ | `struct Alert` | | 149 | | ❌ | `struct ActionSheet` | | 150 | 151 | #### Conditionally Visible Items 152 | 153 | | Status | Name | Notes | 154 | | --- | --- | --- | 155 | | ✅ | `struct EmptyView` | | 156 | | ❌ | `struct EquatableView` | | 157 | 158 | #### Infrequently Used Views 159 | 160 | | Status | Name | Notes | 161 | | --- | --- | --- | 162 | | ⚠️ | `struct AnyView` | `init?(_fromValue value: Any)` missing. | 163 | | ✅ | `struct TupleView` | | 164 | 165 | ### Drawing and Animation 166 | 167 | ##### Essentials 168 | 169 | | Status | Name | Notes | 170 | | --- | --- | --- | 171 | | ⚠️ | `protocol Shape` | | 172 | 173 | #### Animation 174 | 175 | | Status | Name | Notes | 176 | | --- | --- | --- | 177 | | ❌ | `struct Animation` | | 178 | | ❌ | `protocol Animatable` | | 179 | | ❌ | `protocol AnimatableModifier` | | 180 | | ❌ | `func withAnimation(Animation?, () -> Result) -> Result` | | 181 | | ❌ | `struct AnimationPair` | | 182 | | ❌ | `struct EmptyAnimationData` | | 183 | | ❌ | `struct AnyTransition` | | 184 | 185 | #### Shapes 186 | 187 | | Status | Name | Notes | 188 | | --- | --- | --- | 189 | | ⚠️ | `struct Rectangle` | | 190 | | ✅ | `enum Edge` | | 191 | | ❌ | `struct RoundedRectangle` | | 192 | | ⚠️ | `struct Circle` | | 193 | | ❌ | `struct Ellipse` | | 194 | | ❌ | `struct Capsule` | | 195 | | ❌ | `struct Path` | | 196 | 197 | #### Transformed Shapes 198 | 199 | | Status | Name | Notes | 200 | | --- | --- | --- | 201 | | ❌ | `protocol InsettableShape` | | 202 | | ❌ | `struct ScaledShape` | | 203 | | ❌ | `struct RotatedShape` | | 204 | | ❌ | `struct OffsetShape` | | 205 | | ❌ | `struct TransformedShape` | | 206 | 207 | #### Paints, Styles, and Gradients 208 | 209 | | Status | Name | Notes | 210 | | --- | --- | --- | 211 | | ✅ | `struct Color` | | 212 | | ❌ | `struct ImagePaint` | | 213 | | ❌ | `struct Gradient` | | 214 | | ❌ | `struct LinearGradient` | | 215 | | ❌ | `struct AngularGradient` | | 216 | | ❌ | `struct RadialGradient` | | 217 | | ❌ | `struct ForegroundStyle` | | 218 | | ❌ | `struct FillStyle` | | 219 | | ❌ | `protocol ShapeStyle` | | 220 | | ❌ | `enum RoundedCornerStyle` | | 221 | | ❌ | `struct SelectionShapeStyle` | | 222 | | ❌ | `struct SeparatorShapeStyle` | | 223 | | ❌ | `struct StrokeStyle` | | 224 | 225 | #### Geometry 226 | 227 | | Status | Name | Notes | 228 | | --- | --- | --- | 229 | | ❌ | `struct GeometryProxy` | | 230 | | ❌ | `struct GeometryReader` | | 231 | | ❌ | `protocol GeometryEffect` | | 232 | | ❌ | `struct Angle` | | 233 | | ❌ | `struct Anchor` | | 234 | | ❌ | `struct UnitPoint` | | 235 | | ❌ | `enum CoordinateSpace` | | 236 | | ❌ | `struct ProjectionTransform` | | 237 | | ❌ | `protocol VectorArithmetic` | | 238 | 239 | ### State and Data Flow 240 | 241 | #### Bindings 242 | 243 | | Status | Name | Notes | 244 | | --- | --- | --- | 245 | | ⚠️ | `struct Binding` | | 246 | 247 | #### Data-Dependent Views 248 | 249 | | Status | Name | Notes | 250 | | --- | --- | --- | 251 | | ✅ | `struct State` | | 252 | | ❌ | `struct ObservedObject` | | 253 | | ❌ | `struct EnvironmentObject` | | 254 | | ❌ | `struct FetchRequest` | | 255 | | ❌ | `struct FetchedResults` | | 256 | | ⚠️ | `protocol DynamicProperty` | `func update()` missing. | 257 | 258 | #### Environment Values 259 | 260 | | Status | Name | Notes | 261 | | --- | --- | --- | 262 | | ✅ | `struct Environment` | | 263 | | ✅ | `struct EnvironmentValues` | | 264 | 265 | #### Preferences 266 | 267 | | Status | Name | Notes | 268 | | --- | --- | --- | 269 | | ❌ | `protocol PreferenceKey` | | 270 | | ❌ | `struct LocalizedStringKey` | | 271 | 272 | #### Transactions 273 | 274 | | Status | Name | Notes | 275 | | --- | --- | --- | 276 | | ❌ | `struct Transaction` | | 277 | 278 | ### Gestures 279 | 280 | #### Basic Gestures 281 | 282 | | Status | Name | Notes | 283 | | --- | --- | --- | 284 | | ❌ | `struct TapGesture` | | 285 | | ❌ | `struct LongPressGesture` | | 286 | | ❌ | `struct DragGesture` | | 287 | | ❌ | `struct MagnificationGesture` | | 288 | | ❌ | `struct RotationGesture` | | 289 | 290 | #### Combined Gestures 291 | 292 | | Status | Name | Notes | 293 | | --- | --- | --- | 294 | | ❌ | `struct SequenceGesture` | | 295 | | ❌ | `struct SimultaneousGesture` | | 296 | | ❌ | `struct ExclusiveGesture` | | 297 | 298 | #### Custom Gesture 299 | 300 | | Status | Name | Notes | 301 | | --- | --- | --- | 302 | | ❌ | `protocol Gesture` | | 303 | | ❌ | `struct AnyGesture` | | 304 | 305 | #### Dynamic View Properties 306 | 307 | | Status | Name | Notes | 308 | | --- | --- | --- | 309 | | ❌ | `struct GestureState` | | 310 | | ❌ | `struct GestureStateGesture` | | 311 | 312 | #### Gesture Support 313 | 314 | | Status | Name | Notes | 315 | | --- | --- | --- | 316 | | ❌ | `struct GestureMask` | | 317 | | ❌ | `struct EventModifiers` | | 318 | 319 | 320 | ### Legend 321 | 322 | | Symbol | Description | 323 | | --- | --- | 324 | | ✅ | Done | 325 | | ❌ | Open | 326 | | ⚠️ | Incomplete | 327 | 328 | 329 | 330 | 331 | 332 | ## Resources 333 | 334 | ### SwiftUI Interface 335 | 336 | Compared to what you can see in Xcode, this [gist]((https://gist.github.com/Cosmo/b4cd7d4c81bf09c5801459b591a322f9)) shows you more than just the public interfaces. 337 | It shows private properties, and the body of `@inlinable` marked properties, functions, and initializers. 338 | 339 | ``` 340 | /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/SwiftUI.framework/Versions/A/Modules/SwiftUI.swiftmodule/x86_64.swiftinterface 341 | ``` 342 | 343 | ### SwiftWebUI 344 | 345 | [SwiftWebUI](https://github.com/SwiftWebUI/SwiftWebUI) is an implementation of SwiftUI for the web by [Helge Heß](https://github.com/helje5). 346 | This project's goal is focused exclusively on the web. 347 | It deviates a little bit from SwiftUI by taking some shortcuts here and there -- but looks quite complete in functionality and is great for inspiration. 348 | 349 | ### SwiftUI symbols 350 | 351 | This command prints the symbol table of SwiftUI via the `llvm-mn` utility. 352 | 353 | ```bash 354 | nm -gUj /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUI.framework/SwiftUI | swift-demangle | sed 's/SwiftUI.//g' | sed 's/Swift.//g' 355 | ``` 356 | 357 | You can also have a look at this [gist](https://gist.github.com/Cosmo/deeece2ac8b804f4977b388bb7185b98) instead. 358 | 359 | 360 | ### Links 361 | 362 | * [SwiftUI @ViewBuilder Result is a TupleView, How is Apple Using It And Able to Avoid Turning Things Into AnyVIew?](https://forums.swift.org/t/swiftui-viewbuilder-result-is-a-tupleview-how-is-apple-using-it-and-able-to-avoid-turning-things-into-anyview/28181/2) 363 | * [https://stackoverflow.com/questions/56434549/what-enables-swiftuis-dsl](https://stackoverflow.com/questions/56434549/what-enables-swiftuis-dsl) 364 | * [Building Custom Views with SwiftUI](https://developer.apple.com/wwdc19/237) 365 | * [SwiftUI Essentials](https://developer.apple.com/wwdc19/216) 366 | * [Data Flow Through SwiftUI](https://developer.apple.com/wwdc19/226) 367 | * [Introducing SwiftUI: Building Your First App](https://developer.apple.com/wwdc19/231) 368 | * [SwiftUI On All Devices](https://developer.apple.com/wwdc19/240) 369 | 370 | 371 | 372 | ## Special thanks 373 | 374 | I want to give special thanks to [Helge Heß](https://github.com/helje5). He created [SwiftWebUI](https://github.com/SwiftWebUI/SwiftWebUI), contributed many suggestions to OpenSwiftUI, and helped with insights of his findings. 375 | 376 | 377 | --- 378 | 379 | ## Contact 380 | 381 | * Devran "Cosmo" Uenal 382 | * Twitter: [@maccosmo](http://twitter.com/maccosmo) 383 | * LinkedIn: [devranuenal](https://www.linkedin.com/in/devranuenal) 384 | 385 | ## License 386 | 387 | OpenSwiftUI is released under the [MIT License](http://www.opensource.org/licenses/MIT). 388 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Animatable.swift: -------------------------------------------------------------------------------- 1 | public protocol Animatable { 2 | } 3 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Binding.swift: -------------------------------------------------------------------------------- 1 | @propertyWrapper @dynamicMemberLookup public struct Binding { 2 | public var transaction: Transaction 3 | internal var location: AnyLocation 4 | fileprivate var _value: Value 5 | 6 | public init(get: @escaping () -> Value, set: @escaping (Value) -> Void) { 7 | self.transaction = Transaction() 8 | self.location = AnyLocation(value: get()) 9 | self._value = get() 10 | set(_value) 11 | } 12 | 13 | public init(get: @escaping () -> Value, set: @escaping (Value, Transaction) -> Void) { 14 | self.transaction = Transaction() 15 | self.location = AnyLocation(value: get()) 16 | self._value = get() 17 | set(_value, self.transaction) 18 | } 19 | 20 | public static func constant(_ value: Value) -> Binding { 21 | fatalError() 22 | } 23 | 24 | public var wrappedValue: Value { 25 | get { return location._value.pointee } 26 | nonmutating set { location._value.pointee = newValue } 27 | } 28 | 29 | public var projectedValue: Binding { 30 | self 31 | } 32 | 33 | public subscript(dynamicMember keyPath: WritableKeyPath) -> Binding { 34 | fatalError() 35 | } 36 | } 37 | 38 | class StoredLocation: AnyLocation { 39 | 40 | } 41 | 42 | extension Binding { 43 | public func transaction(_ transaction: Transaction) -> Binding { 44 | fatalError() 45 | } 46 | 47 | // public func animation(_ animation: Animation? = .default) -> Binding { 48 | // 49 | // } 50 | } 51 | 52 | extension Binding: DynamicProperty { 53 | public static func _makeProperty(in buffer: inout _DynamicPropertyBuffer, container: _GraphValue, fieldOffset: Int, inputs: inout _GraphInputs) { 54 | 55 | } 56 | } 57 | 58 | extension Binding { 59 | public init(_ base: Binding) where Value == V? { 60 | fatalError() 61 | } 62 | 63 | public init?(_ base: Binding) { 64 | fatalError() 65 | } 66 | 67 | public init(_ base: Binding) where Value == AnyHashable, V : Hashable { 68 | fatalError() 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Graph/Graph.swift: -------------------------------------------------------------------------------- 1 | public struct _Graph { 2 | public init() { 3 | 4 | } 5 | } 6 | 7 | public struct _GraphInputs { 8 | public init() { 9 | 10 | } 11 | } 12 | 13 | public struct _ViewInputs { 14 | public init() { 15 | 16 | } 17 | } 18 | 19 | public struct _ViewListInputs { 20 | public init() { 21 | 22 | } 23 | } 24 | 25 | public struct _ViewOutputs { 26 | public init() { 27 | 28 | } 29 | } 30 | 31 | public struct _ViewListOutputs { 32 | public init() { 33 | 34 | } 35 | } 36 | 37 | public struct _GraphValue: Equatable { 38 | public var value: Value 39 | 40 | public init(value: Value) { 41 | self.value = value 42 | } 43 | 44 | public subscript(keyPath: KeyPath) -> _GraphValue { 45 | get { 46 | fatalError() 47 | } 48 | } 49 | public static func == (a: _GraphValue, b: _GraphValue) -> Bool { 50 | return true 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Layout/Alignment.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct Alignment { 4 | public var horizontal: HorizontalAlignment 5 | public var vertical: VerticalAlignment 6 | 7 | public init(horizontal: HorizontalAlignment, vertical: VerticalAlignment) { 8 | self.horizontal = horizontal 9 | self.vertical = vertical 10 | } 11 | 12 | public static var center: Alignment { 13 | return Alignment(horizontal: HorizontalAlignment.center, vertical: VerticalAlignment.center) 14 | } 15 | 16 | public static var leading: Alignment { 17 | return Alignment(horizontal: HorizontalAlignment.leading, vertical: VerticalAlignment.center) 18 | } 19 | 20 | public static var trailing: Alignment { 21 | return Alignment(horizontal: HorizontalAlignment.trailing, vertical: VerticalAlignment.center) 22 | } 23 | 24 | public static var top: Alignment { 25 | return Alignment(horizontal: HorizontalAlignment.center, vertical: VerticalAlignment.top) 26 | } 27 | 28 | public static var bottom: Alignment { 29 | return Alignment(horizontal: HorizontalAlignment.center, vertical: VerticalAlignment.bottom) 30 | } 31 | 32 | public static var topLeading: Alignment { 33 | return Alignment(horizontal: HorizontalAlignment.leading, vertical: VerticalAlignment.top) 34 | } 35 | 36 | public static var topTrailing: Alignment { 37 | return Alignment(horizontal: HorizontalAlignment.trailing, vertical: VerticalAlignment.top) 38 | } 39 | 40 | public static var bottomLeading: Alignment { 41 | return Alignment(horizontal: HorizontalAlignment.leading, vertical: VerticalAlignment.bottom) 42 | } 43 | 44 | public static var bottomTrailing: Alignment { 45 | return Alignment(horizontal: HorizontalAlignment.trailing, vertical: VerticalAlignment.bottom) 46 | } 47 | } 48 | 49 | public protocol AlignmentID { 50 | static func defaultValue(in context: ViewDimensions) -> CGFloat 51 | } 52 | 53 | struct AlignmentKey: Hashable, Comparable { 54 | private let bits: UInt 55 | internal static func < (lhs: AlignmentKey, rhs: AlignmentKey) -> Bool { 56 | return lhs.bits < rhs.bits 57 | } 58 | } 59 | 60 | // FIXME: This is not the actual implementation. SwiftUI does not use enums. See below 61 | public enum HorizontalAlignment { 62 | case leading 63 | case center 64 | case trailing 65 | } 66 | 67 | // FIXME: This is not the actual implementation. SwiftUI does not use enums. See below. 68 | public enum VerticalAlignment { 69 | case top 70 | case center 71 | case bottom 72 | case firstTextBaseline 73 | case lastTextBaseline 74 | } 75 | 76 | /* 77 | public struct HorizontalAlignment { 78 | internal let key: AlignmentKey 79 | public init(_ id: AlignmentID.Type) { 80 | fatalError() 81 | } 82 | 83 | public static func == (a: HorizontalAlignment, b: HorizontalAlignment) -> Bool { 84 | return a.key == b.key 85 | } 86 | } 87 | 88 | public struct VerticalAlignment { 89 | internal let key: AlignmentKey 90 | public init(_ id: AlignmentID.Type) { 91 | fatalError() 92 | } 93 | 94 | public static func == (a: VerticalAlignment, b: VerticalAlignment) -> Bool { 95 | return a.key == b.key 96 | } 97 | } 98 | 99 | 100 | extension VerticalAlignment { 101 | public static var top: VerticalAlignment { 102 | fatalError() 103 | } 104 | public static var center: VerticalAlignment { 105 | fatalError() 106 | } 107 | public static var bottom: VerticalAlignment { 108 | fatalError() 109 | } 110 | public static var firstTextBaseline: VerticalAlignment { 111 | fatalError() 112 | } 113 | public static var lastTextBaseline: VerticalAlignment { 114 | fatalError() 115 | } 116 | } 117 | 118 | extension VerticalAlignment: Equatable { 119 | } 120 | 121 | extension HorizontalAlignment { 122 | public static var leading: HorizontalAlignment { 123 | fatalError() 124 | } 125 | public static var center: HorizontalAlignment { 126 | fatalError() 127 | } 128 | public static var trailing: HorizontalAlignment { 129 | fatalError() 130 | } 131 | } 132 | 133 | extension HorizontalAlignment: Equatable { 134 | } 135 | */ 136 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Layout/Axis.swift: -------------------------------------------------------------------------------- 1 | public enum Axis: Int8, CaseIterable { 2 | case horizontal 3 | case vertical 4 | } 5 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Layout/Edge.swift: -------------------------------------------------------------------------------- 1 | public enum Edge: Int8, CaseIterable { 2 | public typealias RawValue = Int8 3 | 4 | case top = 1 5 | case leading = 2 6 | case bottom = 4 7 | case trailing = 8 8 | 9 | public struct Set: OptionSet { 10 | public typealias Element = Edge.Set 11 | public typealias ArrayLiteralElement = Edge.Set.Element 12 | public typealias RawValue = Int8 13 | public let rawValue: Int8 14 | 15 | public static let top = Element(.top) 16 | public static let leading = Element(.leading) 17 | public static let bottom = Element(.bottom) 18 | public static let trailing = Element(.trailing) 19 | public static let horizontal = Element(rawValue: leading.rawValue + trailing.rawValue) 20 | public static let vertical = Element(rawValue: top.rawValue + bottom.rawValue) 21 | 22 | public static let all = Element(rawValue: top.rawValue + bottom.rawValue + leading.rawValue + trailing.rawValue) 23 | 24 | public init(rawValue: Int8) { 25 | self.rawValue = rawValue 26 | } 27 | 28 | public init(_ e: Edge) { 29 | self.rawValue = e.rawValue 30 | } 31 | } 32 | } 33 | 34 | extension Edge: Hashable { 35 | } 36 | 37 | extension Edge: RawRepresentable { 38 | } 39 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Layout/EdgeInsets.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct EdgeInsets: Equatable { 4 | public var top: CGFloat 5 | public var leading: CGFloat 6 | public var bottom: CGFloat 7 | public var trailing: CGFloat 8 | 9 | public init(top: CGFloat, leading: CGFloat, bottom: CGFloat, trailing: CGFloat) { 10 | self.top = top 11 | self.leading = leading 12 | self.bottom = bottom 13 | self.trailing = trailing 14 | } 15 | 16 | public init() { 17 | self.init(top: 0, leading: 0, bottom: 0, trailing: 0) 18 | } 19 | } 20 | 21 | extension EdgeInsets { 22 | internal init(_all: CGFloat) { 23 | self.init(top: _all, leading: _all, bottom: _all, trailing: _all) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Layout/Point.swift: -------------------------------------------------------------------------------- 1 | // Should we use CGPoint instead? 2 | public struct Point { 3 | public var x: Int 4 | public var y: Int 5 | 6 | public static let zero = Point(x: 0, y: 0) 7 | } 8 | 9 | extension Point: Equatable { 10 | } 11 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Layout/Size.swift: -------------------------------------------------------------------------------- 1 | // Should we use CGSize instead? 2 | public struct Size { 3 | public var width: Int 4 | public var height: Int 5 | 6 | public static let zero = Size(width: 0, height: 0) 7 | 8 | public init(width: Int, height: Int) { 9 | self.width = width 10 | self.height = height 11 | } 12 | } 13 | 14 | extension Size: Equatable { 15 | } 16 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Layout/ViewDimensions.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct ViewDimensions { 4 | public var width: CGFloat { 5 | return 0 6 | } 7 | public var height: CGFloat { 8 | return 0 9 | } 10 | public subscript(guide: HorizontalAlignment) -> CGFloat { 11 | return 0 12 | } 13 | public subscript(guide: VerticalAlignment) -> CGFloat { 14 | return 0 15 | } 16 | public subscript(explicit guide: HorizontalAlignment) -> CGFloat? { 17 | return 0 18 | } 19 | public subscript(explicit guide: VerticalAlignment) -> CGFloat? { 20 | return 0 21 | } 22 | } 23 | 24 | extension ViewDimensions: Equatable { 25 | public static func == (lhs: ViewDimensions, rhs: ViewDimensions) -> Bool { 26 | return true 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/LocalizedStringKey.swift: -------------------------------------------------------------------------------- 1 | public struct LocalizedStringKey { 2 | internal var key: String 3 | private var hasFormatting: Bool = false 4 | 5 | public init(_ value: String) { 6 | self.key = value 7 | } 8 | 9 | public init(stringLiteral value: String) { 10 | self.key = value 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Modifiers/BackgroundModifier.swift: -------------------------------------------------------------------------------- 1 | public struct _BackgroundModifier: ViewModifier where Background: View { 2 | public typealias Body = Never 3 | public typealias Content = View 4 | 5 | public let background: Background 6 | public let alignment: Alignment 7 | 8 | init(background: Background, alignment: Alignment) { 9 | self.background = background 10 | self.alignment = alignment 11 | } 12 | } 13 | 14 | extension _BackgroundModifier { 15 | public static func _makeView(modifier: _GraphValue<_BackgroundModifier>, inputs: _ViewInputs, body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs) -> _ViewOutputs { 16 | fatalError() 17 | } 18 | } 19 | 20 | extension View { 21 | public func background(_ background: Background, alignment: Alignment = .center) -> some View where Background: View { 22 | return modifier( 23 | _BackgroundModifier(background: background, alignment: alignment)) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Modifiers/EmptyModifier.swift: -------------------------------------------------------------------------------- 1 | //public struct EmptyModifier { 2 | // public static let identity: EmptyModifier 3 | // public init() {} 4 | // 5 | // public static func _makeView(modifier: _GraphValue, inputs: _ViewInputs, body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs) -> _ViewOutputs { 6 | // 7 | // } 8 | // public static func _makeViewList(modifier: _GraphValue, inputs: _ViewListInputs, body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs) -> _ViewListOutputs { 9 | // 10 | // } 11 | // public func body(content: EmptyModifier.Content) -> Never { 12 | // fatalError() 13 | // } 14 | // public typealias Body = Never 15 | //} 16 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Modifiers/EnvironmentKeyWritingModifier.swift: -------------------------------------------------------------------------------- 1 | public protocol EnvironmentKey { 2 | associatedtype Value 3 | static var defaultValue: Self.Value { get } 4 | } 5 | 6 | public struct EnvironmentValues: CustomStringConvertible { 7 | var values: [ObjectIdentifier: Any] = [:] 8 | 9 | public init() { 10 | } 11 | 12 | public subscript(key: K.Type) -> K.Value where K: EnvironmentKey { 13 | get { 14 | if let value = values[ObjectIdentifier(key)] as? K.Value { 15 | return value 16 | } 17 | return K.defaultValue 18 | } 19 | set { 20 | values[ObjectIdentifier(key)] = newValue 21 | } 22 | } 23 | public var description: String { 24 | get { 25 | return "" 26 | } 27 | } 28 | } 29 | 30 | protocol DynamicProperty { 31 | 32 | } 33 | 34 | @propertyWrapper public struct Environment: DynamicProperty { 35 | internal enum Content { 36 | case keyPath(KeyPath) 37 | case value(Value) 38 | } 39 | 40 | internal var content: Environment.Content 41 | 42 | public init(_ keyPath: KeyPath) { 43 | content = .keyPath(keyPath) 44 | } 45 | public var wrappedValue: Value { 46 | get { 47 | switch content { 48 | case let .value(value): 49 | return value 50 | case let .keyPath(keyPath): 51 | // not bound to a view, return the default value. 52 | return EnvironmentValues()[keyPath: keyPath] 53 | } 54 | } 55 | } 56 | 57 | internal func error() -> Never { 58 | fatalError() 59 | } 60 | } 61 | 62 | public struct _EnvironmentKeyWritingModifier: ViewModifier { 63 | public var keyPath: WritableKeyPath 64 | public var value: Value 65 | public init(keyPath: WritableKeyPath, value: Value) { 66 | self.keyPath = keyPath 67 | self.value = value 68 | } 69 | public typealias Body = Never 70 | } 71 | 72 | extension View { 73 | public func environment(_ keyPath: WritableKeyPath, _ value: V) -> some View { 74 | return modifier(_EnvironmentKeyWritingModifier(keyPath: keyPath, value: value)) 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Modifiers/EnvironmentalModifier.swift: -------------------------------------------------------------------------------- 1 | public protocol EnvironmentalModifier : ViewModifier where Self.Body == Never { 2 | associatedtype ResolvedModifier : ViewModifier 3 | func resolve(in environment: EnvironmentValues) -> Self.ResolvedModifier 4 | } 5 | 6 | extension EnvironmentalModifier { 7 | public static func _makeView(modifier: _GraphValue, inputs: _ViewInputs, body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs) -> _ViewOutputs { 8 | fatalError() 9 | } 10 | public static func _makeViewList(modifier: _GraphValue, inputs: _ViewListInputs, body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs) -> _ViewListOutputs { 11 | fatalError() 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Modifiers/PaddingModifier.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct PaddingModifier: ViewModifier { 4 | static let defaultPadding: CGFloat = 8 5 | 6 | public typealias Body = Never 7 | public typealias Content = View 8 | 9 | public var value: EdgeInsets 10 | 11 | init(_ insets: EdgeInsets) { 12 | self.value = insets 13 | } 14 | 15 | init(_ edges: Edge.Set = .all, _ length: CGFloat? = nil) { 16 | let computedLength = length ?? Self.defaultPadding 17 | self.value = EdgeInsets(top: edges.contains(.top) ? computedLength : 0, 18 | leading: edges.contains(.leading) ? computedLength : 0, 19 | bottom: edges.contains(.bottom) ? computedLength : 0, 20 | trailing: edges.contains(.trailing) ? computedLength : 0) 21 | } 22 | 23 | init(_ length: CGFloat) { 24 | self.value = EdgeInsets(top: length, leading: length, bottom: length, trailing: length) 25 | } 26 | } 27 | 28 | extension PaddingModifier: CustomStringConvertible { 29 | public var description: String { 30 | return "PaddingModifier {padding: \(value)}" 31 | } 32 | } 33 | 34 | extension View { 35 | public func padding(_ insets: EdgeInsets) -> some View { 36 | return modifier(PaddingModifier(insets)) 37 | } 38 | 39 | public func padding(_ edges: Edge.Set = .all, _ length: CGFloat? = nil) -> some View { 40 | return modifier(PaddingModifier(edges, length)) 41 | } 42 | 43 | public func padding(_ length: CGFloat) -> some View { 44 | return modifier(PaddingModifier(length)) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Modifiers/ViewModifier.swift: -------------------------------------------------------------------------------- 1 | public protocol ViewModifier { 2 | associatedtype Body: View 3 | typealias Content = _ViewModifier_Content 4 | func body(content: Self.Content) -> Self.Body 5 | } 6 | 7 | extension ViewModifier where Self.Body == Never { 8 | public func body(content: Self.Content) -> Self.Body { 9 | fatalError() 10 | } 11 | } 12 | 13 | extension ViewModifier { 14 | public func concat(_ modifier: T) -> ModifiedContent { 15 | return .init(content: self, modifier: modifier) 16 | } 17 | } 18 | 19 | extension ViewModifier { 20 | static func _makeView(modifier: _GraphValue, inputs: _ViewInputs, body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs) -> _ViewOutputs { 21 | fatalError() 22 | } 23 | static func _makeViewList(modifier: _GraphValue, inputs: _ViewListInputs, body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs) -> _ViewListOutputs { 24 | fatalError() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Modifiers/ViewModifier_Content.swift: -------------------------------------------------------------------------------- 1 | public struct _ViewModifier_Content where Modifier: ViewModifier { 2 | public typealias Body = Never 3 | public static func _makeView(view: _GraphValue<_ViewModifier_Content>, inputs: _ViewInputs) -> _ViewOutputs { 4 | fatalError() 5 | } 6 | public static func _makeViewList(view: _GraphValue<_ViewModifier_Content>, inputs: _ViewListInputs) -> _ViewListOutputs { 7 | fatalError() 8 | } 9 | } 10 | 11 | extension _ViewModifier_Content: View { 12 | public var body: Never { 13 | fatalError() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/PropertyList.swift: -------------------------------------------------------------------------------- 1 | internal struct PropertyList: CustomStringConvertible { 2 | internal var elements: PropertyList.Element? 3 | init() { elements = nil } 4 | var description: String { 5 | return "" 6 | } 7 | } 8 | extension PropertyList { 9 | class Tracker { 10 | } 11 | } 12 | extension PropertyList { 13 | internal class Element: CustomStringConvertible { 14 | internal var description: String { 15 | return "" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/State.swift: -------------------------------------------------------------------------------- 1 | internal class AnyLocationBase { 2 | } 3 | 4 | internal class AnyLocation: AnyLocationBase { 5 | internal let _value = UnsafeMutablePointer.allocate(capacity: 1) 6 | 7 | init(value: Value) { 8 | self._value.pointee = value 9 | } 10 | } 11 | 12 | public struct _DynamicPropertyBuffer { 13 | } 14 | 15 | @propertyWrapper public struct State: DynamicProperty { 16 | internal var _value: Value 17 | internal var _location: AnyLocation? 18 | 19 | public init(wrappedValue value: Value) { 20 | self._value = value 21 | self._location = AnyLocation(value: value) 22 | } 23 | 24 | public init(initialValue value: Value) { 25 | self._value = value 26 | self._location = AnyLocation(value: value) 27 | } 28 | 29 | public var wrappedValue: Value { 30 | get { return _location?._value.pointee ?? _value } 31 | nonmutating set { _location?._value.pointee = newValue } 32 | } 33 | 34 | public var projectedValue: Binding { 35 | return Binding(get: { return self.wrappedValue }, set: { newValue in self.wrappedValue = newValue }) 36 | } 37 | 38 | public static func _makeProperty(in buffer: inout _DynamicPropertyBuffer, container: _GraphValue, fieldOffset: Int, inputs: inout _GraphInputs) { 39 | fatalError() 40 | } 41 | } 42 | 43 | extension State where Value: ExpressibleByNilLiteral { 44 | public init() { 45 | self.init(wrappedValue: nil) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Transaction.swift: -------------------------------------------------------------------------------- 1 | public struct Transaction { 2 | var plist: PropertyList 3 | public init() { 4 | plist = PropertyList() 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/UnaryViewAdaptor.swift: -------------------------------------------------------------------------------- 1 | public struct _UnaryViewAdaptor : View where Content : View { 2 | public var body: Never { 3 | fatalError() 4 | } 5 | 6 | public var content: Content 7 | public init(_ content: Content) { self.content = content } 8 | public static func _makeView(view: _GraphValue<_UnaryViewAdaptor>, inputs: _ViewInputs) -> _ViewOutputs { 9 | fatalError() 10 | } 11 | public typealias Body = Never 12 | } 13 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/ViewBuilder.swift: -------------------------------------------------------------------------------- 1 | @_functionBuilder 2 | public struct ViewBuilder { 3 | public static func buildBlock() -> EmptyView { 4 | return EmptyView() 5 | } 6 | 7 | public static func buildBlock(_ content: Content) -> Content where Content: View { 8 | return content 9 | } 10 | 11 | public static func buildIf(_ content: Content?) -> Content? where Content: View { 12 | return content 13 | } 14 | 15 | public static func buildEither(first: TrueContent) -> _ConditionalContent where TrueContent: View, FalseContent: View { 16 | return .init(storage: .trueContent(first)) 17 | } 18 | public static func buildEither(second: FalseContent) -> _ConditionalContent where TrueContent: View, FalseContent: View { 19 | return .init(storage: .falseContent(second)) 20 | } 21 | } 22 | 23 | extension ViewBuilder { 24 | public static func buildBlock(_ c0: C0, _ c1: C1) -> TupleView<(C0, C1)> where C0: View, C1: View { 25 | return .init((c0, c1)) 26 | } 27 | 28 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2) -> TupleView<(C0, C1, C2)> where C0: View, C1: View, C2: View { 29 | return .init((c0, c1, c2)) 30 | } 31 | 32 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> TupleView<(C0, C1, C2, C3)> where C0: View, C1: View, C2: View, C3: View { 33 | return .init((c0, c1, c2, c3)) 34 | } 35 | 36 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> TupleView<(C0, C1, C2, C3, C4)> where C0: View, C1: View, C2: View, C3: View, C4: View { 37 | return .init((c0, c1, c2, c3, c4)) 38 | } 39 | 40 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> TupleView<(C0, C1, C2, C3, C4, C5)> where C0: View, C1: View, C2: View, C3: View, C4: View, C5: View { 41 | return .init((c0, c1, c2, c3, c4, c5)) 42 | } 43 | 44 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> TupleView<(C0, C1, C2, C3, C4, C5, C6)> where C0: View, C1: View, C2: View, C3: View, C4: View, C5: View, C6: View { 45 | return .init((c0, c1, c2, c3, c4, c5, c6)) 46 | } 47 | 48 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> TupleView<(C0, C1, C2, C3, C4, C5, C6, C7)> where C0: View, C1: View, C2: View, C3: View, C4: View, C5: View, C6: View, C7: View { 49 | return .init((c0, c1, c2, c3, c4, c5, c6, c7)) 50 | } 51 | 52 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> TupleView<(C0, C1, C2, C3, C4, C5, C6, C7, C8)> where C0: View, C1: View, C2: View, C3: View, C4: View, C5: View, C6: View, C7: View, C8: View { 53 | return .init((c0, c1, c2, c3, c4, c5, c6, c7, c8)) 54 | } 55 | 56 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> TupleView<(C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)> where C0: View, C1: View, C2: View, C3: View, C4: View, C5: View, C6: View, C7: View, C8: View, C9: View { 57 | return .init((c0, c1, c2, c3, c4, c5, c6, c7, c8, c9)) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Views/AnyView.swift: -------------------------------------------------------------------------------- 1 | public class AnyViewStorageBase { 2 | 3 | } 4 | 5 | public class AnyViewStorage: AnyViewStorageBase { 6 | public var _view: V 7 | 8 | init(_ view: V) { 9 | self._view = view 10 | } 11 | } 12 | 13 | public struct AnyView: View { 14 | public var _storage: AnyViewStorageBase 15 | 16 | public init(_ view: V) where V: View { 17 | _storage = AnyViewStorage(view) 18 | } 19 | 20 | public init?(_fromValue value: Any) { 21 | fatalError() 22 | } 23 | 24 | public typealias Body = Never 25 | public var body: Never { 26 | fatalError() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Views/Button.swift: -------------------------------------------------------------------------------- 1 | public struct Button