├── .github ├── CODEOWNERS.md └── workflows │ ├── Ubuntu.yml │ └── Windows.yml ├── .gitignore ├── .swiftlint.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── Package.swift ├── README.md └── Sources ├── OpenSwiftUI ├── Accessibility │ ├── Accessibility Fundamentals │ │ ├── AccessibilityActionResult.swift │ │ ├── AccessibilityActionStorage.swift │ │ ├── AccessibilityAttachment.swift │ │ ├── AccessibilityAttachmentModifier.swift │ │ ├── AccessibilityChildBehavior.swift │ │ ├── AccessibilityProperties.swift │ │ ├── AccessibilityPropertiesEntry.swift │ │ ├── AccessibilityScrollAction.swift │ │ ├── AccessibilityTechnologies.swift │ │ ├── AccessibilityTechnologySet.swift │ │ ├── AccessibilityVoidAction.swift │ │ ├── AnyAccessibilityAction.swift │ │ ├── PlatformAccessibilityElementProtocol.swift │ │ └── View+AccessibilityFundamentals.swift │ ├── Accessible Appearance │ │ ├── EnvironmentValues+accessibilityAssistiveAccessEnabled.swift │ │ ├── EnvironmentValues+accessibilityDifferentiateWithoutColor.swift │ │ ├── EnvironmentValues+accessibilityDimFlashingLightsKey.swift │ │ ├── EnvironmentValues+accessibilityInvertColors.swift │ │ ├── EnvironmentValues+accessibilityLargeContentViewerEnabled.swift │ │ ├── EnvironmentValues+accessibilityPlayAnimatedImagesKey.swift │ │ ├── EnvironmentValues+accessibilityReduceMotionKey.swift │ │ ├── EnvironmentValues+accessibilityReduceTransparency.swift │ │ ├── EnvironmentValues+accessibilityShowButtonShapes.swift │ │ ├── EnvironmentValues+legibilityWeight.swift │ │ ├── LegibilityWeight.swift │ │ └── View+AccessibleAppearance.swift │ ├── Accessible Controls │ │ ├── AccessibilityActionCategory.swift │ │ ├── AccessibilityActionKind.swift │ │ ├── AccessibilityAdjustableAction.swift │ │ ├── AccessibilityAdjustmentDirection.swift │ │ ├── AccessibilityDirectTouchOptions.swift │ │ ├── AccessibilityFocusState.swift │ │ ├── AccessibilityQuickActionOutlineStyle.swift │ │ ├── AccessibilityQuickActionPromptStyle.swift │ │ ├── AccessibilityQuickActionStyle.swift │ │ ├── AccessibilityZoomGestureAction.swift │ │ └── View+AccessibilityControls.swift │ ├── Accessible Descriptions │ │ ├── AXCustomContent.swift │ │ ├── AccessibilityCustomContentKey.swift │ │ ├── AccessibilityHeadingLevel.swift │ │ ├── AccessibilityLabelStorage.swift │ │ ├── AccessibilityLabeledPairRole.swift │ │ ├── AccessibilityTextContentType.swift │ │ ├── AccessibilityTraits.swift │ │ ├── AccessibilityValueStorage.swift │ │ ├── AnyAccessibilityValue.swift │ │ ├── RelationshipModifier.swift │ │ └── View+AccessibleDescriptions.swift │ └── Accessible Navigations │ │ ├── AccessibilityOptionalRotorContent.swift │ │ ├── AccessibilityRotorContent.swift │ │ ├── AccessibilityRotorContentBuilder.swift │ │ ├── AccessibilityRotorEntry.swift │ │ ├── AccessibilitySystemRotor.swift │ │ ├── View+AcessibleNavigations.swift │ │ ├── _AccessibilityRotorEntryInputs.swift │ │ └── _AccessibilityRotorEntryOutputs.swift ├── Animations │ ├── AdditiveArithmetic.swift │ ├── Animatable.swift │ └── VectorArithmetic.swift ├── App Structure │ ├── App Extensions │ │ ├── EmptyWidget.swift │ │ ├── EmptyWidgetConfiguration.swift │ │ ├── Widget.swift │ │ ├── WidgetBundle.swift │ │ ├── WidgetBundleBuilder.swift │ │ └── WidgetConfiguration.swift │ ├── App Organization │ │ └── App.swift │ ├── Documents │ │ ├── FileDocument.swift │ │ ├── NewDocumentAction.swift │ │ ├── OpenDocumentAction.swift │ │ ├── ReferenceFileDocument.swift │ │ └── RenameAction.swift │ ├── Immersive Spaces │ │ └── .keep │ ├── Modal Presentations │ │ └── .keep │ ├── Navigation │ │ └── .keep │ ├── Scenes │ │ ├── Scene.swift │ │ ├── SceneBuilder.swift │ │ ├── ScenePhase.swift │ │ ├── _SceneInputs.swift │ │ ├── _SceneModifier.swift │ │ ├── _SceneModifier_Content.swift │ │ ├── _SceneOutputs.swift │ │ └── _TupleScene.swift │ ├── Search │ │ ├── .keep │ │ └── DismissSearchAction.swift │ ├── Toolbars │ │ └── .keep │ └── Windows │ │ ├── DismissAction.swift │ │ ├── MenuBarExtraStyle.swift │ │ ├── OpenWindowAction.swift │ │ ├── WindowGroup.swift │ │ ├── WindowResizability.swift │ │ ├── WindowStyle.swift │ │ ├── WindowStyleModifier.swift │ │ ├── WindowToolbarStyle.swift │ │ └── WindowToolbarStyleModifier.swift ├── Data and Storage │ ├── Environment Values │ │ ├── Accessibility │ │ │ ├── AccessibilityEnabledKey.swift │ │ │ ├── AccessibilitySwitchControlEnabledKey.swift │ │ │ └── AccessibilityVoiceOverEnabledKey.swift │ │ ├── Actions │ │ │ ├── NewDocumentActionKey.swift │ │ │ ├── OpenDocumentActionKey.swift │ │ │ ├── OpenURLActionKey.swift │ │ │ ├── OpenWindowActionKey.swift │ │ │ ├── RefreshActionKey.swift │ │ │ ├── RenameActionKey.swift │ │ │ └── ResetFocusActionKey.swift │ │ ├── AppDefaultStorageKey.swift │ │ ├── CalendarKey.swift │ │ ├── ColorSchemeContrastKey.swift │ │ ├── ColorSchemeKey.swift │ │ ├── Controls and Input │ │ │ └── KeyboardShortcutKey.swift │ │ ├── DismissActionKey.swift │ │ ├── DismissSearchActionKey.swift │ │ ├── DisplayScaleKey.swift │ │ ├── EnabledKey.swift │ │ ├── Environment.swift │ │ ├── EnvironmentKey.swift │ │ ├── EnvironmentKeyWritingModifier.swift │ │ ├── EnvironmentPropertyKey.swift │ │ ├── EnvironmentValues.swift │ │ ├── ImageScaleKey.swift │ │ ├── LocaleKey.swift │ │ └── TimeZoneKey.swift │ ├── Model Data │ │ ├── AnyLocation.swift │ │ ├── AnyLocationBase.swift │ │ ├── Binding.swift │ │ ├── DynamicProperty.swift │ │ ├── EnvironmentObject.swift │ │ ├── Identifiable.swift │ │ ├── MutableBox.swift │ │ ├── Observable.swift │ │ ├── ObservedObject.swift │ │ ├── State.swift │ │ └── _DynamicPropertyBuffer.swift │ ├── Persistent Storage │ │ └── AppStorage.swift │ └── Preferences │ │ └── PreferenceKey.swift ├── Event Handling │ ├── Clipboard │ │ └── .keep │ ├── Drag and Drop │ │ └── .keep │ ├── Focus │ │ └── ResetFocusAction.swift │ ├── Gestures │ │ └── .keep │ ├── Input Events │ │ ├── .keep │ │ ├── EventModifiers.swift │ │ ├── KeyEquivalent.swift │ │ ├── KeyboardShortcut+Localization.swift │ │ ├── KeyboardShortcut+Scene.swift │ │ └── KeyboardShortcut.swift │ └── System Events │ │ ├── .keep │ │ ├── BackgroundTask.swift │ │ └── OpenURLAction.swift ├── Framework Integration │ ├── .keep │ └── AppKit │ │ └── NSApplicationDelegator.swift ├── Platforms │ ├── .keep │ └── Windows and Linux │ │ ├── NSHostingController.swift │ │ └── OpenSwiftUIApplication.swift ├── View Layout │ ├── Custom Layout │ │ ├── .keep │ │ ├── Layout.swift │ │ ├── LayoutDirections.swift │ │ ├── LayoutProperties.swift │ │ ├── LayoutSubview.swift │ │ ├── LayoutValueKey.swift │ │ ├── ProposedViewSize.swift │ │ └── ViewSpacing.swift │ ├── Layout Adjustments │ │ ├── Alignment.swift │ │ ├── AlignmentID.swift │ │ ├── AlignmentKey.swift │ │ ├── Edge.swift │ │ ├── EdgeInsets.swift │ │ ├── HorizontalAlignment.swift │ │ ├── UserInterfaceSizeClass.swift │ │ ├── VerticalAlignment.swift │ │ └── ViewDimensions.swift │ ├── Layout Fundamentals │ │ └── .keep │ ├── Lists │ │ ├── EditMode.swift │ │ ├── Prominence.swift │ │ └── RefreshAction.swift │ ├── Scroll Views │ │ └── .keep │ ├── Tables │ │ └── .keep │ └── View Grouping │ │ └── .keep ├── View Tree │ ├── _Graph.swift │ ├── _GraphInputs.swift │ ├── _GraphInputsModifier.swift │ ├── _GraphOutputs.swift │ ├── _GraphValue.swift │ └── _Tree.swift └── Views │ ├── Animations │ ├── Animation.swift │ ├── EmptyAnimatableData.swift │ ├── Namespace.swift │ └── Transaction.swift │ ├── Control and Indicators │ ├── ControlActiveState.swift │ └── ControlSize.swift │ ├── Drawing and Graphics │ ├── Axis.swift │ ├── BlendMode.swift │ ├── Color.swift │ ├── ColorRenderingMode.swift │ ├── ContentMode.swift │ ├── Gradient.swift │ ├── Point.swift │ ├── Rect.swift │ ├── Size.swift │ └── UnitPoint.swift │ ├── Images │ ├── Image.swift │ ├── Interpolation.swift │ ├── Orientation.swift │ ├── ResizingMode.swift │ ├── Scale.swift │ └── TemplateRenderingMode.swift │ ├── Menu and Commands │ ├── Commands.swift │ ├── CommandsBuilder.swift │ ├── CommandsModifier.swift │ └── EmptyCommands.swift │ ├── Shapes │ └── .keep │ ├── Text Input and Output │ └── LocalizedStringKey.swift │ ├── View Confguration │ ├── ColorScheme.swift │ ├── ColorSchemeContrast.swift │ └── Visibility.swift │ ├── View Fundamentals │ ├── ActivationConditionsModifier.swift │ ├── AnyView.swift │ ├── BackgroundTaskModifier.swift │ ├── CommandsRemovedModifier.swift │ ├── EmptyModifier.swift │ ├── EmptyView.swift │ ├── EnvironmentalModifier.swift │ ├── EquatableView.swift │ ├── Label.swift │ ├── MenuBarExtraStyleModifier.swift │ ├── ModifiedContent.swift │ ├── Never.swift │ ├── PlaceholderContentView.swift │ ├── Text.swift │ ├── TupleView.swift │ ├── VStack.swift │ ├── View.swift │ ├── ViewBuilder.swift │ ├── ViewModifier.swift │ ├── WindowDefaultsPositionModifier.swift │ ├── WindowDefaultsSizeModifier.swift │ ├── WindowResizabilityModifier.swift │ ├── _AppearanceActionModifier.swift │ ├── _ConditionalContent.swift │ ├── _EnvironmentKeyTransformModifier.swift │ ├── _IdentifiedViewProxy.swift │ ├── _PreferenceTransformModifier.swift │ ├── _ValueActionModifier.swift │ ├── _ValueActionModifier2.swift │ ├── _ViewInputs.swift │ ├── _ViewListCountInputs.swift │ ├── _ViewListInputs.swift │ ├── _ViewListOutputs.swift │ ├── _ViewModifier_Content.swift │ └── _ViewOutputs.swift │ └── View Styles │ └── .keep └── OpenSwiftUISample └── MyApp.swift /.github/CODEOWNERS.md: -------------------------------------------------------------------------------- 1 | * @helbertgs -------------------------------------------------------------------------------- /.github/workflows/Ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu 2 | 3 | on: 4 | pull_request: 5 | branches: [ develop ] 6 | 7 | jobs: 8 | ubuntu_test: 9 | name: Execute tests on Ubuntu 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | swift_version: ["6.0"] 14 | runs-on: ubuntu-latest 15 | container: swift:${{ matrix.swift_version }}-bionic 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Building and running tests in debug mode with coverage 19 | run: | 20 | swift test \ 21 | -c debug \ 22 | --enable-code-coverage \ 23 | --build-path .build-test-debug -------------------------------------------------------------------------------- /.github/workflows/Windows.yml: -------------------------------------------------------------------------------- 1 | name: Windows 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | 8 | jobs: 9 | Test: 10 | name: Execute tests on Windows 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | swift_version: ["6.0"] 15 | runs-on: windows-latest 16 | steps: 17 | - uses: compnerd/gha-setup-swift@main 18 | with: 19 | branch: swift-6.0-release 20 | tag: 6.0-RELEASE 21 | 22 | - uses: actions/checkout@v4 23 | - run: swift build 24 | 25 | 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # App packaging 2 | *.ipa 3 | *.dSYM.zip 4 | *.dSYM 5 | 6 | # Swift Package Manager 7 | # 8 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 9 | Packages/ 10 | Package.pins 11 | Package.resolved 12 | 13 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata. 14 | .swiftpm 15 | .build/ 16 | .build-test-debug/ 17 | .build-test-debug-sanitize-thread/ 18 | .build-test-release/ 19 | 20 | # Bazel 21 | bazel-* 22 | 23 | # Xcode 24 | # 25 | # Add this line if you want to avoid checking in source code from the Xcode workspace/project. 26 | *.xcworkspace 27 | *.xcodeproj 28 | 29 | # Others 30 | 31 | .DS_Store 32 | 33 | # Visual Studio Code 34 | .vscode/ -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | excluded: 2 | - Package.swift 3 | - Tests 4 | - .build/ 5 | 6 | included: 7 | - Sources 8 | 9 | disabled_rules: 10 | - block_based_kvo 11 | - class_delegate_protocol 12 | - colon 13 | - cyclomatic_complexity 14 | - explicit_enum_raw_value 15 | - force_cast 16 | - force_try 17 | - force_unwrapping 18 | - function_body_length 19 | - function_parameter_count 20 | - generic_type_name 21 | - identifier_name 22 | - large_tuple 23 | - nesting 24 | - opening_brace 25 | - redundant_string_enum_value 26 | - switch_case_on_newline 27 | - switch_case_alignment 28 | - trailing_comma 29 | - type_body_length 30 | - type_name 31 | 32 | implicit_return: 33 | included: 34 | - closure 35 | 36 | file_length: 37 | warning: 400 38 | error: 1000 39 | ignore_comment_only_lines: true 40 | 41 | line_length: 42 | warning: 150 43 | error: 160 44 | ignores_urls: true 45 | ignores_comments: true 46 | ignores_function_declarations: true 47 | 48 | generic_type_name: 49 | min_length: 2 50 | 51 | attributes: 52 | always_on_line_above: 53 | - "@usableFromInline" 54 | - "@inlinable" -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Helbert Gomes 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. -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:6.0 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 | products: [ 9 | .library( 10 | name: "OpenSwiftUI", 11 | targets: ["OpenSwiftUI"]), 12 | .executable( 13 | name: "OpenSwiftUISample", 14 | targets: ["OpenSwiftUISample"]), 15 | ], 16 | dependencies: [ 17 | .package(url: "https://github.com/OpenCombine/OpenCombine.git", branch: "master"), 18 | .package(url: "https://github.com/helbertgs/AppKit.git", branch: "main"), 19 | .package(url: "https://github.com/swiftlang/swift-docc-plugin", branch: "main") 20 | ], 21 | targets: [ 22 | .target( 23 | name: "OpenSwiftUI", 24 | dependencies: [ 25 | .product(name: "AppKit", package: "AppKit"), 26 | .product(name: "OpenCombine", package: "OpenCombine") 27 | ] 28 | ), 29 | .executableTarget( 30 | name: "OpenSwiftUISample", 31 | dependencies: ["OpenSwiftUI"], 32 | swiftSettings: [ 33 | .unsafeFlags([ "-parse-as-library" ]) 34 | ] 35 | ) 36 | ] 37 | ) 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenSwiftUI 2 | [![Windows](https://github.com/helbertgs/OpenSwiftUI/actions/workflows/Windows.yml/badge.svg)](https://github.com/helbertgs/OpenSwiftUI/actions/workflows/Windows.yml) 3 | [![Ubuntu](https://github.com/helbertgs/OpenSwiftUI/actions/workflows/Ubuntu.yml/badge.svg)](https://github.com/helbertgs/OpenSwiftUI/actions/workflows/Ubuntu.yml) 4 | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/0cdb7c84c14a4e709e938a65ff87e2e4)](https://www.codacy.com/gh/helbertgs/OpenSwiftUI/dashboard?utm_source=github.com&utm_medium=referral&utm_content=helbertgs/OpenSwiftUI&utm_campaign=Badge_Grade) 5 | ![Swift Version](https://badgen.net/badge/Swift/6.0/orange) 6 | ![Swift Package Manager Version](https://badgen.net/badge/Swift%20Package%20Manager/6.0/orange) 7 | ![Windows](https://badgen.net/badge/Windows/Latest/blue) 8 | ![Linux](https://badgen.net/badge/Ubuntu/Latest/orange) 9 | ![OpenGL](https://badgen.net/badge/OpenGL/3.3+/blue) 10 | 11 | 12 | Declare the user interface and behavior for your app on every platform. Open-source framework based on Apple's SwiftUI. 13 | 14 | # Overview 15 | 16 | OpenSwiftUI provides views, controls, and layout structures for declaring your app’s user interface. The framework provides event handlers for delivering taps, gestures, and other types of input to your app, and tools to manage the flow of data from your app’s models down to the views and controls that users will see and interact with. 17 | 18 | Define your app structure using the App protocol, and populate it with scenes that contain the views that make up your app’s user interface. Create your own custom views that conform to the View protocol, and compose them with OpenSwiftUI views for displaying text, images, and custom shapes using stacks, lists, and more. Apply powerful modifiers to built-in views and your own views to customize their rendering and interactivity. Share code between apps on multiple platforms with views and controls that adapt to their context and presentation. 19 | 20 | You can integrate OpenSwiftUI views with objects from the [OpenGL]() and [OpenUIKit]() frameworks to take further advantage of platform-specific functionality. You can also customize accessibility support in OpenSwiftUI, and localize your app’s interface for different languages, countries, or cultural regions. 21 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityActionResult.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct AccessibilityActionResult { 4 | public init() { 5 | } 6 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityActionStorage.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class AccessibilityActionStorage : AnyAccessibilityAction { 4 | var action: Value 5 | var category: AccessibilityActionCategory? 6 | var label: Text? 7 | var image: Image? 8 | var handler: Any? 9 | var seed: Int 10 | 11 | init(action: Value, category: AccessibilityActionCategory?, label: Text?, image: Image?, handler: Any?, seed: Int) { 12 | self.action = action 13 | self.category = category 14 | self.label = label 15 | self.image = image 16 | self.handler = handler 17 | self.seed = seed 18 | } 19 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityAttachment.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct AccessibilityAttachment { 4 | var properties: AccessibilityProperties 5 | var platformElement: (any PlatformAccessibilityElementProtocol)? 6 | 7 | init(properties: AccessibilityProperties, platformElement: (any PlatformAccessibilityElementProtocol)?) { 8 | self.properties = properties 9 | self.platformElement = platformElement 10 | } 11 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityAttachmentModifier.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A view modifier that adds accessibility properties to the view 4 | public struct AccessibilityAttachmentModifier { 5 | let storage: MutableBox 6 | let behavior: AccessibilityChildBehavior? 7 | 8 | public init(storage: MutableBox, behavior: AccessibilityChildBehavior?) { 9 | self.storage = storage 10 | self.behavior = behavior 11 | } 12 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityChildBehavior.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Defines the behavior for the child elements of the new parent element. 4 | public struct AccessibilityChildBehavior: Equatable, Hashable, Sendable { 5 | 6 | // MARK: - Getting behaviors 7 | 8 | /// Any child accessibility element’s properties are merged into the new accessibility element. 9 | public static let combine: AccessibilityChildBehavior = .init() 10 | 11 | /// Any child accessibility elements become children of the new accessibility element. 12 | public static let contain: AccessibilityChildBehavior = .init() 13 | 14 | /// Any child accessibility elements become hidden. 15 | public static let ignore: AccessibilityChildBehavior = .init() 16 | 17 | // MARK: - Create a Behaviour 18 | 19 | public init() { 20 | } 21 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityProperties.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class AccessibilityProperties { 4 | let storage: [ObjectIdentifier: Any] 5 | 6 | init(storage: [ObjectIdentifier: Any]) { 7 | self.storage = storage 8 | } 9 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityPropertiesEntry.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class AccessibilityPropertiesEntry { 4 | let typedValue: Value 5 | 6 | init(typedValue: Value) { 7 | self.typedValue = typedValue 8 | } 9 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityScrollAction.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityScrollAction { 4 | init() { 5 | } 6 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityTechnologySet.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | @frozen public struct AccessibilityTechnologySet : OptionSet, CaseIterable, Equatable, Hashable, Sendable { 4 | 5 | // MARK: - Static Property(ies). 6 | 7 | public static let voiceOver : AccessibilityTechnologySet = .init(rawValue: 1 << 0) 8 | public static let switchControl : AccessibilityTechnologySet = .init(rawValue: 1 << 1) 9 | 10 | // MARK: - Public Property(ies). 11 | 12 | public var rawValue: Int 13 | public static let allCases: [AccessibilityTechnologySet] = [.voiceOver, .switchControl] 14 | 15 | // MARK: - Constructor(s). 16 | 17 | @inlinable public init(rawValue: Int) { 18 | self.rawValue = rawValue 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AccessibilityVoidAction.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class AccessibilityVoidAction { 4 | var kind: AccessibilityActionKind 5 | 6 | init(kind: AccessibilityActionKind) { 7 | self.kind = kind 8 | } 9 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/AnyAccessibilityAction.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class AnyAccessibilityAction { 4 | var bridged: Bool = false 5 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/PlatformAccessibilityElementProtocol.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol PlatformAccessibilityElementProtocol { 4 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessibility Fundamentals/View+AccessibilityFundamentals.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension View { 4 | 5 | // MARK: - Creating accessible elements 6 | 7 | /// Creates a new accessibility element, or modifies the AccessibilityChildBehavior of the existing accessibility element. 8 | /// - Parameter children: The behavior to use when creating or transforming an accessibility element. The default is ignore 9 | nonisolated public func accessibilityElement(children: AccessibilityChildBehavior = .ignore) -> some View { 10 | fatalError() 11 | } 12 | 13 | /// Replaces the existing accessibility element’s children with one or more new synthetic accessibility elements. 14 | /// - Parameter children: A ViewBuilder that represents the replacement child views the framework uses to generate accessibility elements. 15 | nonisolated public func accessibilityChildren(@ViewBuilder children: () -> V) -> some View where V : View { 16 | fatalError() 17 | } 18 | 19 | /// Replaces one or more accessibility elements for this view with new accessibility elements. 20 | /// - Parameter representation: A hidden view that the accessibility system uses to generate accessibility elements. 21 | nonisolated public func accessibilityRepresentation(@ViewBuilder representation: () -> V) -> some View where V : View { 22 | fatalError() 23 | } 24 | 25 | // MARK: - Identifying elements 26 | 27 | /// Uses the string you specify to identify the view. 28 | /// Use this value for testing. It isn’t visible to the user. 29 | nonisolated public func accessibilityIdentifier(_ identifier: String) -> ModifiedContent { 30 | fatalError() 31 | } 32 | 33 | /// Uses the string you specify to identify the view. 34 | /// Use this value for testing. It isn’t visible to the user. 35 | /// - Parameters: 36 | /// - identifier: The accessibility identifier to apply. 37 | /// - isEnabled: If true the accessibility identifier is applied; otherwise the accessibility identifier is unchanged. 38 | nonisolated public func accessibilityIdentifier(_ identifier: String, isEnabled: Bool) -> ModifiedContent { 39 | fatalError() 40 | } 41 | 42 | // MARK: - Hiding elements 43 | 44 | /// Specifies whether to hide this view from system accessibility features. 45 | nonisolated public func accessibilityHidden(_ hidden: Bool) -> ModifiedContent { 46 | fatalError() 47 | } 48 | 49 | /// Specifies whether to hide this view from system accessibility features. 50 | /// - Parameters: 51 | /// - hidden: Whether to hide this view from accessibility features. 52 | /// - isEnabled: If true the accessibility hidden state is applied; otherwise the accessibility hidden state is unchanged. 53 | nonisolated public func accessibilityHidden(_ hidden: Bool, isEnabled: Bool) -> ModifiedContent { 54 | fatalError() 55 | } 56 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityAssistiveAccessEnabled.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityAssistiveAccessEnabledKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// A Boolean value that indicates whether Assistive Access is in use. 11 | var accessibilityAssistiveAccessEnabled : Bool { 12 | get { self[AccessibilityAssistiveAccessEnabledKey.self] } 13 | set { self[AccessibilityAssistiveAccessEnabledKey.self] = newValue } 14 | } 15 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityDifferentiateWithoutColor.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityDifferentiateWithoutColorKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// Whether the system preference for Differentiate without Color is enabled. 11 | /// If this is true, UI should not convey information using color alone and instead should use shapes or glyphs to convey information. 12 | var accessibilityDifferentiateWithoutColor : Bool { 13 | get { self[AccessibilityDifferentiateWithoutColorKey.self] } 14 | set { self[AccessibilityDifferentiateWithoutColorKey.self] = newValue } 15 | } 16 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityDimFlashingLightsKey.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | struct AccessibilityDimFlashingLightsKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// A Boolean value that indicates whether the user has enabled an assistive technology. 11 | /// 12 | /// The default value is `false`. 13 | public var AccessibilityDimFlashingLightsKey: Bool { 14 | get { self[AccessibilityEnabledKey.self] } 15 | set { self[AccessibilityEnabledKey.self] = newValue } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityInvertColors.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityInvertColorsKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// Whether the system preference for Invert Colors is enabled. 11 | /// If this property’s value is true then the display will be inverted. 12 | /// In these cases it may be needed for UI drawing to be adjusted to in order to display optimally when inverted. 13 | var accessibilityInvertColors : Bool { 14 | get { self[AccessibilityInvertColorsKey.self] } 15 | set { self[AccessibilityInvertColorsKey.self] = newValue } 16 | } 17 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityLargeContentViewerEnabled.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityLargeContentViewerEnabledKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// Whether the Large Content Viewer is enabled. 11 | /// The system can automatically provide a large content view with accessibilityShowsLargeContentViewer() or you can provide your own with accessibilityShowsLargeContentViewer(_:). 12 | /// While it is not necessary to check this value before adding a large content view, it may be helpful if you need to adjust the behavior of a gesture. 13 | /// For example, a button with a long press handler might increase its long press duration so the user can read the text in the large content viewer first. 14 | var accessibilityLargeContentViewerEnabled : Bool { 15 | get { self[AccessibilityLargeContentViewerEnabledKey.self] } 16 | set { self[AccessibilityLargeContentViewerEnabledKey.self] = newValue } 17 | } 18 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityPlayAnimatedImagesKey.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | struct AccessibilityPlayAnimatedImagesKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// Whether the setting for playing animations in an animated image is on. When this value is false, any presented image that contains animation should not play automatically. 11 | /// The default value is `false`. 12 | public var accessibilityPlayAnimatedImages: Bool { 13 | get { self[AccessibilityPlayAnimatedImagesKey.self] } 14 | set { self[AccessibilityPlayAnimatedImagesKey.self] = newValue } 15 | } 16 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityReduceMotionKey.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | struct AccessibilityReduceMotionKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// Whether the setting for playing animations in an animated image is on. When this value is false, any presented image that contains animation should not play automatically. 11 | /// The default value is `false`. 12 | public var accessibilityReduceMotion: Bool { 13 | get { self[AccessibilityReduceMotionKey.self] } 14 | set { self[AccessibilityReduceMotionKey.self] = newValue } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityReduceTransparency.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityReduceTransparencyKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// Whether the system preference for Reduce Transparency is enabled. 11 | /// If this property’s value is true, UI (mainly window) backgrounds should not be semi-transparent; they should be opaque. 12 | var accessibilityReduceTransparency : Bool { 13 | get { self[AccessibilityReduceTransparencyKey.self] } 14 | set { self[AccessibilityReduceTransparencyKey.self] = newValue } 15 | } 16 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+accessibilityShowButtonShapes.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityShowButtonShapesKey : EnvironmentKey { 4 | static var defaultValue: Bool { 5 | false 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// Whether the system preference for Show Button Shapes is enabled. 11 | /// If this property’s value is true, interactive custom controls such as buttons should be drawn in such a way that their edges and borders are clearly visible. 12 | var accessibilityShowButtonShapes : Bool { 13 | get { self[AccessibilityShowButtonShapesKey.self] } 14 | set { self[AccessibilityShowButtonShapesKey.self] = newValue } 15 | } 16 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/EnvironmentValues+legibilityWeight.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct LegibilityWeightKey : EnvironmentKey { 4 | static var defaultValue: LegibilityWeight? { 5 | nil 6 | } 7 | } 8 | 9 | extension EnvironmentValues { 10 | /// The font weight to apply to text. 11 | /// This value reflects the value of the Bold Text display setting found in the Accessibility settings. 12 | var legibilityWeight : LegibilityWeight? { 13 | get { self[LegibilityWeightKey.self] } 14 | set { self[LegibilityWeightKey.self] = newValue } 15 | } 16 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/LegibilityWeight.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | /// The Accessibility Bold Text user setting options. 4 | /// 5 | /// The app can't override the user's choice. 6 | public enum LegibilityWeight : String, Equatable, Hashable { 7 | 8 | // MARK: - Case(s). 9 | 10 | /// Use regular font weight (no Accessibility Bold). 11 | case regular 12 | 13 | /// Use heavier font weight (force Accessibility Bold). 14 | case bold 15 | 16 | // MARK: - Equatable. 17 | 18 | /// Returns a Boolean value indicating whether two values are equal. 19 | /// 20 | /// Equality is the inverse of inequality. For any values `a` and `b`, 21 | /// `a == b` implies that `a != b` is `false`. 22 | /// 23 | /// - Parameters: 24 | /// - lhs: A value to compare. 25 | /// - rhs: Another value to compare. 26 | public static func == (lhs: LegibilityWeight, rhs: LegibilityWeight) -> Bool { 27 | lhs.rawValue == rhs.rawValue 28 | } 29 | 30 | // MARK: - Hashable. 31 | 32 | /// Hashes the essential components of this value by feeding them into the 33 | /// given hasher. 34 | /// 35 | /// Implement this method to conform to the `Hashable` protocol. The 36 | /// components used for hashing must be the same as the components compared 37 | /// in your type's `==` operator implementation. Call `hasher.combine(_:)` 38 | /// with each of these components. 39 | /// 40 | /// - Important: Never call `finalize()` on `hasher`. Doing so may become a 41 | /// compile-time error in the future. 42 | /// 43 | /// - Parameter hasher: The hasher to use when combining the components 44 | /// of this instance. 45 | public func hash(into hasher: inout Hasher) { 46 | hasher.combine(rawValue) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Appearance/View+AccessibleAppearance.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension View { 4 | 5 | // MARK: - Managing color 6 | 7 | /// Sets whether this view should ignore the system Smart Invert setting. 8 | /// Use this modifier to suppress Smart Invert in a view that shouldn’t be inverted. Or pass an active argument of false to begin following the Smart Invert setting again when it was previously disabled. 9 | /// - Parameter active: A true value ignores the system Smart Invert setting. A false value follows the system setting. 10 | /// - Returns: The modified view. 11 | nonisolated public func accessibilityIgnoresInvertColors(_ active: Bool = true) -> some View { 12 | fatalError() 13 | } 14 | 15 | // MARK: - Enlarging content 16 | 17 | /// Adds a default large content view to be shown by the large content viewer. 18 | /// - Returns: The modified view. 19 | nonisolated public func accessibilityShowsLargeContentViewer() -> some View { 20 | fatalError() 21 | } 22 | 23 | /// Adds a custom large content view to be shown by the large content viewer. 24 | /// - Returns: The modified view. 25 | nonisolated public func accessibilityShowsLargeContentViewer(@ViewBuilder _ largeContentView: () -> V) -> some View where V : View { 26 | fatalError() 27 | } 28 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityActionCategory.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Designates an accessibility action category that is provided and named by the system. 4 | @frozen public struct AccessibilityActionCategory: Equatable, Sendable { 5 | 6 | // MARK: - Type Properties 7 | 8 | /// An accessibility action category for the default actions of a view. This category replaces the system provided actions rotor for accessibility technologies like VoiceOver. 9 | public static let `default`: AccessibilityActionCategory = .init(.init()) 10 | 11 | /// An accessibility action category for associating actions related to editing text. This category replaces the system provided Edit actions for accessibility technologies like VoiceOver. 12 | public static let edit: AccessibilityActionCategory = .init(.init()) 13 | 14 | /// The name for the category of the accessibility actions. 15 | public let name: Text 16 | 17 | // MARK: - Initializers 18 | 19 | /// Creates a custom action category labeled by name. 20 | /// - Parameter name: The name for the category of the accessibility actions. 21 | @inlinable public init(_ name: Text) { 22 | self.name = name 23 | } 24 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityActionKind.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// The structure that defines the kinds of available accessibility actions. 4 | public struct AccessibilityActionKind : Equatable, Sendable { 5 | 6 | // MARK: - Getting the kind of action 7 | 8 | var kind: ActionKind 9 | 10 | /// The value that represents the default accessibility action. 11 | public static var `default`: AccessibilityActionKind { 12 | .init(kind: .default) 13 | } 14 | 15 | /// The value that represents an accessibility action that dismisses a modal view or cancels an operation. 16 | public static var escape: AccessibilityActionKind { 17 | .init(kind: .escape) 18 | } 19 | 20 | public static var delete: AccessibilityActionKind { 21 | .init(kind: .delete) 22 | } 23 | 24 | public static var magicTap: AccessibilityActionKind { 25 | .init(kind: .magicTap) 26 | } 27 | 28 | public static var showMenu: AccessibilityActionKind { 29 | .init(kind: .showMenu) 30 | } 31 | 32 | // MARK: - Creating an action type 33 | 34 | public init(named name: Text) { 35 | self = .init(kind: .custom(name)) 36 | } 37 | 38 | init(kind: ActionKind) { 39 | self.kind = kind 40 | } 41 | } 42 | 43 | extension AccessibilityActionKind { 44 | enum ActionKind: Equatable { 45 | case `default` 46 | case escape 47 | case delete 48 | case magicTap 49 | case showMenu 50 | case custom(Text) 51 | 52 | static func == (_ lhs: ActionKind, _ rhs: ActionKind) -> Bool { 53 | return switch (lhs, rhs) { 54 | case (.default, .default): true 55 | case (.escape, .escape): true 56 | case (.delete, .delete): true 57 | case (.magicTap, .magicTap): true 58 | case (.showMenu, .showMenu): true 59 | case let (.custom(txtLhs), .custom(txtRhs)): txtLhs == txtRhs 60 | default: false 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityAdjustableAction.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class AccessibilityAdjustableAction : AnyAccessibilityAction { 4 | var continuous: Bool? 5 | 6 | init(continuous: Bool?) { 7 | self.continuous = continuous 8 | } 9 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityAdjustmentDirection.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A directional indicator you use when making an accessibility adjustment. 4 | public enum AccessibilityAdjustmentDirection : Copyable, Equatable, Hashable, Sendable { 5 | 6 | // MARK: - Getting an adjustment direction 7 | 8 | case decrement 9 | case increment 10 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityDirectTouchOptions.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// An option set that defines the functionality of a view’s direct touch area. 4 | public struct AccessibilityDirectTouchOptions: Equatable, OptionSet, Sendable { 5 | 6 | // MARK: - Element 7 | 8 | public var rawValue: Int 9 | 10 | // MARK: - Getting the options 11 | 12 | /// Prevents touch passthrough with the direct touch area until an assistive technology, such as VoiceOver, has activated the direct touch area through a user action, for example a double tap. 13 | public static let requiresActivation: AccessibilityDirectTouchOptions = .init(rawValue: 1) 14 | 15 | /// Allows a direct touch area to immediately receive touch events without an assitive technology, such as VoiceOver, speaking. Appropriate for apps that provide direct audio feedback on touch that would conflict with speech feedback. 16 | public static let silentOnTouch: AccessibilityDirectTouchOptions = .init(rawValue: 2) 17 | 18 | // MARK: - Creating a set of options 19 | 20 | /// Create a set of direct touch options 21 | public init(rawValue: Int) { 22 | self.rawValue = rawValue 23 | } 24 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityFocusState.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A property wrapper type that can read and write a value that OpenSwiftUI updates as the focus of any active accessibility technology, such as VoiceOver, changes. 4 | @frozen public struct AccessibilityFocusState where Value : Hashable { 5 | 6 | private var value: Value 7 | 8 | // MARK: - Creating a focus state 9 | 10 | /// Creates a new accessibility focus state for a Boolean value. 11 | public init(value: Value) { 12 | self.value = value 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityQuickActionOutlineStyle.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A presentation style that displays a prompt to the user when the accessibility quick action is active. 4 | /// Don’t use this type directly. Instead, use outline. 5 | public struct AccessibilityQuickActionOutlineStyle : AccessibilityQuickActionStyle, Sendable { 6 | public init() { } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityQuickActionPromptStyle.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A presentation style that displays a prompt to the user when the accessibility quick action is active. 4 | public struct AccessibilityQuickActionPromptStyle : AccessibilityQuickActionStyle, Sendable { 5 | public init() { } 6 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityQuickActionStyle.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public protocol AccessibilityQuickActionStyle { 4 | 5 | // MARK: - Getting built-in menu styles 6 | /// A presentation style that animates an outline around the view when the accessibility quick action is active. 7 | static var outline: AccessibilityQuickActionOutlineStyle { get } 8 | 9 | /// A presentation style that displays a prompt to the user when the accessibility quick action is active. 10 | static var prompt: AccessibilityQuickActionPromptStyle { get } 11 | } 12 | 13 | extension AccessibilityQuickActionStyle { 14 | public static var outline: AccessibilityQuickActionOutlineStyle { 15 | .init() 16 | } 17 | } 18 | 19 | extension AccessibilityQuickActionStyle { 20 | public static var prompt: AccessibilityQuickActionPromptStyle { 21 | .init() 22 | } 23 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Controls/AccessibilityZoomGestureAction.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Position and direction information of a zoom gesture that someone performs with an assistive technology like VoiceOver 4 | public struct AccessibilityZoomGestureAction { 5 | 6 | @frozen public enum Direction: Equatable, Hashable, Sendable { 7 | case zoomIn 8 | case zoomOut 9 | } 10 | 11 | // MARK: - Getting the action’s direction 12 | 13 | /// The zoom gesture’s direction. 14 | public let direction: Direction 15 | 16 | // MARK: - Getting location information 17 | 18 | /// The zoom gesture’s activation point, normalized to the accessibility element’s frame. 19 | public let location: UnitPoint 20 | 21 | /// The zoom gesture’s activation point within the window’s coordinate space. 22 | public let point: Point 23 | 24 | /// Create a new AccessibilityZoomGestureAction 25 | /// - Parameters: 26 | /// - direction: The zoom gesture’s direction. 27 | /// - location: The zoom gesture’s activation point, normalized to the accessibility element’s frame. 28 | /// - point: The zoom gesture’s activation point within the window’s coordinate space. 29 | public init(direction: Direction, location: UnitPoint, point: Point) { 30 | self.direction = direction 31 | self.location = location 32 | self.point = point 33 | } 34 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AXCustomContent.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Objects that define custom content and the timing of its output. 4 | public class AXCustomContent { 5 | 6 | // MARK: - Defining custom content 7 | 8 | /// A localized string that identifies the label for this content. 9 | public let label: String 10 | 11 | /// A localized string that provides a value for the label. 12 | public let value: String 13 | 14 | /// An object that determines when to output custom accessibility content. 15 | public let importance: AXCustomContent.Importance 16 | 17 | // MARK: - Creating custom content 18 | 19 | /// Creates new custom content with a label and value. 20 | /// - Parameters: 21 | /// - label: A localized string that identifies the label for this content. 22 | /// - value: A localized string that provides a value for the label. 23 | /// - importance: An object that determines when to output custom accessibility content. 24 | public init(label: String, value: String, importance: Importance = .default) { 25 | self.label = label 26 | self.value = value 27 | self.importance = importance 28 | } 29 | 30 | /// Objects that control the timing of content output. 31 | public enum Importance: BitwiseCopyable, Equatable, Hashable, Sendable { 32 | 33 | // MARK: - Setting content importance 34 | 35 | /// Output the content to the user on demand. 36 | case `default` 37 | 38 | /// Output the content to the user immediately. 39 | case high 40 | } 41 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AccessibilityCustomContentKey.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Key used to specify the identifier and label associated with an entry of additional accessibility information. 4 | /// Use AccessibilityCustomContentKey and the associated modifiers taking this value as a parameter in order to simplify clearing or replacing entries of additional information that are manipulated from multiple places in your code. 5 | public struct AccessibilityCustomContentKey: Copyable, Equatable { 6 | 7 | // MARK: - Creating a key 8 | 9 | /// Create an AccessibilityCustomContentKey with the specified label. 10 | /// - Parameter labelKey: Localized text describing to the user what is contained in this additional information entry. For example: “orientation”. This will also be used as the identifier. 11 | public init(_ labelKey: LocalizedStringKey) { } 12 | 13 | /// Create an AccessibilityCustomContentKey with the specified label and identifier. 14 | /// - Parameters: 15 | /// - label: Localized text describing to the user what is contained in this additional information entry. For example: “orientation”. 16 | /// - id: String used to identify the additional information entry to OpenSwiftUI. Adding an entry will replace any previous value with the same identifier. 17 | public init(_ label: Text, id: String) { } 18 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AccessibilityHeadingLevel.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// The hierarchy of a heading in relation other headings. 4 | @frozen public enum AccessibilityHeadingLevel: BitwiseCopyable, Copyable, Equatable, Hashable, Sendable { 5 | 6 | // MARK: - Getting the heading level 7 | 8 | /// Level 1 heading. 9 | case h1 10 | 11 | /// Level 2 heading. 12 | case h2 13 | 14 | /// Level 3 heading. 15 | case h3 16 | 17 | /// Level 4 heading. 18 | case h4 19 | 20 | /// Level 5 heading. 21 | case h5 22 | 23 | /// Level 6 heading. 24 | case h6 25 | 26 | /// A heading without a hierarchy. 27 | case unspecified 28 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AccessibilityLabelStorage.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityLabelStorage { 4 | var texts: Text 5 | var placement: Placement 6 | 7 | init(texts: Text, placement: Placement) { 8 | self.texts = texts 9 | self.placement = placement 10 | } 11 | } 12 | 13 | extension AccessibilityLabelStorage { 14 | enum Placement { 15 | case assign 16 | } 17 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AccessibilityLabeledPairRole.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// The role of an accessibility element in a label / content pair. 4 | @frozen public enum AccessibilityLabeledPairRole: BitwiseCopyable, Copyable, Equatable, Hashable, Sendable { 5 | 6 | // MARK: - Getting roles 7 | 8 | /// This element represents the content part of the label / content pair. 9 | case content 10 | 11 | /// This element represents the label part of the label / content pair. 12 | case label 13 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AccessibilityTextContentType.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Textual context that assistive technologies can use to improve the presentation of spoken text. 4 | public struct AccessibilityTextContentType: Sendable { 5 | // MARK: - Getting content types 6 | 7 | /// A type that represents text used for input, like in the Terminal app. 8 | public static let console: AccessibilityTextContentType = .init() 9 | 10 | /// A type that represents text used by a file browser, like in the Finder app in macOS. 11 | public static let fileSystem: AccessibilityTextContentType = .init() 12 | 13 | /// A type that represents text used in a message, like in the Messages app. 14 | public static let messaging: AccessibilityTextContentType = .init() 15 | 16 | /// A type that represents text used in a story or poem, like in the Books app. 17 | public static let narrative: AccessibilityTextContentType = .init() 18 | 19 | /// A type that represents generic text that has no specific type. 20 | public static let plain: AccessibilityTextContentType = .init() 21 | 22 | /// A type that represents text used in source code, like in Swift Playgrounds. 23 | public static let sourceCode: AccessibilityTextContentType = .init() 24 | 25 | /// A type that represents text used in a grid of data, like in the Numbers app. 26 | public static let spreadsheet: AccessibilityTextContentType = .init() 27 | 28 | /// A type that represents text used in a document, like in the Pages app. 29 | public static let wordProcessing: AccessibilityTextContentType = .init() 30 | 31 | init() { } 32 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AccessibilityTraits.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A set of accessibility traits that describe how an element behaves. 4 | public struct AccessibilityTraits: Sendable { 5 | 6 | // MARK: - Getting traits 7 | 8 | /// The accessibility element allows direct touch interaction for VoiceOver users. 9 | public static let allowsDirectInteraction: AccessibilityTraits = .init() 10 | 11 | /// The accessibility element causes an automatic page turn when VoiceOver finishes reading the text within it. 12 | public static let causesPageTurn: AccessibilityTraits = .init() 13 | 14 | /// The accessibility element is a button. 15 | public static let isButton: AccessibilityTraits = .init() 16 | 17 | /// The accessibility element is a header that divides content into sections, like the title of a navigation bar. 18 | public static let isHeader: AccessibilityTraits = .init() 19 | 20 | /// The accessibility element is an image. 21 | public static let isImage: AccessibilityTraits = .init() 22 | 23 | /// The accessibility element behaves as a keyboard key. 24 | public static let isKeyboardKey: AccessibilityTraits = .init() 25 | 26 | /// The accessibility element is a link. 27 | public static let isLink: AccessibilityTraits = .init() 28 | 29 | /// The accessibility element is modal. 30 | public static let isModal: AccessibilityTraits = .init() 31 | 32 | /// The accessibility element is a search field. 33 | public static let isSearchField: AccessibilityTraits = .init() 34 | 35 | /// The accessibility element is currently selected. 36 | public static let isSelected: AccessibilityTraits = .init() 37 | 38 | /// The accessibility element is a static text that cannot be modified by the user. 39 | public static let isStaticText: AccessibilityTraits = .init() 40 | 41 | /// The accessibility element provides summary information when the application starts. 42 | public static let isSummaryElement: AccessibilityTraits = .init() 43 | 44 | /// The accessibility element is a toggle. 45 | public static let isToggle: AccessibilityTraits = .init() 46 | 47 | /// The accessibility element plays its own sound when activated. 48 | public static let playsSound: AccessibilityTraits = .init() 49 | 50 | /// The accessibility element starts a media session when it is activated. 51 | public static let startsMediaSession: AccessibilityTraits = .init() 52 | 53 | /// The accessibility element frequently updates its label or value. 54 | public static let updatesFrequently: AccessibilityTraits = .init() 55 | 56 | // MARK: - Type Properties 57 | 58 | /// The accessibility element is a tab bar 59 | public static let isTabBar: AccessibilityTraits = .init() 60 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AccessibilityValueStorage.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AccessibilityValueStorage { 4 | let value: AnyAccessibilityValue? 5 | let description: Array 6 | 7 | init(value: AnyAccessibilityValue?, description: Array) { 8 | self.value = value 9 | self.description = description 10 | } 11 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/AnyAccessibilityValue.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct AnyAccessibilityValue { 4 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Descriptions/RelationshipModifier.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct RelationshipModifier { 4 | 5 | } 6 | 7 | struct AccessibilityRelationshipModifier { 8 | let relationship: AccessibilityRelationshipScope 9 | 10 | init(relationship: AccessibilityRelationshipScope) { 11 | self.relationship = relationship 12 | } 13 | } 14 | 15 | struct AccessibilityRelationshipScope { 16 | enum Relationship { 17 | case labeledPair 18 | } 19 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Navigations/AccessibilityOptionalRotorContent.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | @frozen @MainActor @preconcurrency 4 | public struct AccessibilityOptionalRotorContent: AccessibilityRotorContent where Content : AccessibilityRotorContent { 5 | 6 | public let content: Content? 7 | 8 | @inlinable public init(_ content: Content?) { 9 | self.content = content 10 | } 11 | 12 | public var body: some AccessibilityRotorContent { 13 | fatalError() 14 | } 15 | 16 | nonisolated public static func _makeEntries(content: _GraphValue>, inputs: _AccessibilityRotorEntryInputs) -> _AccessibilityRotorEntryOutputs { 17 | .init() 18 | } 19 | 20 | nonisolated public static func _entryCount(inputs: _AccessibilityRotorEntryInputs) -> Int? { 21 | 0 22 | } 23 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Navigations/AccessibilityRotorContent.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | @MainActor @preconcurrency 4 | public protocol AccessibilityRotorContent { 5 | 6 | // MARK: - Supporting types 7 | 8 | /// The type for the internal content of this AccessibilityRotorContent. 9 | associatedtype Body : AccessibilityRotorContent 10 | 11 | /// The internal content of this AccessibilityRotorContent. 12 | @AccessibilityRotorContentBuilder var body: Self.Body { get } 13 | 14 | nonisolated static func _makeEntries(content: _GraphValue, inputs: _AccessibilityRotorEntryInputs) -> _AccessibilityRotorEntryOutputs 15 | nonisolated static func _entryCount(inputs: _AccessibilityRotorEntryInputs) -> Int? 16 | } 17 | 18 | extension Never: AccessibilityRotorContent { 19 | nonisolated public static func _makeEntries(content: _GraphValue, inputs: _AccessibilityRotorEntryInputs) -> _AccessibilityRotorEntryOutputs { 20 | fatalError() 21 | } 22 | 23 | nonisolated public static func _entryCount(inputs: _AccessibilityRotorEntryInputs) -> Int? { 24 | fatalError() 25 | } 26 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Navigations/AccessibilityRotorContentBuilder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Result builder you use to generate rotor entry content. 4 | @MainActor @resultBuilder public struct AccessibilityRotorContentBuilder { 5 | 6 | public static func buildExpression(_ content: Content) -> Content where Content: AccessibilityRotorContent { 7 | content 8 | } 9 | 10 | public static func buildBlock(_ content: Content) -> some AccessibilityRotorContent where Content: AccessibilityRotorContent { 11 | content 12 | } 13 | 14 | public static func buildIf(_ content: Content?) -> some AccessibilityRotorContent where Content: AccessibilityRotorContent { 15 | AccessibilityOptionalRotorContent(content) 16 | } 17 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Navigations/AccessibilitySystemRotor.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct AccessibilitySystemRotor: Sendable { 4 | 5 | // MARK: - Iterating through text 6 | 7 | /// System Rotor allowing users to iterate through all text fields. 8 | public static let textFields: AccessibilitySystemRotor = .init() 9 | 10 | /// System Rotor allowing users to iterate through all the ranges of bolded text. 11 | public static let boldText: AccessibilitySystemRotor = .init() 12 | 13 | /// System Rotor allowing users to iterate through all the ranges of italicized text. 14 | public static let italicText: AccessibilitySystemRotor = .init() 15 | 16 | /// System Rotor allowing users to iterate through all the ranges of underlined text. 17 | public static let underlineText: AccessibilitySystemRotor = .init() 18 | 19 | /// System Rotor allowing users to iterate through all the ranges of mis-spelled words. 20 | public static let misspelledWords: AccessibilitySystemRotor = .init() 21 | 22 | // MARK: - Iterating through headings 23 | 24 | /// System Rotor allowing users to iterate through all headings. 25 | public static let headings: AccessibilitySystemRotor = .init() 26 | 27 | /// System Rotors allowing users to iterate through all headings, of various heading levels. 28 | public static func headings(level: AccessibilityHeadingLevel) -> AccessibilitySystemRotor { 29 | .init() 30 | } 31 | 32 | // MARK: - Iterating through links 33 | 34 | /// System Rotor allowing users to iterate through all links. 35 | public static let links: AccessibilitySystemRotor = .init() 36 | 37 | /// System Rotors allowing users to iterate through links or visited links. 38 | public static func links(visited: Bool) -> AccessibilitySystemRotor { 39 | .init() 40 | } 41 | 42 | // MARK: - Iterating through other elements 43 | 44 | /// System Rotor allowing users to iterate through all images. 45 | public static let images: AccessibilitySystemRotor = .init() 46 | 47 | /// System Rotor allowing users to iterate through all landmarks. 48 | public static let landmarks: AccessibilitySystemRotor = .init() 49 | 50 | /// System Rotor allowing users to iterate through all lists. 51 | public static let lists: AccessibilitySystemRotor = .init() 52 | 53 | /// System Rotor allowing users to iterate through all tables. 54 | public static let tables: AccessibilitySystemRotor = .init() 55 | 56 | init() { } 57 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Navigations/_AccessibilityRotorEntryInputs.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct _AccessibilityRotorEntryInputs { 4 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Accessibility/Accessible Navigations/_AccessibilityRotorEntryOutputs.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct _AccessibilityRotorEntryOutputs { 4 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Animations/AdditiveArithmetic.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A type with values that support addition and subtraction. 4 | public protocol AdditiveArithmetic : Equatable { 5 | 6 | // MARK: - Type Properties 7 | 8 | /// The zero value. 9 | /// 10 | /// Zero is the identity element for addition. For any value, x + .zero == x and .zero + x == x. 11 | static var zero: Self { get } 12 | 13 | // MARK: - Operators 14 | 15 | /// Returns the given number unchanged. 16 | /// 17 | /// You can use the unary plus operator (+) to provide symmetry in your code for positive numbers when also using the unary minus operator. 18 | /// - Returns: The given argument without any changes. 19 | static prefix func + (x: Self) -> Self 20 | 21 | /// Adds two values and produces their sum. 22 | /// - Parameters: 23 | /// - lhs: The first value to add. 24 | /// - rhs: The second value to add. 25 | static func + (lhs: Self, rhs: Self) -> Self 26 | 27 | /// Adds two values and stores the result in the left-hand-side variable. 28 | /// - Parameters: 29 | /// - lhs: The first value to add. 30 | /// - rhs: The second value to add. 31 | static func += (lhs: inout Self, rhs: Self) 32 | 33 | /// Subtracts one value from another and produces their difference. 34 | /// - Parameters: 35 | /// - lhs: A numeric value. 36 | /// - rhs: The value to subtract from lhs. 37 | static func - (lhs: Self, rhs: Self) -> Self 38 | 39 | /// Subtracts the second value from the first and stores the difference in the left-hand-side variable. 40 | /// - Parameters: 41 | /// - lhs: A numeric value. 42 | /// - rhs: The value to subtract from lhs. 43 | static func -= (lhs: inout Self, rhs: Self) 44 | } 45 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Animations/Animatable.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A type that describes how to animate a property of a view. 4 | public protocol Animatable { 5 | 6 | // MARK: - Animating data 7 | 8 | /// The type defining the data to animate. 9 | associatedtype AnimatableData : VectorArithmetic 10 | 11 | /// The data to animate. 12 | var animatableData: Self.AnimatableData { get set } 13 | } 14 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/Animations/VectorArithmetic.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A type that can serve as the animatable data of an animatable type. 4 | /// 5 | /// VectorArithmetic extends the ``AdditiveArithmetic`` protocol with scalar multiplication and a way to query the vector magnitude of the value. 6 | /// Use this type as the animatableData associated type of a type that conforms to the ``Animatable`` protocol. 7 | public protocol VectorArithmetic : AdditiveArithmetic { 8 | 9 | // MARK: - Manipulating values 10 | 11 | /// Returns the dot-product of this vector arithmetic instance with itself. 12 | var magnitudeSquared: Double { get } 13 | 14 | /// Multiplies each component of this value by the given value. 15 | mutating func scale(by rhs: Double) 16 | 17 | /// Returns a value with each component of this value multiplied by the given value. 18 | func scaled(by rhs: Double) -> Self 19 | 20 | /// Interpolates this value with other by the specified amount. 21 | /// This is equivalent to self = self + (other - self) * amount. 22 | mutating func interpolate(towards other: Self, amount: Double) 23 | 24 | /// Returns this value interpolated with other by the specified amount. 25 | /// This result is equivalent to self + (other - self) * amount. 26 | func interpolated(towards other: Self, amount: Double) -> Self 27 | } 28 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/App Extensions/EmptyWidget.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | @frozen public struct EmptyWidget : Widget { 4 | 5 | // MARK: - Associated Type(s). 6 | 7 | /// The type of configuration representing the content of the widget. 8 | public typealias Body = EmptyWidgetConfiguration 9 | 10 | // MARK: - Property(ies). 11 | 12 | /// The content and behavior of the widget. 13 | public var body : Self.Body { 14 | .init() 15 | } 16 | 17 | // MARK: - Constructor(s). 18 | 19 | /// Creates a widget using body as its content. 20 | public init() { } 21 | 22 | // MARK: - Static Function(s). 23 | 24 | /// Initializes and runs the widget. 25 | public static func main() { } 26 | } 27 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/App Extensions/EmptyWidgetConfiguration.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | /// An empty widget configuration. 4 | @frozen public struct EmptyWidgetConfiguration : WidgetConfiguration { 5 | 6 | // MARK: - Associated Type(s). 7 | 8 | /// The type of widget configuration representing the body of this configuration. 9 | /// When you create a custom widget, Swift infers this type from your implementation of the required body property. 10 | public typealias Body = Never 11 | 12 | // MARK: - Property(ies). 13 | 14 | /// The content and behavior of the widget. 15 | public var body : Never { 16 | fatalError() 17 | } 18 | 19 | // MARK: - Constructor(s). 20 | 21 | @inlinable public init() { } 22 | } 23 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/App Extensions/Widget.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | /// The configuration and content of a widget to display on the Home screen or in Notification Center. 4 | public protocol Widget { 5 | 6 | // MARK: - Associated Type(s). 7 | 8 | /// The type of configuration representing the content of the widget. 9 | associatedtype Body: WidgetConfiguration 10 | 11 | // MARK: - Property(ies). 12 | 13 | /// The content and behavior of the widget. 14 | var body : Self.Body { get } 15 | 16 | // MARK: - Constructor(s). 17 | 18 | /// Creates a widget using body as its content. 19 | init() 20 | 21 | // MARK: - Static Function(s). 22 | 23 | /// Initializes and runs the widget. 24 | static func main() 25 | } 26 | 27 | extension Widget { 28 | 29 | /// Creates a widget using body as its content. 30 | public init() { 31 | fatalError() 32 | } 33 | 34 | /// Initializes and runs the widget. 35 | public static func main() { } 36 | } 37 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/App Extensions/WidgetBundle.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | /// A container used to expose multiple widgets from a single widget extension. 4 | public protocol WidgetBundle { 5 | 6 | // MARK: - Associated Type(s). 7 | 8 | /// The type of widget that represents the content of the bundle. 9 | associatedtype Body: Widget 10 | 11 | // MARK: - Property(ies). 12 | 13 | /// Declares the group of widgets that an app supports. 14 | @WidgetBundleBuilder var body : Self.Body { get } 15 | 16 | // MARK: - Constructor(s). 17 | 18 | /// Creates a widget bundle using the bundle’s body as its content. 19 | init() 20 | 21 | // MARK: - Static Function(s). 22 | 23 | /// Initializes and runs the widget bundle. 24 | static func main() 25 | } 26 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/App Extensions/WidgetBundleBuilder.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | /// A custom attribute that constructs a widget bundle’s body. 4 | @frozen @resultBuilder public struct WidgetBundleBuilder { 5 | public static func buildBlock() -> some Widget { 6 | EmptyWidget() 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/App Extensions/WidgetConfiguration.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | /// A type that describes a widget’s content. 4 | public protocol WidgetConfiguration { 5 | 6 | // MARK: - Associated Type(s). 7 | 8 | /// The type of widget configuration representing the body of this configuration. 9 | associatedtype Body: WidgetConfiguration 10 | 11 | // MARK: - Property(ies). 12 | 13 | /// The content and behavior of the widget. 14 | var body : Self.Body { get } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Documents/FileDocument.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | public protocol FileDocument : Equatable, Hashable { 4 | } 5 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Documents/NewDocumentAction.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | public struct NewDocumentAction : Equatable, Hashable { 4 | 5 | /// Presents a new document window, using the provided closure to specify 6 | /// the initial document contents. 7 | /// 8 | /// In order to present the document, your ``App`` must define a 9 | /// ``DocumentGroup`` with the editor role for the type of the presented 10 | /// value. 11 | /// 12 | /// - Parameter newDocument: The initial document to use when the window is 13 | /// presented. 14 | public func callAsFunction(_ newDocument: @autoclosure @escaping () -> D) async where D : FileDocument { 15 | fatalError() 16 | } 17 | 18 | /// Presents a new document window, using the provided closure to specify 19 | /// the initial document contents. 20 | /// 21 | /// In order to present the document, your ``App`` must define a 22 | /// ``DocumentGroup`` with the editor role for the type of the presented 23 | /// value. 24 | /// 25 | /// - Parameter newDocument: The initial document to use when the window is 26 | /// presented. 27 | public func callAsFunction(_ newDocument: @escaping () -> D) async where D : ReferenceFileDocument { 28 | fatalError() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Documents/OpenDocumentAction.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Swift 3 | 4 | public struct OpenDocumentAction { 5 | 6 | /// Opens the document at the specified file URL, if it a type that's 7 | /// defined by a document group defined in this app. 8 | /// 9 | /// The document is be opened in a new window, if not already opened. 10 | /// Otherwise, the window containing the document at the specified URL will 11 | /// be brought to the front. 12 | /// 13 | /// - Parameter url: A file URL which points to an existing document. 14 | public func callAsFunction(at url: URL) async throws { 15 | fatalError() 16 | } 17 | } 18 | 19 | extension OpenDocumentAction : Equatable { 20 | public static func == (_ lhs: OpenDocumentAction, _ rhs: OpenDocumentAction) -> Bool { 21 | ObjectIdentifier(type(of: lhs.self)) == ObjectIdentifier(type(of: rhs.self)) 22 | } 23 | } -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Documents/ReferenceFileDocument.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | public protocol ReferenceFileDocument { 4 | } 5 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Immersive Spaces/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helbertgs/OpenSwiftUI/03e526e88ba17504b9575a2b3bc63405d2a2852d/Sources/OpenSwiftUI/App Structure/Immersive Spaces/.keep -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Modal Presentations/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helbertgs/OpenSwiftUI/03e526e88ba17504b9575a2b3bc63405d2a2852d/Sources/OpenSwiftUI/App Structure/Modal Presentations/.keep -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Navigation/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helbertgs/OpenSwiftUI/03e526e88ba17504b9575a2b3bc63405d2a2852d/Sources/OpenSwiftUI/App Structure/Navigation/.keep -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Scenes/SceneBuilder.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | @resultBuilder public struct SceneBuilder { 4 | public static func buildBlock(_ content: Content) -> Content where Content : Scene { 5 | content 6 | } 7 | 8 | @_alwaysEmitIntoClient 9 | public static func buildBlock(_ c0: C0, _ c1: C1) -> some Scene where C0: Scene, C1: Scene { 10 | _TupleScene((c0, c1)) 11 | } 12 | 13 | @_alwaysEmitIntoClient 14 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2) -> some Scene where C0: Scene, C1: Scene, C2: Scene { 15 | _TupleScene((c0, c1, c2)) 16 | } 17 | 18 | @_alwaysEmitIntoClient 19 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> some Scene where C0: Scene, C1: Scene, C2: Scene, C3: Scene { 20 | _TupleScene((c0, c1, c2, c3)) 21 | } 22 | 23 | @_alwaysEmitIntoClient 24 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> some Scene where C0: Scene, C1: Scene, C2: Scene, C3: Scene, C4: Scene { 25 | _TupleScene((c0, c1, c2, c3, c4)) 26 | } 27 | 28 | @_alwaysEmitIntoClient 29 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> some Scene where C0: Scene, C1: Scene, C2: Scene, C3: Scene, C4: Scene, C5: Scene { 30 | _TupleScene((c0, c1, c2, c3, c4, c5)) 31 | } 32 | 33 | @_alwaysEmitIntoClient 34 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> some Scene where C0: Scene, C1: Scene, C2: Scene, C3: Scene, C4: Scene, C5: Scene, C6: Scene { 35 | _TupleScene((c0, c1, c2, c3, c4, c5, c6)) 36 | } 37 | 38 | @_alwaysEmitIntoClient 39 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> some Scene where C0: Scene, C1: Scene, C2: Scene, C3: Scene, C4: Scene, C5: Scene, C6: Scene, C7: Scene { 40 | _TupleScene((c0, c1, c2, c3, c4, c5, c6, c7)) 41 | } 42 | 43 | @_alwaysEmitIntoClient 44 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> some Scene where C0: Scene, C1: Scene, C2: Scene, C3: Scene, C4: Scene, C5: Scene, C6: Scene, C7: Scene, C8: Scene { 45 | _TupleScene((c0, c1, c2, c3, c4, c5, c6, c7, c8)) 46 | } 47 | 48 | @_alwaysEmitIntoClient 49 | public static func buildBlock(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> some Scene where C0: Scene, C1: Scene, C2: Scene, C3: Scene, C4: Scene, C5: Scene, C6: Scene, C7: Scene, C8: Scene, C9: Scene { 50 | _TupleScene((c0, c1, c2, c3, c4, c5, c6, c7, c8, c9)) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Scenes/_SceneInputs.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | @dynamicMemberLookup 4 | @frozen public struct _SceneInputs { 5 | 6 | // MARK: - Property(ies). 7 | 8 | @usableFromInline var props: [String: Any] 9 | 10 | // MARK: - Constructor(s). 11 | 12 | @inlinable internal init(props: [String : Any] = [:]) { 13 | self.props = props 14 | } 15 | 16 | // MARK: - Subscript(s). 17 | 18 | @inlinable internal subscript(dynamicMember member: String) -> U { 19 | get { props[member] as! U } 20 | set { props[member] = newValue } 21 | } 22 | } 23 | 24 | extension _SceneInputs { 25 | static func + (_ lhs: _SceneOutputs, _ rhs: _SceneInputs) -> _SceneInputs { 26 | var output = _SceneInputs() 27 | lhs.props.forEach { (key: String, value: Any) in 28 | output.props[key] = value 29 | } 30 | 31 | rhs.props.forEach { (key: String, value: Any) in 32 | output.props[key] = value 33 | } 34 | 35 | return output 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Scenes/_SceneModifier.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | public protocol _SceneModifier { 4 | 5 | // MARK: - Associated Type(s). 6 | 7 | associatedtype Body : Scene 8 | 9 | // MARK: - Type Alias. 10 | 11 | typealias SceneContent = _SceneModifier_Content 12 | 13 | // MARK: - Property(ies). 14 | 15 | @SceneBuilder func body(content: Self.SceneContent) -> Self.Body 16 | 17 | // MARK: - Static Function(s). 18 | 19 | static func _makeScene(modifier: _GraphValue, inputs: _SceneInputs, body: @escaping (_Graph, _SceneInputs) -> _SceneOutputs) -> _SceneOutputs 20 | } 21 | 22 | extension _SceneModifier { 23 | @inlinable internal func concat(_ modifier: T) -> ModifiedContent { 24 | .init(content: self, modifier: modifier) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Scenes/_SceneModifier_Content.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | public struct _SceneModifier_Content : Scene where Modifier : _SceneModifier { 4 | 5 | // MARK: - Type Alias. 6 | 7 | public typealias Body = Never 8 | 9 | // MARK: - Property(ies). 10 | 11 | public var body: Never { 12 | fatalError() 13 | } 14 | 15 | // MARK: - Static Function(s). 16 | 17 | public static func _makeScene(scene: _GraphValue<_SceneModifier_Content>, inputs: _SceneInputs) -> _SceneOutputs { 18 | fatalError() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Scenes/_SceneOutputs.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | @dynamicMemberLookup 4 | @frozen public struct _SceneOutputs { 5 | 6 | // MARK: - Property(ies). 7 | 8 | @usableFromInline var props: [String: Any] 9 | 10 | // MARK: - Constructor(s). 11 | 12 | @inlinable internal init(props: [String : Any] = [:]) { 13 | self.props = props 14 | } 15 | 16 | // MARK: - Subscript(s). 17 | 18 | @inlinable internal subscript(dynamicMember member: String) -> U { 19 | get { props[member] as! U } 20 | set { props[member] = newValue } 21 | } 22 | } 23 | 24 | extension _SceneOutputs { 25 | static func + (_ lhs: _SceneOutputs, _ rhs: _SceneOutputs) -> _SceneOutputs { 26 | var output = _SceneOutputs() 27 | lhs.props.forEach { (key: String, value: Any) in 28 | output.props[key] = value 29 | } 30 | 31 | rhs.props.forEach { (key: String, value: Any) in 32 | output.props[key] = value 33 | } 34 | 35 | return output 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Scenes/_TupleScene.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | @usableFromInline 4 | internal struct _TupleScene : Scene { 5 | 6 | // MARK: - Type Alias. 7 | 8 | @usableFromInline 9 | internal typealias Body = Never 10 | 11 | // MARK: - Property(ies). 12 | 13 | @usableFromInline 14 | internal var value: T 15 | 16 | @usableFromInline 17 | internal var body: Swift.Never { 18 | fatalError() 19 | } 20 | 21 | // MARK: - Constructor(s). 22 | 23 | @usableFromInline 24 | internal init(_ value: T) { 25 | self.value = value 26 | } 27 | 28 | // MARK: - Static Function(s). 29 | 30 | @usableFromInline 31 | internal static func _makeScene(scene: _GraphValue<_TupleScene>, inputs: _SceneInputs) -> _SceneOutputs { 32 | // var outputs = _SceneOutputs() 33 | // var scenes = [_SceneOutputs]() 34 | // 35 | // for child in Mirror(reflecting: scene.value.value).children { 36 | // let scene = child.value as! (any Scene) 37 | // scenes.append(_makeScene(scene: scene, inputs: inputs)) 38 | // } 39 | // 40 | // outputs.scenes = scenes 41 | // return outputs 42 | return .init() 43 | } 44 | 45 | // internal static func _makeScene(scene: T, inputs: _SceneInputs) -> _SceneOutputs where T: Scene { 46 | // T._makeScene(scene: _GraphValue(scene), inputs: inputs) 47 | // } 48 | } 49 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Search/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helbertgs/OpenSwiftUI/03e526e88ba17504b9575a2b3bc63405d2a2852d/Sources/OpenSwiftUI/App Structure/Search/.keep -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Toolbars/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helbertgs/OpenSwiftUI/03e526e88ba17504b9575a2b3bc63405d2a2852d/Sources/OpenSwiftUI/App Structure/Toolbars/.keep -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Windows/MenuBarExtraStyle.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | /// A specification for the appearance and behavior of a menu bar extra scene. 4 | public protocol MenuBarExtraStyle { 5 | } 6 | 7 | /// A menu bar extra style that renders its contents in a popover-like window. 8 | /// 9 | /// Use ``MenuBarExtraStyle/window`` to construct this style. 10 | public struct WindowMenuBarExtraStyle : MenuBarExtraStyle { 11 | 12 | /// Creates a window menu bar extra style. 13 | public init() { } 14 | } 15 | 16 | extension MenuBarExtraStyle where Self == WindowMenuBarExtraStyle { 17 | 18 | /// A menu bar extra style that renders its contents in a popover-like 19 | /// window. 20 | /// 21 | /// The styling and layout of controls is similar to that when contained 22 | /// in a normal window, compared to the menu-like layout that the 23 | /// ``MenuBarExtraStyle/menu`` style provides. 24 | public static var window: WindowMenuBarExtraStyle { .init() } 25 | } 26 | 27 | /// A menu bar extra style that renders its contents as a menu that pulls 28 | /// down from the icon in the menu bar. 29 | /// 30 | /// Use ``MenuBarExtraStyle/menu`` to construct this style. 31 | public struct PullDownMenuBarExtraStyle : MenuBarExtraStyle { 32 | 33 | /// Creates a pull down menu bar extra style. 34 | public init() { 35 | } 36 | } 37 | 38 | extension MenuBarExtraStyle where Self == PullDownMenuBarExtraStyle { 39 | 40 | /// A menu bar extra style that renders its contents as a menu that pulls 41 | /// down from the icon in the menu bar. 42 | public static var menu: PullDownMenuBarExtraStyle { .init() } 43 | } 44 | 45 | /// The default menu bar extra style. 46 | /// You can also use ``MenuBarExtraStyle/automatic`` to construct this style. 47 | public struct AutomaticMenuBarExtraStyle : MenuBarExtraStyle { 48 | 49 | /// Creates an automatic menu bar extra style. 50 | public init() { 51 | } 52 | } 53 | 54 | extension MenuBarExtraStyle where Self == AutomaticMenuBarExtraStyle { 55 | 56 | /// The default menu bar extra style. 57 | public static var automatic: AutomaticMenuBarExtraStyle { .init() } 58 | } 59 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Windows/WindowStyle.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | /// A specification for the appearance and interaction of a window. 4 | public protocol WindowStyle { 5 | associatedtype _Body : View 6 | } 7 | 8 | /// The default window style. 9 | public struct DefaultWindowStyle : WindowStyle { 10 | public typealias _Body = Never 11 | } 12 | 13 | /// A window style which hides both the window’s title and the backing of the titlebar area, allowing more of the window’s content to show. 14 | public struct HiddenTitleBarWindowStyle : WindowStyle { 15 | public typealias _Body = Never 16 | } 17 | 18 | /// A window style which displays the title bar section of the window. 19 | public struct TitleBarWindowStyle : WindowStyle { 20 | public typealias _Body = Never 21 | } 22 | 23 | extension WindowStyle where Self == DefaultWindowStyle { 24 | /// The default window style. 25 | public static var automatic : DefaultWindowStyle { .init() } 26 | } 27 | 28 | extension WindowStyle where Self == HiddenTitleBarWindowStyle { 29 | /// A window style which hides both the window’s title and the backing of the titlebar area, allowing more of the window’s content to show. 30 | public static var hiddenTitleBar : HiddenTitleBarWindowStyle { .init() } 31 | } 32 | 33 | extension WindowStyle where Self == TitleBarWindowStyle { 34 | /// A window style which displays the title bar section of the window. 35 | public static var titleBar : TitleBarWindowStyle { .init() } 36 | } 37 | -------------------------------------------------------------------------------- /Sources/OpenSwiftUI/App Structure/Windows/WindowStyleModifier.swift: -------------------------------------------------------------------------------- 1 | import Swift 2 | 3 | public struct WindowStyleModifier