SwiftUI directed Server Driven UI

Related tags

Animation SDUI
Overview

Server Driven UI (SDUI)

Intentions

Make a Server Driven UI module for SwiftUI applications that has a direct use. That way the application maintainer would only be concerned with the components and templates of the application. Since SwiftUI differs from UIKit making it easier to write code for screens, this module would not be directed for that use solely. But, directed for a screen with unusual changes of UI, end-client personalized UI, or any other type of UI that need to be controlled by the backend.

Basic Architecture

State Machine

State machine to control the states for fetching, loading and presenting a screen. It also has auxiliaries states for error cases and the initial state. Follow its drawing:

stateDiagram-v2
    S: START
    F: FETCH
    L: LOAD
    P: PRESENT
    E: ERROR
    S --> F: initiate
    F --> L: load data
    L --> P: succes
    P --> F: react
    F --> E: bad data
    L --> E: failure
    E --> F: retry

Decoding

The JSON object that is received has the following format:

{
    "screenName": "<screen-name>",
    "templates": [
        {
            "id": "<template-id>",
            "type": "<template-type>",
            "order": 1,
            "componentsId": [
                {
                    "id": "<component-id>",
                    "order": 1
                },
                {
                    "...": "..."
                }
            ]
        },
        {
            "...": "..."
        }
    ],
    "components": [
        {
            "id": "<component-id>",
            "type": "<component-type>",
            "bodyId": "<body-id>"
        },
        {
            "...": "..."
        }
    ],
    "body": [
        {
            "id": "<body-id>",
            "body": {
                "<body-key>": "<body-key-value>",
                "...": "..." 
            }
        },
        {
            "...": "..."
        }
    ]
}

And is decoded into the following swift object:

ScreenModel(
    screenName: "<screen-name>",
    templates: [
        SDUI.TemplateModel(
            id: "<template-id>",
            type: SDUI.TemplateType(rawValue: "<template-type>"),
            components: [
                SDUI.ComponentModel(
                    id: "<component-id>",
                    type: SDUI.ComponentType(rawValue: "<component-type>"),
                    body: SDUI.BodyModel(
                        id: "<body-id>",
                        data: [
                            "<body-key>": "<body-key-value>",
                            ...
                        ]
                    )
                ),
                ...
            ]
        ),
        ...
    ]
) 
You might also like...
Incognito animation made with SwiftUI
Incognito animation made with SwiftUI

IncognitoSwiftUI Incognito animation made with SwiftUI Incognito Mode / Private Browsing Private browsing is a privacy feature in some web browsers. W

SwiftUI Animation
SwiftUI Animation

Hey there Hi, I'm Arvind Patel, a iOS Developer 🚀 from India. Beside's programming, I enjoy eating food and Watching Movies. I'm a creative problem s

SwiftUI Package for Configurable Confetti Animation 🎉
SwiftUI Package for Configurable Confetti Animation 🎉

🎊 ConfettiSwiftUI 🎊 Swift package for displaying configurable confetti animation. Find the demo project here. Installation: It requires iOS 14 and X

Animations created with SwiftUI.
Animations created with SwiftUI.

A repository containing a variety of animations and Animated components created in SwiftUI that you can use in your own projects.

Colorful - A SwiftUI implementation of AppleCard's animated colorful blur background.
Colorful - A SwiftUI implementation of AppleCard's animated colorful blur background.

Colorful - A SwiftUI implementation of AppleCard's animated colorful blur background.

A SwiftUI implementation of Wave animating shape.
A SwiftUI implementation of Wave animating shape.

WaveAnimation A SwiftUI implementation of Wave animating shape. Preview Usage import SineWaveShape SineWaveShape(percent: 0.4, strength: 30, frequency

An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Match animations in SwiftUI and UIKit/AppKit
Match animations in SwiftUI and UIKit/AppKit

MatchedAnimation Match animations in SwiftUI and UIKit/AppKit. /// Draw a box in

A very basic calculator in swiftUI which uses NSExpression

Calculatrice-Avec-NS Une calculatrice très basic en swiftUI qui utilise NSExpres

Comments
  • Tests Template

    Tests Template

    • 1: Include new dependency for tests ViewInspector into SDUITests target of main module
    • 2: Make Test for template render using the package

    Also:

    • Complements LinkerMock
    • Corrects initialization of TemplateTest for using render
    opened by Hilst 0
Owner
Felipe Hilst
Electrical Engineering - Automation and Control In São Paulo, SP Currently working with iOS development
Felipe Hilst
Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers

Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers. It's magic. Features Animate a

Robert-Hein Hooijmans 1.3k Nov 17, 2022
Swift interpolation for gesture-driven animations

Interpolate Interpolate is a powerful Swift interpolation framework for creating interactive gesture-driven animations. Usage The ?? idea of Interpola

Roy Marmelstein 1.8k Dec 20, 2022
Designed for gesture-driven animations. Fast, simple, & extensible!

Yet Another Animation Library Designed for gesture-driven animations. Fast, simple, & extensible! It is written in pure swift 3.1 with protocol orient

Luke Zhao 509 Dec 21, 2022
MobilePillowTalkLite - An iOS & SwiftUI server monitor tool for linux based machines using remote proc file system with script execution

# PillowTalk - iOS/Lite bbtop PillowTalk -> 枕头逼逼 -> bbtop! An iOS & SwiftUI serv

Lakr Aream 416 Dec 16, 2022
SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image

SwiftUI.AnimatedImage SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image Screen.Recording.2021-07-31.at.02.18.33.mov Insta

Marcin Krzyzanowski 50 Oct 14, 2022
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

Gordan Glavaš 9 Nov 5, 2022
SwiftUI project demonstrating Custom coded confetti animation for checkout page

Confetti-Checkout SwiftUI project demonstrating Custom coded confetti animation for checkout page NOTE: CAEmitterLayer is not used but all the confett

Waseem akram 29 Sep 28, 2022
Fortune spinning wheel library built using SwiftUI, supports dynamic content.

Fortune Wheel Fortune spinning wheel ?? library built using SwiftUI, supports dynamic content. Preview - Spin Wheel ⚙️ CocoaPods Installation FortuneW

Sameer Nawaz 51 Dec 23, 2022