Code Monkey home page Code Monkey logo

dynamicui's Introduction

DynamicUI

Convert your JSON to a SwiftUI View.

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+

Installation

Install using Swift Package Manager

dependencies: [
    .package(url: "https://github.com/0xWDG/DynamicUI.git", .branch("main")),
],
targets: [
    .target(name: "MyTarget", dependencies: [
        .product(name: "DynamicUI", package: "DynamicUI"),
    ]),
]

And import it:

import DynamicUI

Usage

import DynamicUI

struct ContentView: View {
    let json = """
    [
        {
            "type": "Text",
            "title": "Wait, am i generating views from JSON?"
        }
    ]
    """.data(using: .utf8)

    var body: some View {
        DynamicUI(
            json: json
        )
    }
}

Supported View Types:

Please note: Items prefixed with ⚠ may ignore passed parameters.
Items with a strikethrough are not yet supported.

VStack
{
    "type": "VStack",
    "children": [  ]
}
HStack
{
    "type": "HStack",
    "children": [  ]
}
ZStack
{
    "type": "ZStack",
    "children": [  ]
}
List
{
    "type": "List",
    "children": [  ]
}
ScrollView
{
    "type": "ScrollView",
    "children": [  ]
}
NavigationView
{
    "type": "NavigationView",
    "children": [  ]
}
Form
{
    "type": "Form",
    "children": [  ]
}
Text
{
    "type": "Text",
    "title": "..."
}
Image
{
    "type": "Image",
    "imageURL": "systemName"
}
Divider
{
    "type": "Divider"
}
Spacer
{
    "type": "Spacer"
}
Label
{
    "type": "Label",
    "title": "..."
}
TextField
{
    "type": "TextField",
    "title": "...",
    "defaultValue": "..."
}
SecureField
{
    "type": "SecureField",
    "title": "...",
    "defaultValue": "..."
}
TextEditor
{
    "type": "TextEditor",
    "title": "...",
    "defaultValue": "..."
}
Toggle
{
    "type": "Toggle",
    "title": "Turn me on!",
    "defaultValue": true
}
⚠ Gauge
{
    "type": "Gauge",
    "title": "...",
    "defaultValue": 0.5
}
⚠ ProgressView
{
    "type": "ProgressView",
    "title": "...",
    "value": 50,
    "total": 100
}
Slider
{
    "type": "Slider",
    "title": "...",
    "minLabel": "min",
    "maxLabel": "max"
}
GroupBox
{
    "type": "GroupBox",
    "children": [ ]
}
DisclosureGroup
{
    "type": "DisclosureGroup",
    "children": [ ]
}
HSplitView
{
    "type": "HSplitView",
    "children": [ ]
}
VSplitView
{
    "type": "VSplitView",
    "children": [ ]
}
⚠ Picker
{
    "type": "Picker",
    "title": "...",
    "values": ["...", "..."]
}
⚠ NavigationSplitView
{
    "type": "NavigationSplitView",
    "children": [ ]
}
⚠ TabView
{
    "type": "TabView",
    "children": [ ]
}

Images

image

Contact

We can get in touch via Twitter/X, Discord, Mastodon, Threads, Bluesky.

Alternatively you can visit my Website.

dynamicui's People

Contributors

0xwdg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.