Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#306 [feat] 대표 룰 UI #309

Merged
merged 27 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2c981f6
#310 [chore] 기존의 check icon, selector 삭제 후 design system에 생성
murjune Sep 2, 2023
822cfec
#310 [ui(designSystem)] HousCheckBox Component
murjune Sep 2, 2023
edcb936
#310 [Chore] 패키징 및 컴포넌트 분리
murjune Sep 2, 2023
58e5c09
#310 [Delete] DeleteRuleScreen
murjune Sep 2, 2023
7952cc4
#310 [add] 대표 룰 UIModel
murjune Sep 2, 2023
1a2bf64
#310 [chore] lint 추가
murjune Sep 2, 2023
b65be9b
#310 [ui] RepresentRuleList Component
murjune Sep 2, 2023
b888199
#310 [fix] HousCheckBox - Modifier
murjune Sep 2, 2023
e841074
#310 [fix] RepresentRuleList - Modifier 변경
murjune Sep 2, 2023
cc369bb
#310 [add] strings
murjune Sep 2, 2023
58c49cc
#310 [ui] RuleNavGraph, 대표룰 Screen
murjune Sep 2, 2023
b84b3ca
#310 [fix] padding 변경
murjune Sep 2, 2023
eeeb491
Merge branch 'develop' into feature/#310-representation-rule-ui-prese…
murjune Sep 2, 2023
a57c596
#310 [ui] navigate Represent Rule Screen
murjune Sep 2, 2023
01152cc
#310 [Delete] DeleteRuleScreen
murjune Aug 26, 2023
0144b73
#310 [add] 대표 룰 UIModel
murjune Aug 26, 2023
56bfc7d
#310 [chore] lint 추가
murjune Aug 27, 2023
0ed922f
#310 [ui] RepresentRuleList Component
murjune Aug 28, 2023
a63fe75
#310 [fix] HousCheckBox - Modifier
murjune Aug 29, 2023
33e5ed1
#310 [fix] RepresentRuleList - Modifier 변경
murjune Aug 30, 2023
bb43d9d
#310 [add] strings
murjune Aug 31, 2023
031a36c
#310 [ui] RuleNavGraph, 대표룰 Screen
murjune Sep 1, 2023
3d93c1c
#310 [fix] padding 변경
murjune Sep 2, 2023
9b82d8e
Merge branch 'ddddddd' into feature/#310-representation-rule-ui-prese…
murjune Sep 2, 2023
59d3f70
#310 [chore] ktlint
murjune Sep 3, 2023
445f4e0
Merge remote-tracking branch 'origin/develop' into feature/#310-repre…
murjune Sep 5, 2023
b0b3014
#310 [fix] HousCheckBox - isChecked, onCheckedChanged defaultValue 삭제
murjune Sep 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fun MainRuleContent(
onSearch: (String) -> Unit = {},
onOpenDetailRule: (Int) -> Unit = {},
onNavigateToAddRule: () -> Unit = {},
onNavigateToRepresentRule: () -> Unit = {},
onFinish: () -> Unit = {}
) {
val focusManager = LocalFocusManager.current
Expand All @@ -42,7 +43,8 @@ fun MainRuleContent(
.padding(
start = 16.dp,
end = 16.dp
).pointerInput(Unit) {
)
.pointerInput(Unit) {
detectTapGestures(
onTap = {
focusManager.clearFocus()
Expand All @@ -52,7 +54,8 @@ fun MainRuleContent(
horizontalAlignment = Alignment.CenterHorizontally
) {
MainRuleToolbar(
onBack = onFinish
onBack = onFinish,
onNavigateToRepresentRule = onNavigateToRepresentRule
)
Spacer(modifier = Modifier.padding(top = 4.dp))
HousTextField(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -32,7 +28,7 @@ fun MainRuleList(
mainRules: List<Rule> = emptyList()
) {
if (mainRules.isEmpty()) {
MainRuleEmptyContent()
RuleEmptyContent()
murjune marked this conversation as resolved.
Show resolved Hide resolved
} else {
Spacer(modifier = Modifier.height(16.dp))
LazyColumn {
Expand All @@ -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 = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { }
Expand Down Expand Up @@ -62,7 +62,7 @@ fun MainRuleToolbar(
)
}
)
MainRuleDropDownMenu(expanded, onDismiss)
MainRuleDropDownMenu(expanded, onDismiss, onNavigateToRepresentRule)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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(
modifier: Modifier = Modifier,
rules: List<RepresentRuleUiModel> = emptyList(),
onClick: (Int) -> Unit = {}
) {
if (rules.isEmpty()) {
RuleEmptyContent()
}
LazyColumn(modifier = modifier) {
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 = 8.dp, top = 12.dp, bottom = 12.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 = rules, onClick = 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
)
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fun RuleNavGraph(
mainRuleScreen(navController)
addRuleScreen(navController::popBackStack)
updateRuleScreen(navController)
representativeRuleScreen(navController::popBackStack)
}
}

Expand Down Expand Up @@ -101,9 +102,10 @@ 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,
deleteRule = viewModel::deleteRule
)
}
}
Expand Down Expand Up @@ -303,8 +305,12 @@ private fun NavGraphBuilder.addRuleScreen(onBack: () -> Unit) {
}
}

// Navigation
private fun NavGraphBuilder.representativeRuleScreen(onBack: () -> Unit) {
composable(RulesScreens.Represent.route) {
}
}

// Navigation
fun NavController.navigateToAddRule() {
navigate(RulesScreens.Add.route)
}
Expand All @@ -316,3 +322,7 @@ fun NavController.navigateUpdateRule(detailRuleUiModel: DetailRuleUiModel) {
)
navigate(RulesScreens.Update.route)
}

fun NavController.navigateToRepresentRule() {
navigate(RulesScreens.Represent.route)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class DetailRuleUiModel(
val updatedAt: String = ""
) : Parcelable

@Suppress("DataClassPrivateConstructor")
@Parcelize
data class PhotoUiModel private constructor(
val url: String = "",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.runtime.setValue
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

Expand Down
Loading
Loading