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 30 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 @@ -20,16 +20,17 @@ import hous.release.designsystem.component.FabScreenSlot
import hous.release.designsystem.component.HousTextField
import hous.release.designsystem.component.HousTextFieldMode
import hous.release.designsystem.theme.HousTheme
import hous.release.domain.entity.rule.MainRule
import hous.release.domain.entity.rule.Rule
import hous.release.feature.todo.R

@Composable
fun MainRuleContent(
mainRules: List<MainRule> = emptyList(),
mainRules: List<Rule> = emptyList(),
searchQuery: String = "",
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 Expand Up @@ -83,10 +86,10 @@ private fun MainRuleScreenPreView2() {
HousTheme {
MainRuleContent(
mainRules = listOf(
MainRule().copy(id = 1, name = "test1", isNew = true),
MainRule().copy(id = 2, name = "test2", isNew = false),
MainRule().copy(id = 3, name = "test3", isNew = true),
MainRule().copy(id = 4, name = "test4", isNew = false)
Rule().copy(id = 1, name = "test1", isNew = true),
Rule().copy(id = 2, name = "test2", isNew = false),
Rule().copy(id = 3, name = "test3", isNew = true),
Rule().copy(id = 4, name = "test4", isNew = false)
)
)
}
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,28 +10,25 @@ 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.MainRule
import hous.release.domain.entity.rule.Rule

@Composable
fun MainRuleList(
onNavigateToDetailRule: (Int) -> Unit = {},
mainRules: List<MainRule> = emptyList()
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,24 +42,10 @@ 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 = {},
mainRule: MainRule = MainRule()
mainRule: Rule = Rule()
) {
val focusManager = LocalFocusManager.current
HousRuleSlot(
Expand Down Expand Up @@ -106,10 +88,10 @@ private fun MainRuleContentPreview() {
HousTheme {
MainRuleList(
mainRules = listOf(
MainRule().copy(id = 1, name = "test1", isNew = true),
MainRule().copy(id = 2, name = "test2", isNew = false),
MainRule().copy(id = 3, name = "test3", isNew = true),
MainRule().copy(id = 4, name = "test4", isNew = false)
Rule().copy(id = 1, name = "test1", isNew = true),
Rule().copy(id = 2, name = "test2", isNew = false),
Rule().copy(id = 3, name = "test3", isNew = true),
Rule().copy(id = 4, name = "test4", isNew = false)
)
)
}
Expand All @@ -131,7 +113,7 @@ private fun NewMainRulePreview() {
HousTheme {
Surface {
MainRuleItem(
mainRule = MainRule().copy(isNew = true)
mainRule = Rule().copy(isNew = true)
)
}
}
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
Loading
Loading