Skip to content

A custom SwiftUI EnvironmentValue for dynamically reading a view's SafeArea inset dimensions.

License

Notifications You must be signed in to change notification settings

CypherPoet/SafeAreaInsetDimensionsEnvironmentValue

Repository files navigation

SafeAreaInsetDimensionsEnvironmentValue

Twitter: @cypher_poet

A custom SwiftUI EnvironmentValue for dynamically reading a View's SafeArea inset dimensions.

Installation

Xcode Projects

Select File -> Swift Packages -> Add Package Dependency and enter https://github.com/CypherPoet/SafeAreaInsetDimensionsEnvironmentValue.

Swift Package Manager Projects

You can add SafeAreaInsetDimensionsEnvironmentValue as a package dependency in your Package.swift file:

let package = Package(
    //...
    dependencies: [
        .package(
            name: "SafeAreaInsetDimensionsEnvironmentValue",
            url: "https://github.com/CypherPoet/SafeAreaInsetDimensionsEnvironmentValue",
            .upToNextMinor(from: "0.1.0")
        ),
    ],
    //...
)

From there, refer to SafeAreaInsetDimensionsEnvironmentValue as a "target dependency" in any of your package's targets that need it.

targets: [
    .target(
        name: "YourLibrary",
        dependencies: [
          "SafeAreaInsetDimensionsEnvironmentValue",
        ],
        ...
    ),
    ...
]

Then simply import SafeAreaInsetDimensionsEnvironmentValue wherever you’d like to use it.

📝 Note: To make the library available to your entire project, you could also leverage the functionality of the _@exported keyword by placing the following line somewhere at the top level of your project:

@_exported import SafeAreaInsetDimensionsEnvironmentValue

Usage

Contributing

Contributions to SafeAreaInsetDimensionsEnvironmentValue are most welcome. Check out some of the issue templates for more info.

💻 Developing

Requirements

  • Xcode 13.0+

📜 Creating & Building Documentation

Documentation is built with Xcode's DocC. See Apple's guidance on how to build, run, and create DocC content.

For now, the best way to view the docs is to open the project in Xcode and run the Build Documentation command. At some point in the future, I'm hoping to leverage the tooling the develops for generating/hosting DocC documentation. (Please feel free to let me know if you have any ideas or tooling recommendations around this 🙂).

🏷 License

SafeAreaInsetDimensionsEnvironmentValue is available under the MIT license. See the LICENSE file for more info.