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 @@ -97,12 +97,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 +115,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
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -107,23 +108,23 @@ fun HistoryRegistrationScreen(
val scope = rememberCoroutineScope()
val focusManager = LocalFocusManager.current
val scrollState = rememberScrollState()
var isContinuousState by remember { mutableStateOf(false) }
var historyTypeState by remember { mutableStateOf(HistoryRegistrationType.TAKE) }
var priceText by remember { mutableStateOf("") }
var userNameText by remember { mutableStateOf(name) }
var relationId by remember { mutableLongStateOf(id) }
var selectedYear by remember { mutableIntStateOf(calendarConfig.getCalendarYear()) }
var selectedMonth by remember { mutableIntStateOf(calendarConfig.getCalendarMonth()) }
var selectedDay by remember { mutableIntStateOf(calendarConfig.getCalendarDay()) }
var eventTypeText by remember { mutableStateOf("") }
var selectedEventId by remember { mutableLongStateOf(-1) }
var memoText by remember { mutableStateOf("") }
var isContinuousState by rememberSaveable { mutableStateOf(false) }
var historyTypeState by rememberSaveable { mutableStateOf(HistoryRegistrationType.TAKE) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 enum 이라 bundle 에 못넣어요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HistoryRegistrationType요??
이거 잘 저장되는거 같은데 다른 문제가 있나요

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다시 찾아보니 enum 은 Serializable 이네요
https://developer.android.com/reference/kotlin/java/lang/Enum
문제 없을 것 같습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 LocalDate를 bundle에 넣으려면 년월일 나눠서 array로 저장하는게 최선인가요?

var priceText by rememberSaveable { mutableStateOf("") }
var userNameText by rememberSaveable { mutableStateOf(name) }
var relationId by rememberSaveable { mutableLongStateOf(id) }
var selectedYear by rememberSaveable { mutableIntStateOf(calendarConfig.getCalendarYear()) }
var selectedMonth by rememberSaveable { mutableIntStateOf(calendarConfig.getCalendarMonth()) }
var selectedDay by rememberSaveable { mutableIntStateOf(calendarConfig.getCalendarDay()) }
var eventTypeText by rememberSaveable { mutableStateOf("") }
var selectedEventId by rememberSaveable { mutableLongStateOf(-1) }
var memoText by rememberSaveable { mutableStateOf("") }
val tagIdList = remember { mutableStateListOf<Long>() }

var isCalendarShowingState by remember { mutableStateOf(false) }
var isAddNameShowingState by remember { mutableStateOf(false) }
var isCalendarShowingState by rememberSaveable { mutableStateOf(false) }
var isAddNameShowingState by rememberSaveable { mutableStateOf(false) }

var isViewUnRecordMessage by remember { mutableStateOf("") }
var isViewUnRecordMessage by rememberSaveable { mutableStateOf("") }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

필요한 것만 saveable 하게 만들어주세요


val typePositionState = animateDpAsState(
targetValue = if (historyTypeState == HistoryRegistrationType.TAKE) 0.dp else 106.dp,
Expand Down Expand Up @@ -152,7 +153,7 @@ fun HistoryRegistrationScreen(
tagIdList.clear()
} else {
if (isHome) {
appState.navController.navigate(HomeConstant.ROUTE)
appState.navController.navigate(HomeConstant.ROUTE_STRUCTURE)
} else {
appState.navController.popBackStack()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun HistoryUnrecordedScreen(
}

fun navigateToHome() {
appState.navController.navigate(HomeConstant.ROUTE)
appState.navController.navigate(HomeConstant.ROUTE_STRUCTURE)
}

fun navigateToBack() {
Expand Down
Loading
Loading