GithubHelp home page GithubHelp logo

jsonvistas's Introduction

A Tool To Make Auto Layout Visual Format Strings


What is this?

This should make it easier to create views from code, and easier to transmit layouts in json.

The purpose of this project is to better understand Auto Layout Visual Format and to make it easier to use. Ironically this project is made in SwiftUI for macOS. This single page app creates Visual Format Strings that are only useful for what SwiftUI is intended to replace.

Here is the Apple Auto-Layout Visual Format Documentation

How to use the app


Create views, then drag, tap, double table, long press, and arrange them to create Visual Format Strings

app demo

Example Output

H:|-[bottom]-|
H:|-[top]-|
H:|-[mid_left]-[mid_right]-|
V:|-[top]-[mid_right]-[bottom]-|
V:|-[top]-[mid_left]-[bottom]-|

Visual Format Grammar


Syntax:

  • Orientation
    • Optional, ignoring this implies horizontal
    • H: or V:
  • Superview
    • Optional, ignoring this could lead to unexpected views
    • | No hyphen suggests the view should touch the superview/container
    • |-, or -| A hyphen provides >=8 units of space away from the superview/container
  • Connection
    • Optional, ignoring this will cause a few things
      • H:|(view) The view will hug the container on the left side
      • (view)(other_view) The view will hug the other_view
    • - A single hyphen will provide some default amount of padding depending on the other side of the view
    • -units@priority- This will create a distance of the number of units at the given priority
  • View
    • (unique_id_string) This will relate to a view of the same name, the id string should be unique
(<orientation>:)?(<superview><connection>)?<view>(<connection><view>)*(<connection><superview>)?

Another Explanation:

  • ? indicates 0 or 1 are allowed
  • Asterisk(*) indicates 1 or more are necessary
  • orientation: H:, V:
  • superview: |
  • connection: ``, -, `-(value)-`
  • view: [unique_string_id(relation)]
  • relation: todo, basically width or height of a view would be H:[viewName(==width)] or V:[viewName(>=minHeight)]

Error Handling


If you make a syntactic mistake, an exception is thrown with a diagnostic message. For example:

Expected ':' after 'V' to specify vertical arrangement
V|[backgroundBox]|
 ^
 
A predicate on a view's thickness must end with ')' and the view must end with ']'
|[whiteBox1][blackBox4(blackWidth][redBox]|
                                 ^
 
Unable to find view with name blackBox
|[whiteBox2][blackBox]
                     ^
 
Unknown relation. Must be ==, >=, or <=
V:|[blackBox4(>30)]|
               ^

TODO:


  • Relations
  • Predicates and Predicate Lists
  • Priority
  • Metrics
  • Examples

jsonvistas's People

Contributors

michael94ellis avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.