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: over 1 year 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 (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-20T20:15:27.000Z (over 1 year ago)
- Last Synced: 2025-04-19T14:58:30.604Z (over 1 year 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: 33
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
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://swiftpackageindex.com/0xWDG/DynamicUI) [](https://swiftpackageindex.com/0xWDG/DynamicUI)
[](https://swift.org/package-manager)

> [!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 DynamicUI
struct 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
🦋 [@0xWDG](https://bsky.app/profile/0xWDG.bsky.social)
🐘 [mastodon.social/@0xWDG](https://mastodon.social/@0xWDG)
🐦 [@0xWDG](https://x.com/0xWDG)
🧵 [@0xWDG](https://www.threads.net/@0xWDG)
🌐 [wesleydegroot.nl](https://wesleydegroot.nl)
🤖 [Discord](https://discordapp.com/users/918438083861573692)