Skip to content

Commit

Permalink
#2 - Home section - Slot APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
jhg3410 committed Jan 27, 2023
1 parent acd80c5 commit c904e7f
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.codelab.basiclayouts.ui.theme.MySootheTheme
import java.util.*

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -174,9 +175,20 @@ fun FavoriteCollectionsGrid(
// Step: Home section - Slot APIs
@Composable
fun HomeSection(
modifier: Modifier = Modifier
@StringRes title: Int,
modifier: Modifier = Modifier,
content: @Composable () -> Unit
) {
// Implement composable here
Column(modifier) {
Text(
text = stringResource(id = title).uppercase(locale = Locale.getDefault()),
style = MaterialTheme.typography.h2,
modifier = Modifier
.paddingFromBaseline(top = 40.dp, bottom = 8.dp)
.padding(horizontal = 16.dp)
)
content()
}
}

// Step: Home screen - Scrolling
Expand Down Expand Up @@ -265,7 +277,11 @@ fun AlignYourBodyRowPreview() {
@Preview(showBackground = true, backgroundColor = 0xFFF0EAE2)
@Composable
fun HomeSectionPreview() {
MySootheTheme { HomeSection() }
MySootheTheme {
HomeSection(title = R.string.align_your_body) {
AlignYourBodyRow()
}
}
}

@Preview(showBackground = true, backgroundColor = 0xFFF0EAE2)
Expand Down

0 comments on commit c904e7f

Please sign in to comment.