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

Feature/mz 181 ledger filter #85

Merged
merged 15 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
b9e6b02
feat: μž₯λΆ€ ν•„ν„° 이동 μ‹œ Argument와 ν•¨κ»˜ μ΄λ™ν•˜κ²Œ κ΅¬ν˜„
jinukeu Jan 17, 2024
067141b
feat: μž₯λΆ€ ν•„ν„° μΉ΄ν…Œκ³ λ¦¬, λ‚ μ§œ 선택 λ™μž‘ κ΅¬ν˜„
jinukeu Jan 17, 2024
894e787
feat: μž₯λΆ€ λ‚ μ§œ ν•„ν„° 적용
jinukeu Jan 17, 2024
c880dd2
rename: OnBottomReached이 λ™μž‘ν•˜λŠ” μ•„μ΄ν…œμ˜ μ΅œμ†Œ 개수 λ§€κ°œλ³€μˆ˜ 이름 λ³€κ²½
jinukeu Jan 17, 2024
36304d3
fix: μž₯λΆ€ λ‚ μ§œ ν•„ν„°μ—μ„œ μ’…λ£Œ λ‚ μ§œ λ²”μœ„κ°€ μ˜¬λ°”λ₯΄μ§€ μ•ŠλŠ” ν˜„μƒ μˆ˜μ •
jinukeu Jan 17, 2024
75ed3f2
feat: λ°›μ•„μš” ν™”λ©΄μ—μ„œ ν•„ν„° 제거 κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 17, 2024
bc0ad85
fix: collectWithLifecycle ν™•μž₯ ν•¨μˆ˜μ˜ keyκ°€ μ˜¬λ°”λ₯΄κ²Œ μ„€μ •λ˜μ–΄μžˆμ§€ μ•Šλ˜ 문제 ν•΄κ²°
jinukeu Jan 17, 2024
46c83e3
feat: μž₯λΆ€ μ •λ ¬ κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 22, 2024
b1a8733
feat: μž₯λΆ€ μΉ΄ν…Œκ³ λ¦¬ μ •λ ¬ κΈ°λŠ₯ κ΅¬ν˜„
jinukeu Jan 22, 2024
2be2372
fix: ν•„ν„° 쑰건 λ³€κ²½
jinukeu Jan 22, 2024
d88424a
chore: ktlint
jinukeu Jan 22, 2024
a51c671
Merge branch 'develop' into feature/MZ-181-ledger-filter
jinukeu Jan 22, 2024
a6f015f
chore: resolve conflict
jinukeu Jan 22, 2024
ce1a658
chore: resolve conflict
jinukeu Jan 22, 2024
dc14044
feat: LedgerFilterScreen μ˜ˆμ™Έ 핸듀링
jinukeu Jan 23, 2024
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,58 @@
package com.susu.core.designsystem.component.button

import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.R
import com.susu.core.designsystem.theme.Gray10
import com.susu.core.designsystem.theme.SusuTheme

@Composable
fun FilterButton(
isFiltered: Boolean = false,
onClickFilterButton: () -> Unit,
) {
if (isFiltered) {
SusuFilledButton(
color = FilledButtonColor.Black,
style = SmallButtonStyle.height32,
leftIcon = {
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(id = com.susu.core.ui.R.drawable.ic_filter),
contentDescription = stringResource(R.string.content_description_filter_icon),
tint = Gray10,
)
},
onClick = onClickFilterButton,
)
} else {
SusuGhostButton(
color = GhostButtonColor.Black,
style = SmallButtonStyle.height32,
text = stringResource(com.susu.core.ui.R.string.word_filter),
leftIcon = {
Icon(
modifier = Modifier.size(16.dp),
painter = painterResource(id = com.susu.core.ui.R.drawable.ic_filter),
contentDescription = stringResource(R.string.content_description_filter_icon),
)
},
onClick = onClickFilterButton,
)
}
}

@Preview
@Composable
fun FilterButtonPreview() {
SusuTheme {
FilterButton {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fun RefreshButton(
.susuClickable(onClick = onClick)
.padding(SusuTheme.spacing.spacing_xs),
painter = painterResource(id = R.drawable.ic_refresh),
contentDescription = stringResource(R.string.content_description_refresh),
contentDescription = stringResource(com.susu.core.ui.R.string.content_description_refresh),
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.susu.core.designsystem.component.button

import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.susu.core.designsystem.theme.Gray10
import com.susu.core.designsystem.theme.SusuTheme
import com.susu.core.ui.extension.susuClickable

@Composable
fun SelectedFilterButton(
color: FilledButtonColor = FilledButtonColor.Orange,
style: @Composable () -> ButtonStyle = XSmallButtonStyle.height28,
name: String = "",
onClickCloseIcon: () -> Unit = {},
) {
SusuFilledButton(
color = color,
style = style,
text = name,
isClickable = false,
rightIcon = {
Icon(
modifier = Modifier
.clip(CircleShape)
.size(12.dp)
.susuClickable(onClick = onClickCloseIcon),
painter = painterResource(id = com.susu.core.ui.R.drawable.ic_close),
contentDescription = stringResource(id = com.susu.core.ui.R.string.content_description_close_icon),
tint = Gray10,
)
},
)
}

@Preview
@Composable
fun SelectedFilterButtonPreview() {
SusuTheme {
SelectedFilterButton()
}
}
2 changes: 1 addition & 1 deletion core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<string name="content_description_back_icon">λ’€λ‘œκ°€κΈ° μ•„μ΄μ½˜</string>
<string name="content_description_logo_image">둜고 이미지</string>
<string name="content_description_notification_icon">μ•Œλ¦Ό μ•„μ΄μ½˜</string>
<string name="content_description_refresh">μƒˆλ‘œκ³ μΉ¨</string>
<string name="content_description_filter_icon">ν•„ν„° μ•„μ΄μ½˜</string>
</resources>
17 changes: 7 additions & 10 deletions core/ui/src/main/java/com/susu/core/ui/extension/Flow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import kotlinx.coroutines.flow.collect

@Composable
inline fun <reified T> Flow<T>.collectWithLifecycle(
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
noinline action: suspend (T) -> Unit,
) {
LaunchedEffect(key1 = Unit) {
lifecycleOwner.lifecycleScope.launch {
flowWithLifecycle(lifecycleOwner.lifecycle, minActiveState).collect {
action(it)
}
val lifecycleOwner = LocalLifecycleOwner.current

LaunchedEffect(this, lifecycleOwner) {
lifecycleOwner.lifecycle.repeatOnLifecycle(minActiveState) {
[email protected] { action(it) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fun LazyGridState.OnBottomReached(
// tells how many items before we reach the bottom of the list
// to call onLoadMore function
buffer: Int = 0,
minItemsCount: Int = 0,
onLoadMore: () -> Unit,
) {
// Buffer must be positive.
Expand All @@ -23,6 +24,7 @@ fun LazyGridState.OnBottomReached(
val shouldLoadMore = remember {
derivedStateOf {
val lastVisibleItem = layoutInfo.visibleItemsInfo.lastOrNull() ?: return@derivedStateOf false
if (lastVisibleItem.index < minItemsCount) return@derivedStateOf false

lastVisibleItem.index >= layoutInfo.totalItemsCount - 1 - buffer
}
Expand Down
1 change: 1 addition & 0 deletions core/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="word_next">λ‹€μŒ</string>
<string name="word_done">μ™„λ£Œ</string>
<string name="word_apply_filter">ν•„ν„° μ μš©ν•˜κΈ°</string>
<string name="content_description_refresh">μƒˆλ‘œκ³ μΉ¨</string>
<string name="word_input_placeholder">μž…λ ₯ν•΄μ£Όμ„Έμš”</string>
<string name="sns_kakao">μΉ΄μΉ΄μ˜€ν†‘</string>
<string name="sns_naver">넀이버</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class LedgerRepositoryImpl @Inject constructor(
) : LedgerRepository {
override suspend fun getLedgerList(
title: String?,
categoryId: Long?,
categoryIdList: List<Int>?,
fromStartAt: LocalDateTime,
toEndAt: LocalDateTime,
page: Int?,
sort: String?,
): List<Ledger> = ledgerService.getLedgerList(
title = title,
categoryId = categoryId,
categoryIdList = categoryIdList,
fromStartAt = fromStartAt.toKotlinLocalDateTime(),
toEndAt = toEndAt.toKotlinLocalDateTime(),
page = page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface LedgerService {
@GET("ledgers")
suspend fun getLedgerList(
@Query("title") title: String?,
@Query("categoryId") categoryId: Long?,
@Query("categoryIds") categoryIdList: List<Int>?,
@Query("fromStartAt") fromStartAt: LocalDateTime,
@Query("toEndAt") toEndAt: LocalDateTime,
@Query("page") page: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.time.LocalDateTime
interface LedgerRepository {
suspend fun getLedgerList(
title: String?,
categoryId: Long?,
categoryIdList: List<Int>?,
fromStartAt: LocalDateTime,
toEndAt: LocalDateTime,
page: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class GetLedgerListUseCase @Inject constructor(
with(param) {
ledgerRepository.getLedgerList(
title = title,
categoryId = categoryId,
fromStartAt = fromStartAt,
toEndAt = toEndAt,
categoryIdList = categoryIdList,
fromStartAt = fromStartAt ?: LocalDateTime.now().minusYears(10),
toEndAt = toEndAt ?: LocalDateTime.now().plusYears(10),
page = page,
sort = sort,
)
Expand All @@ -23,9 +23,9 @@ class GetLedgerListUseCase @Inject constructor(

data class Param(
val title: String? = null,
val categoryId: Long? = null,
val fromStartAt: LocalDateTime = LocalDateTime.now().minusYears(10),
val toEndAt: LocalDateTime = LocalDateTime.now(),
val categoryIdList: List<Int>? = null,
val fromStartAt: LocalDateTime? = null,
val toEndAt: LocalDateTime? = null,
val page: Int? = null,
val sort: String? = null,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.susu.feature.mypage.navigation.navigateMyPage
import com.susu.feature.mypage.navigation.navigateMyPageInfo
import com.susu.feature.mypage.navigation.navigateMyPageSocial
import com.susu.feature.received.navigation.ReceivedRoute
import com.susu.feature.received.navigation.argument.FilterArgument
import com.susu.feature.received.navigation.navigateLedgerAdd
import com.susu.feature.received.navigation.navigateLedgerDetail
import com.susu.feature.received.navigation.navigateLedgerEdit
Expand Down Expand Up @@ -51,7 +52,7 @@ internal class MainNavigator(
get() = when (currentDestination?.route) {
in listOf(
ReceivedRoute.ledgerSearchRoute,
ReceivedRoute.ledgerFilterRoute,
ReceivedRoute.ledgerFilterRoute("{${ReceivedRoute.FILTER_ARGUMENT_NAME}}"),
ReceivedRoute.envelopeDetailRoute,
ReceivedRoute.envelopeEditRoute,
SentRoute.sentEnvelopeRoute,
Expand Down Expand Up @@ -133,8 +134,8 @@ internal class MainNavigator(
navController.navigateLedgerEdit(ledger)
}

fun navigateLedgerFilter() {
navController.navigateLedgerFilter()
fun navigateLedgerFilter(filter: FilterArgument) {
navController.navigateLedgerFilter(filter)
}

fun navigateLedgerAdd() {
Expand Down
Loading