-
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.
Browse files
Browse the repository at this point in the history
[Feature] MainScreen stars 컴포넌트를 구현합니다.
- Loading branch information
Showing
10 changed files
with
241 additions
and
15 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
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
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
68 changes: 68 additions & 0 deletions
68
main-presentation/src/main/java/com/teamhy2/feature/main/component/StarsComponent.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,68 @@ | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.teamhy2.hongikyeolgong2.main.presentation.R | ||
|
||
private const val STAR_IMAGE_SIZE = 40 | ||
|
||
@Composable | ||
fun StarsComponent( | ||
starCount: Int, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Row( | ||
modifier = modifier, | ||
) { | ||
repeat(3) { position -> | ||
Image( | ||
painter = getStarPainter(starCount, position + 1), | ||
contentDescription = null, | ||
modifier = Modifier.size(STAR_IMAGE_SIZE.dp), | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun getStarPainter( | ||
starCount: Int, | ||
position: Int, | ||
): Painter { | ||
return when { | ||
starCount >= position -> painterResource(id = getStarDrawableId(position)) | ||
else -> painterResource(id = R.drawable.ic_star_0) | ||
} | ||
} | ||
|
||
private fun getStarDrawableId(position: Int): Int { | ||
return when (position) { | ||
1 -> R.drawable.ic_star_1 | ||
2 -> R.drawable.ic_star_2 | ||
3 -> R.drawable.ic_star_3 | ||
else -> R.drawable.ic_star_0 | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
private fun StarCount1ComponentPreview() { | ||
StarsComponent(starCount = 1) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
private fun StarsCount2ComponentPreview() { | ||
StarsComponent(starCount = 2) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
private fun StarsCount3ComponentPreview() { | ||
StarsComponent(starCount = 3) | ||
} |
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
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
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,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="32dp" | ||
android:height="32dp" | ||
android:viewportWidth="32" | ||
android:viewportHeight="32"> | ||
<path | ||
android:pathData="M16.631,9.847L18.779,13.756C18.833,13.854 18.913,13.934 19.011,13.987L22.928,16.119C23.334,16.34 23.335,16.922 22.93,17.144L19.022,19.292C18.924,19.346 18.843,19.427 18.79,19.525L16.658,23.442C16.438,23.847 15.855,23.849 15.633,23.444L13.485,19.535C13.431,19.437 13.351,19.357 13.253,19.304L9.336,17.171C8.93,16.951 8.929,16.369 9.334,16.147L13.242,13.999C13.34,13.945 13.421,13.864 13.474,13.766L15.606,9.849C15.827,9.444 16.409,9.442 16.631,9.847Z" | ||
android:fillColor="#3A3E49"/> | ||
</vector> |
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,20 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="32dp" | ||
android:height="32dp" | ||
android:viewportWidth="32" | ||
android:viewportHeight="32"> | ||
<path | ||
android:pathData="M16.631,9.847L18.779,13.756C18.833,13.854 18.913,13.934 19.011,13.987L22.928,16.119C23.334,16.34 23.335,16.922 22.93,17.144L19.022,19.292C18.924,19.346 18.843,19.427 18.79,19.525L16.658,23.442C16.438,23.847 15.855,23.849 15.633,23.444L13.485,19.535C13.431,19.437 13.351,19.357 13.253,19.304L9.336,17.171C8.93,16.951 8.929,16.369 9.334,16.147L13.242,13.999C13.34,13.945 13.421,13.864 13.474,13.766L15.606,9.849C15.827,9.444 16.409,9.442 16.631,9.847Z"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:centerX="16.132" | ||
android:centerY="16.646" | ||
android:gradientRadius="6.043" | ||
android:type="radial"> | ||
<item android:offset="0" android:color="#FF18275D"/> | ||
<item android:offset="1" android:color="#FF263B85"/> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
</vector> |
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,20 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="32dp" | ||
android:height="32dp" | ||
android:viewportWidth="32" | ||
android:viewportHeight="32"> | ||
<path | ||
android:pathData="M16.631,9.847L18.779,13.756C18.833,13.854 18.913,13.934 19.011,13.987L22.928,16.119C23.334,16.34 23.335,16.922 22.93,17.144L19.022,19.292C18.924,19.346 18.843,19.427 18.79,19.525L16.658,23.442C16.438,23.847 15.855,23.849 15.633,23.444L13.485,19.535C13.431,19.437 13.351,19.357 13.253,19.304L9.336,17.171C8.93,16.951 8.929,16.369 9.334,16.147L13.242,13.999C13.34,13.945 13.421,13.864 13.474,13.766L15.606,9.849C15.827,9.444 16.409,9.442 16.631,9.847Z"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:centerX="16.132" | ||
android:centerY="16.646" | ||
android:gradientRadius="6.043" | ||
android:type="radial"> | ||
<item android:offset="0" android:color="#FF334FB2"/> | ||
<item android:offset="1" android:color="#FF6384FA"/> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
</vector> |
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,20 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="32dp" | ||
android:height="32dp" | ||
android:viewportWidth="32" | ||
android:viewportHeight="32"> | ||
<path | ||
android:pathData="M16.631,9.847L18.779,13.756C18.833,13.854 18.913,13.934 19.011,13.987L22.928,16.119C23.334,16.34 23.335,16.922 22.93,17.144L19.022,19.292C18.924,19.346 18.843,19.427 18.79,19.525L16.658,23.442C16.438,23.847 15.855,23.849 15.633,23.444L13.485,19.535C13.431,19.437 13.351,19.357 13.253,19.304L9.336,17.171C8.93,16.951 8.929,16.369 9.334,16.147L13.242,13.999C13.34,13.945 13.421,13.864 13.474,13.766L15.606,9.849C15.827,9.444 16.409,9.442 16.631,9.847Z"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:centerX="16.542" | ||
android:centerY="16.486" | ||
android:gradientRadius="7.661" | ||
android:type="radial"> | ||
<item android:offset="0" android:color="#FFBAFF28"/> | ||
<item android:offset="1" android:color="#FFFFFF40"/> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
</vector> |