From 031a36c31bd69e2974a30aad5fc65ccd3b814037 Mon Sep 17 00:00:00 2001 From: murjune Date: Fri, 1 Sep 2023 11:21:51 +0000 Subject: [PATCH] =?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" }