Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xwdg/dynamicui
Create a SwiftUI user interface through a JSON file. The JSON file will contain the structure of the user interface, and the program will create the user interface based on the JSON file.
https://github.com/0xwdg/dynamicui
0xwdg dynamic dynamicui hacktoberfest interface spm swift swiftui user view
Last synced: 11 days ago
JSON representation
Create a SwiftUI user interface through a JSON file. The JSON file will contain the structure of the user interface, and the program will create the user interface based on the JSON file.
- Host: GitHub
- URL: https://github.com/0xwdg/dynamicui
- Owner: 0xWDG
- License: mit
- Created: 2024-04-15T11:16:16.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-26T13:05:53.000Z (4 months ago)
- Last Synced: 2024-11-02T06:31:20.537Z (18 days ago)
- Topics: 0xwdg, dynamic, dynamicui, hacktoberfest, interface, spm, swift, swiftui, user, view
- Language: Swift
- Homepage: https://0xwdg.github.io/DynamicUI/
- Size: 14.8 MB
- Stars: 13
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DynamicUI
Create a SwiftUI user interface through a JSON file. The JSON file will contain the structure of the user interface, and the program will create the user interface based on the JSON file.
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FDynamicUI%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/0xWDG/DynamicUI) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FDynamicUI%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/0xWDG/DynamicUI)
[![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager)
![License](https://img.shields.io/github/license/0xWDG/Inspect)> [!WARNING]
>
> This is a work in progress and not yet ready for production use. \
> Please feel free to contribute, report issues, or request features.## Requirements
- Swift 5.9+ (Xcode 15+)
- iOS 15+, macOS 12+, tvOS 14+, watchOS 7+, macCatalyst 15+, visionOS 1.0+## Installation
Install using Swift Package Manager
```swift
dependencies: [
.package(url: "https://github.com/0xWDG/DynamicUI.git", branch: "main"),
],
targets: [
.target(name: "MyTarget", dependencies: [
.product(name: "DynamicUI", package: "DynamicUI"),
]),
]
```And import it:
```swift
import DynamicUI
```## Usage
```swift
import SwiftUI
import DynamicUIstruct ContentView: View {
let json = """
[
{
"type": "Text",
"title": "Wait, am i generating views from JSON?",
"modifiers": {"foregroundStyle":"red","opacity":0.6}
},
{
"type": "Button",
"title": "Click me",
"eventHandler": "customHandler"
},
{
"type": "Toggle",
"title": "Toggle me",
"identifier": "my.toggle.1"
}
]
""".data(using: .utf8)var body: some View {
DynamicUI(
json: json,
callback: { component in
// This contains everything passed as a component (type, title, identifier, ...)
print(component)
}
)
}
}
```### Playground Application:
In the directory `Playground` is a Xcode project to build the [Playground Application](#Playground)
### Supported View Types:
_Please note:_ Items prefixed with ⚠ may ignore passed parameters.
Items with a strikethrough are not yet supported.VStack
```JSON
{
"type": "VStack",
"children": [ ]
}
```HStack
```JSON
{
"type": "HStack",
"children": [ ]
}
```ZStack
```JSON
{
"type": "ZStack",
"children": [ ]
}
```List
```JSON
{
"type": "List",
"children": [ ]
}
```ScrollView
```JSON
{
"type": "ScrollView",
"children": [ ]
}
```NavigationView
```JSON
{
"type": "NavigationView",
"children": [ ]
}
```Form
```JSON
{
"type": "Form",
"children": [ ]
}
```Button
```JSON
{
"type": "Button",
"title": "Click me!"
}
```Text
```JSON
{
"type": "Text",
"title": "..."
}
```Image
```JSON
{
"type": "Image",
"imageURL": "systemName"
}
```Divider
```JSON
{
"type": "Divider"
}
```Spacer
```JSON
{
"type": "Spacer"
}
```Label
```JSON
{
"type": "Label",
"title": "..."
}
```TextField
```JSON
{
"type": "TextField",
"title": "...",
"defaultValue": "..."
}
```SecureField
```JSON
{
"type": "SecureField",
"title": "...",
"defaultValue": "..."
}
```TextEditor
```JSON
{
"type": "TextEditor",
"title": "...",
"defaultValue": "..."
}
```Toggle
```JSON
{
"type": "Toggle",
"title": "Turn me on!",
"defaultValue": true
}
```⚠ Gauge
```JSON
{
"type": "Gauge",
"title": "...",
"defaultValue": 0.5
}
```⚠ ProgressView
```JSON
{
"type": "ProgressView",
"title": "...",
"value": 50,
"total": 100
}
```Slider
```JSON
{
"type": "Slider",
"title": "...",
"minLabel": "min",
"maxLabel": "max"
}
```GroupBox
```JSON
{
"type": "GroupBox",
"children": [ ]
}
```DisclosureGroup
```JSON
{
"type": "DisclosureGroup",
"children": [ ]
}
```HSplitView
```JSON
{
"type": "HSplitView",
"children": [ ]
}
```VSplitView
```JSON
{
"type": "VSplitView",
"children": [ ]
}
```⚠ Picker
```JSON
{
"type": "Picker",
"title": "...",
"values": ["...", "..."]
}
```⚠ NavigationSplitView
```JSON
{
"type": "NavigationSplitView",
"children": [ ]
}
```⚠ TabView
```JSON
{
"type": "TabView",
"children": [ ]
}
```## Images
### Playground
### V0.0.1 in action
## Used By
- [Aurora Editor](https://github.com/AuroraEditor/AuroraEditor) for custom views in extensions.
## Contact
We can get in touch via [Twitter/X](https://twitter.com/0xWDG), [Discord](https://discordapp.com/users/918438083861573692), [Mastodon](https://mastodon.social/@0xWDG), [Email](mailto:[email protected]), [Website](https://wesleydegroot.nl).