Skip to content
This repository has been archived by the owner on Aug 16, 2019. It is now read-only.

JSON parsing and factories #7

Merged
merged 30 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
823cb16
ADD first draft for component factories. Not happy yet; WIP
Jan 11, 2017
6eb292f
ADD JSONReader to read a json file into a dictionary (JSONObject)
AndreasThenn Jan 12, 2017
8c6bc88
ADD unit tests for JSONReader
Jan 12, 2017
ba91bc7
REM line_length setting for SwiftLint again, because new SwiftLint ve…
AndreasThenn Jan 12, 2017
6ecf8d0
Add JSONFactory wrapper
joanromano Jan 12, 2017
77b4626
Update swiftlint tests file
joanromano Jan 12, 2017
df43352
Add tests to JSONReader
joanromano Jan 12, 2017
d6c16f6
Add JSONFactoryError for JSONFactory error handling
joanromano Jan 12, 2017
2a4fd05
Minor header fixes
joanromano Jan 12, 2017
be460f6
Fix swift lint rules with new version
joanromano Jan 13, 2017
f524260
Update project set up
joanromano Jan 13, 2017
26acb59
Update app_structure.json and tests to reflect current schema
joanromano Jan 13, 2017
62ca01d
Refactor using a single JSONFactory which holds builder closures
joanromano Jan 13, 2017
06b4bcd
Remove swiftlint line length since we use the default
joanromano Jan 13, 2017
d8ff008
Add public init in JSONFactory
joanromano Jan 13, 2017
98a5b1d
Merge branch 'master' into feature/jsonParsing
joanromano Jan 13, 2017
d218084
Fix code in example
joanromano Jan 13, 2017
81a720f
Fix line length violation on ExpressibleByComponentMeta documentation
joanromano Jan 13, 2017
b3cc35b
CRC
joanromano Jan 16, 2017
e030bf4
Use JSONObject type when possible
joanromano Jan 16, 2017
dadde5d
Re build example
joanromano Jan 18, 2017
ae229e1
Added gemfile to fix buddybuild
Jan 18, 2017
452a56b
Added another gemfile
Jan 18, 2017
50dcde2
ADD danger to the gemfile
Jan 18, 2017
abd0a79
Add danger-swiftlint
Jan 18, 2017
c80a885
Update documentation
joanromano Jan 19, 2017
57b6d0b
Update code and documentation with snake case keys
joanromano Jan 19, 2017
8119b1b
Remove fast test
joanromano Jan 19, 2017
6a9d36a
Update json example with snake case
joanromano Jan 19, 2017
63a84b9
Fix link on Readme
joanromano Jan 19, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions Documentation/JSON schema guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# JSON schema guide

This is a reference for the JSON schema provided by Matrioska, which should be followed in order to register `Component`s and build the provided standard components.

## JSON schemas for `Component` and `ComponentMeta`

Below you can find a detailed schema for `Component`s and for each configuration (`ComponentMeta`).

### Component schema

| Key | Type | Description |
| --- | ---- | ----------- |
| `type` | `String` | The type of the component. Used for factory registration. |

### StackConfig schema

| Key | Type | Description | Maps to | Optional | Default value |
| --- | ---- | ----------- | ------- | -------- | ------------- |
| `title` | `String` | The title of the stack. | `title` | Yes | `nil` |
| `spacing` | `Float` | The spacing of the components inside the stack. | `spacing` | Yes | `10` |
| `axis` | `Int` | The orientation of the stack. Can be either `0`(horizontal) or `1`(vertical). | `axis` | Yes | `1` |
| `preserve_parent_width` | `Bool` | Whether the arranged subviews should preserve the parent width or their own intrinsicContentSize. | `preserveParentWidth` | Yes | `false` |
| `background_color` | `String` | The background color of the stack. Alpha and compact forms are not supported. Valid formats: `0x123456` or `123456`. | `backgroundColor` | Yes | `ffffff`(white) |

### TabBarConfig schema

| Key | Type | Description | Maps to | Optional | Default value |
| --- | ---- | ----------- | ------- | -------- | ------------- |
| `selected_index` | `Int` | The selected index of the tab bar. | `selectedIndex` | No | . |

### Tab schema

| Key | Type | Description | Maps to | Optional | Default value |
| --- | ---- | ----------- | ------- | -------- | ------------- |
| `title` | `String` | The title to display on the tab. | `title` | No | . |
| `icon_name` | `Int` | The name of the icon to display on the tab. | `iconName` | No | . |

## Example JSON

```
{
"structure": {
"type": "tabbar",
"meta": {
"selected_index": 1
},
"children": [{
"type": "navigation",
"meta": {
"title": "history_title",
"icon_name": "history_tab_icon"
},
"children": [{
"type": "stack",
"meta": {
"axis": 1,
"preserve_parent_width": true,
"background_color": "0x123456"
},
"children": [{
"type": "table_view"
}]
}]
}, {
"type": "navigation",
"meta": {
"title": "main_tab_title",
"icon_name": "main_tab_icon"
},
"children": [{
"type": "stack",
"meta": {
"axis": 1,
"title": "Main stack",
"preserve_parent_width": true,
"spacing": "5"
},
"children": [{
"type": "label",
"meta": {
}
}, {
"type": "test_feature",
"meta": {
}
}
]
}]
}]
}
}
```
2 changes: 1 addition & 1 deletion Example/MatrioskaExample/TileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit
import Matrioska

struct TileConfig: MaterializableComponentMeta {
struct TileConfig: ExpressibleByComponentMeta {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe setup buddybuild quickly so we can make sure to not break the example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do so

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (wanted to see how it works), I created a runtastic team on buddybuild. Will invite you guys. Btw I think buddybuild also supports libraries now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nevermind that's only for payed plans.

let text: String?
let color: UIColor?

Expand Down
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- Matrioska (0.1.0):
- Matrioska (0.1.0-alpha1):
- SnapKit (~> 3.0)
- SnapKit (3.0.2)
- SnapKit (3.1.2)

DEPENDENCIES:
- Matrioska (from `../Matrioska.podspec`)
Expand All @@ -12,8 +12,8 @@ EXTERNAL SOURCES:
:path: "../Matrioska.podspec"

SPEC CHECKSUMS:
Matrioska: 872321eb578deb7af60323aa61126ee13e0d3fbd
SnapKit: 2e456761aa92d4d4067a7a5594c18769d451a8ad
Matrioska: b070c1ad36e64bdf7ab9d847033e2a5e4d2b8ec7
SnapKit: 12b24f569cb7c143acc9c22b9d91b23e7b1c84a2

PODFILE CHECKSUM: b63a58336b9471a5dbe1ffe7ea7d0b94f6dbf667

Expand Down
10 changes: 5 additions & 5 deletions Example/Pods/Local Podspecs/Matrioska.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading