From 2c981f64abd389845056e3892e0d7da3e7735a27 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 15:04:04 +0900 Subject: [PATCH 01/24] =?UTF-8?q?#310=20[chore]=20=EA=B8=B0=EC=A1=B4?= =?UTF-8?q?=EC=9D=98=20check=20icon,=20selector=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=ED=9B=84=20design=20system=EC=97=90=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/drawable/ic_our_rules_delete_unchecked.xml | 11 ----------- .../drawable/selector_our_rules_delete_check_box.xml | 5 ----- .../src/main/res/drawable/ic_check.xml | 3 --- 3 files changed, 19 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_our_rules_delete_unchecked.xml delete mode 100644 app/src/main/res/drawable/selector_our_rules_delete_check_box.xml rename app/src/main/res/drawable/ic_our_rules_delete_checked.xml => designsystem/src/main/res/drawable/ic_check.xml (82%) diff --git a/app/src/main/res/drawable/ic_our_rules_delete_unchecked.xml b/app/src/main/res/drawable/ic_our_rules_delete_unchecked.xml deleted file mode 100644 index 0d8d6c656..000000000 --- a/app/src/main/res/drawable/ic_our_rules_delete_unchecked.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/selector_our_rules_delete_check_box.xml b/app/src/main/res/drawable/selector_our_rules_delete_check_box.xml deleted file mode 100644 index 77f4d2f13..000000000 --- a/app/src/main/res/drawable/selector_our_rules_delete_check_box.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_our_rules_delete_checked.xml b/designsystem/src/main/res/drawable/ic_check.xml similarity index 82% rename from app/src/main/res/drawable/ic_our_rules_delete_checked.xml rename to designsystem/src/main/res/drawable/ic_check.xml index 4d5719c9f..f67e11cd7 100644 --- a/app/src/main/res/drawable/ic_our_rules_delete_checked.xml +++ b/designsystem/src/main/res/drawable/ic_check.xml @@ -3,9 +3,6 @@ android:height="20dp" android:viewportWidth="20" android:viewportHeight="20"> - Date: Sat, 2 Sep 2023 15:04:41 +0900 Subject: [PATCH 02/24] #310 [ui(designSystem)] HousCheckBox Component --- .../designsystem/component/HousCheckBox.kt | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt diff --git a/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt b/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt new file mode 100644 index 000000000..849a8f722 --- /dev/null +++ b/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt @@ -0,0 +1,147 @@ +package hous.release.designsystem.component + +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.Indication +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.Icon +import androidx.compose.material.Surface +import androidx.compose.material.ripple.rememberRipple +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +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.res.painterResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import hous.release.designsystem.R +import hous.release.designsystem.theme.HousBlue +import hous.release.designsystem.theme.HousBlueL1 +import hous.release.designsystem.theme.HousRed +import hous.release.designsystem.theme.HousTheme +import hous.release.designsystem.theme.HousWhite + +@OptIn(ExperimentalMaterialApi::class) +@Composable +fun HousCheckBox( + modifier: Modifier = CheckBoxModifier, + shape: Shape = CircleShape, + backgroundColor: Color = HousBlue, + borderColor: Color = HousBlueL1, + enabled: Boolean = true, + isChecked: Boolean = false, + onCheckedChange: () -> Unit = {}, + interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, + indicator: Indication = rememberRipple(), + content: (@Composable () -> Unit)? = null +) { + val content: @Composable () -> Unit = { + if (content != null) { + content() + } else { + Icon( + painter = painterResource(id = R.drawable.ic_check), + tint = HousWhite, + contentDescription = "", + modifier = modifier.clickable( + interactionSource = interactionSource, + indication = indicator, + enabled = enabled, + role = Role.Checkbox, + onClick = onCheckedChange + ) + ) + } + } + Surface( + enabled = enabled, + onClick = onCheckedChange, + modifier = modifier, + shape = shape, + color = if (isChecked) backgroundColor else HousWhite, + border = if (isChecked) null else BorderStroke(1.dp, borderColor), + interactionSource = interactionSource + ) { + if (isChecked) { + content() + } + } +} + +@Preview("HousCheckBox - Rule UseCase", showBackground = true) +@Composable +private fun PreviewRuleCheckBoxUsecase() { + HousTheme { + var isChecked by remember { mutableStateOf(true) } + val onCheckedChange: () -> Unit = { isChecked = !isChecked } + HousCheckBox( + isChecked = isChecked, + onCheckedChange = onCheckedChange + ) + } +} + +@Preview("HousCheckBox - Rule UseCase2", showBackground = true) +@Composable +private fun PreviewRuleCheckBoxUsecase2() { + HousTheme { + var isChecked by remember { mutableStateOf(true) } + val onCheckedChange: () -> Unit = { isChecked = !isChecked } + HousCheckBox( + modifier = Modifier.size(32.dp).padding(4.dp), + shape = RoundedCornerShape(3.dp), + backgroundColor = HousRed, + borderColor = HousRed, + isChecked = isChecked, + onCheckedChange = onCheckedChange + ) { + Icon( + painter = painterResource(id = R.drawable.ic_check), + tint = HousWhite, + contentDescription = "" + ) + } + } +} + +@Preview("HousCheckBox - Rule UseCase3", showBackground = true) +@Composable +private fun PreviewRuleCheckBoxUsecase3() { + HousTheme { + var isChecked by remember { mutableStateOf(true) } + val onCheckedChange: () -> Unit = { isChecked = !isChecked } + HousCheckBox( + backgroundColor = HousWhite, + borderColor = HousRed, + isChecked = isChecked, + onCheckedChange = onCheckedChange + ) { + Box( + modifier = Modifier + .clip(CircleShape) + .border(1.dp, HousRed, CircleShape) + .padding(2.dp) + .clip(CircleShape) + .background(HousRed) + ) + } + } +} + +private val CheckBoxModifier = Modifier + .size(24.dp) + .padding(2.dp) From edcb936556fdc4d054ebaf38ed0dc9b5f9105c5e Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 15:56:38 +0900 Subject: [PATCH 03/24] =?UTF-8?q?#310=20[Chore]=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=95=20=EB=B0=8F=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/component/RuleEmptyContent.kt | 39 +++++++++++++++++++ .../main/DetailRuleBottomSheetContent.kt | 2 +- .../our_rules/component/main/MainRuleList.kt | 22 +---------- .../{ => update}/BasicUpdateRuleScreen.kt | 3 +- .../component/{ => update}/PhotoGrid.kt | 2 +- .../{ => update}/RuleAddPhotoButton.kt | 2 +- .../{ => update}/RulePhotoStatusBar.kt | 2 +- .../our_rules/screen/AddRuleScreen.kt | 2 +- 8 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/component/RuleEmptyContent.kt rename app/src/main/java/hous/release/android/presentation/our_rules/component/{ => update}/BasicUpdateRuleScreen.kt (97%) rename app/src/main/java/hous/release/android/presentation/our_rules/component/{ => update}/PhotoGrid.kt (98%) rename app/src/main/java/hous/release/android/presentation/our_rules/component/{ => update}/RuleAddPhotoButton.kt (97%) rename app/src/main/java/hous/release/android/presentation/our_rules/component/{ => update}/RulePhotoStatusBar.kt (95%) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/RuleEmptyContent.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/RuleEmptyContent.kt new file mode 100644 index 000000000..5acc2f71b --- /dev/null +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/RuleEmptyContent.kt @@ -0,0 +1,39 @@ +package hous.release.android.presentation.our_rules.component + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import hous.release.android.R +import hous.release.designsystem.theme.HousG5 +import hous.release.designsystem.theme.HousTheme + +@Composable +fun RuleEmptyContent( + modifier: Modifier = Modifier.fillMaxWidth().padding(top = 88.dp) +) { + Column( + modifier = modifier, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text( + text = stringResource(id = R.string.hous_empty_our_rules), + color = HousG5, + style = HousTheme.typography.b2 + ) + } +} + +@Preview("RuleEmptyContent - RuleScreen에 Rule이 없을 떄", showBackground = true) +@Composable +private fun Preview() { + HousTheme { + RuleEmptyContent() + } +} diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/main/DetailRuleBottomSheetContent.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/main/DetailRuleBottomSheetContent.kt index cc2fa6153..a5c2936de 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/main/DetailRuleBottomSheetContent.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/main/DetailRuleBottomSheetContent.kt @@ -10,7 +10,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import hous.release.android.presentation.our_rules.component.PhotoGrid +import hous.release.android.presentation.our_rules.component.update.PhotoGrid import hous.release.android.presentation.our_rules.model.DetailRuleUiModel import hous.release.designsystem.component.HousDetailBottomSheet import hous.release.designsystem.theme.HousBlack diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleList.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleList.kt index 327bd6ad8..bdaa37d59 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleList.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleList.kt @@ -1,7 +1,6 @@ package hous.release.android.presentation.our_rules.component.main import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -11,18 +10,15 @@ import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalFocusManager -import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import hous.release.android.R +import hous.release.android.presentation.our_rules.component.RuleEmptyContent 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 import hous.release.designsystem.theme.HousTheme import hous.release.domain.entity.rule.Rule @@ -32,7 +28,7 @@ fun MainRuleList( mainRules: List = emptyList() ) { if (mainRules.isEmpty()) { - MainRuleEmptyContent() + RuleEmptyContent() } else { Spacer(modifier = Modifier.height(16.dp)) LazyColumn { @@ -46,20 +42,6 @@ fun MainRuleList( } } -@Composable -private fun MainRuleEmptyContent() { - Column( - modifier = Modifier.fillMaxWidth().padding(top = 88.dp), - horizontalAlignment = Alignment.CenterHorizontally - ) { - Text( - text = stringResource(id = R.string.hous_empty_our_rules), - color = HousG5, - style = HousTheme.typography.b2 - ) - } -} - @Composable private fun MainRuleItem( onClick: () -> Unit = {}, diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/BasicUpdateRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/update/BasicUpdateRuleScreen.kt similarity index 97% rename from app/src/main/java/hous/release/android/presentation/our_rules/component/BasicUpdateRuleScreen.kt rename to app/src/main/java/hous/release/android/presentation/our_rules/component/update/BasicUpdateRuleScreen.kt index 5a04d5f73..858c00fc8 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/BasicUpdateRuleScreen.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/update/BasicUpdateRuleScreen.kt @@ -1,4 +1,4 @@ -package hous.release.android.presentation.our_rules.component +package hous.release.android.presentation.our_rules.component.update import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Column @@ -25,6 +25,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import hous.release.android.R +import hous.release.android.presentation.our_rules.component.RuleToolbar import hous.release.android.presentation.our_rules.component.add.RuleTitleGuide import hous.release.android.presentation.our_rules.model.PhotoUiModel import hous.release.designsystem.component.HousTextField diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/PhotoGrid.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/update/PhotoGrid.kt similarity index 98% rename from app/src/main/java/hous/release/android/presentation/our_rules/component/PhotoGrid.kt rename to app/src/main/java/hous/release/android/presentation/our_rules/component/update/PhotoGrid.kt index cea38a891..e8588c412 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/PhotoGrid.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/update/PhotoGrid.kt @@ -1,4 +1,4 @@ -package hous.release.android.presentation.our_rules.component +package hous.release.android.presentation.our_rules.component.update import android.annotation.SuppressLint import android.graphics.Bitmap diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/RuleAddPhotoButton.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/update/RuleAddPhotoButton.kt similarity index 97% rename from app/src/main/java/hous/release/android/presentation/our_rules/component/RuleAddPhotoButton.kt rename to app/src/main/java/hous/release/android/presentation/our_rules/component/update/RuleAddPhotoButton.kt index ee8378138..fb8222e47 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/RuleAddPhotoButton.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/update/RuleAddPhotoButton.kt @@ -1,4 +1,4 @@ -package hous.release.android.presentation.our_rules.component +package hous.release.android.presentation.our_rules.component.update import androidx.compose.foundation.Image import androidx.compose.foundation.background diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/RulePhotoStatusBar.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/update/RulePhotoStatusBar.kt similarity index 95% rename from app/src/main/java/hous/release/android/presentation/our_rules/component/RulePhotoStatusBar.kt rename to app/src/main/java/hous/release/android/presentation/our_rules/component/update/RulePhotoStatusBar.kt index 623978721..a720dfeda 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/RulePhotoStatusBar.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/update/RulePhotoStatusBar.kt @@ -1,4 +1,4 @@ -package hous.release.android.presentation.our_rules.component +package hous.release.android.presentation.our_rules.component.update import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/AddRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/AddRuleScreen.kt index 7d2afc0f8..b94ae03c4 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/AddRuleScreen.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/AddRuleScreen.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import hous.release.android.R -import hous.release.android.presentation.our_rules.component.BasicUpdateRuleScreen +import hous.release.android.presentation.our_rules.component.update.BasicUpdateRuleScreen import hous.release.android.presentation.our_rules.model.PhotoUiModel import hous.release.designsystem.theme.HousTheme From 58e5c09a9a3f3d20238a7bd39a7c09e5714a0a92 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 15:57:30 +0900 Subject: [PATCH 04/24] #310 [Delete] DeleteRuleScreen --- .../our_rules/screen/DeleteRuleScreen.kt | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/screen/DeleteRuleScreen.kt diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/DeleteRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/DeleteRuleScreen.kt deleted file mode 100644 index 9ef7d74c5..000000000 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/DeleteRuleScreen.kt +++ /dev/null @@ -1,26 +0,0 @@ -package hous.release.android.presentation.our_rules.screen - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import hous.release.designsystem.theme.HousTheme - -@Composable -fun DeleteRuleScreen( - ruleId: Int = 0 -) { - Column( - modifier = Modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center - ) { - Text( - text = "Delete Rule $ruleId", - style = HousTheme.typography.h1 - ) - } -} From 7952cc4d27dd934f065822754fff3484ae755df3 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 15:57:48 +0900 Subject: [PATCH 05/24] =?UTF-8?q?#310=20[add]=20=EB=8C=80=ED=91=9C=20?= =?UTF-8?q?=EB=A3=B0=20UIModel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/model/RepresentRuleUiModel.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/model/RepresentRuleUiModel.kt diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/model/RepresentRuleUiModel.kt b/app/src/main/java/hous/release/android/presentation/our_rules/model/RepresentRuleUiModel.kt new file mode 100644 index 000000000..91d293a8b --- /dev/null +++ b/app/src/main/java/hous/release/android/presentation/our_rules/model/RepresentRuleUiModel.kt @@ -0,0 +1,18 @@ +package hous.release.android.presentation.our_rules.model + +import hous.release.domain.entity.rule.Rule + +@Suppress("DataClassPrivateConstructor") +data class RepresentRuleUiModel private constructor( + val id: Int, + val name: String, + val isRepresent: Boolean +) { + companion object { + fun from(rule: Rule) = RepresentRuleUiModel( + rule.id, + rule.name, + rule.isRepresent + ) + } +} From 1a2bf64e2b6f60b93af8f0d6a2cc4cbffe704178 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 15:58:07 +0900 Subject: [PATCH 06/24] =?UTF-8?q?#310=20[chore]=20lint=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/presentation/our_rules/model/DetailRuleUiModel.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/model/DetailRuleUiModel.kt b/app/src/main/java/hous/release/android/presentation/our_rules/model/DetailRuleUiModel.kt index e1f0dc56b..78c0dd983 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/model/DetailRuleUiModel.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/model/DetailRuleUiModel.kt @@ -13,6 +13,7 @@ data class DetailRuleUiModel( val updatedAt: String = "" ) : Parcelable +@Suppress("DataClassPrivateConstructor") @Parcelize data class PhotoUiModel private constructor( val url: String = "", From b65be9b8aae90872aaced2f4e7d93388f160ed38 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 15:58:32 +0900 Subject: [PATCH 07/24] #310 [ui] RepresentRuleList Component --- .../component/represent/RepresentRuleList.kt | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt new file mode 100644 index 000000000..0f5cc07cc --- /dev/null +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt @@ -0,0 +1,121 @@ +package hous.release.android.presentation.our_rules.component.represent + +import androidx.compose.foundation.LocalIndication +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import hous.release.android.presentation.our_rules.component.RuleEmptyContent +import hous.release.android.presentation.our_rules.model.RepresentRuleUiModel +import hous.release.designsystem.component.HousCheckBox +import hous.release.designsystem.component.HousRuleSlot +import hous.release.designsystem.theme.HousTheme +import hous.release.domain.entity.rule.Rule + +@Composable +fun RepresentRuleList( + rules: List = emptyList(), + onClick: (Int) -> Unit = {} +) { + if (rules.isEmpty()) { + RuleEmptyContent() + } + LazyColumn { + itemsIndexed(rules, key = { _, rule -> rule.id }) { _, rule -> + RepresentRuleItem(rule, onClick) + } + } +} + +@Composable +private fun RepresentRuleItem( + rule: RepresentRuleUiModel, + onClick: (Int) -> Unit = {} +) { + val interactionSource = remember { MutableInteractionSource() } + + HousRuleSlot( + modifier = Modifier + .fillMaxWidth() + .clickable( + interactionSource = interactionSource, + onClick = { onClick(rule.id) }, + indication = LocalIndication.current + ) + .padding(start = 16.dp, top = 12.dp, bottom = 12.dp, end = 16.dp), + text = rule.name, + isShowTrailingIcon = true, + leadingIcon = { + HousCheckBox( + interactionSource = interactionSource, + onCheckedChange = { onClick(rule.id) }, + isChecked = rule.isRepresent + ) + }, + trailingIcon = {} + ) +} + +@Preview(name = "RepresentRuleList - General", showBackground = true) +@Composable +private fun Preview1() { + HousTheme { + var rules by remember { + mutableStateOf( + listOf( + Rule( + id = 1, + name = "text1", + isRepresent = true + ), + Rule(id = 2, "text 2") + ).map { RepresentRuleUiModel.from(it) } + ) + } + val onClick: (Int) -> Unit = { id -> + rules = rules.map { + if (it.id == id) { + it.copy(isRepresent = !it.isRepresent) + } else { + it + } + } + } + RepresentRuleList(rules, onClick) + } +} + +@Preview(name = "RepresentRuleList - Empty Rule", showBackground = true) +@Composable +private fun Preview2() { + HousTheme { + RepresentRuleList() + } +} + +@Preview(name = "RepresentRuleItem", showBackground = true) +@Composable +private fun Preview3() { + HousTheme { + var isRepresent by remember { mutableStateOf(false) } + val onClick: (Int) -> Unit = { + isRepresent = !isRepresent + } + RepresentRuleItem( + rule = RepresentRuleUiModel.from( + Rule(isRepresent = isRepresent) + ), + onClick = onClick + ) + } +} From b8881997294043e4406aa148a4bc4500e313a584 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 16:36:55 +0900 Subject: [PATCH 08/24] #310 [fix] HousCheckBox - Modifier --- .../java/hous/release/designsystem/component/HousCheckBox.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt b/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt index 849a8f722..50e048e41 100644 --- a/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt +++ b/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt @@ -57,7 +57,7 @@ fun HousCheckBox( painter = painterResource(id = R.drawable.ic_check), tint = HousWhite, contentDescription = "", - modifier = modifier.clickable( + modifier = Modifier.clickable( interactionSource = interactionSource, indication = indicator, enabled = enabled, From e8410744a657f3b64e61b16b8b8de8df16c5be29 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 16:37:39 +0900 Subject: [PATCH 09/24] =?UTF-8?q?#310=20[fix]=20RepresentRuleList=20-=20Mo?= =?UTF-8?q?difier=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/component/represent/RepresentRuleList.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt index 0f5cc07cc..b9b699b18 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt @@ -24,13 +24,14 @@ import hous.release.domain.entity.rule.Rule @Composable fun RepresentRuleList( + modifier: Modifier = Modifier, rules: List = emptyList(), onClick: (Int) -> Unit = {} ) { if (rules.isEmpty()) { RuleEmptyContent() } - LazyColumn { + LazyColumn(modifier = modifier) { itemsIndexed(rules, key = { _, rule -> rule.id }) { _, rule -> RepresentRuleItem(rule, onClick) } @@ -52,7 +53,7 @@ private fun RepresentRuleItem( onClick = { onClick(rule.id) }, indication = LocalIndication.current ) - .padding(start = 16.dp, top = 12.dp, bottom = 12.dp, end = 16.dp), + .padding(start = 24.dp, top = 12.dp, bottom = 12.dp, end = 16.dp), text = rule.name, isShowTrailingIcon = true, leadingIcon = { @@ -91,7 +92,7 @@ private fun Preview1() { } } } - RepresentRuleList(rules, onClick) + RepresentRuleList(rules = rules, onClick = onClick) } } From cc369bb287a692a763dec702ef0f534e5f50c1fd Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 16:38:04 +0900 Subject: [PATCH 10/24] #310 [add] strings --- app/src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 56c2817ee..73cd5a787 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -112,6 +112,7 @@ 아직 우리 집 Rules가 없어요! Rules 추가 Rules 수정 + 대표 Rules 선택 추가 저장 삭제 From 58c49ccf0799b88eae582628fbc9d35e879fbab8 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 16:38:43 +0900 Subject: [PATCH 11/24] =?UTF-8?q?#310=20[ui]=20RuleNavGraph,=20=EB=8C=80?= =?UTF-8?q?=ED=91=9C=EB=A3=B0=20Screen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/graph/RuleNavGraph.kt | 5 ++ .../our_rules/screen/RepresentRuleScreen.kt | 69 +++++++++++++++++++ .../our_rules/screen/type/RulesScreens.kt | 3 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt b/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt index 638a1e40d..197c175f2 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt @@ -49,6 +49,7 @@ fun RuleNavGraph( mainRuleScreen(navController) addRuleScreen(navController::popBackStack) updateRuleScreen(navController) + representativeRuleScreen(navController::popBackStack) } } @@ -214,6 +215,10 @@ private fun NavGraphBuilder.addRuleScreen(onBack: () -> Unit) { } } +private fun NavGraphBuilder.representativeRuleScreen(onBack: () -> Unit) { + composable(RulesScreens.Represent.route) { + } +} // Navigation fun NavController.navigateToAddRule() { diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt new file mode 100644 index 000000000..7c5acedfc --- /dev/null +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt @@ -0,0 +1,69 @@ +package hous.release.android.presentation.our_rules.screen + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import hous.release.android.R +import hous.release.android.presentation.our_rules.component.RuleToolbar +import hous.release.android.presentation.our_rules.component.represent.RepresentRuleList +import hous.release.android.presentation.our_rules.model.RepresentRuleUiModel +import hous.release.designsystem.theme.HousTheme +import hous.release.domain.entity.rule.Rule + +@Composable +fun RepresentRuleScreen( + rules: List = emptyList(), + isChanged: Boolean = false, + onSave: () -> Unit = {}, + onBack: () -> Unit = {}, + onRuleClick: (Int) -> Unit = {} +) { + Column( + modifier = Modifier.fillMaxSize() + ) { + RuleToolbar( + title = stringResource(id = R.string.our_rule_represent_rule_title), + trailingTitle = stringResource(id = R.string.our_rule_save_new_rule), + isButtonActive = isChanged, + onBack = onBack, + onAddButton = onSave + ) + Spacer(modifier = Modifier.height(20.dp)) + RepresentRuleList( + rules = rules, + onClick = onRuleClick + ) + } +} + +@Preview("대표룰 Screen - General", showBackground = true) +@Composable +private fun Preview1() { + HousTheme { + RepresentRuleScreen( + rules = listOf( + Rule( + id = 1, + name = "text1", + isRepresent = true + ), + Rule(id = 2, "text 2") + ).map { RepresentRuleUiModel.from(it) } + ) + } +} + +@Preview("대표룰 Screen - Empty", showBackground = true) +@Composable +private fun Preview2() { + HousTheme { + RepresentRuleScreen() + } +} diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/type/RulesScreens.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/type/RulesScreens.kt index 0508be949..9b154ebfa 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/type/RulesScreens.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/type/RulesScreens.kt @@ -6,8 +6,9 @@ sealed class RulesScreens(val route: String) { object Update : RulesScreens("update") + object Represent : RulesScreens("represent") + companion object { - private const val DETAIL_RULE_GRAPH_ROUTE = "detail_rules_graph" const val RULE_GRAPH_ROUTE = "rules" const val DETAIL_RULE_KEY = "id" } From b84b3cae44e981c6f05f8cce85aa9d18bcc14422 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 16:42:20 +0900 Subject: [PATCH 12/24] =?UTF-8?q?#310=20[fix]=20padding=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/component/represent/RepresentRuleList.kt | 2 +- .../presentation/our_rules/screen/RepresentRuleScreen.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt index b9b699b18..96fc3bbab 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt @@ -53,7 +53,7 @@ private fun RepresentRuleItem( onClick = { onClick(rule.id) }, indication = LocalIndication.current ) - .padding(start = 24.dp, top = 12.dp, bottom = 12.dp, end = 16.dp), + .padding(start = 8.dp, top = 12.dp, bottom = 12.dp), text = rule.name, isShowTrailingIcon = true, leadingIcon = { diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt index 7c5acedfc..ef47c5d36 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt @@ -37,6 +37,7 @@ fun RepresentRuleScreen( ) Spacer(modifier = Modifier.height(20.dp)) RepresentRuleList( + modifier = Modifier.padding(horizontal = 16.dp), rules = rules, onClick = onRuleClick ) From a57c596498404487952979f7fbcc23c761a85b77 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 17:42:38 +0900 Subject: [PATCH 13/24] #310 [ui] navigate Represent Rule Screen --- .../our_rules/component/main/MainRuleContent.kt | 7 +++++-- .../our_rules/component/main/MainRuleToolbar.kt | 4 ++-- .../android/presentation/our_rules/graph/RuleNavGraph.kt | 6 +++++- .../presentation/our_rules/screen/MainRuleScreen.kt | 2 ++ .../presentation/our_rules/screen/UpdateRuleScreen.kt | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleContent.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleContent.kt index 9103f18c7..f3e78e9b9 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleContent.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleContent.kt @@ -30,6 +30,7 @@ fun MainRuleContent( onSearch: (String) -> Unit = {}, onOpenDetailRule: (Int) -> Unit = {}, onNavigateToAddRule: () -> Unit = {}, + onNavigateToRepresentRule: () -> Unit = {}, onFinish: () -> Unit = {} ) { val focusManager = LocalFocusManager.current @@ -42,7 +43,8 @@ fun MainRuleContent( .padding( start = 16.dp, end = 16.dp - ).pointerInput(Unit) { + ) + .pointerInput(Unit) { detectTapGestures( onTap = { focusManager.clearFocus() @@ -52,7 +54,8 @@ fun MainRuleContent( horizontalAlignment = Alignment.CenterHorizontally ) { MainRuleToolbar( - onBack = onFinish + onBack = onFinish, + onNavigateToRepresentRule = onNavigateToRepresentRule ) Spacer(modifier = Modifier.padding(top = 4.dp)) HousTextField( diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleToolbar.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleToolbar.kt index c4f7d8459..364aa24f1 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleToolbar.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/main/MainRuleToolbar.kt @@ -24,7 +24,7 @@ import hous.release.designsystem.theme.HousTheme @Composable fun MainRuleToolbar( - onClickSetting: () -> Unit = {}, + onNavigateToRepresentRule: () -> Unit = {}, modifier: Modifier = Modifier, title: String = "우리 집 Rules", onBack: () -> Unit = { } @@ -62,7 +62,7 @@ fun MainRuleToolbar( ) } ) - MainRuleDropDownMenu(expanded, onDismiss) + MainRuleDropDownMenu(expanded, onDismiss, onNavigateToRepresentRule) } } diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt b/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt index 2b7426edb..41a598886 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt @@ -102,6 +102,7 @@ private fun NavGraphBuilder.mainRuleScreen( onSearch = viewModel::searchRule, onNavigateToAddRule = viewModel::canAddRule, onNavigateToUpdateRule = navController::navigateUpdateRule, + onNavigateToRepresentRule = navController::navigateToRepresentRule, onFinish = activity::finish, refresh = viewModel::fetchMainRules, deleteRule = viewModel::deleteRule, @@ -309,7 +310,6 @@ private fun NavGraphBuilder.representativeRuleScreen(onBack: () -> Unit) { } } // Navigation - fun NavController.navigateToAddRule() { navigate(RulesScreens.Add.route) } @@ -321,3 +321,7 @@ fun NavController.navigateUpdateRule(detailRuleUiModel: DetailRuleUiModel) { ) navigate(RulesScreens.Update.route) } + +fun NavController.navigateToRepresentRule() { + navigate(RulesScreens.Represent.route) +} \ No newline at end of file diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/MainRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/MainRuleScreen.kt index 2ecf8e611..24dc5a9d4 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/MainRuleScreen.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/MainRuleScreen.kt @@ -38,6 +38,7 @@ fun MainRuleScreen( onSearch: (String) -> Unit = {}, onNavigateToUpdateRule: (DetailRuleUiModel) -> Unit = {}, onNavigateToAddRule: () -> Unit = {}, + onNavigateToRepresentRule: () -> Unit = {}, onFinish: () -> Unit = {}, refresh: () -> Unit = {} ) { @@ -108,6 +109,7 @@ fun MainRuleScreen( } }, onNavigateToAddRule = onNavigateToAddRule, + onNavigateToRepresentRule = onNavigateToRepresentRule, onFinish = onFinish ) } diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/UpdateRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/UpdateRuleScreen.kt index 7fa49b9bd..909c2b549 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/UpdateRuleScreen.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/UpdateRuleScreen.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import hous.release.android.R -import hous.release.android.presentation.our_rules.component.BasicUpdateRuleScreen +import hous.release.android.presentation.our_rules.component.update.BasicUpdateRuleScreen import hous.release.android.presentation.our_rules.model.PhotoUiModel import hous.release.designsystem.theme.HousTheme From 01152cca1f766a028d5cad20c75049b646b114b7 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 26 Aug 2023 10:21:23 +0000 Subject: [PATCH 14/24] #310 [Delete] DeleteRuleScreen --- .../our_rules/screen/DeleteRuleScreen.kt | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/screen/DeleteRuleScreen.kt diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/DeleteRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/DeleteRuleScreen.kt deleted file mode 100644 index 9ef7d74c5..000000000 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/DeleteRuleScreen.kt +++ /dev/null @@ -1,26 +0,0 @@ -package hous.release.android.presentation.our_rules.screen - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import hous.release.designsystem.theme.HousTheme - -@Composable -fun DeleteRuleScreen( - ruleId: Int = 0 -) { - Column( - modifier = Modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center - ) { - Text( - text = "Delete Rule $ruleId", - style = HousTheme.typography.h1 - ) - } -} From 0144b73d37101de239246ae51933a6a078240d5e Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 26 Aug 2023 11:21:51 +0000 Subject: [PATCH 15/24] =?UTF-8?q?#310=20[add]=20=EB=8C=80=ED=91=9C=20?= =?UTF-8?q?=EB=A3=B0=20UIModel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/model/RepresentRuleUiModel.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/model/RepresentRuleUiModel.kt diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/model/RepresentRuleUiModel.kt b/app/src/main/java/hous/release/android/presentation/our_rules/model/RepresentRuleUiModel.kt new file mode 100644 index 000000000..91d293a8b --- /dev/null +++ b/app/src/main/java/hous/release/android/presentation/our_rules/model/RepresentRuleUiModel.kt @@ -0,0 +1,18 @@ +package hous.release.android.presentation.our_rules.model + +import hous.release.domain.entity.rule.Rule + +@Suppress("DataClassPrivateConstructor") +data class RepresentRuleUiModel private constructor( + val id: Int, + val name: String, + val isRepresent: Boolean +) { + companion object { + fun from(rule: Rule) = RepresentRuleUiModel( + rule.id, + rule.name, + rule.isRepresent + ) + } +} From 56bfc7d2d8d520144a19bd076376584af440586a Mon Sep 17 00:00:00 2001 From: murjune Date: Sun, 27 Aug 2023 11:21:23 +0000 Subject: [PATCH 16/24] =?UTF-8?q?#310=20[chore]=20lint=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/presentation/our_rules/model/DetailRuleUiModel.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/model/DetailRuleUiModel.kt b/app/src/main/java/hous/release/android/presentation/our_rules/model/DetailRuleUiModel.kt index e1f0dc56b..78c0dd983 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/model/DetailRuleUiModel.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/model/DetailRuleUiModel.kt @@ -13,6 +13,7 @@ data class DetailRuleUiModel( val updatedAt: String = "" ) : Parcelable +@Suppress("DataClassPrivateConstructor") @Parcelize data class PhotoUiModel private constructor( val url: String = "", From 0ed922f49a10bacb3fee080c53eadf97c5f0e1a5 Mon Sep 17 00:00:00 2001 From: murjune Date: Mon, 28 Aug 2023 11:41:23 +0000 Subject: [PATCH 17/24] #310 [ui] RepresentRuleList Component --- .../component/represent/RepresentRuleList.kt | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt new file mode 100644 index 000000000..0f5cc07cc --- /dev/null +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt @@ -0,0 +1,121 @@ +package hous.release.android.presentation.our_rules.component.represent + +import androidx.compose.foundation.LocalIndication +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import hous.release.android.presentation.our_rules.component.RuleEmptyContent +import hous.release.android.presentation.our_rules.model.RepresentRuleUiModel +import hous.release.designsystem.component.HousCheckBox +import hous.release.designsystem.component.HousRuleSlot +import hous.release.designsystem.theme.HousTheme +import hous.release.domain.entity.rule.Rule + +@Composable +fun RepresentRuleList( + rules: List = emptyList(), + onClick: (Int) -> Unit = {} +) { + if (rules.isEmpty()) { + RuleEmptyContent() + } + LazyColumn { + itemsIndexed(rules, key = { _, rule -> rule.id }) { _, rule -> + RepresentRuleItem(rule, onClick) + } + } +} + +@Composable +private fun RepresentRuleItem( + rule: RepresentRuleUiModel, + onClick: (Int) -> Unit = {} +) { + val interactionSource = remember { MutableInteractionSource() } + + HousRuleSlot( + modifier = Modifier + .fillMaxWidth() + .clickable( + interactionSource = interactionSource, + onClick = { onClick(rule.id) }, + indication = LocalIndication.current + ) + .padding(start = 16.dp, top = 12.dp, bottom = 12.dp, end = 16.dp), + text = rule.name, + isShowTrailingIcon = true, + leadingIcon = { + HousCheckBox( + interactionSource = interactionSource, + onCheckedChange = { onClick(rule.id) }, + isChecked = rule.isRepresent + ) + }, + trailingIcon = {} + ) +} + +@Preview(name = "RepresentRuleList - General", showBackground = true) +@Composable +private fun Preview1() { + HousTheme { + var rules by remember { + mutableStateOf( + listOf( + Rule( + id = 1, + name = "text1", + isRepresent = true + ), + Rule(id = 2, "text 2") + ).map { RepresentRuleUiModel.from(it) } + ) + } + val onClick: (Int) -> Unit = { id -> + rules = rules.map { + if (it.id == id) { + it.copy(isRepresent = !it.isRepresent) + } else { + it + } + } + } + RepresentRuleList(rules, onClick) + } +} + +@Preview(name = "RepresentRuleList - Empty Rule", showBackground = true) +@Composable +private fun Preview2() { + HousTheme { + RepresentRuleList() + } +} + +@Preview(name = "RepresentRuleItem", showBackground = true) +@Composable +private fun Preview3() { + HousTheme { + var isRepresent by remember { mutableStateOf(false) } + val onClick: (Int) -> Unit = { + isRepresent = !isRepresent + } + RepresentRuleItem( + rule = RepresentRuleUiModel.from( + Rule(isRepresent = isRepresent) + ), + onClick = onClick + ) + } +} From a63fe7578f4ded56ae8d7f187126f38ea453feb9 Mon Sep 17 00:00:00 2001 From: murjune Date: Tue, 29 Aug 2023 13:41:23 +0000 Subject: [PATCH 18/24] #310 [fix] HousCheckBox - Modifier --- .../java/hous/release/designsystem/component/HousCheckBox.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt b/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt index 849a8f722..50e048e41 100644 --- a/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt +++ b/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt @@ -57,7 +57,7 @@ fun HousCheckBox( painter = painterResource(id = R.drawable.ic_check), tint = HousWhite, contentDescription = "", - modifier = modifier.clickable( + modifier = Modifier.clickable( interactionSource = interactionSource, indication = indicator, enabled = enabled, From 33e5ed101d365a6650c77b2c182c03194388975a Mon Sep 17 00:00:00 2001 From: murjune Date: Wed, 30 Aug 2023 06:41:23 +0000 Subject: [PATCH 19/24] =?UTF-8?q?#310=20[fix]=20RepresentRuleList=20-=20Mo?= =?UTF-8?q?difier=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/component/represent/RepresentRuleList.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt index 0f5cc07cc..b9b699b18 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt @@ -24,13 +24,14 @@ import hous.release.domain.entity.rule.Rule @Composable fun RepresentRuleList( + modifier: Modifier = Modifier, rules: List = emptyList(), onClick: (Int) -> Unit = {} ) { if (rules.isEmpty()) { RuleEmptyContent() } - LazyColumn { + LazyColumn(modifier = modifier) { itemsIndexed(rules, key = { _, rule -> rule.id }) { _, rule -> RepresentRuleItem(rule, onClick) } @@ -52,7 +53,7 @@ private fun RepresentRuleItem( onClick = { onClick(rule.id) }, indication = LocalIndication.current ) - .padding(start = 16.dp, top = 12.dp, bottom = 12.dp, end = 16.dp), + .padding(start = 24.dp, top = 12.dp, bottom = 12.dp, end = 16.dp), text = rule.name, isShowTrailingIcon = true, leadingIcon = { @@ -91,7 +92,7 @@ private fun Preview1() { } } } - RepresentRuleList(rules, onClick) + RepresentRuleList(rules = rules, onClick = onClick) } } From bb43d9d254bd1c4b193cd7197d86f7942eff0e50 Mon Sep 17 00:00:00 2001 From: murjune Date: Thu, 31 Aug 2023 07:31:11 +0000 Subject: [PATCH 20/24] #310 [add] strings --- app/src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 56c2817ee..73cd5a787 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -112,6 +112,7 @@ 아직 우리 집 Rules가 없어요! Rules 추가 Rules 수정 + 대표 Rules 선택 추가 저장 삭제 From 031a36c31bd69e2974a30aad5fc65ccd3b814037 Mon Sep 17 00:00:00 2001 From: murjune Date: Fri, 1 Sep 2023 11:21:51 +0000 Subject: [PATCH 21/24] =?UTF-8?q?#310=20[ui]=20RuleNavGraph,=20=EB=8C=80?= =?UTF-8?q?=ED=91=9C=EB=A3=B0=20Screen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/graph/RuleNavGraph.kt | 5 ++ .../our_rules/screen/RepresentRuleScreen.kt | 69 +++++++++++++++++++ .../our_rules/screen/type/RulesScreens.kt | 3 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt b/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt index 638a1e40d..197c175f2 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt @@ -49,6 +49,7 @@ fun RuleNavGraph( mainRuleScreen(navController) addRuleScreen(navController::popBackStack) updateRuleScreen(navController) + representativeRuleScreen(navController::popBackStack) } } @@ -214,6 +215,10 @@ private fun NavGraphBuilder.addRuleScreen(onBack: () -> Unit) { } } +private fun NavGraphBuilder.representativeRuleScreen(onBack: () -> Unit) { + composable(RulesScreens.Represent.route) { + } +} // Navigation fun NavController.navigateToAddRule() { diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt new file mode 100644 index 000000000..7c5acedfc --- /dev/null +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt @@ -0,0 +1,69 @@ +package hous.release.android.presentation.our_rules.screen + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import hous.release.android.R +import hous.release.android.presentation.our_rules.component.RuleToolbar +import hous.release.android.presentation.our_rules.component.represent.RepresentRuleList +import hous.release.android.presentation.our_rules.model.RepresentRuleUiModel +import hous.release.designsystem.theme.HousTheme +import hous.release.domain.entity.rule.Rule + +@Composable +fun RepresentRuleScreen( + rules: List = emptyList(), + isChanged: Boolean = false, + onSave: () -> Unit = {}, + onBack: () -> Unit = {}, + onRuleClick: (Int) -> Unit = {} +) { + Column( + modifier = Modifier.fillMaxSize() + ) { + RuleToolbar( + title = stringResource(id = R.string.our_rule_represent_rule_title), + trailingTitle = stringResource(id = R.string.our_rule_save_new_rule), + isButtonActive = isChanged, + onBack = onBack, + onAddButton = onSave + ) + Spacer(modifier = Modifier.height(20.dp)) + RepresentRuleList( + rules = rules, + onClick = onRuleClick + ) + } +} + +@Preview("대표룰 Screen - General", showBackground = true) +@Composable +private fun Preview1() { + HousTheme { + RepresentRuleScreen( + rules = listOf( + Rule( + id = 1, + name = "text1", + isRepresent = true + ), + Rule(id = 2, "text 2") + ).map { RepresentRuleUiModel.from(it) } + ) + } +} + +@Preview("대표룰 Screen - Empty", showBackground = true) +@Composable +private fun Preview2() { + HousTheme { + RepresentRuleScreen() + } +} diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/type/RulesScreens.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/type/RulesScreens.kt index 0508be949..9b154ebfa 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/type/RulesScreens.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/type/RulesScreens.kt @@ -6,8 +6,9 @@ sealed class RulesScreens(val route: String) { object Update : RulesScreens("update") + object Represent : RulesScreens("represent") + companion object { - private const val DETAIL_RULE_GRAPH_ROUTE = "detail_rules_graph" const val RULE_GRAPH_ROUTE = "rules" const val DETAIL_RULE_KEY = "id" } From 3d93c1cfbbf60b82f9e2b2cab253ad32db68ccf9 Mon Sep 17 00:00:00 2001 From: murjune Date: Sat, 2 Sep 2023 16:42:20 +0900 Subject: [PATCH 22/24] =?UTF-8?q?#310=20[fix]=20padding=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../our_rules/component/represent/RepresentRuleList.kt | 2 +- .../presentation/our_rules/screen/RepresentRuleScreen.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt index b9b699b18..96fc3bbab 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/component/represent/RepresentRuleList.kt @@ -53,7 +53,7 @@ private fun RepresentRuleItem( onClick = { onClick(rule.id) }, indication = LocalIndication.current ) - .padding(start = 24.dp, top = 12.dp, bottom = 12.dp, end = 16.dp), + .padding(start = 8.dp, top = 12.dp, bottom = 12.dp), text = rule.name, isShowTrailingIcon = true, leadingIcon = { diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt b/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt index 7c5acedfc..ef47c5d36 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/screen/RepresentRuleScreen.kt @@ -37,6 +37,7 @@ fun RepresentRuleScreen( ) Spacer(modifier = Modifier.height(20.dp)) RepresentRuleList( + modifier = Modifier.padding(horizontal = 16.dp), rules = rules, onClick = onRuleClick ) From 59d3f70b0bf65c2aa983ca13b306e93e252112e7 Mon Sep 17 00:00:00 2001 From: murjune Date: Sun, 3 Sep 2023 17:51:04 +0900 Subject: [PATCH 23/24] #310 [chore] ktlint --- .../android/presentation/our_rules/graph/RuleNavGraph.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt b/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt index 41a598886..0b23cd913 100644 --- a/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt +++ b/app/src/main/java/hous/release/android/presentation/our_rules/graph/RuleNavGraph.kt @@ -105,7 +105,7 @@ private fun NavGraphBuilder.mainRuleScreen( onNavigateToRepresentRule = navController::navigateToRepresentRule, onFinish = activity::finish, refresh = viewModel::fetchMainRules, - deleteRule = viewModel::deleteRule, + deleteRule = viewModel::deleteRule ) } } @@ -309,6 +309,7 @@ private fun NavGraphBuilder.representativeRuleScreen(onBack: () -> Unit) { composable(RulesScreens.Represent.route) { } } + // Navigation fun NavController.navigateToAddRule() { navigate(RulesScreens.Add.route) @@ -324,4 +325,4 @@ fun NavController.navigateUpdateRule(detailRuleUiModel: DetailRuleUiModel) { fun NavController.navigateToRepresentRule() { navigate(RulesScreens.Represent.route) -} \ No newline at end of file +} From b0b3014d8dfdd4c1110e1c7d4258ec548f491a73 Mon Sep 17 00:00:00 2001 From: murjune Date: Wed, 6 Sep 2023 00:24:43 +0900 Subject: [PATCH 24/24] =?UTF-8?q?#310=20[fix]=20HousCheckBox=20-=20isCheck?= =?UTF-8?q?ed,=20onCheckedChanged=20defaultValue=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/hous/release/designsystem/component/HousCheckBox.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt b/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt index 50e048e41..9233af089 100644 --- a/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt +++ b/designsystem/src/main/java/hous/release/designsystem/component/HousCheckBox.kt @@ -39,12 +39,12 @@ import hous.release.designsystem.theme.HousWhite @Composable fun HousCheckBox( modifier: Modifier = CheckBoxModifier, + isChecked: Boolean, + onCheckedChange: () -> Unit, shape: Shape = CircleShape, backgroundColor: Color = HousBlue, borderColor: Color = HousBlueL1, enabled: Boolean = true, - isChecked: Boolean = false, - onCheckedChange: () -> Unit = {}, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, indicator: Indication = rememberRipple(), content: (@Composable () -> Unit)? = null