From 356e5e4815370ba0f828ee3047fc60ed3f20caf8 Mon Sep 17 00:00:00 2001 From: DwEnn Date: Wed, 16 Aug 2023 20:32:03 +0900 Subject: [PATCH 1/7] =?UTF-8?q?navigation=20=EC=9D=B4=EB=A6=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/navigation/TopLevelDestination.kt | 6 +++--- app/src/main/java/com/keyme/app/ui/KeymeApp.kt | 10 +++++----- .../{FeedRoute.kt => DailyKeymeTestRoute.kt} | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) rename presentation/src/main/java/com/keyme/presentation/feed/ui/{FeedRoute.kt => DailyKeymeTestRoute.kt} (76%) diff --git a/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt b/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt index 785c8fe..e21b5a6 100644 --- a/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt +++ b/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt @@ -1,7 +1,7 @@ package com.keyme.app.navigation import androidx.annotation.DrawableRes -import com.keyme.presentation.feed.ui.FeedDestination +import com.keyme.presentation.feed.ui.DailyKeymeTest import com.keyme.presentation.myprofile.ui.MyProfileDestination import com.keyme.presentation.navigation.KeymeNavigationDestination @@ -14,8 +14,8 @@ data class TopLevelDestination( val keymeTopLevelDestinations = listOf( TopLevelDestination( - route = FeedDestination.route, - destination = FeedDestination.destination, + route = DailyKeymeTest.route, + destination = DailyKeymeTest.destination, selectedIconResId = com.keyme.presentation.R.drawable.icon_tab_feed, unselectedIconResId = com.keyme.presentation.R.drawable.icon_tab_feed_unselected, ), diff --git a/app/src/main/java/com/keyme/app/ui/KeymeApp.kt b/app/src/main/java/com/keyme/app/ui/KeymeApp.kt index aefac2f..feb08ef 100644 --- a/app/src/main/java/com/keyme/app/ui/KeymeApp.kt +++ b/app/src/main/java/com/keyme/app/ui/KeymeApp.kt @@ -17,8 +17,8 @@ import com.keyme.app.navigation.keymeTopLevelDestinations import com.keyme.presentation.alarm.ui.AlarmDestination import com.keyme.presentation.alarm.ui.alarmGraph import com.keyme.presentation.designsystem.theme.KeymeTheme -import com.keyme.presentation.feed.ui.FeedDestination -import com.keyme.presentation.feed.ui.feedGraph +import com.keyme.presentation.feed.ui.DailyKeymeTest +import com.keyme.presentation.feed.ui.dailyKeymeTestGraph import com.keyme.presentation.keymetest.KeymeTestDestination import com.keyme.presentation.keymetest.keymeTestGraph import com.keyme.presentation.myprofile.ui.KeymeQuestionResultDestination @@ -51,13 +51,13 @@ fun KeymeApp() { ) { onboardingGraph( navigateToOnboardingTest = { appState.navigate(KeymeTestDestination) }, - navigateToMyDaily = { appState.navigate(FeedDestination) }, + navigateToMyDaily = { appState.navigate(DailyKeymeTest) }, ) keymeTestGraph( onBackClick = appState::onBackClick, - navigateToMyDaily = { appState.navigate(FeedDestination) }, + navigateToMyDaily = { appState.navigate(DailyKeymeTest) }, ) - feedGraph( + dailyKeymeTestGraph( navigateToAlarm = { appState.navigate(AlarmDestination) }, nestedGraphs = { alarmGraph(onBackClick = appState::onBackClick) diff --git a/presentation/src/main/java/com/keyme/presentation/feed/ui/FeedRoute.kt b/presentation/src/main/java/com/keyme/presentation/feed/ui/DailyKeymeTestRoute.kt similarity index 76% rename from presentation/src/main/java/com/keyme/presentation/feed/ui/FeedRoute.kt rename to presentation/src/main/java/com/keyme/presentation/feed/ui/DailyKeymeTestRoute.kt index 6abf46e..149ea87 100644 --- a/presentation/src/main/java/com/keyme/presentation/feed/ui/FeedRoute.kt +++ b/presentation/src/main/java/com/keyme/presentation/feed/ui/DailyKeymeTestRoute.kt @@ -18,28 +18,28 @@ import androidx.navigation.navigation import com.keyme.presentation.R import com.keyme.presentation.navigation.KeymeNavigationDestination -object FeedDestination : KeymeNavigationDestination { - override val route = "feed_route" - override val destination = "feed_destination" +object DailyKeymeTest : KeymeNavigationDestination { + override val route = "daily_keyme_test_route" + override val destination = "daily_keyme_test_destination" } -fun NavGraphBuilder.feedGraph( +fun NavGraphBuilder.dailyKeymeTestGraph( navigateToAlarm: () -> Unit, nestedGraphs: NavGraphBuilder.() -> Unit, ) { navigation( - route = FeedDestination.route, - startDestination = FeedDestination.destination, + route = DailyKeymeTest.route, + startDestination = DailyKeymeTest.destination, ) { - composable(route = FeedDestination.destination) { - FeedRoute(navigateToAlarm = navigateToAlarm) + composable(route = DailyKeymeTest.destination) { + DailyKeymeTestRoute(navigateToAlarm = navigateToAlarm) } nestedGraphs() } } @Composable -fun FeedRoute( +fun DailyKeymeTestRoute( navigateToAlarm: () -> Unit, ) { Row(modifier = Modifier.fillMaxSize()) { From f77f9ad27deb961da234deeafce387029004dcd0 Mon Sep 17 00:00:00 2001 From: DwEnn Date: Wed, 16 Aug 2023 20:33:12 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=EB=AF=B8=EC=82=AC=EC=9A=A9=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../keyme/presentation/feed/MainActivity.kt | 31 ------------------- .../keyme/presentation/feed/MainViewModel.kt | 8 ----- 2 files changed, 39 deletions(-) delete mode 100644 presentation/src/main/java/com/keyme/presentation/feed/MainActivity.kt delete mode 100644 presentation/src/main/java/com/keyme/presentation/feed/MainViewModel.kt diff --git a/presentation/src/main/java/com/keyme/presentation/feed/MainActivity.kt b/presentation/src/main/java/com/keyme/presentation/feed/MainActivity.kt deleted file mode 100644 index 5c3699e..0000000 --- a/presentation/src/main/java/com/keyme/presentation/feed/MainActivity.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.keyme.presentation.feed - -import android.os.Bundle -import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent -import androidx.activity.viewModels -import androidx.compose.foundation.layout.Column -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class MainActivity : ComponentActivity() { - - private val mainViewModel: MainViewModel by viewModels() - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - setContent { Screen(viewModel = mainViewModel) } - } -} - -@Composable -private fun Screen( - viewModel: MainViewModel, -) { - Column { - Text(text = "Sample") - } -} diff --git a/presentation/src/main/java/com/keyme/presentation/feed/MainViewModel.kt b/presentation/src/main/java/com/keyme/presentation/feed/MainViewModel.kt deleted file mode 100644 index a4f9b8d..0000000 --- a/presentation/src/main/java/com/keyme/presentation/feed/MainViewModel.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.keyme.presentation.feed - -import androidx.lifecycle.ViewModel -import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject - -@HiltViewModel -class MainViewModel @Inject constructor() : ViewModel() From 81c4c6054931655316b2481c041907ca7dd573ff Mon Sep 17 00:00:00 2001 From: DwEnn Date: Wed, 16 Aug 2023 20:33:52 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80=EB=AA=85=20?= =?UTF-8?q?=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/keyme/app/navigation/TopLevelDestination.kt | 2 +- app/src/main/java/com/keyme/app/ui/KeymeApp.kt | 4 ++-- .../{feed/ui => dailykeymetest}/DailyKeymeTestRoute.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename presentation/src/main/java/com/keyme/presentation/{feed/ui => dailykeymetest}/DailyKeymeTestRoute.kt (97%) diff --git a/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt b/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt index e21b5a6..1de5367 100644 --- a/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt +++ b/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt @@ -1,7 +1,7 @@ package com.keyme.app.navigation import androidx.annotation.DrawableRes -import com.keyme.presentation.feed.ui.DailyKeymeTest +import com.keyme.presentation.dailykeymetest.DailyKeymeTest import com.keyme.presentation.myprofile.ui.MyProfileDestination import com.keyme.presentation.navigation.KeymeNavigationDestination diff --git a/app/src/main/java/com/keyme/app/ui/KeymeApp.kt b/app/src/main/java/com/keyme/app/ui/KeymeApp.kt index feb08ef..bac0679 100644 --- a/app/src/main/java/com/keyme/app/ui/KeymeApp.kt +++ b/app/src/main/java/com/keyme/app/ui/KeymeApp.kt @@ -17,8 +17,8 @@ import com.keyme.app.navigation.keymeTopLevelDestinations import com.keyme.presentation.alarm.ui.AlarmDestination import com.keyme.presentation.alarm.ui.alarmGraph import com.keyme.presentation.designsystem.theme.KeymeTheme -import com.keyme.presentation.feed.ui.DailyKeymeTest -import com.keyme.presentation.feed.ui.dailyKeymeTestGraph +import com.keyme.presentation.dailykeymetest.DailyKeymeTest +import com.keyme.presentation.dailykeymetest.dailyKeymeTestGraph import com.keyme.presentation.keymetest.KeymeTestDestination import com.keyme.presentation.keymetest.keymeTestGraph import com.keyme.presentation.myprofile.ui.KeymeQuestionResultDestination diff --git a/presentation/src/main/java/com/keyme/presentation/feed/ui/DailyKeymeTestRoute.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt similarity index 97% rename from presentation/src/main/java/com/keyme/presentation/feed/ui/DailyKeymeTestRoute.kt rename to presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt index 149ea87..c944963 100644 --- a/presentation/src/main/java/com/keyme/presentation/feed/ui/DailyKeymeTestRoute.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt @@ -1,4 +1,4 @@ -package com.keyme.presentation.feed.ui +package com.keyme.presentation.dailykeymetest import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box From 0e023ba3ec5f9fa40f61ffb6e0c9de95e2a38bae Mon Sep 17 00:00:00 2001 From: DwEnn Date: Wed, 16 Aug 2023 23:22:43 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=EB=8D=B0=EC=9D=BC=EB=A6=AC=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20ui,=20animation=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/navigation/TopLevelDestination.kt | 6 +- .../main/java/com/keyme/app/ui/KeymeApp.kt | 6 +- .../java/com/keyme/app/ui/KeymeAppState.kt | 3 +- .../dailykeymetest/DailyKeymeTestRoute.kt | 31 ++- .../dailykeymetest/DailyKeymeTestScreen.kt | 209 ++++++++++++++++++ 5 files changed, 232 insertions(+), 23 deletions(-) create mode 100644 presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt diff --git a/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt b/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt index 1de5367..11596ca 100644 --- a/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt +++ b/app/src/main/java/com/keyme/app/navigation/TopLevelDestination.kt @@ -1,7 +1,7 @@ package com.keyme.app.navigation import androidx.annotation.DrawableRes -import com.keyme.presentation.dailykeymetest.DailyKeymeTest +import com.keyme.presentation.dailykeymetest.DailyKeymeTestDestination import com.keyme.presentation.myprofile.ui.MyProfileDestination import com.keyme.presentation.navigation.KeymeNavigationDestination @@ -14,8 +14,8 @@ data class TopLevelDestination( val keymeTopLevelDestinations = listOf( TopLevelDestination( - route = DailyKeymeTest.route, - destination = DailyKeymeTest.destination, + route = DailyKeymeTestDestination.route, + destination = DailyKeymeTestDestination.destination, selectedIconResId = com.keyme.presentation.R.drawable.icon_tab_feed, unselectedIconResId = com.keyme.presentation.R.drawable.icon_tab_feed_unselected, ), diff --git a/app/src/main/java/com/keyme/app/ui/KeymeApp.kt b/app/src/main/java/com/keyme/app/ui/KeymeApp.kt index bac0679..46adbe6 100644 --- a/app/src/main/java/com/keyme/app/ui/KeymeApp.kt +++ b/app/src/main/java/com/keyme/app/ui/KeymeApp.kt @@ -17,7 +17,7 @@ import com.keyme.app.navigation.keymeTopLevelDestinations import com.keyme.presentation.alarm.ui.AlarmDestination import com.keyme.presentation.alarm.ui.alarmGraph import com.keyme.presentation.designsystem.theme.KeymeTheme -import com.keyme.presentation.dailykeymetest.DailyKeymeTest +import com.keyme.presentation.dailykeymetest.DailyKeymeTestDestination import com.keyme.presentation.dailykeymetest.dailyKeymeTestGraph import com.keyme.presentation.keymetest.KeymeTestDestination import com.keyme.presentation.keymetest.keymeTestGraph @@ -51,11 +51,11 @@ fun KeymeApp() { ) { onboardingGraph( navigateToOnboardingTest = { appState.navigate(KeymeTestDestination) }, - navigateToMyDaily = { appState.navigate(DailyKeymeTest) }, + navigateToMyDaily = { appState.navigate(DailyKeymeTestDestination) }, ) keymeTestGraph( onBackClick = appState::onBackClick, - navigateToMyDaily = { appState.navigate(DailyKeymeTest) }, + navigateToMyDaily = { appState.navigate(DailyKeymeTestDestination) }, ) dailyKeymeTestGraph( navigateToAlarm = { appState.navigate(AlarmDestination) }, diff --git a/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt b/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt index 99a76b3..26c6727 100644 --- a/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt +++ b/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt @@ -14,6 +14,7 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import com.keyme.app.navigation.TopLevelDestination +import com.keyme.presentation.dailykeymetest.DailyKeymeTestDestination import com.keyme.presentation.navigation.KeymeNavigationDestination import com.keyme.presentation.onboarding.OnboardingDestination import com.keyme.presentation.onboarding.OnboardingStepsEnum @@ -42,7 +43,7 @@ class KeymeAppState( val currentDestination: NavDestination? @Composable get() = navController.currentBackStackEntryAsState().value?.destination - val startDestination = OnboardingDestination + val startDestination = DailyKeymeTestDestination var isOnBoarding by mutableStateOf(false) diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt index c944963..292f8ee 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt @@ -15,10 +15,11 @@ import androidx.compose.ui.unit.dp import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable import androidx.navigation.navigation +import com.keyme.domain.entity.member.Member import com.keyme.presentation.R import com.keyme.presentation.navigation.KeymeNavigationDestination -object DailyKeymeTest : KeymeNavigationDestination { +object DailyKeymeTestDestination : KeymeNavigationDestination { override val route = "daily_keyme_test_route" override val destination = "daily_keyme_test_destination" } @@ -28,10 +29,10 @@ fun NavGraphBuilder.dailyKeymeTestGraph( nestedGraphs: NavGraphBuilder.() -> Unit, ) { navigation( - route = DailyKeymeTest.route, - startDestination = DailyKeymeTest.destination, + route = DailyKeymeTestDestination.route, + startDestination = DailyKeymeTestDestination.destination, ) { - composable(route = DailyKeymeTest.destination) { + composable(route = DailyKeymeTestDestination.destination) { DailyKeymeTestRoute(navigateToAlarm = navigateToAlarm) } nestedGraphs() @@ -42,16 +43,14 @@ fun NavGraphBuilder.dailyKeymeTestGraph( fun DailyKeymeTestRoute( navigateToAlarm: () -> Unit, ) { - Row(modifier = Modifier.fillMaxSize()) { - Box(modifier = Modifier.fillMaxWidth()) { - Icon( - modifier = Modifier - .align(Alignment.CenterEnd) - .padding(16.dp) - .clickable { navigateToAlarm() }, - painter = painterResource(id = R.drawable.icon_noti), - contentDescription = "", - ) - } - } + + DailyKeymeTestScreen( + myCharacter = Member( + friendCode = "", + id = 0, + nickname = "", + profileImage = "", + profileThumbnail = "", + ), + ) } diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt new file mode 100644 index 0000000..2dda2d6 --- /dev/null +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt @@ -0,0 +1,209 @@ +package com.keyme.presentation.dailykeymetest + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.core.animateDpAsState +import androidx.compose.animation.core.spring +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.slideIn +import androidx.compose.animation.slideOut +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshotFlow +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.dp +import androidx.compose.ui.zIndex +import coil.compose.AsyncImage +import coil.request.ImageRequest +import com.keyme.domain.entity.member.Member +import com.keyme.domain.entity.response.Category +import com.keyme.presentation.designsystem.component.KeymeText +import com.keyme.presentation.designsystem.component.KeymeTextType +import com.keyme.presentation.designsystem.theme.keyme_black +import com.keyme.presentation.utils.ColorUtil +import com.keyme.presentation.utils.clickableRippleEffect +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.launch + +@Composable +fun DailyKeymeTestScreen( + myCharacter: Member, +) { + Box(modifier = Modifier.fillMaxSize()) { + WelComeTextTitle(modifier = Modifier.zIndex(1f), myCharacter = myCharacter) + + DailyKeymeTestCircle( + modifier = Modifier + .align(Alignment.Center) + .clickableRippleEffect(bounded = false) { + + }, + categories = categories, + ) + } +} + +@Composable +private fun WelComeTextTitle(modifier: Modifier = Modifier, myCharacter: Member) { + KeymeText( + modifier = modifier + .padding(vertical = 75.dp, horizontal = 16.dp) + .fillMaxWidth(), + text = "환영해요 ${myCharacter.nickname}님! 이제 문제를 풀어볼까요?", + keymeTextType = KeymeTextType.HEADING_1, + color = Color(0xFFF8F8F8), + ) +} + +val categories = listOf( + Category( + color = "FFB2F5", + iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", + name = "", + ), + Category( + color = "E5D85C", + iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", + name = "", + ), + Category( + color = "993800", + iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", + name = "", + ), + Category( + color = "6B66FF", + iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", + name = "", + ), +) + +@Composable +private fun DailyKeymeTestCircle(modifier: Modifier = Modifier, categories: List) { + var expand by remember { mutableStateOf(false) } + + var selectedIndex = 0 + var selectedCategory by remember { mutableStateOf(categories[selectedIndex++]) } + + LaunchedEffect(key1 = selectedCategory) { + expand = true + delay(800L) + expand = false + } + + val coroutineScope = rememberCoroutineScope() + LaunchedEffect(key1 = Unit) { + snapshotFlow { expand } + .filter { !it } + .collectLatest { isAnimEnd -> + coroutineScope.launch { + delay(800L) + selectedIndex = if (selectedIndex > categories.lastIndex) 0 else selectedIndex + selectedCategory = categories[selectedIndex++] + } + } + } + + DailyKeymeTestCircleImpl(modifier, expand = expand, category = selectedCategory) +} + +private val initialSize = 0.dp +private val expandedSize = 90.dp + +@Composable +private fun DailyKeymeTestCircleImpl( + modifier: Modifier = Modifier, + expand: Boolean, + category: Category, +) { + val size by animateDpAsState( + targetValue = if (expand) expandedSize else initialSize, + animationSpec = spring( + stiffness = 100f, + ), + label = "", + ) + + Box( + modifier = modifier + .fillMaxWidth() + .padding(90.dp - size / 2) + .aspectRatio(1f) + .border(width = 1.dp, color = Color(0x4DFFFFFF), shape = CircleShape) + .clip(CircleShape) + .padding(1.dp) + .background(color = Color(0x26FFFFFF), shape = CircleShape) + .onGloballyPositioned { + it.size + }, + contentAlignment = Alignment.Center, + ) { + Box( + modifier = Modifier + .background(color = ColorUtil.hexStringToColor(category.color), shape = CircleShape) + .size(size), + ) + + AnimatedVisibility( + visible = expand, + enter = slideIn( + animationSpec = spring( + stiffness = 100f, + ), + initialOffset = { IntOffset(200, 200) }, + ) + fadeIn(), + exit = slideOut( + animationSpec = spring( + stiffness = 100f, + ), + targetOffset = { IntOffset(200, 200) }, + ) + fadeOut(), + ) { + AsyncImage( + modifier = Modifier.size(24.dp), + model = ImageRequest.Builder(LocalContext.current) + .data(category.iconUrl) + .build(), + contentDescription = "", + contentScale = ContentScale.Crop, + ) + } + } +} + +@Preview +@Composable +fun DailyKeymeTestCirclePreview() { + Box( + modifier = Modifier + .fillMaxSize() + .background(color = keyme_black), + contentAlignment = Alignment.Center, + ) { + DailyKeymeTestCircle(categories = categories) + } +} From f8f3623f2c5422130bf3dbdab6f691bf5fd9eeed Mon Sep 17 00:00:00 2001 From: DwEnn Date: Wed, 16 Aug 2023 23:48:54 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=EB=8D=B0=EC=9D=BC=EB=A6=AC=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=92=80=EC=9D=B4=20=ED=99=94=EB=A9=B4=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/keyme/data/remote/api/KeymeApi.kt | 8 ++ .../keyme/data/remote/di/RepositoryModule.kt | 5 ++ .../repositoryimpl/KeymeTestRepositoryImpl.kt | 19 +++++ .../com/keyme/domain/entity/member/Member.kt | 10 +-- .../entity/response/DailyTestResponse.kt | 5 ++ .../entity/response/OnBoardingTestResponse.kt | 5 ++ .../com/keyme/domain/entity/response/Test.kt | 26 +++++++ .../domain/repository/KeymeTestRepository.kt | 11 +++ .../usecase/GetDailyKeymeTestUseCase.kt | 11 +++ .../dailykeymetest/DailyKeymeTestRoute.kt | 21 +++--- .../dailykeymetest/DailyKeymeTestScreen.kt | 74 ++++++++++--------- .../dailykeymetest/DailyKeymeTestViewModel.kt | 37 ++++++++++ .../com/keyme/presentation/utils/ColorUtil.kt | 2 - 13 files changed, 185 insertions(+), 49 deletions(-) create mode 100644 data/src/main/java/com/keyme/data/remote/repositoryimpl/KeymeTestRepositoryImpl.kt create mode 100644 domain/src/main/java/com/keyme/domain/entity/response/DailyTestResponse.kt create mode 100644 domain/src/main/java/com/keyme/domain/entity/response/OnBoardingTestResponse.kt create mode 100644 domain/src/main/java/com/keyme/domain/entity/response/Test.kt create mode 100644 domain/src/main/java/com/keyme/domain/repository/KeymeTestRepository.kt create mode 100644 domain/src/main/java/com/keyme/domain/usecase/GetDailyKeymeTestUseCase.kt create mode 100644 presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt diff --git a/data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt b/data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt index 382f3a2..77147e2 100644 --- a/data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt +++ b/data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt @@ -1,8 +1,10 @@ package com.keyme.data.remote.api import com.keyme.domain.entity.request.SignInRequest +import com.keyme.domain.entity.response.DailyTestResponse import com.keyme.domain.entity.response.MemberStatistics import com.keyme.domain.entity.response.MemberStatisticsResponse +import com.keyme.domain.entity.response.OnBoardingTestResponse import com.keyme.domain.entity.response.QuestionSolvedScoreListResponse import com.keyme.domain.entity.response.QuestionSolvedScoreResponse import com.keyme.domain.entity.response.QuestionStatisticsResponse @@ -50,4 +52,10 @@ interface KeymeApi { @Query("limit") limit: Int = 20, @Query("ownerId") ownerId: Int, ): QuestionSolvedScoreListResponse + + @GET("tests/onboarding") + suspend fun getOnBoardingTest(): OnBoardingTestResponse + + @GET("tests/daily") + suspend fun getDailyTest(): DailyTestResponse } diff --git a/data/src/main/java/com/keyme/data/remote/di/RepositoryModule.kt b/data/src/main/java/com/keyme/data/remote/di/RepositoryModule.kt index 8649ec5..d08432f 100644 --- a/data/src/main/java/com/keyme/data/remote/di/RepositoryModule.kt +++ b/data/src/main/java/com/keyme/data/remote/di/RepositoryModule.kt @@ -1,8 +1,10 @@ package com.keyme.data.remote.di +import com.keyme.data.remote.repositoryimpl.KeymeTestRepositoryImpl import com.keyme.data.remote.repositoryimpl.MemberRepositoryImpl import com.keyme.data.remote.repositoryimpl.QuestionRepositoryImpl import com.keyme.data.remote.repositoryimpl.SignInRepositoryImpl +import com.keyme.domain.repository.KeymeTestRepository import com.keyme.domain.repository.MemberRepository import com.keyme.domain.repository.QuestionRepository import com.keyme.domain.repository.SignInRepository @@ -23,4 +25,7 @@ abstract class RepositoryModule { @Binds abstract fun bindQuestionRepository(impl: QuestionRepositoryImpl): QuestionRepository + + @Binds + abstract fun bindKeymeTestRepository(impl: KeymeTestRepositoryImpl): KeymeTestRepository } diff --git a/data/src/main/java/com/keyme/data/remote/repositoryimpl/KeymeTestRepositoryImpl.kt b/data/src/main/java/com/keyme/data/remote/repositoryimpl/KeymeTestRepositoryImpl.kt new file mode 100644 index 0000000..b19135e --- /dev/null +++ b/data/src/main/java/com/keyme/data/remote/repositoryimpl/KeymeTestRepositoryImpl.kt @@ -0,0 +1,19 @@ +package com.keyme.data.remote.repositoryimpl + +import com.keyme.data.remote.api.KeymeApi +import com.keyme.domain.entity.response.DailyTestResponse +import com.keyme.domain.entity.response.OnBoardingTestResponse +import com.keyme.domain.repository.KeymeTestRepository +import javax.inject.Inject + +class KeymeTestRepositoryImpl @Inject constructor( + private val keymeApi: KeymeApi, +) : KeymeTestRepository { + override suspend fun getOnBoardingTest(): OnBoardingTestResponse { + return keymeApi.getOnBoardingTest() + } + + override suspend fun getDailyTest(): DailyTestResponse { + return keymeApi.getDailyTest() + } +} diff --git a/domain/src/main/java/com/keyme/domain/entity/member/Member.kt b/domain/src/main/java/com/keyme/domain/entity/member/Member.kt index 573cb82..b273eda 100644 --- a/domain/src/main/java/com/keyme/domain/entity/member/Member.kt +++ b/domain/src/main/java/com/keyme/domain/entity/member/Member.kt @@ -1,11 +1,11 @@ package com.keyme.domain.entity.member data class Member( - val friendCode: String, - val id: Int, - val nickname: String, - val profileImage: String, - val profileThumbnail: String, + val friendCode: String = "", + val id: Int = 0, + val nickname: String = "", + val profileImage: String = "", + val profileThumbnail: String = "", ) { companion object { val EMPTY = Member(friendCode = "", id = 0, nickname = "", profileImage = "", profileThumbnail = "") diff --git a/domain/src/main/java/com/keyme/domain/entity/response/DailyTestResponse.kt b/domain/src/main/java/com/keyme/domain/entity/response/DailyTestResponse.kt new file mode 100644 index 0000000..9535232 --- /dev/null +++ b/domain/src/main/java/com/keyme/domain/entity/response/DailyTestResponse.kt @@ -0,0 +1,5 @@ +package com.keyme.domain.entity.response + +import com.keyme.domain.entity.BaseResponse + +class DailyTestResponse: BaseResponse() diff --git a/domain/src/main/java/com/keyme/domain/entity/response/OnBoardingTestResponse.kt b/domain/src/main/java/com/keyme/domain/entity/response/OnBoardingTestResponse.kt new file mode 100644 index 0000000..b1d4468 --- /dev/null +++ b/domain/src/main/java/com/keyme/domain/entity/response/OnBoardingTestResponse.kt @@ -0,0 +1,5 @@ +package com.keyme.domain.entity.response + +import com.keyme.domain.entity.BaseResponse + +class OnBoardingTestResponse : BaseResponse() diff --git a/domain/src/main/java/com/keyme/domain/entity/response/Test.kt b/domain/src/main/java/com/keyme/domain/entity/response/Test.kt new file mode 100644 index 0000000..298ae8c --- /dev/null +++ b/domain/src/main/java/com/keyme/domain/entity/response/Test.kt @@ -0,0 +1,26 @@ +package com.keyme.domain.entity.response + +import com.keyme.domain.entity.member.Member + +data class Test( + val questions: List, + val owner: Member, + val solvedCount: Int, + val testId: Int, + val testResultId: Int, + val title: String, +) { + companion object { + val EMPTY = Test( + questions = listOf(), + owner = Member( + friendCode = "", + id = 0, + nickname = "", + profileImage = "", + profileThumbnail = "", + ), + solvedCount = 0, testId = 0, testResultId = 0, title = "", + ) + } +} diff --git a/domain/src/main/java/com/keyme/domain/repository/KeymeTestRepository.kt b/domain/src/main/java/com/keyme/domain/repository/KeymeTestRepository.kt new file mode 100644 index 0000000..f0fad81 --- /dev/null +++ b/domain/src/main/java/com/keyme/domain/repository/KeymeTestRepository.kt @@ -0,0 +1,11 @@ +package com.keyme.domain.repository + +import com.keyme.domain.entity.response.DailyTestResponse +import com.keyme.domain.entity.response.OnBoardingTestResponse + +interface KeymeTestRepository { + + suspend fun getOnBoardingTest(): OnBoardingTestResponse + + suspend fun getDailyTest(): DailyTestResponse +} diff --git a/domain/src/main/java/com/keyme/domain/usecase/GetDailyKeymeTestUseCase.kt b/domain/src/main/java/com/keyme/domain/usecase/GetDailyKeymeTestUseCase.kt new file mode 100644 index 0000000..cf1b323 --- /dev/null +++ b/domain/src/main/java/com/keyme/domain/usecase/GetDailyKeymeTestUseCase.kt @@ -0,0 +1,11 @@ +package com.keyme.domain.usecase + +import com.keyme.domain.entity.apiResult +import com.keyme.domain.repository.KeymeTestRepository +import javax.inject.Inject + +class GetDailyKeymeTestUseCase @Inject constructor( + private val keymeTestRepository: KeymeTestRepository, +) { + suspend operator fun invoke() = apiResult { keymeTestRepository.getDailyTest() } +} diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt index 292f8ee..75cf8b2 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt @@ -8,10 +8,13 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.Icon import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable import androidx.navigation.navigation @@ -33,7 +36,7 @@ fun NavGraphBuilder.dailyKeymeTestGraph( startDestination = DailyKeymeTestDestination.destination, ) { composable(route = DailyKeymeTestDestination.destination) { - DailyKeymeTestRoute(navigateToAlarm = navigateToAlarm) + DailyKeymeTestRoute() } nestedGraphs() } @@ -41,16 +44,16 @@ fun NavGraphBuilder.dailyKeymeTestGraph( @Composable fun DailyKeymeTestRoute( - navigateToAlarm: () -> Unit, + dailyKeymeTestViewModel: DailyKeymeTestViewModel = hiltViewModel(), ) { + val myCharacter by dailyKeymeTestViewModel.myCharacterState.collectAsStateWithLifecycle() + val dailyKeymeTest by dailyKeymeTestViewModel.dailyKeymeTestState.collectAsStateWithLifecycle() DailyKeymeTestScreen( - myCharacter = Member( - friendCode = "", - id = 0, - nickname = "", - profileImage = "", - profileThumbnail = "", - ), + myCharacter = myCharacter, + dailyKeymeTest = dailyKeymeTest, + onDailyKeymeTestClick = { + // todo navigate to keyme test + } ) } diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt index 2dda2d6..33bb7d6 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt @@ -39,6 +39,7 @@ import coil.compose.AsyncImage import coil.request.ImageRequest import com.keyme.domain.entity.member.Member import com.keyme.domain.entity.response.Category +import com.keyme.domain.entity.response.Test import com.keyme.presentation.designsystem.component.KeymeText import com.keyme.presentation.designsystem.component.KeymeTextType import com.keyme.presentation.designsystem.theme.keyme_black @@ -52,17 +53,16 @@ import kotlinx.coroutines.launch @Composable fun DailyKeymeTestScreen( myCharacter: Member, + dailyKeymeTest: Test, + onDailyKeymeTestClick: () -> Unit, ) { Box(modifier = Modifier.fillMaxSize()) { WelComeTextTitle(modifier = Modifier.zIndex(1f), myCharacter = myCharacter) DailyKeymeTestCircle( - modifier = Modifier - .align(Alignment.Center) - .clickableRippleEffect(bounded = false) { - - }, - categories = categories, + modifier = Modifier.align(Alignment.Center), + categories = dailyKeymeTest.questions.map { it.category }, + onClick = onDailyKeymeTestClick, ) } } @@ -79,31 +79,14 @@ private fun WelComeTextTitle(modifier: Modifier = Modifier, myCharacter: Member) ) } -val categories = listOf( - Category( - color = "FFB2F5", - iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", - name = "", - ), - Category( - color = "E5D85C", - iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", - name = "", - ), - Category( - color = "993800", - iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", - name = "", - ), - Category( - color = "6B66FF", - iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", - name = "", - ), -) - @Composable -private fun DailyKeymeTestCircle(modifier: Modifier = Modifier, categories: List) { +private fun DailyKeymeTestCircle( + modifier: Modifier = Modifier, + categories: List, + onClick: () -> Unit, +) { + if (categories.isEmpty()) return + var expand by remember { mutableStateOf(false) } var selectedIndex = 0 @@ -128,7 +111,7 @@ private fun DailyKeymeTestCircle(modifier: Modifier = Modifier, categories: List } } - DailyKeymeTestCircleImpl(modifier, expand = expand, category = selectedCategory) + DailyKeymeTestCircleImpl(modifier, expand = expand, category = selectedCategory, onClick = onClick) } private val initialSize = 0.dp @@ -139,6 +122,7 @@ private fun DailyKeymeTestCircleImpl( modifier: Modifier = Modifier, expand: Boolean, category: Category, + onClick: () -> Unit, ) { val size by animateDpAsState( targetValue = if (expand) expandedSize else initialSize, @@ -159,7 +143,8 @@ private fun DailyKeymeTestCircleImpl( .background(color = Color(0x26FFFFFF), shape = CircleShape) .onGloballyPositioned { it.size - }, + } + .clickableRippleEffect { onClick() }, contentAlignment = Alignment.Center, ) { Box( @@ -204,6 +189,29 @@ fun DailyKeymeTestCirclePreview() { .background(color = keyme_black), contentAlignment = Alignment.Center, ) { - DailyKeymeTestCircle(categories = categories) + DailyKeymeTestCircle(categories = categories, onClick = { }) } } + +val categories = listOf( + Category( + color = "FFB2F5", + iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", + name = "", + ), + Category( + color = "E5D85C", + iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", + name = "", + ), + Category( + color = "993800", + iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", + name = "", + ), + Category( + color = "6B66FF", + iconUrl = "https://keyme-ec2-access-s3.s3.ap-northeast-2.amazonaws.com/test_star.png", + name = "", + ), +) diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt new file mode 100644 index 0000000..93d2077 --- /dev/null +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt @@ -0,0 +1,37 @@ +package com.keyme.presentation.dailykeymetest + +import com.keyme.domain.entity.member.Member +import com.keyme.domain.entity.response.Test +import com.keyme.domain.usecase.GetDailyKeymeTestUseCase +import com.keyme.domain.usecase.GetMyCharacterUseCase +import com.keyme.presentation.BaseViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import javax.inject.Inject + +@HiltViewModel +class DailyKeymeTestViewModel @Inject constructor( + private val getMyCharacterUseCase: GetMyCharacterUseCase, + private val getDailyKeymeTestUseCase: GetDailyKeymeTestUseCase, +): BaseViewModel() { + + private val _myCharacterState = MutableStateFlow(Member.EMPTY) + val myCharacterState = _myCharacterState.asStateFlow() + + private val _dailyKeymeTestState = MutableStateFlow(Test.EMPTY) + val dailyKeymeTestState = _dailyKeymeTestState.asStateFlow() + +// private val _dailyTestStatisticsState = MutableStateFlow(TestSta) + + init { + load() + } + + private fun load() { + apiCall(apiRequest = { getDailyKeymeTestUseCase() }) { + _dailyKeymeTestState.value = it + } + _myCharacterState.value = getMyCharacterUseCase.invoke() + } +} diff --git a/presentation/src/main/java/com/keyme/presentation/utils/ColorUtil.kt b/presentation/src/main/java/com/keyme/presentation/utils/ColorUtil.kt index ed6f052..0c95b7c 100644 --- a/presentation/src/main/java/com/keyme/presentation/utils/ColorUtil.kt +++ b/presentation/src/main/java/com/keyme/presentation/utils/ColorUtil.kt @@ -16,8 +16,6 @@ object ColorUtil { (green and 0xFF shl 8) or (blue and 0xFF) - Timber.d("argbColor = $argbColor") - Color(argbColor) } else { Color.Unspecified From 6a9decc38d2494493e1eac514e2d243dd75e4446 Mon Sep 17 00:00:00 2001 From: DwEnn Date: Thu, 17 Aug 2023 00:28:18 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=EB=8D=B0=EC=9D=BC=EB=A6=AC=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EA=B2=B0=EA=B3=BC=20=ED=99=94=EB=A9=B4=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/keyme/app/ui/KeymeAppState.kt | 2 +- .../com/keyme/data/remote/api/KeymeApi.kt | 11 +- .../repositoryimpl/KeymeTestRepositoryImpl.kt | 5 + .../domain/entity/response/TestStatistic.kt | 7 + .../entity/response/TestStatisticResponse.kt | 5 + .../domain/repository/KeymeTestRepository.kt | 3 + .../usecase/GetKeymeTestStatisticUseCase.kt | 12 ++ .../dailykeymetest/DailyKeymeTestRoute.kt | 2 + .../dailykeymetest/DailyKeymeTestScreen.kt | 30 +++- .../DailyKeymeTestStatisticScreen.kt | 137 ++++++++++++++++++ .../dailykeymetest/DailyKeymeTestViewModel.kt | 24 ++- .../src/main/res/drawable/icon_member.xml | 12 ++ 12 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 domain/src/main/java/com/keyme/domain/entity/response/TestStatistic.kt create mode 100644 domain/src/main/java/com/keyme/domain/entity/response/TestStatisticResponse.kt create mode 100644 domain/src/main/java/com/keyme/domain/usecase/GetKeymeTestStatisticUseCase.kt create mode 100644 presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestStatisticScreen.kt create mode 100644 presentation/src/main/res/drawable/icon_member.xml diff --git a/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt b/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt index 6d24fd4..34c6ac0 100644 --- a/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt +++ b/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt @@ -42,7 +42,7 @@ class KeymeAppState( val currentDestination: NavDestination? @Composable get() = navController.currentBackStackEntryAsState().value?.destination - val startDestination = DailyKeymeTestDestination + val startDestination = OnboardingDestination var isOnBoarding by mutableStateOf(false) diff --git a/data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt b/data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt index 77147e2..b9dd4e7 100644 --- a/data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt +++ b/data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt @@ -9,6 +9,7 @@ import com.keyme.domain.entity.response.QuestionSolvedScoreListResponse import com.keyme.domain.entity.response.QuestionSolvedScoreResponse import com.keyme.domain.entity.response.QuestionStatisticsResponse import com.keyme.domain.entity.response.SignInResponse +import com.keyme.domain.entity.response.TestStatisticResponse import retrofit2.http.Body import retrofit2.http.GET import retrofit2.http.POST @@ -22,11 +23,6 @@ interface KeymeApi { @Body signInRequest: SignInRequest, ): SignInResponse -// @GET("tests/{id}/statistics") -// suspend fun getKeymeTestResultStatistics( -// @Path("id") questionId: String, -// ): KeymeTestResultStatisticsResponse - @GET("members/{memberId}/statistics") suspend fun getMemberStatistics( @Path("memberId") memberId: String, @@ -58,4 +54,9 @@ interface KeymeApi { @GET("tests/daily") suspend fun getDailyTest(): DailyTestResponse + + @GET("tests/{id}/statistics") + suspend fun getTestStatistic( + @Path("id") testId: Int, + ): TestStatisticResponse } diff --git a/data/src/main/java/com/keyme/data/remote/repositoryimpl/KeymeTestRepositoryImpl.kt b/data/src/main/java/com/keyme/data/remote/repositoryimpl/KeymeTestRepositoryImpl.kt index b19135e..0915866 100644 --- a/data/src/main/java/com/keyme/data/remote/repositoryimpl/KeymeTestRepositoryImpl.kt +++ b/data/src/main/java/com/keyme/data/remote/repositoryimpl/KeymeTestRepositoryImpl.kt @@ -3,6 +3,7 @@ package com.keyme.data.remote.repositoryimpl import com.keyme.data.remote.api.KeymeApi import com.keyme.domain.entity.response.DailyTestResponse import com.keyme.domain.entity.response.OnBoardingTestResponse +import com.keyme.domain.entity.response.TestStatisticResponse import com.keyme.domain.repository.KeymeTestRepository import javax.inject.Inject @@ -16,4 +17,8 @@ class KeymeTestRepositoryImpl @Inject constructor( override suspend fun getDailyTest(): DailyTestResponse { return keymeApi.getDailyTest() } + + override suspend fun getTestStatistic(testId: Int): TestStatisticResponse { + return keymeApi.getTestStatistic(testId) + } } diff --git a/domain/src/main/java/com/keyme/domain/entity/response/TestStatistic.kt b/domain/src/main/java/com/keyme/domain/entity/response/TestStatistic.kt new file mode 100644 index 0000000..086fbcb --- /dev/null +++ b/domain/src/main/java/com/keyme/domain/entity/response/TestStatistic.kt @@ -0,0 +1,7 @@ +package com.keyme.domain.entity.response + +data class TestStatistic( + val averageRate: Float, + val solvedCount: Int, + val questionsStatistics: List, +) diff --git a/domain/src/main/java/com/keyme/domain/entity/response/TestStatisticResponse.kt b/domain/src/main/java/com/keyme/domain/entity/response/TestStatisticResponse.kt new file mode 100644 index 0000000..adfab9d --- /dev/null +++ b/domain/src/main/java/com/keyme/domain/entity/response/TestStatisticResponse.kt @@ -0,0 +1,5 @@ +package com.keyme.domain.entity.response + +import com.keyme.domain.entity.BaseResponse + +class TestStatisticResponse: BaseResponse() diff --git a/domain/src/main/java/com/keyme/domain/repository/KeymeTestRepository.kt b/domain/src/main/java/com/keyme/domain/repository/KeymeTestRepository.kt index f0fad81..9ddcc88 100644 --- a/domain/src/main/java/com/keyme/domain/repository/KeymeTestRepository.kt +++ b/domain/src/main/java/com/keyme/domain/repository/KeymeTestRepository.kt @@ -2,10 +2,13 @@ package com.keyme.domain.repository import com.keyme.domain.entity.response.DailyTestResponse import com.keyme.domain.entity.response.OnBoardingTestResponse +import com.keyme.domain.entity.response.TestStatisticResponse interface KeymeTestRepository { suspend fun getOnBoardingTest(): OnBoardingTestResponse suspend fun getDailyTest(): DailyTestResponse + + suspend fun getTestStatistic(testId: Int): TestStatisticResponse } diff --git a/domain/src/main/java/com/keyme/domain/usecase/GetKeymeTestStatisticUseCase.kt b/domain/src/main/java/com/keyme/domain/usecase/GetKeymeTestStatisticUseCase.kt new file mode 100644 index 0000000..267d9e7 --- /dev/null +++ b/domain/src/main/java/com/keyme/domain/usecase/GetKeymeTestStatisticUseCase.kt @@ -0,0 +1,12 @@ +package com.keyme.domain.usecase + +import com.keyme.domain.entity.apiResult +import com.keyme.domain.repository.KeymeTestRepository +import javax.inject.Inject + +class GetKeymeTestStatisticUseCase @Inject constructor( + private val keymeTestRepository: KeymeTestRepository, +) { + + suspend operator fun invoke(testId: Int) = apiResult { keymeTestRepository.getTestStatistic(testId) } +} diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt index 75cf8b2..63336d7 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt @@ -48,10 +48,12 @@ fun DailyKeymeTestRoute( ) { val myCharacter by dailyKeymeTestViewModel.myCharacterState.collectAsStateWithLifecycle() val dailyKeymeTest by dailyKeymeTestViewModel.dailyKeymeTestState.collectAsStateWithLifecycle() + val dailyKeymeTestStatistic by dailyKeymeTestViewModel.dailyKeymeTestStatisticState.collectAsStateWithLifecycle() DailyKeymeTestScreen( myCharacter = myCharacter, dailyKeymeTest = dailyKeymeTest, + dailyKeymeTestStatistic = dailyKeymeTestStatistic, onDailyKeymeTestClick = { // todo navigate to keyme test } diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt index 33bb7d6..e271207 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestScreen.kt @@ -10,6 +10,7 @@ import androidx.compose.animation.slideOut import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -40,6 +41,7 @@ import coil.request.ImageRequest import com.keyme.domain.entity.member.Member import com.keyme.domain.entity.response.Category import com.keyme.domain.entity.response.Test +import com.keyme.domain.entity.response.TestStatistic import com.keyme.presentation.designsystem.component.KeymeText import com.keyme.presentation.designsystem.component.KeymeTextType import com.keyme.presentation.designsystem.theme.keyme_black @@ -54,19 +56,33 @@ import kotlinx.coroutines.launch fun DailyKeymeTestScreen( myCharacter: Member, dailyKeymeTest: Test, + dailyKeymeTestStatistic: TestStatistic? = null, onDailyKeymeTestClick: () -> Unit, ) { Box(modifier = Modifier.fillMaxSize()) { - WelComeTextTitle(modifier = Modifier.zIndex(1f), myCharacter = myCharacter) - - DailyKeymeTestCircle( - modifier = Modifier.align(Alignment.Center), - categories = dailyKeymeTest.questions.map { it.category }, - onClick = onDailyKeymeTestClick, - ) + if (dailyKeymeTestStatistic != null) { + DailyKeymeTestStatisticScreen(myCharacter, dailyKeymeTestStatistic) + } else { + DailKeymeTestScreen(myCharacter, dailyKeymeTest, onDailyKeymeTestClick) + } } } +@Composable +fun BoxScope.DailKeymeTestScreen( + myCharacter: Member, + dailyKeymeTest: Test, + onDailyKeymeTestClick: () -> Unit, +) { + WelComeTextTitle(modifier = Modifier.zIndex(1f), myCharacter = myCharacter) + + DailyKeymeTestCircle( + modifier = Modifier.align(Alignment.Center), + categories = dailyKeymeTest.questions.map { it.category }, + onClick = onDailyKeymeTestClick, + ) +} + @Composable private fun WelComeTextTitle(modifier: Modifier = Modifier, myCharacter: Member) { KeymeText( diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestStatisticScreen.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestStatisticScreen.kt new file mode 100644 index 0000000..285e4ef --- /dev/null +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestStatisticScreen.kt @@ -0,0 +1,137 @@ +package com.keyme.presentation.dailykeymetest + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Icon +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import coil.request.ImageRequest +import com.keyme.domain.entity.member.Member +import com.keyme.domain.entity.response.QuestionStatistic +import com.keyme.domain.entity.response.TestStatistic +import com.keyme.presentation.R +import com.keyme.presentation.designsystem.component.KeymeText +import com.keyme.presentation.designsystem.component.KeymeTextType +import com.keyme.presentation.utils.ColorUtil + +@Composable +fun DailyKeymeTestStatisticScreen( + myCharacter: Member, + dailyKeymeTestStatistic: TestStatistic, +) { + Column(modifier = Modifier.fillMaxSize()) { + StatisticTextTitle(myCharacter = myCharacter) + Spacer(modifier = Modifier.height(96.dp)) + StatisticList(myCharacter, dailyKeymeTestStatistic) + } +} + +@Composable +private fun StatisticTextTitle(modifier: Modifier = Modifier, myCharacter: Member) { + KeymeText( + modifier = modifier + .padding(vertical = 75.dp, horizontal = 16.dp) + .fillMaxWidth(), + text = "${myCharacter.nickname}님 친구들의 답변이 쌓이고 있어요!", + keymeTextType = KeymeTextType.HEADING_1, + color = Color(0xFFF8F8F8), + ) +} + +@Composable +private fun StatisticList( + myCharacter: Member, + dailyKeymeTestStatistic: TestStatistic, +) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + ) { + Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) { + Icon( + painter = painterResource(id = R.drawable.icon_member), + contentDescription = "", + tint = Color.White, + ) + + KeymeText( + text = "${dailyKeymeTestStatistic.solvedCount}명의 친구가 문제를 풀었어요", + keymeTextType = KeymeTextType.BODY_4, + color = Color.White, + ) + } + + LazyColumn(modifier = Modifier.fillMaxWidth()) { + items(dailyKeymeTestStatistic.questionsStatistics) { + QuestionStatisticItem(myCharacter = myCharacter, statistic = it) + } + } + } +} + +@Composable +private fun QuestionStatisticItem(myCharacter: Member, statistic: QuestionStatistic) { + Row( + modifier = Modifier + .fillMaxWidth() + .background(color = Color(0x0DFFFFFF), shape = RoundedCornerShape(size = 14.dp)) + .padding(horizontal = 14.dp, vertical = 20.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp), + ) { + Box( + modifier = Modifier + .size(40.dp) + .background( + color = ColorUtil.hexStringToColor(statistic.category.color), + shape = CircleShape, + ), + contentAlignment = Alignment.Center, + ) { + AsyncImage( + modifier = Modifier.size(20.dp), + model = ImageRequest.Builder(LocalContext.current) + .data(statistic.category.iconUrl) + .build(), + contentDescription = "", + contentScale = ContentScale.Crop, + ) + } + + Column(verticalArrangement = Arrangement.spacedBy(6.dp)) { + KeymeText( + text = "${myCharacter.nickname}님의 ${statistic.category.name} 정도는?", + keymeTextType = KeymeTextType.BODY_3_SEMIBOLD, + color = Color.White, + ) + + KeymeText( + text = "평균점수 | ${statistic.avgScore}점", + keymeTextType = KeymeTextType.BODY_4, + color = Color(0x80FFFFFF), + ) + } + } +} diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt index 93d2077..acbaf4a 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt @@ -2,19 +2,28 @@ package com.keyme.presentation.dailykeymetest import com.keyme.domain.entity.member.Member import com.keyme.domain.entity.response.Test +import com.keyme.domain.entity.response.TestStatistic import com.keyme.domain.usecase.GetDailyKeymeTestUseCase +import com.keyme.domain.usecase.GetKeymeTestStatisticUseCase import com.keyme.domain.usecase.GetMyCharacterUseCase import com.keyme.presentation.BaseViewModel import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.filterNot +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.onEach import javax.inject.Inject @HiltViewModel class DailyKeymeTestViewModel @Inject constructor( private val getMyCharacterUseCase: GetMyCharacterUseCase, private val getDailyKeymeTestUseCase: GetDailyKeymeTestUseCase, -): BaseViewModel() { + private val getKeymeTestStatisticUseCase: GetKeymeTestStatisticUseCase, +) : BaseViewModel() { private val _myCharacterState = MutableStateFlow(Member.EMPTY) val myCharacterState = _myCharacterState.asStateFlow() @@ -22,7 +31,8 @@ class DailyKeymeTestViewModel @Inject constructor( private val _dailyKeymeTestState = MutableStateFlow(Test.EMPTY) val dailyKeymeTestState = _dailyKeymeTestState.asStateFlow() -// private val _dailyTestStatisticsState = MutableStateFlow(TestSta) + private val _dailyKeymeTestStatisticState = MutableStateFlow(null) + val dailyKeymeTestStatisticState = _dailyKeymeTestStatisticState.asStateFlow() init { load() @@ -33,5 +43,15 @@ class DailyKeymeTestViewModel @Inject constructor( _dailyKeymeTestState.value = it } _myCharacterState.value = getMyCharacterUseCase.invoke() + + dailyKeymeTestState + .map { it.testId } + .filter { it != 0 } + .distinctUntilChanged() + .onEach { + apiCall(apiRequest = { getKeymeTestStatisticUseCase(it) }) {statistic -> + _dailyKeymeTestStatisticState.value = statistic + } + }.launchIn(baseViewModelScope) } } diff --git a/presentation/src/main/res/drawable/icon_member.xml b/presentation/src/main/res/drawable/icon_member.xml new file mode 100644 index 0000000..3714d38 --- /dev/null +++ b/presentation/src/main/res/drawable/icon_member.xml @@ -0,0 +1,12 @@ + + + + From e9e96948d9807a7b24cef6f8b57d7224af7f1f95 Mon Sep 17 00:00:00 2001 From: DwEnn Date: Thu, 17 Aug 2023 00:30:57 +0900 Subject: [PATCH 7/7] =?UTF-8?q?lint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/keyme/app/ui/KeymeApp.kt | 2 +- .../main/java/com/keyme/app/ui/KeymeAppState.kt | 1 - .../domain/entity/response/DailyTestResponse.kt | 2 +- .../java/com/keyme/domain/entity/response/Test.kt | 5 ++++- .../entity/response/TestStatisticResponse.kt | 2 +- .../dailykeymetest/DailyKeymeTestRoute.kt | 15 +-------------- .../DailyKeymeTestStatisticScreen.kt | 1 - .../dailykeymetest/DailyKeymeTestViewModel.kt | 3 +-- .../com/keyme/presentation/utils/ColorUtil.kt | 1 - 9 files changed, 9 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/keyme/app/ui/KeymeApp.kt b/app/src/main/java/com/keyme/app/ui/KeymeApp.kt index 46adbe6..8232410 100644 --- a/app/src/main/java/com/keyme/app/ui/KeymeApp.kt +++ b/app/src/main/java/com/keyme/app/ui/KeymeApp.kt @@ -16,9 +16,9 @@ import com.keyme.app.navigation.TopLevelDestination import com.keyme.app.navigation.keymeTopLevelDestinations import com.keyme.presentation.alarm.ui.AlarmDestination import com.keyme.presentation.alarm.ui.alarmGraph -import com.keyme.presentation.designsystem.theme.KeymeTheme import com.keyme.presentation.dailykeymetest.DailyKeymeTestDestination import com.keyme.presentation.dailykeymetest.dailyKeymeTestGraph +import com.keyme.presentation.designsystem.theme.KeymeTheme import com.keyme.presentation.keymetest.KeymeTestDestination import com.keyme.presentation.keymetest.keymeTestGraph import com.keyme.presentation.myprofile.ui.KeymeQuestionResultDestination diff --git a/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt b/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt index 34c6ac0..e2dff85 100644 --- a/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt +++ b/app/src/main/java/com/keyme/app/ui/KeymeAppState.kt @@ -14,7 +14,6 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import com.keyme.app.navigation.TopLevelDestination -import com.keyme.presentation.dailykeymetest.DailyKeymeTestDestination import com.keyme.presentation.navigation.KeymeNavigationDestination import com.keyme.presentation.onboarding.OnboardingDestination import com.keyme.presentation.onboarding.OnboardingViewModel diff --git a/domain/src/main/java/com/keyme/domain/entity/response/DailyTestResponse.kt b/domain/src/main/java/com/keyme/domain/entity/response/DailyTestResponse.kt index 9535232..ec15b24 100644 --- a/domain/src/main/java/com/keyme/domain/entity/response/DailyTestResponse.kt +++ b/domain/src/main/java/com/keyme/domain/entity/response/DailyTestResponse.kt @@ -2,4 +2,4 @@ package com.keyme.domain.entity.response import com.keyme.domain.entity.BaseResponse -class DailyTestResponse: BaseResponse() +class DailyTestResponse : BaseResponse() diff --git a/domain/src/main/java/com/keyme/domain/entity/response/Test.kt b/domain/src/main/java/com/keyme/domain/entity/response/Test.kt index 298ae8c..7676753 100644 --- a/domain/src/main/java/com/keyme/domain/entity/response/Test.kt +++ b/domain/src/main/java/com/keyme/domain/entity/response/Test.kt @@ -20,7 +20,10 @@ data class Test( profileImage = "", profileThumbnail = "", ), - solvedCount = 0, testId = 0, testResultId = 0, title = "", + solvedCount = 0, + testId = 0, + testResultId = 0, + title = "", ) } } diff --git a/domain/src/main/java/com/keyme/domain/entity/response/TestStatisticResponse.kt b/domain/src/main/java/com/keyme/domain/entity/response/TestStatisticResponse.kt index adfab9d..7f42564 100644 --- a/domain/src/main/java/com/keyme/domain/entity/response/TestStatisticResponse.kt +++ b/domain/src/main/java/com/keyme/domain/entity/response/TestStatisticResponse.kt @@ -2,4 +2,4 @@ package com.keyme.domain.entity.response import com.keyme.domain.entity.BaseResponse -class TestStatisticResponse: BaseResponse() +class TestStatisticResponse : BaseResponse() diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt index 63336d7..2e5da22 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt @@ -1,25 +1,12 @@ package com.keyme.presentation.dailykeymetest -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable import androidx.navigation.navigation -import com.keyme.domain.entity.member.Member -import com.keyme.presentation.R import com.keyme.presentation.navigation.KeymeNavigationDestination object DailyKeymeTestDestination : KeymeNavigationDestination { @@ -56,6 +43,6 @@ fun DailyKeymeTestRoute( dailyKeymeTestStatistic = dailyKeymeTestStatistic, onDailyKeymeTestClick = { // todo navigate to keyme test - } + }, ) } diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestStatisticScreen.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestStatisticScreen.kt index 285e4ef..a578b7c 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestStatisticScreen.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestStatisticScreen.kt @@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn diff --git a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt index acbaf4a..2f636de 100644 --- a/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt +++ b/presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestViewModel.kt @@ -12,7 +12,6 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filter -import kotlinx.coroutines.flow.filterNot import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach @@ -49,7 +48,7 @@ class DailyKeymeTestViewModel @Inject constructor( .filter { it != 0 } .distinctUntilChanged() .onEach { - apiCall(apiRequest = { getKeymeTestStatisticUseCase(it) }) {statistic -> + apiCall(apiRequest = { getKeymeTestStatisticUseCase(it) }) { statistic -> _dailyKeymeTestStatisticState.value = statistic } }.launchIn(baseViewModelScope) diff --git a/presentation/src/main/java/com/keyme/presentation/utils/ColorUtil.kt b/presentation/src/main/java/com/keyme/presentation/utils/ColorUtil.kt index 0c95b7c..f9fa480 100644 --- a/presentation/src/main/java/com/keyme/presentation/utils/ColorUtil.kt +++ b/presentation/src/main/java/com/keyme/presentation/utils/ColorUtil.kt @@ -1,7 +1,6 @@ package com.keyme.presentation.utils import androidx.compose.ui.graphics.Color -import timber.log.Timber object ColorUtil { fun hexStringToColor(value: String): Color {