Skip to content

Commit

Permalink
Merge pull request #277 from droidknights/2024/feature/sponsor
Browse files Browse the repository at this point in the history
[후원사] 2024 후원사 데이터 반영
  • Loading branch information
taehwandev authored Apr 24, 2024
2 parents 7d743e6 + 77e20c5 commit 9d209c6
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 38 deletions.
34 changes: 23 additions & 11 deletions core/data/src/main/assets/sponsors.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
[
{
"name": "당근마켓",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnights2023_App/main/feature/home/src/main/res/drawable/img_sponsor_daangn.png",
"name": "당근",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnightsApp/main/feature/home/src/main/res/drawable/img_sponsor_daangn.png",
"homepage": "https://about.daangn.com/",
"grade": "platinum"
},
{
"name": "현대자동차",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnights2023_App/main/feature/home/src/main/res/drawable/img_sponsor_hyundai.png",
"homepage": "https://talent.hyundai.com/main/main.hc",
"name": "카카오뱅크",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnightsApp/main/feature/home/src/main/res/drawable/img_sponsor_kakaobank.png",
"homepage": "https://recruit.kakaobank.com/",
"grade": "platinum"
},
{
"name": "헤이딜러",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnights2023_App/main/feature/home/src/main/res/drawable/img_sponsor_prnd_company.png",
"homepage": "https://www.prnd.co.kr/",
"name": "젯브레인",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnightsApp/main/feature/home/src/main/res/drawable/img_sponsor_jetbrains.png",
"homepage": "http://www.jetbrains.com/ko-kr/",
"grade": "gold"
},
{
"name": "채널톡",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnights2023_App/main/feature/home/src/main/res/drawable/img_sponsor_channel_talk.png",
"homepage": "https://channel.io/ko",
"name": "점핏",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnightsApp/main/feature/home/src/main/res/drawable/img_sponsor_jumpit.png",
"homepage": "https://www.jumpit.co.kr/?utm_source=jumpit&utm_medium=offline&utm_campaign=droidknights",
"grade": "gold"
},
{
"name": "레진 엔터테인먼트",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnightsApp/main/feature/home/src/main/res/drawable/img_sponsor_lezhin.png",
"homepage": "https://kstd-lezhin.career.greetinghr.com/career",
"grade": "silver"
},
{
"name": "헤이딜러",
"imageUrl": "https://raw.githubusercontent.com/droidknights/DroidKnightsApp/main/feature/home/src/main/res/drawable/img_sponsor_prnd_company.png",
"homepage": "https://www.prnd.co.kr/",
"grade": "silver"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ internal data class SponsorResponse(

@SerialName("gold")
GOLD,

@SerialName("silver")
SILVER,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ internal fun SponsorResponse.toData(): Sponsor = Sponsor(
grade = when (grade) {
SponsorResponse.Grade.PLATINUM -> Sponsor.Grade.PLATINUM
SponsorResponse.Grade.GOLD -> Sponsor.Grade.GOLD
SponsorResponse.Grade.SILVER -> Sponsor.Grade.SILVER
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ internal class DefaultSponsorRepositoryTest : StringSpec() {
)
"역직렬화 테스트" {
val expected = Sponsor(
name = "당근마켓",
imageUrl = "https://raw.githubusercontent.com/droidknights/DroidKnights2023_App/main/feature/home/src/main/res/drawable/img_sponsor_daangn.png",
name = "당근",
imageUrl = "https://raw.githubusercontent.com/droidknights/DroidKnightsApp/main/feature/home/src/main/res/drawable/img_sponsor_daangn.png",
homepage = "https://about.daangn.com/",
grade = Sponsor.Grade.PLATINUM,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ data class Sponsor(
val homepage: String,
val grade: Grade,
) {
enum class Grade(val priority: Int) { PLATINUM(0), GOLD(1), }
enum class Grade(val priority: Int) { PLATINUM(0), GOLD(1), SILVER(2) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SponsorScreenTest {

// then
composeTestRule
.onNodeWithText("플래티넘 1곳, 골드 1곳이\n후원해주셨습니다.")
.onNodeWithText("플래티넘 1곳, 골드 1곳, 실버 1곳이\n후원해주셨습니다.")
.assertExists()
}

Expand All @@ -73,6 +73,12 @@ class SponsorScreenTest {
grade = Sponsor.Grade.PLATINUM,
imageUrl = "https://avatars.githubusercontent.com/u/25101514",
),
Sponsor(
name = "Sponsor3",
homepage = "https://www.instagram.com/droid_knights",
grade = Sponsor.Grade.SILVER,
imageUrl = "https://avatars.githubusercontent.com/u/25101514",
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand Down Expand Up @@ -69,7 +67,8 @@ private fun SponsorCardContents(uiState: SponsorsUiState.Sponsors) {
text = stringResource(
id = R.string.sponsor_card_description,
uiState.platinumCount,
uiState.goldCount
uiState.goldCount,
uiState.silverCount
),
style = KnightsTheme.typography.titleSmallR,
color = DuskGray,
Expand All @@ -85,31 +84,27 @@ private fun SponsorCardContents(uiState: SponsorsUiState.Sponsors) {
private fun SponsorGroup(
sponsors: PersistentList<Sponsor>,
) {
val platinumSponsors = sponsors.filter { it.grade == Sponsor.Grade.PLATINUM }
val goldSponsors = sponsors.filter { it.grade == Sponsor.Grade.GOLD }

val platinumSponsorsState by rememberUpdatedState(platinumSponsors)
val goldSponsorsState by rememberUpdatedState(goldSponsors)

Column(
modifier = Modifier
.fillMaxWidth()
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
SponsorGroupRow(
modifier = Modifier
.wrapContentWidth()
.padding(end = 36.dp),
sponsors = platinumSponsorsState
)

SponsorGroupRow(
modifier = Modifier
.wrapContentWidth()
.padding(start = 36.dp),
sponsors = goldSponsorsState
)
sponsors
.groupBy { it.grade }
.toSortedMap(compareBy { it.priority })
.values
.forEachIndexed { index, groupedSponsorsByGrade ->
SponsorGroupRow(
modifier = Modifier
.wrapContentWidth()
.padding(
start = if (index % 2 == 0) 0.dp else 36.dp,
end = if (index % 2 == 0) 36.dp else 0.dp,
),
sponsors = groupedSponsorsByGrade
)
}
}
}

Expand Down Expand Up @@ -147,6 +142,7 @@ private fun SponsorLogo(
val gradeIcon = when (sponsor.grade) {
Sponsor.Grade.GOLD -> R.drawable.ic_crown_gold
Sponsor.Grade.PLATINUM -> R.drawable.ic_crown_platinum
Sponsor.Grade.SILVER -> R.drawable.ic_crown_silver
}
Box(modifier = Modifier.padding(3.dp)) {
NetworkImage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ sealed interface SponsorsUiState {

val goldCount: Int
get() = sponsors.count { it.grade == Sponsor.Grade.GOLD }

val silverCount: Int
get() = sponsors.count { it.grade == Sponsor.Grade.SILVER }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ internal class SponsorsUiStatePreviewParameterProvider : PreviewParameterProvide
grade = Sponsor.Grade.PLATINUM,
imageUrl = "https://avatars.githubusercontent.com/u/25101514",
),
Sponsor(
name = "Sponsor3",
homepage = "https://www.instagram.com/droid_knights",
grade = Sponsor.Grade.SILVER,
imageUrl = "https://avatars.githubusercontent.com/u/25101514",
),
)
),
)
Expand Down
10 changes: 10 additions & 0 deletions feature/home/src/main/res/drawable/ic_crown_silver.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<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="M28.2,12.121C28.46,12.154 28.704,12.264 28.901,12.436C29.099,12.607 29.242,12.833 29.311,13.085C29.38,13.338 29.373,13.605 29.289,13.853L25.243,26.249C25.202,26.374 25.133,26.488 25.043,26.583C24.952,26.678 24.841,26.751 24.718,26.797C24.595,26.843 24.463,26.861 24.332,26.849C24.201,26.837 24.074,26.796 23.962,26.729C23.937,26.714 21.14,25.103 16.231,25.103C11.322,25.103 8.526,26.714 8.498,26.73C8.385,26.797 8.259,26.837 8.129,26.849C7.998,26.86 7.867,26.842 7.744,26.796C7.621,26.75 7.511,26.677 7.42,26.582C7.33,26.487 7.261,26.373 7.221,26.249L3.174,13.85C3.093,13.602 3.087,13.336 3.157,13.084C3.227,12.833 3.37,12.608 3.567,12.437C3.765,12.267 4.008,12.158 4.267,12.125C4.526,12.093 4.789,12.137 5.022,12.253L10.512,14.988L15.097,7.369C15.215,7.173 15.381,7.011 15.58,6.899C15.778,6.787 16.003,6.728 16.231,6.728C16.459,6.728 16.684,6.787 16.882,6.899C17.081,7.011 17.247,7.173 17.365,7.369L21.95,14.984L27.442,12.25C27.676,12.133 27.94,12.088 28.2,12.121Z"
android:fillColor="#c0c0c0"
android:fillType="evenOdd"/>
</vector>
Binary file not shown.
Binary file modified feature/home/src/main/res/drawable/img_sponsor_daangn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion feature/home/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<string name="session_card_title">자리를 빛내주신 스피커와\n올해 세션을 소개합니다</string>
<string name="session_card_caption">스피커 라인업 &amp; 세션 목록</string>
<string name="sponsor_card_title">이 기업들이 후원해요</string>
<string name="sponsor_card_description">플래티넘 %d곳, 골드 %d곳이\n후원해주셨습니다.</string>
<string name="sponsor_card_description">플래티넘 %d곳, 골드 %d곳, 실버 %d곳이\n후원해주셨습니다.</string>
</resources>

0 comments on commit 9d209c6

Please sign in to comment.