Skip to content

Commit

Permalink
Merge pull request #383 from georgejecook/chore/build-improvement3
Browse files Browse the repository at this point in the history
docs: adds docs for view fragments
  • Loading branch information
georgejecook authored May 20, 2023
2 parents 8c31f2a + 4d68077 commit 48bd4c8
Show file tree
Hide file tree
Showing 31 changed files with 187 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ jobs:
with:
node-version: "18.4.0"
- run: npm ci
- run: npm run ropm
- run: npm run build
# - run: npm run publish-coverage
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
node-version: "14.18.1"
- name: Run full CI
run: npm ci
- name: ropm
run: npm run ropm
- name: Build
run: npm run build
- name: Configure npm
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
111 changes: 111 additions & 0 deletions docs/View-Framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,114 @@ In addition the view framework contains many base classes that can be used
Maestro makes use of many different mixin classes, which handle different aspects of view management (e.g. utils, focus, key handling), and then bundles these together in base classes (views and screens).

Aggregate views for tab (i.e. iOS style TabController navigation) and stack (i.e. iOS style NavController navigation) are provided


## Fragments and json support

in Maestro framework, we predominantly build our views and screens from json. Why?

- It's generally quicker to work with than the xml
- Easy to export from figma
- Easy to import form apis/CMS
- Easy to write inline
- Gives better performance control, as one can defer view instantion.


Maestro has several methods for building views in this manner, all available on BaseView. These methods allow for view creation, and automatically creating field pointers to the created views, and can even automatically bind views.

An example of creating a fragment.


```
@it("creates a view fragment, with children, with bindings, and works multiple times")
function _()
json = {
"_type": "Rectangle"
"id": "v1"
"height": "${json.height}"
"_children": [
{
"_type": "mv_Label"
"id": "v2"
"text": "${json.item1.a}"
}
{
"_type": "mv_Label"
"id": "v3"
"text": "${json.item2.subItem.b}"
"_children": [
{
"_type": "mv_Label"
"id": "v4"
"text": "${json.others[1]}"
}
]
}
]
}
data = {
json: {
"height": 200.0
item1: {
"a": "first"
}
item2: {
subItem: {
"b": "second"
}
}
others: [
"third", "fourth"
]
}
}
view = mv.createFragment(json, invalid, data)
m.assertSubType(view, "Rectangle")
m.assertEqual(view.id, "v1")
m.assertEqual(view.height, 200.0)
child1 = view.getChild(0)
m.assertSubType(child1, "mv_Label")
m.assertEqual(child1.id, "v2")
m.assertEqual(child1.text, "first")
child2 = view.getChild(1)
m.assertSubType(child2, "mv_Label")
m.assertEqual(child2.id, "v3")
m.assertEqual(child2.text, "second")
child2_1 = child2.getChild(0)
m.assertSubType(child2_1, "mv_Label")
m.assertEqual(child2_1.id, "v4")
m.assertEqual(child2_1.text, "fourth")
view = mv.createFragment(json, invalid, data)
m.assertSubType(view, "Rectangle")
m.assertEqual(view.id, "v1")
m.assertEqual(view.height, 200.0)
child1 = view.getChild(0)
m.assertSubType(child1, "mv_Label")
m.assertEqual(child1.id, "v2")
m.assertEqual(child1.text, "first")
child2 = view.getChild(1)
m.assertSubType(child2, "mv_Label")
m.assertEqual(child2.id, "v3")
m.assertEqual(child2.text, "second")
child2_1 = child2.getChild(0)
m.assertSubType(child2_1, "mv_Label")
m.assertEqual(child2_1.id, "v4")
m.assertEqual(child2_1.text, "fourth")
end function
```
50 changes: 25 additions & 25 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,38 +65,38 @@ Been in production for > 2 years at:

