Basic Structuring

The format of Appstent view content document is JSON based, and therefore the Appstent SDK in order to successfully render content views, expects the content to have valid JSON format.

Every content view is represented by a JSON object, with valid and supported view type identified by the "type" field. The value of the type field is a string containing one of the following values:

  • text

  • image

  • video

  • webView

  • divider

  • spacer

  • tabbedView

  • navigationView

  • navigationLink

  • list

  • grid

  • hStack

  • vStack

  • zStack

  • disclosureGroup

  • menu

  • gradientView

  • included

  • custom

Each view type has its own specific additional property fields. E.g. the following view renders a view of image type with its sourceType identified as remote and source representing the remote path.

{
    "type": "image",
    "source": "https://picsum.photos/id/1018/300/200.jpg",
    "sourceType": "remote"
}

If the value of the type field is not recognized by the Appstent SDK, the entire JSON object and any sub-objects will be ignored and not rendered.

Collection Views

Some of the views are of collection types. That is they contain one or more views. With the exception of some collection views, most of the collection views have views field that is of JSON array type. For example, following JSON contains a collection type vStack that contain 2 more text type views:

{
  "type": "vStack",
  "views": [
  	{
            "type": "text",
            "font": "largeTitle",
            "text": "Large Title Style"
        },
	{
            "type": "text",
            "font": "title",
            "text": "Title Style"
        }
  ]
}

Visibility

All content view types support visibility field. This field controls view's visibility by a set of visibility rules as represented in JSON as array of objects each containing mandatory ruleName field and other properties based on the rule type.

Appstent SDK also provide support of custom visibility rules if the CustomContentViewProvider object for iOS and CustomContentDataProvider object for Android is provided by the application, with the visibility method implemented to support custom visibility rules implementation.

Platform Specific Fields

If a view property needs to be customized for a specific platform, the key name should be preceded by ios: or android: prefixes. For example, the following view content JSON have some common fields while some other fields platform-customized.

{
    "type": "image",
    "ios:source": "chevron.right",
    "android:source": "arrow.forward",
    "sourceType": "system",
    "ios:height": 10,
    "android:width": 20,
    "android:offsetX": -10,
    "ios:width": 10
}

Integrating Other Content Views

When creating a complex content view, its a good idea to break it down to many individual content view documents and reuse and reference them when needed in larger multi-layered content screens. This can be done by creating a content view with included as the type value, and source providing the document path.

The following snippet shows an example of an included content view combined with other embedded content views:

{
  "type": "zStack",
  "alignment": "bottomLeading",
  "height": 400,
  "views": [
    {
      "type": "image",
      "source": "https://picsum.photos/seed/3/300/400",
      "sourceType": "remote"
    },
    {
      "type": "included",
      "source": "LandmarksApp/featuredCardOverlay"
    }
  ]
}

Last updated