Skip to content

Commit

Permalink
Add support for rendering collection blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
RyosukeCla committed Feb 16, 2024
1 parent e714b69 commit 082a86e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.nativebrik.sdk.component.renderer

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.nativebrik.sdk.schema.CollectionKind
import com.nativebrik.sdk.schema.UIBlock

@Composable
Expand All @@ -14,6 +15,14 @@ internal fun Block(block: UIBlock, modifier: Modifier = Modifier) {
}
is UIBlock.UnionUIImageBlock -> Image(block = block.data, modifier)
is UIBlock.UnionUITextBlock -> Text(block = block.data, modifier)
is UIBlock.UnionUICollectionBlock -> {
val collection = block.data
when (collection.data?.kind) {
CollectionKind.CAROUSEL -> Carousel(block = collection, modifier)
CollectionKind.GRID -> Grid(block = collection, modifier)
else -> Grid(block = collection, modifier)
}
}
else -> Unit
}
}

0 comments on commit 082a86e

Please sign in to comment.