Skip to content

Instantly share code, notes, and snippets.

@rbro112
rbro112 / sample_gp_response.json
Last active February 6, 2023 09:07
A full sample GP response for a simple listing screen.
{
"screens": [
{
"id": "ROOT",
"screenProperties": {},
"layout": {
"wide": {},
"compact": {
"type": "SingleColumnLayout",
"main": {
@rbro112
rbro112 / TitleSectionComponent.kt
Created June 28, 2021 05:24
Example of a section with an IAction handling.
@SectionComponentType(SectionComponentType.TITLE)
class TitleSectionComponent : SectionComponent<TitleSection>() {
override fun buildSectionUI(section: TitleSection) {
// Build title UI elements
if (!section.subtitle.isNullOrEmpty() {
Text(
@rbro112
rbro112 / iactions.graphqls
Last active June 28, 2021 18:21
A sample of the GP IAction schema.
interface IAction {}
# A simple action that will navigate the user to the screen matching the screenId when invoked
type NavigateToScreen implements IAction {
screenId: String
}
# A sample TitleSection using an IAction type to handle the click of the subtitle
type TitleSection {
...
@rbro112
rbro112 / ilayouts.graphqls
Created June 28, 2021 04:41
A sample of the GP ILayout schema.
interface ILayout {}
type SectionDetail {
# References a SectionContainer in the GPResponse.sections array
sectionId: String
# Styling data
topPadding: Int
bottomPadding: Int
@rbro112
rbro112 / screens.graphqls
Created June 28, 2021 04:35
A sample of the GP screens schema.
type ScreenContainer {
id: String
# Properties such as how to launch this screen (popup, sheet, etc.)
screenProperties: ScreenProperties
layout: LayoutsPerFormFactor
}
# Specifies the ILayout type depending on rotation, client screen density, etc.
// This annotation builds a Map<SectionComponentType, SectionComponent> that GP uses to render sections
@SectionComponentType(SectionComponentType.TITLE)
class TitleSectionComponent : SectionComponent<TitleSection>() {
// Developers override this method and build UI from TitleSection corresponding to TITLE
override fun buildSectionUI(section: TitleSection) {
// Text() Turns our title into a styled TextView
Text(
text = section.title,
@rbro112
rbro112 / sections.graphqls
Last active December 5, 2021 03:49
A sample of the GP section schema.
# Example sections
type HeroSection {
# Image urls
images: [String]!
}
type TitleSection {
title: String!,
titleStyle: TextStyle!
@rbro112
rbro112 / gp_response.graphqls
Last active June 28, 2021 04:12
Sample GP Response interface.
interface GPResponse {
sections: [SectionContainer]
screens: [ScreenContainer]
# ... Other metadata, logging data or feature-specific logic
}