Skip to content

Commit

Permalink
Merge pull request #5 from mkeeda/fix-preview-background
Browse files Browse the repository at this point in the history
Make PreviewBackground for shorthand of SpaceshipTheme and Surface
  • Loading branch information
mkeeda authored Aug 22, 2021
2 parents 3c65f6b + cb71425 commit 7a92ce2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import dev.mkeeda.spaceship.data.TimelinePostDetails
import dev.mkeeda.spaceship.data.fakeTimeListDetails
import dev.mkeeda.spaceship.ui.theme.SpaceshipTheme
import dev.mkeeda.spaceship.ui.util.PreviewBackground

@Composable
fun PostDetailsScreen(postId: Int) {
Expand Down Expand Up @@ -47,10 +47,10 @@ fun PostDetails(postDetails: TimelinePostDetails) {
}
}

@Preview(showBackground = true)
@Preview
@Composable
fun PostDetailsScreenPreview() {
SpaceshipTheme {
PreviewBackground {
PostDetails(postDetails = fakeTimeListDetails(postId = 0))
}
}
10 changes: 5 additions & 5 deletions app/src/main/java/dev/mkeeda/spaceship/ui/timeline/TimeLine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import dev.mkeeda.spaceship.data.TimelinePost
import dev.mkeeda.spaceship.data.longFakeTimelinePostItems
import dev.mkeeda.spaceship.ui.theme.SpaceshipTheme
import dev.mkeeda.spaceship.ui.util.PreviewBackground

@Composable
fun TimelineScreen(openPostDetails: (TimelinePost) -> Unit) {
Expand All @@ -50,10 +50,10 @@ fun Timeline(
}
}

@Preview(showBackground = true)
@Preview
@Composable
fun TimelineScreenPreview() {
SpaceshipTheme {
PreviewBackground {
Timeline(
postItems = longFakeTimelinePostItems,
openPostDetails = {}
Expand Down Expand Up @@ -102,10 +102,10 @@ fun TimelineRow(
}
}

@Preview(showBackground = true)
@Preview
@Composable
fun PostRowPreview() {
SpaceshipTheme {
PreviewBackground {
TimelineRow(
post = TimelinePost(
id = 0,
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/dev/mkeeda/spaceship/ui/util/Preview.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dev.mkeeda.spaceship.ui.util

import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import dev.mkeeda.spaceship.ui.theme.SpaceshipTheme

@Composable
fun PreviewBackground(content: @Composable () -> Unit) {
SpaceshipTheme {
Surface(content = content)
}
}

0 comments on commit 7a92ce2

Please sign in to comment.