Skip to content

Commit

Permalink
Merge pull request #329 from tmdgh1592/feature/#308-분리한-컴포넌트-Preview-작성
Browse files Browse the repository at this point in the history
[개선] 분리한 컴포넌트 preview 작성
  • Loading branch information
taehwandev authored Jun 10, 2024
2 parents 1407cb9 + 160d21a commit 4d2455e
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.droidknights.app.core.designsystem.theme.KnightsTheme
import com.droidknights.app.core.designsystem.theme.Purple01
import com.droidknights.app.core.designsystem.theme.White
import com.droidknights.app.core.model.Room
import com.droidknights.app.core.model.Session
import com.droidknights.app.feature.bookmark.R
import com.droidknights.app.feature.bookmark.model.BookmarkItemUiState
import kotlinx.collections.immutable.ImmutableSet
import kotlinx.collections.immutable.persistentSetOf
import kotlinx.datetime.LocalDateTime

@Composable
internal fun EditModeLeadingItem(
Expand Down Expand Up @@ -58,3 +63,45 @@ internal fun EditModeLeadingItem(
)
}
}

private val SampleBookmarkItemUiState = BookmarkItemUiState(
index = 0,
session = Session(
id = "1",
title = "Session Title",
content = "Compose 성능 최적화를 위한 Stability 마스터하기",
speakers = emptyList(),
tags = emptyList(),
room = Room.TRACK1,
startTime = LocalDateTime(2022, 1, 1, 10, 0, 0),
endTime = LocalDateTime(2022, 1, 1, 11, 0, 0),
isBookmarked = true,
),
)

private val SampleSelectedSessionIds = persistentSetOf("1", "2", "3")
private val SampleUnselectedSessionIds = persistentSetOf("-1")

@Preview
@Composable
private fun CheckedEditModeLeadingItemPreview() {
KnightsTheme {
EditModeLeadingItem(
itemState = SampleBookmarkItemUiState,
selectedSessionIds = SampleSelectedSessionIds,
onSelectedItem = {}
)
}
}

@Preview
@Composable
private fun UncheckedEditModeLeadingItemPreview() {
KnightsTheme {
EditModeLeadingItem(
itemState = SampleBookmarkItemUiState,
selectedSessionIds = SampleUnselectedSessionIds,
onSelectedItem = {}
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.droidknights.app.feature.contributor.component

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -14,6 +15,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.droidknights.app.core.designsystem.component.KnightsCard
import com.droidknights.app.core.designsystem.component.NetworkImage
Expand All @@ -27,7 +29,7 @@ import com.valentinilk.shimmer.shimmer
@Composable
internal fun ContributorCard(
contributor: Contributor?,
modifier: Modifier,
modifier: Modifier = Modifier,
) {
val uriHandler = LocalUriHandler.current
val shimmerModifier = if (contributor == null) {
Expand Down Expand Up @@ -88,3 +90,19 @@ internal fun ContributorCard(
}
}
}

@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun ContributorCardPreview() {
KnightsTheme {
ContributorCard(
contributor = Contributor(
id = 1L,
name = "Droid Knights",
imageUrl = "",
githubUrl = ""
),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package com.droidknights.app.feature.contributor.component

import android.content.res.Configuration
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.droidknights.app.core.designsystem.component.KnightsTopAppBar
import com.droidknights.app.core.designsystem.component.TopAppBarNavigationType
import com.droidknights.app.core.designsystem.theme.KnightsTheme
import com.droidknights.app.feature.contributor.R

@Composable
Expand All @@ -29,3 +36,24 @@ internal fun ContributorTopAppBar(
containerColor = containerColor,
)
}

@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun ContributorTopAppBarPreview() {
KnightsTheme {
Column {
ContributorTopAppBar(
isAtTop = false,
onBackClick = {},
)

Spacer(modifier = Modifier.padding(top = 20.dp))

ContributorTopAppBar(
isAtTop = true,
onBackClick = {},
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
Expand All @@ -14,6 +15,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.droidknights.app.core.designsystem.theme.Black
import com.droidknights.app.core.designsystem.theme.KnightsTheme
Expand Down Expand Up @@ -76,3 +78,17 @@ private fun ContributorBannerContent(
)
}
}

@Preview
@Composable
private fun ContributorTopBannerPreview() {
KnightsTheme {
Column {
ContributorTopBanner(darkTheme = false)

Spacer(modifier = Modifier.padding(top = 20.dp))

ContributorTopBanner(darkTheme = true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ internal class RoomPreviewParameterProvider : PreviewParameterProvider<Room> {
)
}

@Preview
@Composable
private fun TagChipPreview() {
TagChip(Tag("Android"))
}

@Preview
@Composable
fun TrackChipPreview(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -45,6 +46,7 @@ import com.droidknights.app.core.ui.RoomText
import com.droidknights.app.feature.session.R
import com.droidknights.app.feature.session.model.SessionState
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -186,6 +188,21 @@ private fun Modifier.tabIndicatorOffset(
.width(currentTabWidth)
}

@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
@Composable
private fun SessionTopAppBarPreview() {
KnightsTheme {
SessionTopAppBar(
sessionState = SessionState(
sessions = persistentListOf(),
listState = rememberLazyListState()
),
onBackClick = { }
)
}
}

@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
@Composable
Expand Down

0 comments on commit 4d2455e

Please sign in to comment.