## Table of Contents
* [About](/docs/About.md)
- [Getting started](/docs/About:-Getting-started.md)
- [Bsc plugin](/docs/About:-Bsc-plugin.md)
- [Justification](/docs/About:-Justification.md)
- [Getting started](/docs/About-Getting-started.md)
- [Bsc plugin](/docs/About-Bsc-plugin.md)
- [Justification](/docs/About-Justification.md)
* [Utils](/docs/Utils.md)
- [mc (maestro core utils)](/docs/Utils:-mc-maestro-core-utils.md)
- [mc.Tasks](/docs/Utils:-mc.tasks-maestro-core-tasks.md)
- [mc.Serialization](/docs/Utils:-mc.utils.Serialization.md)
- [mc.Collections](/docs/Utils:-mc.utils.Collections.md)
- [mc (maestro core utils)](/docs/Utils-mc-maestro-core-utils.md)
- [mc.Tasks](/docs/Utils-mc.tasks-maestro-core-tasks.md)
- [mc.Serialization](/docs/Utils-mc.utils.Serialization.md)
- [mc.Collections](/docs/Utils-mc.utils.Collections.md)
* [Node Classes](/docs/Node-Classes.md)
- [Testing](/docs/Node-Classes:-Testing.md)
- [Config](/docs/Node-Classes:-Config.md)
- [How to write](/docs/Node-Classes:-How-to-write.md)
- [Implementation](/docs/Node-Classes:-Implementation.md)
- [Node task](/docs/Node-Classes:-Node-task.md)
- [Testing](/docs/Node-Classes-Testing.md)
- [Config](/docs/Node-Classes-Config.md)
- [How to write](/docs/Node-Classes-How-to-write.md)
- [Implementation](/docs/Node-Classes-Implementation.md)
- [Node task](/docs/Node-Classes-Node-task.md)
* [View Framework](/docs/View-Framework.md)
- [BaseScreen](/docs/View-Framework:-BaseScreen.md)
- [BaseView](/docs/View-Framework:-BaseView.md)
- [Aggregate Views](/docs/View-Framework:-Aggregate-Views.md)
- [View Transitions](/docs/View-Framework:-View-Transitions.md)
- [Component lifecycle](/docs/View-Framework:-Component-lifecycle.md)
- [Mixins](/docs/View-Framework:-Mixins.md)
- [Styles and Bundles](/docs/View-Framework:-Styles-and-Bundles.md)
- [BaseScreen](/docs/View-Framework-BaseScreen.md)
- [BaseView](/docs/View-Framework-BaseView.md)
- [Aggregate Views](/docs/View-Framework-Aggregate-Views.md)
- [View Transitions](/docs/View-Framework-View-Transitions.md)
- [Component lifecycle](/docs/View-Framework-Component-lifecycle.md)
- [Mixins](/docs/View-Framework-Mixins.md)
- [Styles and Bundles](/docs/View-Framework-Styles-and-Bundles.md)
* [MVVM Framework](/docs/MVVM-Framework.md)
- [Observables and ViewModels](/docs/MVVM-Framework:-Observables-and-ViewModels.md)
- [XML binding syntax](/docs/MVVM-Framework:-XML-binding-syntax.md)
- [Observables and ViewModels](/docs/MVVM-Framework-Observables-and-ViewModels.md)
- [XML binding syntax](/docs/MVVM-Framework-XML-binding-syntax.md)
* [IOC Framework](/docs/IOC-Framework.md)
* [More maestro goodness](/docs/More-maestro-goodness.md)
* [List Component](/docs/List-Component.md)
- [Sample](/docs/List-Component:-Sample.md)
- [Getting started](/docs/About:-Getting-started.md)
- [Callbacks](/docs/List-Component:-Callbacks.md)
- [CustomCells](/docs/List-Component:-CustomCells.md)
- [Sample](/docs/List-Component-Sample.md)
- [Getting started](/docs/About-Getting-started.md)
- [Callbacks](/docs/List-Component-Callbacks.md)
- [CustomCells](/docs/List-Component-CustomCells.md)
* [Command Sequences and controlling application launch] (/docs/command-and-launch.md)
* [Debugging](/docs/Debugging.md)
* [API documentation](/docs/API-Docs.md)
47 changes: 46 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"dependencies": {
"@rokucommunity/bslib": "^0.1.1",
"cz-conventional-changelog": "^3.3.0",
"log": "npm:roku-log@^0.10.1"
"log": "npm:roku-log@^0.10.1",
"rename": "^1.0.4"
},
"devDependencies": {
"@rokucommunity/bslint": "^0.8.1",
Expand Down

0 comments on commit 48bd4c8

Please sign in to comment.