Skip to content

Commit

Permalink
Merge pull request #304 from Hous-Release/feature/#302-main-rule-repr…
Browse files Browse the repository at this point in the history
…esentation-rule-apply

#302 [Feat] MainRule Screen에 대표 룰 UI 적용
  • Loading branch information
murjune authored Sep 2, 2023
2 parents 7294285 + 2919ce1 commit a0b9101
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import hous.release.android.R
import hous.release.designsystem.component.HousDot
import hous.release.designsystem.component.HousDotType
import hous.release.designsystem.component.HousRuleSlot
import hous.release.designsystem.theme.HousBlue
import hous.release.designsystem.theme.HousG5
Expand Down Expand Up @@ -76,7 +77,7 @@ private fun MainRuleItem(
text = mainRule.name,
isShowTrailingIcon = mainRule.isNew,
leadingIcon = {
HousDot(mainRule.isNew)
HousDot(HousDotType.from(isNew = mainRule.isNew, isRepresent = mainRule.isRepresent))
},
trailingIcon = {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ data class MainRulesResponse(
data class MainRuleResponse(
val id: Int = -1,
val name: String = "",
val isRepresent: Boolean = false,
val createdAt: String = "",
val isNew: Boolean = false
) {
fun toMainRule() = MainRule(
id = id,
name = name,
isRepresent = isRepresent,
createdAt = createdAt.substringBefore('T').replace('-', '.'),
isNew = isNew
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ internal class RuleRepositoryImplTest {
MainRule(
34,
"dd123xd",
true,
"2023.03.16",
true
),
MainRule(
35,
"ㄷ슏슛ㄷ",
true,
"2023.05.05",
false
)
Expand All @@ -52,12 +54,14 @@ internal class RuleRepositoryImplTest {
MainRuleResponse(
34,
"dd123xd",
true,
"2023-03-16T17:19:42.158498",
true
),
MainRuleResponse(
35,
"ㄷ슏슛ㄷ",
true,
"2023-05-05T19:31:34.794815",
false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ internal class RuleServiceTest {
MainRuleResponse(
34,
"dd123xd",
true,
"2023-03-16T17:19:42.158498",
true
),
MainRuleResponse(
35,
"ㄷ슏슛ㄷ",
false,
"2023-05-05T19:31:34.794815",
false
)
Expand Down
2 changes: 2 additions & 0 deletions data/src/test/res/rule/success_main_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
{
"id": 34,
"name": "dd123xd",
"isRepresent": true,
"createdAt": "2023-03-16T17:19:42.158498",
"isNew": true
},
{
"id": 35,
"name": "ㄷ슏슛ㄷ",
"isRepresent": false,
"createdAt": "2023-05-05T19:31:34.794815",
"isNew": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,51 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import hous.release.designsystem.theme.HousBlue
import hous.release.designsystem.theme.HousBlueL1
import hous.release.designsystem.theme.HousG3
import hous.release.designsystem.theme.HousTheme

enum class HousDotType {
NEW,
NORMAL,
REPRESENTATIVE;

companion object {
fun from(isNew: Boolean = false, isRepresent: Boolean = false): HousDotType {
return when {
isNew -> NEW
isRepresent -> REPRESENTATIVE
else -> NORMAL
}
}
}
}

@Composable
fun HousDot(
isNew: Boolean = false
housDotType: HousDotType = HousDotType.NORMAL
) {
Box(
modifier = Modifier
.padding(8.dp)
.size(8.dp)
.clip(CircleShape)
.background(if (isNew) HousBlueL1 else HousG3)
.background(
color = when (housDotType) {
HousDotType.NEW -> HousBlueL1
HousDotType.NORMAL -> HousG3
HousDotType.REPRESENTATIVE -> HousBlue
}
)
)
}

@Preview(name = "newType - hous dash", showBackground = true)
@Composable
private fun HousDashPreview() {
HousTheme {
HousDot(isNew = true)
HousDot(HousDotType.from(isNew = true))
}
}

Expand All @@ -42,3 +65,11 @@ private fun HousDashPreview2() {
HousDot()
}
}

@Preview(name = "representative - hous dash", showBackground = true)
@Composable
private fun HousDashPreview3() {
HousTheme {
HousDot(HousDotType.from(isRepresent = true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun HousEditRulePreview() {
text = "text",
isShowTrailingIcon = false,
leadingIcon = {
HousDot(true)
HousDot()
},
trailingIcon = {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import hous.release.domain.entity.Rule
data class MainRule(
override val id: Int = NO_ID,
override val name: String = NO_NAME,
val isRepresent: Boolean = false,
val createdAt: String = "",
val isNew: Boolean = false
) : Rule(id, name) {
Expand Down

0 comments on commit a0b9101

Please sign in to comment.