From 7e58ee5e6c7ed7b93f5e6ecffabb111e1d84d27d Mon Sep 17 00:00:00 2001 From: Raphael Salaja Date: Fri, 6 Oct 2023 18:59:26 +0100 Subject: [PATCH] feat: updated readme with more information (#6) --- README.md | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fd8cf1a..4dc3a9c 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,85 @@ https://github.com/rafunderscore/Layers/assets/52125687/5ca08ccc-1989-4c90-8a96-683bdf59329c -Layers is a SwiftUI library for creating layered user interfaces. -It's a simple and easy to use solution for creating smooth and performant animations between modal views. +Layers is a powerful SwiftUI library designed for creating layered user interfaces, enhancing your app's user experience with smooth and performant animations between modal views. ---- +## Vision -### Vision +While Layers isn't a perfect solution, it's a solid starting point. We believe in the power of open source and want the community to contribute and build upon Layers. If you have any suggestions or would like to contribute, please feel free to open an issue. -Layers as it stands is not a perfect solution, but it's a start. Which is why I'm releasing it as an open source project, for the community to build upon. +## Usage -If you'd like to contribute to Layers feel free to open an issue if you have any suggestions. +To get started with Layers: + +1. Download the repository and check out the example. +2. For integration into your own projects, copy the source folder into your project. +> We have plans to convert this project into a package for easier updates in the future. + +### Creating Layers + +To create your own Layer, follow these steps: + +```swift +@Bindable var layers: LayerModel = .init( + index: 0, + max: 3, + headers: [ + 0: AnyView(ExampleHeader1()), + 1: AnyView(ExampleHeader2()), + 2: AnyView(ExampleHeader3()), + ], + contents: [ + 0: AnyView(ExampleContent1()), + 1: AnyView(ExampleContent2()), + 2: AnyView(ExampleContent3()), + ], + buttons: [ + 0: [["Cancel": "xmark.circle"], ["Continue": "checkmark.circle"]], + 1: [["Cancel": "xmark.circle"], ["Continue": "checkmark.circle"]], + 2: [["Cancel": "xmark.circle"], ["Continue": "checkmark.circle"]], + ] +) +``` + +Within your view, create content wrapped within a Layer: + +```swift +var body: some View { + Layer { + layers.getCurrentHeader() + .id("layer.stack.header.\(layers.index)") + + layers.getCurrentContent() + .id("layer.stack.content.\(layers.index)") + + HStack { + if !layers.getCurrentButtons()[0].isEmpty { + LayerButton(text: Binding.constant(layers.getCurrentButtons()[0].keys.first ?? ""), + icon: Binding.constant(layers.getCurrentButtons()[0].values.first ?? ""), + background: .orange) + { + layers.previous() + } + } + if !layers.getCurrentButtons()[1].isEmpty { + LayerButton(text: Binding.constant(layers.getCurrentButtons()[1].keys.first ?? ""), + icon: Binding.constant(layers.getCurrentButtons()[1].values.first ?? ""), + background: .blue) + { + layers.next() + } + } + } + } +} +``` + +This setup allows you to customize your layers extensively without diving into numerous pages or extraneous files. Future iterations will further streamline this workflow. + +##Contributing + +We welcome and encourage contributions to this project. If you have bug fixes or new features in mind, please create a new issue to discuss them. If you're interested in contributing code, fork the repository and submit a pull request. Make sure to document your changes and thoroughly test the project before submitting a pull request. Maintain consistency with the project's code style. + +## Disclaimer + +This project is open source under the MIT license, granting you full access to the source code for modifications to suit your needs. Please note that this project is in beta, so there may be bugs or areas for improvement. If you discover any issues or have suggestions, please report them by creating a new issue.