Skip to content

Instantly share code, notes, and snippets.

@rbro112
Last active June 27, 2021 23:32
Show Gist options
  • Save rbro112/c1ec7e56bb75334f6253a5c60806b31b to your computer and use it in GitHub Desktop.
Save rbro112/c1ec7e56bb75334f6253a5c60806b31b to your computer and use it in GitHub Desktop.
// 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,
style = section.titleStyle
)
// Optionally build a subtitle if present in the TitleSection data model
if (!section.subtitle.isNullOrEmpty() {
Text(
text = section.subtitle,
style = section.subtitleStyle
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment