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

[Fix] 오류 & 최종 디자인 수정 #134

Merged
merged 14 commits into from
Mar 10, 2024
2 changes: 1 addition & 1 deletion data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
implementation(libs.bundles.logging)
debugImplementation(libs.okhttp3.logging.interceptor)

implementation(libs.bundles.kakao)
implementation(libs.kakao.friend)
}

fun getLocalProperty(propertyKey: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data class GetGroupStatisticsItemRes(
@SerialName("event")
val event: String,
@SerialName("amount")
val amount: Long
val amount: Double
) : DataMapper<GroupStatistics> {
override fun toDomain(): GroupStatistics {
return GroupStatistics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,31 @@ class MockStatisticsRepository @Inject constructor() : StatisticsRepository {
listOf(
GroupStatistics(
event = "결혼",
amount = Random.nextLong(50_000, 200_000)
amount = Random.nextDouble(50_000.0, 200_000.0)
),
GroupStatistics(
event = "생일",
amount = Random.nextLong(50_000, 400_000)
amount = Random.nextDouble(50_000.0, 400_000.0)
),
GroupStatistics(
event = "돌잔치",
amount = Random.nextLong(0, 50_000)
amount = Random.nextDouble(0.0, 50_000.0)
),
GroupStatistics(
event = "출산",
amount = Random.nextLong(0, 50_000)
amount = Random.nextDouble(0.0, 50_000.0)
),
GroupStatistics(
event = "개업",
amount = Random.nextLong(40_000, 300_000)
amount = Random.nextDouble(40_000.0, 300_000.0)
),
GroupStatistics(
event = "랜덤이벤트1",
amount = Random.nextLong(0, 500_000)
amount = Random.nextDouble(0.0, 500_000.0)
),
GroupStatistics(
event = "랜덤이벤트2",
amount = Random.nextLong(50_000, 100_000)
amount = Random.nextDouble(50_000.0, 100_000.0)
),
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package ac.dnd.mour.android.domain.model.feature.statistics

data class GroupStatistics(
val event: String,
val amount: Long
val amount: Double
) {
companion object {
val empty = GroupStatistics(
event = "",
amount = 0
amount = 0.0
)
}
}
2 changes: 2 additions & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ dependencies {
implementation(platform(libs.firebase.bom))
implementation(libs.bundles.logging)

implementation(libs.kakao.user)

debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.test.manifest)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package ac.dnd.mour.android.presentation.common.util

import android.content.Context
import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.common.model.ClientError
import com.kakao.sdk.common.model.ClientErrorCause
import com.kakao.sdk.user.UserApiClient

fun loginWithKakao(
context: Context,
onSuccess: (OAuthToken) -> Unit,
onFailure: (Throwable) -> Unit
) {
loginWithKakaoTalk(
context = context,
onSuccess = onSuccess,
onFailure = { exception ->
if ((exception as? ClientError)?.reason == ClientErrorCause.NotSupported) {
loginWithKakaoAccount(
context = context,
onSuccess = onSuccess,
onFailure = onFailure
)
} else {
onFailure(exception)
}
}
)
}

fun loginWithKakaoTalk(
context: Context,
onSuccess: (OAuthToken) -> Unit,
onFailure: (Throwable) -> Unit
) {
UserApiClient.instance.loginWithKakaoTalk(context) { token, error ->
token?.let { onSuccess(it) }
error?.let { onFailure(it) }
}
}

fun loginWithKakaoAccount(
context: Context,
onSuccess: (OAuthToken) -> Unit,
onFailure: (Throwable) -> Unit
) {
UserApiClient.instance.loginWithKakaoAccount(context) { token, error ->
token?.let { onSuccess(it) }
error?.let { onFailure(it) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fun CalendarComponent(
LaunchedEffect(selectedYear, selectedMonth) {
dayItems.clear()
dayItems.addAll(calendarConfig.getCurrentCalendarDate(selectedYear, selectedMonth))
onDaySelect(calendarConfig.getCalendarDay())
onDaySelect(selectedDay)
}

Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fun ManageSystemUiState(
}.orEmpty()

when (route) {
HomeConstant.ROUTE,
HomeConstant.ROUTE_STRUCTURE,
ScheduleAddConstant.ROUTE -> {
SideEffect {
appState.systemUiController.setStatusBarColor(Gray000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import ac.dnd.mour.android.presentation.ui.main.home.history.historyDestination
import ac.dnd.mour.android.presentation.ui.main.home.mypage.myPageDestination
import ac.dnd.mour.android.presentation.ui.main.home.schedule.scheduleDestination
import ac.dnd.mour.android.presentation.ui.main.home.statistics.statisticsDestination
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand All @@ -27,9 +29,20 @@ fun NavGraphBuilder.homeDestination(
defaultValue = ""
}
)
) {
) { entry ->

val message = entry.savedStateHandle.getStateFlow(
HomeConstant.ROUTE_ARGUMENT_MESSAGE,
initialValue = ""
).collectAsState()

val viewModel: HomeViewModel = hiltViewModel()
if(message.value.isNotEmpty()){
LaunchedEffect(Unit) {
viewModel.viewMessage(message.value)
entry.savedStateHandle.remove<String>(HomeConstant.ROUTE_ARGUMENT_MESSAGE)
}
}

val model: HomeModel = let {
val state by viewModel.state.collectAsStateWithLifecycle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,13 @@ class HomeViewModel @Inject constructor(
savedStateHandle.get<String>(HomeConstant.ROUTE_ARGUMENT_MESSAGE) ?: ""
}

init {
if (message.isNotEmpty()) {
viewMessage(message)
}
}

fun onIntent(intent: HomeIntent) {

}

private fun viewMessage(message: String) {
fun viewMessage(message: String) {
launch {
_event.emit(HomeEvent.ShowSnackBar(message))
}
savedStateHandle.remove<String>(HomeConstant.ROUTE_ARGUMENT_MESSAGE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,20 @@ fun RelationScreen(
)
appState.navController.navigate(route)
} else {
val route = makeRoute(
HomeConstant.ROUTE,
listOf(HomeConstant.ROUTE_ARGUMENT_MESSAGE to "등록이 완료되었습니다.")
appState.navController.previousBackStackEntry?.savedStateHandle?.set(
HomeConstant.ROUTE_ARGUMENT_MESSAGE,
"등록이 완료되었습니다.",
)
appState.navController.navigate(route) {
popUpTo(RelationConstant.ROUTE) {
inclusive = true
}
}
appState.navController.popBackStack()
// val route = makeRoute(
// HomeConstant.ROUTE,
// listOf(HomeConstant.ROUTE_ARGUMENT_MESSAGE to "등록이 완료되었습니다.")
// )
// appState.navController.navigate(route) {
// popUpTo(RelationConstant.ROUTE) {
// inclusive = true
// }
// }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ fun HistoryPageScreen(
handler: CoroutineExceptionHandler,
viewType: HistoryViewType,
searchText: String,
onRecord: () -> Unit
onRecord: () -> Unit,
isExpanded: Boolean
) {
var selectedGroupId by remember { mutableLongStateOf(-1) }
var isDropDownMenuExpanded by remember { mutableStateOf(false) }
Expand All @@ -97,12 +98,6 @@ fun HistoryPageScreen(
)
}.sortedByDescending {
it.relationList.size
}.filter {
if (searchText.isNotEmpty()) {
it.name.contains(searchText)
} else {
true
}
}

val relations = groups.flatMap { it.relationList }
Expand All @@ -121,6 +116,13 @@ fun HistoryPageScreen(
else if (selectedGroupId < 0) false
else it.group.id == selectedGroupId
}
.filter {
if (searchText.isNotEmpty()) {
it.name.contains(searchText)
} else {
true
}
}

fun navigateToHistoryDetail(id: Long) {
val route = makeRoute(
Expand Down Expand Up @@ -217,7 +219,8 @@ fun HistoryPageScreen(
contentAlignment = Alignment.Center
) {
EmptyRelationView(
onRecord = onRecord
onRecord = onRecord,
isExpanded = isExpanded
)
}
} else {
Expand Down Expand Up @@ -373,6 +376,7 @@ private fun GroupChipListComponent(

@Composable
private fun EmptyRelationView(
isExpanded: Boolean,
onRecord: () -> Unit
) {
Column(
Expand All @@ -382,7 +386,7 @@ private fun EmptyRelationView(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Spacer(modifier = Modifier.weight(60f))
Spacer(modifier = Modifier.weight(if (isExpanded) 1f else 60f))
Text(
text = "아직 주고 받은 내역이 없어요.",
style = Body1.merge(
Expand Down Expand Up @@ -427,7 +431,7 @@ private fun EmptyRelationView(
letterSpacing = (-0.25).sp
)
}
Spacer(modifier = Modifier.weight(118f))
Spacer(modifier = Modifier.weight(if (isExpanded) 1f else 118f))
}
}

Expand All @@ -436,7 +440,8 @@ private fun EmptyRelationView(
private fun EmptyRelationViewPreview() {
Box(modifier = Modifier.height(198.dp)) {
EmptyRelationView(
onRecord = {}
onRecord = {},
isExpanded = true
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private fun HistoryScreen(
}
}
}

val searchBoxHeightState = animateDpAsState(
targetValue = when (swipeState.progress.to) {
HistoryViewSwipingType.COLLAPSED -> 0.dp
Expand Down Expand Up @@ -497,7 +498,8 @@ private fun HistoryScreen(
searchText = searchText,
onRecord = {
navigateToAddRelation()
}
},
isExpanded = swipeState.progress.to == HistoryViewSwipingType.EXPANDED
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import ac.dnd.mour.android.presentation.common.theme.Gray000
import ac.dnd.mour.android.presentation.common.theme.Gray100
import ac.dnd.mour.android.presentation.common.theme.Headline0
import ac.dnd.mour.android.presentation.common.theme.Headline3
import ac.dnd.mour.android.presentation.common.util.expansion.measureTextWidth
import ac.dnd.mour.android.presentation.model.history.HistoryDetailGrowthType
import ac.dnd.mour.android.presentation.model.history.HistoryTagType
import androidx.compose.foundation.Image
Expand Down Expand Up @@ -48,6 +47,7 @@ import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.rememberLottieComposition
import kotlinx.datetime.LocalDate
import java.text.DecimalFormat

@Composable
fun HistoryDetailBackgroundComponent(
Expand Down Expand Up @@ -216,7 +216,10 @@ fun HistoryDetailBackgroundComponent(
Row(verticalAlignment = Alignment.CenterVertically) {
val nameLength = model.relationDetail.name.length
Text(
text = if (nameLength < 8) model.relationDetail.name else model.relationDetail.name.substring(0,8),
text = if (nameLength < 8) model.relationDetail.name else model.relationDetail.name.substring(
0,
8
),
fontWeight = FontWeight.SemiBold,
style = Headline0.merge(color = Gray000),
overflow = TextOverflow.Ellipsis,
Expand Down Expand Up @@ -248,7 +251,7 @@ fun HistoryDetailBackgroundComponent(
)
Spacer(modifier = Modifier.width(14.dp))
Text(
text = "${model.relationDetail.takeMoney}원",
text = DecimalFormat("#,###").format(model.relationDetail.takeMoney) + "원",
style = Headline3.merge(
color = Gray000,
fontWeight = FontWeight.SemiBold
Expand All @@ -266,7 +269,7 @@ fun HistoryDetailBackgroundComponent(
)
Spacer(modifier = Modifier.width(14.dp))
Text(
text = "-${model.relationDetail.giveMoney}원",
text = "-" + DecimalFormat("#,###").format(model.relationDetail.giveMoney) + "원",
style = Headline3.merge(
color = Gray000,
fontWeight = FontWeight.SemiBold
Expand Down
Loading
Loading