-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from SOPT-all/feat/component-progressbar
[feat] Progress Bar 컴포넌트 구현
- Loading branch information
Showing
11 changed files
with
469 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
.../java/org/android/bbangzip/presentation/component/progressbar/BbangZipBasicProgressBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.android.bbangzip.presentation.component.progressbar | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxHeight | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.android.bbangzip.ui.theme.BbangZipTheme | ||
|
||
@Composable | ||
fun BbangZipBasicProgressBar( | ||
progress: Float, | ||
modifier: Modifier = Modifier, | ||
backgroundColor: Color = BbangZipTheme.colors.fillStrong_68645E_16, | ||
progressColor: Color = BbangZipTheme.colors.labelNormal_282119, | ||
clipShape: Shape = RoundedCornerShape(4.dp), | ||
) { | ||
Box( | ||
modifier = | ||
modifier | ||
.clip(clipShape) | ||
.background(backgroundColor) | ||
.height(8.dp) | ||
.fillMaxWidth(), | ||
) { | ||
Box( | ||
modifier = | ||
Modifier | ||
.clip(clipShape) | ||
.background(progressColor) | ||
.fillMaxHeight() | ||
.fillMaxWidth(progress), | ||
) | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun BbangZipProgressBarPreview() { | ||
Column( | ||
modifier = | ||
Modifier | ||
.background(color = Color.Gray) | ||
.fillMaxSize(), | ||
) { | ||
BbangZipBasicProgressBar( | ||
progress = 0.5f, | ||
) | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
.../java/org/android/bbangzip/presentation/component/progressbar/BbangZipLevelProgressBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package org.android.bbangzip.presentation.component.progressbar | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.res.vectorResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.android.bbangzip.R | ||
import org.android.bbangzip.presentation.component.chip.BbangZipChip | ||
import org.android.bbangzip.presentation.type.BbangZipLevelType | ||
import org.android.bbangzip.ui.theme.BBANGZIPTheme | ||
import org.android.bbangzip.ui.theme.BbangZipTheme | ||
|
||
@Composable | ||
fun BbangZipLevelProgressBar( | ||
level: Int, | ||
currentPoint: Int, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val levelType = BbangZipLevelType.entries[level - 1] | ||
|
||
Column( | ||
modifier = modifier, | ||
) { | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Row { | ||
BbangZipChip( | ||
backgroundColor = BbangZipTheme.colors.statusPositive_3D3730, | ||
text = stringResource(R.string.progressbar_chip_level, level.toString()), | ||
) | ||
|
||
Spacer(modifier = Modifier.padding(8.dp)) | ||
|
||
Text( | ||
text = levelType.bbangZipName, | ||
style = BbangZipTheme.typography.body1Bold, | ||
color = BbangZipTheme.colors.labelNormal_282119, | ||
) | ||
} | ||
|
||
BbangZipPoint( | ||
currentPoint = currentPoint.toString(), | ||
totalPoint = levelType.bbangZipLevelPoint.toString(), | ||
) | ||
} | ||
|
||
Spacer(Modifier.height(4.dp)) | ||
|
||
BbangZipBasicProgressBar( | ||
progress = currentPoint.toFloat() / levelType.bbangZipLevelPoint.toFloat(), | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun BbangZipPoint( | ||
modifier: Modifier = Modifier, | ||
currentPoint: String, | ||
totalPoint: String, | ||
) { | ||
Row( | ||
modifier = modifier, | ||
horizontalArrangement = Arrangement.Start, | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Icon( | ||
imageVector = ImageVector.vectorResource(R.drawable.ic_trophy_default_24), | ||
contentDescription = stringResource(R.string.bbangzip_trophy_description), | ||
tint = BbangZipTheme.colors.labelAlternative_282119_61, | ||
) | ||
|
||
Text( | ||
text = stringResource(R.string.bbangzip_level_point, currentPoint, totalPoint), | ||
modifier = Modifier.padding(start = 1.dp), | ||
style = BbangZipTheme.typography.label2Medium, | ||
color = BbangZipTheme.colors.labelAlternative_282119_61, | ||
) | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun BbangZipLevelProgressBarPreview() { | ||
BBANGZIPTheme { | ||
Column( | ||
modifier = | ||
Modifier | ||
.background(Color.Yellow) | ||
.fillMaxSize(), | ||
) { | ||
BbangZipLevelProgressBar( | ||
level = 1, | ||
currentPoint = 50, | ||
) | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...ain/java/org/android/bbangzip/presentation/component/progressbar/OnboardingProgressBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.android.bbangzip.presentation.component.progressbar | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.android.bbangzip.presentation.component.pushicon.BbangZipPushIcon | ||
import org.android.bbangzip.presentation.model.BbangZipPushIconState | ||
import org.android.bbangzip.presentation.type.OnboardingType | ||
import org.android.bbangzip.ui.theme.BbangZipTheme | ||
|
||
@Composable | ||
fun OnboardingProgressBar( | ||
onboardingType: OnboardingType, | ||
modifier: Modifier = Modifier, | ||
) { | ||
val currentPage = onboardingType.ordinal + 1 | ||
val progress = | ||
when (onboardingType) { | ||
OnboardingType.FIRST -> 0.04f | ||
OnboardingType.SECOND -> 0.5f | ||
OnboardingType.THIRD -> 1f | ||
} | ||
|
||
Column(modifier = modifier) { | ||
Row( | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
modifier = Modifier.fillMaxWidth(), | ||
) { | ||
OnboardingType.entries.forEachIndexed { index, _ -> | ||
val state = | ||
if (index < currentPage) { | ||
BbangZipPushIconState.Positive | ||
} else { | ||
BbangZipPushIconState.Disable | ||
} | ||
|
||
BbangZipPushIcon( | ||
pushIconText = (index + 1).toString(), | ||
bbangZipPushIconState = state, | ||
) | ||
} | ||
} | ||
} | ||
|
||
Spacer(modifier = Modifier.height(8.dp)) | ||
|
||
BbangZipBasicProgressBar( | ||
progress = progress, | ||
backgroundColor = BbangZipTheme.colors.fillStrong_68645E_16, | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun OnboardingProgressBarPreview() { | ||
val testPages = listOf(0, 1, 2) | ||
|
||
Column { | ||
testPages.forEach { currentPage -> | ||
OnboardingProgressBar( | ||
onboardingType = OnboardingType.entries[currentPage], | ||
) | ||
|
||
Spacer(modifier = Modifier.height(8.dp)) | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
app/src/main/java/org/android/bbangzip/presentation/component/pushicon/BbangZipPushIcon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.android.bbangzip.presentation.component.pushicon | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.android.bbangzip.presentation.model.BbangZipPushIconState | ||
import org.android.bbangzip.presentation.model.getBackgroundColor | ||
import org.android.bbangzip.ui.theme.BBANGZIPTheme | ||
import org.android.bbangzip.ui.theme.BbangZipTheme | ||
|
||
@Composable | ||
fun BbangZipPushIcon( | ||
modifier: Modifier = Modifier, | ||
pushIconText: String, | ||
bbangZipPushIconState: BbangZipPushIconState = BbangZipPushIconState.Disable, | ||
) { | ||
Box( | ||
contentAlignment = Alignment.Center, | ||
modifier = | ||
modifier | ||
.background(color = bbangZipPushIconState.getBackgroundColor(), shape = CircleShape) | ||
.padding(horizontal = 6.dp, vertical = 3.dp), | ||
) { | ||
Text( | ||
text = pushIconText, | ||
style = BbangZipTheme.typography.caption2Bold, | ||
color = BbangZipTheme.colors.staticWhite_FFFFFF, | ||
) | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
private fun BbangZipPushIconPreview() { | ||
BBANGZIPTheme { | ||
Row { | ||
BbangZipPushIcon( | ||
pushIconText = "1", | ||
bbangZipPushIconState = BbangZipPushIconState.Positive, | ||
) | ||
|
||
BbangZipPushIcon( | ||
pushIconText = "2", | ||
bbangZipPushIconState = BbangZipPushIconState.Disable, | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.