From 87041af1168d630c06f24b226b18c4a9b10940d2 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Nov 2024 09:48:03 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[feat]=20#6=20=ED=99=88=20=EB=B7=B0=20-=20A?= =?UTF-8?q?syncImage=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../and/presentation/ui/home/HomeRoute.kt | 2 +- .../and/presentation/ui/home/HomeScreen.kt | 43 ++++++++----------- .../ui/home/component/HomeAsyncImage.kt | 26 +++++++++++ 3 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 app/src/main/java/org/sopt/and/presentation/ui/home/component/HomeAsyncImage.kt diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt index 42c5b27..09e6cd9 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt @@ -17,7 +17,7 @@ fun HomeRoute( val homeState by homeViewModel.uiState.collectAsState() LaunchedEffect(homeState.homeStatus) { - if (homeState.homeStatus == HomeContract.HomeStatus.Idle) { + if (homeState.homeStatus == HomeContract.HomeStatus.Loading) { homeViewModel.setHomeImgList() } } diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt index 30e222f..e4cb9ee 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt @@ -6,11 +6,13 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.pager.HorizontalPager @@ -36,6 +38,7 @@ import coil3.request.ImageRequest import coil3.request.crossfade import org.sopt.and.R import org.sopt.and.presentation.ui.component.TextWithNavigateButton +import org.sopt.and.presentation.ui.home.component.HomeAsyncImage import org.sopt.and.ui.theme.ANDANDROIDTheme import org.sopt.and.ui.theme.Gray100 import org.sopt.and.ui.theme.GrayBlack @@ -128,14 +131,8 @@ fun HomeBannerItem( .fillMaxWidth() .clip(RoundedCornerShape(15.dp)) ) { - AsyncImage( - model = ImageRequest.Builder(context = LocalContext.current) - .data(bannerImg) - .crossfade(enable = true) - .build(), - contentDescription = null, - contentScale = ContentScale.Crop, - modifier = Modifier.fillMaxWidth() + HomeAsyncImage( + imgUrl = bannerImg ) HomeBannerItemCountText( @@ -172,17 +169,14 @@ fun HomeBannerItemCountText( fun EditorRecommendedItem( recommendedItem: String ) { - AsyncImage( - model = ImageRequest.Builder(context = LocalContext.current) - .data(recommendedItem) - .crossfade(enable = true) - .build(), - contentDescription = null, - contentScale = ContentScale.Crop, + val imageWidth = (LocalConfiguration.current.screenWidthDp.dp)/3 + + HomeAsyncImage( + imgUrl = recommendedItem, modifier = Modifier - .fillMaxWidth() + .width(imageWidth) .clip(RoundedCornerShape(15.dp)) - .size(width = 144.dp, height = 192.dp) + .aspectRatio(3f/4f) ) } @@ -191,21 +185,18 @@ fun TodayTopRankingImgList( ranking: Int, rankingItem: String, ) { + val imageWidth = (LocalConfiguration.current.screenWidthDp.dp)/2 + Box( modifier = Modifier .fillMaxWidth() ) { - AsyncImage( - model = ImageRequest.Builder(context = LocalContext.current) - .data(rankingItem) - .crossfade(enable = true) - .build(), - contentDescription = null, - contentScale = ContentScale.Crop, + HomeAsyncImage( + imgUrl = rankingItem, modifier = Modifier - .fillMaxWidth() + .width(imageWidth) .clip(RoundedCornerShape(15.dp)) - .size(width = 180.dp, height = 240.dp) + .aspectRatio(3f/4f) ) Text( diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/component/HomeAsyncImage.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/component/HomeAsyncImage.kt new file mode 100644 index 0000000..d5a181b --- /dev/null +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/component/HomeAsyncImage.kt @@ -0,0 +1,26 @@ +package org.sopt.and.presentation.ui.home.component + +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext +import coil3.compose.AsyncImage +import coil3.request.ImageRequest +import coil3.request.crossfade + +@Composable +fun HomeAsyncImage( + imgUrl: String, + modifier: Modifier = Modifier +) { + AsyncImage( + model = ImageRequest.Builder(context = LocalContext.current) + .data(imgUrl) + .crossfade(enable = true) + .build(), + contentDescription = null, + contentScale = ContentScale.Crop, + modifier = modifier.fillMaxWidth() + ) +} \ No newline at end of file From d955581f5967274d75507aa40d36f1164d440943 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Nov 2024 10:05:55 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[mod]=20#6=20=ED=99=88=20=EB=B7=B0=20-=20=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../and/presentation/ui/home/HomeScreen.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt index e4cb9ee..d816543 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt @@ -10,8 +10,8 @@ import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.itemsIndexed @@ -26,16 +26,12 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalConfiguration -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import coil3.compose.AsyncImage -import coil3.request.ImageRequest -import coil3.request.crossfade import org.sopt.and.R import org.sopt.and.presentation.ui.component.TextWithNavigateButton import org.sopt.and.presentation.ui.home.component.HomeAsyncImage @@ -169,14 +165,14 @@ fun HomeBannerItemCountText( fun EditorRecommendedItem( recommendedItem: String ) { - val imageWidth = (LocalConfiguration.current.screenWidthDp.dp)/3 + val imageWidth = (LocalConfiguration.current.screenWidthDp.dp) / 3 HomeAsyncImage( imgUrl = recommendedItem, modifier = Modifier .width(imageWidth) .clip(RoundedCornerShape(15.dp)) - .aspectRatio(3f/4f) + .aspectRatio(3f / 4f) ) } @@ -185,26 +181,28 @@ fun TodayTopRankingImgList( ranking: Int, rankingItem: String, ) { - val imageWidth = (LocalConfiguration.current.screenWidthDp.dp)/2 + val imageWidth = (LocalConfiguration.current.screenWidthDp.dp) / 2 Box( modifier = Modifier - .fillMaxWidth() + .padding(start = 10.dp, bottom = 28.dp) ) { HomeAsyncImage( imgUrl = rankingItem, modifier = Modifier .width(imageWidth) .clip(RoundedCornerShape(15.dp)) - .aspectRatio(3f/4f) + .aspectRatio(3f / 4f) ) Text( text = (ranking + 1).toString(), color = White, fontSize = 42.sp, + fontStyle = FontStyle.Italic, modifier = Modifier .align(Alignment.BottomStart) + .offset(x = (-10).dp, y = 28.dp) ) } } From 0802ada6bc73ddcb8121095dcf91fbeb59ef262b Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Nov 2024 10:12:36 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[mod]=20#6=20=EC=A0=84=EB=B0=98=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EC=9D=B8=EC=9E=90=20=EC=9E=91=EC=84=B1=20=EC=88=9C?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/sopt/and/presentation/ui/auth/login/LoginRoute.kt | 4 ++-- .../org/sopt/and/presentation/ui/auth/login/LoginScreen.kt | 4 ++-- .../sopt/and/presentation/ui/auth/register/RegisterRoute.kt | 4 ++-- .../and/presentation/ui/auth/register/RegisterScreen.kt | 2 +- .../org/sopt/and/presentation/ui/component/WaveAllButton.kt | 2 +- .../org/sopt/and/presentation/ui/component/WaveTextField.kt | 4 ++-- .../ui/component/WaveTextFieldWithShowAndHide.kt | 4 ++-- .../java/org/sopt/and/presentation/ui/home/HomeScreen.kt | 4 ++-- .../main/java/org/sopt/and/presentation/ui/my/MyScreen.kt | 5 ++--- .../and/presentation/ui/navigator/WaveBottomNavigation.kt | 6 +++--- .../org/sopt/and/presentation/ui/navigator/WaveNavHost.kt | 2 +- 11 files changed, 20 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt b/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt index 49c90b4..5c9ef50 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt @@ -18,9 +18,9 @@ import org.sopt.and.R @Composable fun LoginRoute( paddingValues: PaddingValues, - loginViewModel: LoginViewModel = hiltViewModel(), navigateToRegister: () -> Unit, - navigateToHome: () -> Unit + navigateToHome: () -> Unit, + loginViewModel: LoginViewModel = hiltViewModel() ) { val loginState by loginViewModel.uiState.collectAsState() val loginEffect = loginViewModel.uiEffect diff --git a/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginScreen.kt b/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginScreen.kt index 05ab750..636a411 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginScreen.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginScreen.kt @@ -33,7 +33,6 @@ import timber.log.Timber @Composable fun LoginScreen( - modifier: Modifier = Modifier, email: String, password: String, showPassword: Boolean, @@ -42,7 +41,8 @@ fun LoginScreen( onPasswordVisibilityChange: () -> Unit, onLoginBtnClick: () -> Unit, onNavigateToRegisterBtnClick: () -> Unit, - snackBarHostState: SnackbarHostState + snackBarHostState: SnackbarHostState, + modifier: Modifier = Modifier ) { Box( modifier = modifier diff --git a/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterRoute.kt b/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterRoute.kt index 2644887..07bb842 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterRoute.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterRoute.kt @@ -15,8 +15,8 @@ import org.sopt.and.util.showToast @Composable fun RegisterRoute( - registerViewModel: RegisterViewModel = hiltViewModel(), - navigateToLogin: () -> Unit + navigateToLogin: () -> Unit, + registerViewModel: RegisterViewModel = hiltViewModel() ) { val registerState by registerViewModel.uiState.collectAsState() val registerEffect = registerViewModel.uiEffect diff --git a/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterScreen.kt b/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterScreen.kt index 63dc834..fe7850e 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterScreen.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterScreen.kt @@ -33,7 +33,6 @@ import org.sopt.and.ui.theme.White @Composable fun RegisterScreen( - modifier: Modifier = Modifier, email: String, password: String, showPassword: Boolean, @@ -42,6 +41,7 @@ fun RegisterScreen( onPasswordVisibilityChange: () -> Unit, onBackBtnClick: () -> Unit, onRegisterBtnClick: () -> Unit, + modifier: Modifier = Modifier ) { Column( diff --git a/app/src/main/java/org/sopt/and/presentation/ui/component/WaveAllButton.kt b/app/src/main/java/org/sopt/and/presentation/ui/component/WaveAllButton.kt index ff31c9e..4ce80a6 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/component/WaveAllButton.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/component/WaveAllButton.kt @@ -19,9 +19,9 @@ import timber.log.Timber @Composable fun WaveAllButton( buttonText: String, - buttonColor: Color = BlueButton, onClickButton: () -> Unit, modifier: Modifier = Modifier, + buttonColor: Color = BlueButton ) { Button( modifier = Modifier diff --git a/app/src/main/java/org/sopt/and/presentation/ui/component/WaveTextField.kt b/app/src/main/java/org/sopt/and/presentation/ui/component/WaveTextField.kt index b5cdf04..e946c56 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/component/WaveTextField.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/component/WaveTextField.kt @@ -24,8 +24,8 @@ import org.sopt.and.ui.theme.White fun WaveTextField( placeholder: String, value: String, - onValueChange: (String) -> Unit = { _ -> }, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, + onValueChange: (String) -> Unit = { _ -> } ) { TextField( value = value, diff --git a/app/src/main/java/org/sopt/and/presentation/ui/component/WaveTextFieldWithShowAndHide.kt b/app/src/main/java/org/sopt/and/presentation/ui/component/WaveTextFieldWithShowAndHide.kt index ed9f81d..37329ba 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/component/WaveTextFieldWithShowAndHide.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/component/WaveTextFieldWithShowAndHide.kt @@ -29,10 +29,10 @@ import org.sopt.and.ui.theme.White fun WaveTextFieldWithShowAndHide( placeholder: String, value: String, - modifier: Modifier = Modifier, + changePasswordVisibility: () -> Unit, onValueChange: (String) -> Unit = { _ -> }, showPassword: Boolean = false, - changePasswordVisibility: () -> Unit + modifier: Modifier = Modifier ) { TextField( value = value, diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt index d816543..24309ba 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt @@ -42,12 +42,12 @@ import org.sopt.and.ui.theme.White @Composable fun HomeScreen( - modifier: Modifier = Modifier, bannerImgList: List, numPages: String, onCurrentPageChanged: (Int) -> Unit, editorRecommendedImgList: List, - todayTopRankingImgList: List + todayTopRankingImgList: List, + modifier: Modifier = Modifier ) { Column( modifier = modifier diff --git a/app/src/main/java/org/sopt/and/presentation/ui/my/MyScreen.kt b/app/src/main/java/org/sopt/and/presentation/ui/my/MyScreen.kt index aed20ea..923ab23 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/my/MyScreen.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/my/MyScreen.kt @@ -8,7 +8,6 @@ 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.padding import androidx.compose.foundation.layout.size import androidx.compose.material3.Icon @@ -30,8 +29,8 @@ import org.sopt.and.ui.theme.White @Composable fun MyScreen( - modifier: Modifier = Modifier, - userName: String + userName: String, + modifier: Modifier = Modifier ) { Column( modifier = modifier diff --git a/app/src/main/java/org/sopt/and/presentation/ui/navigator/WaveBottomNavigation.kt b/app/src/main/java/org/sopt/and/presentation/ui/navigator/WaveBottomNavigation.kt index 3393c75..bc70c67 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/navigator/WaveBottomNavigation.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/navigator/WaveBottomNavigation.kt @@ -30,12 +30,12 @@ import org.sopt.and.ui.theme.White @Composable fun WaveBottomNavigation( - modifier: Modifier = Modifier, - isVisible: Boolean = false, - context: Context = LocalContext.current, bottomNaviItems: List, currentBottomNaviItem: WaveBottomNavigationType?, onClickBottomNavItem: (WaveBottomNavigationType) -> Unit, + modifier: Modifier = Modifier, + isVisible: Boolean = false, + context: Context = LocalContext.current ) { AnimatedVisibility(visible = isVisible) { Row( diff --git a/app/src/main/java/org/sopt/and/presentation/ui/navigator/WaveNavHost.kt b/app/src/main/java/org/sopt/and/presentation/ui/navigator/WaveNavHost.kt index f6bc19c..001d0e9 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/navigator/WaveNavHost.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/navigator/WaveNavHost.kt @@ -17,8 +17,8 @@ import org.sopt.and.presentation.ui.search.searchNavGraph @Composable fun WaveNavHost( paddingValues: PaddingValues, - modifier: Modifier = Modifier, navigator: WaveNavigator, + modifier: Modifier = Modifier ) { Box( modifier = modifier From 27ccc0da1ade0071ee96ef765bdd79c032616133 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Nov 2024 10:17:45 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[mod]=20#6=20collectAsState=20->=20collectA?= =?UTF-8?q?sStateWithLifecycle=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt | 3 ++- .../sopt/and/presentation/ui/auth/register/RegisterRoute.kt | 3 ++- .../main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt b/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt index 5c9ef50..eeff315 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/auth/login/LoginRoute.kt @@ -12,6 +12,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import kotlinx.coroutines.launch import org.sopt.and.R @@ -22,7 +23,7 @@ fun LoginRoute( navigateToHome: () -> Unit, loginViewModel: LoginViewModel = hiltViewModel() ) { - val loginState by loginViewModel.uiState.collectAsState() + val loginState by loginViewModel.uiState.collectAsStateWithLifecycle() val loginEffect = loginViewModel.uiEffect val snackBarHostState = remember { SnackbarHostState() } diff --git a/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterRoute.kt b/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterRoute.kt index 07bb842..0e56324 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterRoute.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/auth/register/RegisterRoute.kt @@ -10,6 +10,7 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import org.sopt.and.R import org.sopt.and.util.showToast @@ -18,7 +19,7 @@ fun RegisterRoute( navigateToLogin: () -> Unit, registerViewModel: RegisterViewModel = hiltViewModel() ) { - val registerState by registerViewModel.uiState.collectAsState() + val registerState by registerViewModel.uiState.collectAsStateWithLifecycle() val registerEffect = registerViewModel.uiEffect val context = LocalContext.current diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt index 09e6cd9..82d5d06 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt @@ -8,13 +8,14 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle @Composable fun HomeRoute( paddingValues: PaddingValues, homeViewModel: HomeViewModel = hiltViewModel() ) { - val homeState by homeViewModel.uiState.collectAsState() + val homeState by homeViewModel.uiState.collectAsStateWithLifecycle() LaunchedEffect(homeState.homeStatus) { if (homeState.homeStatus == HomeContract.HomeStatus.Loading) { From bd7bc6ea14b8d8060f54798addff70f605e4e92a Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Nov 2024 10:33:49 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[mod]=20#6=20=ED=99=88=20=EB=B7=B0=20-=20se?= =?UTF-8?q?tHomeImgList=20=ED=98=B8=EC=B6=9C=201=ED=9A=8C=EB=A7=8C=20?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/sopt/and/presentation/ui/home/HomeRoute.kt | 8 ++------ .../org/sopt/and/presentation/ui/home/HomeViewModel.kt | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt index 82d5d06..de0392a 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeRoute.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel @@ -17,13 +16,10 @@ fun HomeRoute( ) { val homeState by homeViewModel.uiState.collectAsStateWithLifecycle() - LaunchedEffect(homeState.homeStatus) { - if (homeState.homeStatus == HomeContract.HomeStatus.Loading) { - homeViewModel.setHomeImgList() - } + LaunchedEffect(Unit) { + homeViewModel.setHomeImgList() } - HomeScreen( modifier = Modifier .padding(paddingValues), diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeViewModel.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeViewModel.kt index 1625489..581c95a 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeViewModel.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeViewModel.kt @@ -20,7 +20,7 @@ class HomeViewModel @Inject constructor() : TODO("Not yet implemented") } - val mockBannerItem = listOf( + private val mockBannerItem = listOf( "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202409/1726468505828994516.webp", "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202409/1727073001312600950.webp", "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202410/1728548543503727711.webp", @@ -29,7 +29,7 @@ class HomeViewModel @Inject constructor() : "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202409/1725362669902656119.webp" ) - val mockEditorRecommendedItem = listOf( + private val mockEditorRecommendedItem = listOf( "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202410/1729230112230270084.webp", "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202406/1717859400991205300.webp", "https://image.wavve.com/v1/thumbnails/480_720_20_80/BMS/TVSeason/2023/K01_T2009-0520-2.webp", @@ -40,7 +40,7 @@ class HomeViewModel @Inject constructor() : "https://image.wavve.com/v1/thumbnails/480_720_20_80/movieImg/MovieGroup/2023/GMV_CD01_WR0000011336-Vertical_LogoY_RTC.webp" ) - val mockTodayTopRankingItem = listOf( + private val mockTodayTopRankingItem = listOf( "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202409/1726468463104944317.webp", "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202311/1698908212143109040.webp", "https://image.wavve.com/v1/thumbnails/480_720_20_80/meta/image/202311/1701072276533128034.webp", From 8d52d521a2a05d8fcb776ab92a29cb876a6f9de6 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Nov 2024 10:39:35 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[mod]=20#6=20=ED=99=88=20=EB=B7=B0=20-=20La?= =?UTF-8?q?zyRow=20contentType,=20key=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/and/presentation/ui/home/HomeScreen.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt index 24309ba..1ccfd03 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeScreen.kt @@ -85,10 +85,10 @@ fun HomeScreen( contentPadding = PaddingValues(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(12.dp) ) { - itemsIndexed(editorRecommendedImgList, - key = { index, _ -> index }, - contentType = { _, item -> item } - ) { index, item -> + itemsIndexed( + editorRecommendedImgList, + key = { index, _ -> index } + ) { _, item -> EditorRecommendedItem(recommendedItem = item) } } @@ -103,9 +103,9 @@ fun HomeScreen( contentPadding = PaddingValues(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(12.dp) ) { - itemsIndexed(todayTopRankingImgList, - key = { index, _ -> index }, - contentType = { _, item -> item } + itemsIndexed( + todayTopRankingImgList, + key = { _, item -> item } ) { index, item -> TodayTopRankingImgList(ranking = index, rankingItem = item) } From f8642885d765e43f13b8e073b502ea4c0dbad47e Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Nov 2024 10:42:24 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[mod]=20#6=20=ED=99=88=20=EB=B7=B0=20-=20co?= =?UTF-8?q?py=20=ED=95=A8=EC=88=98=EB=A5=BC=201=EB=B2=88=EB=A7=8C=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=ED=95=98=EB=8A=94=20=EA=B2=83=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../and/presentation/ui/home/HomeViewModel.kt | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeViewModel.kt b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeViewModel.kt index 581c95a..31456d4 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/home/HomeViewModel.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/home/HomeViewModel.kt @@ -58,22 +58,13 @@ class HomeViewModel @Inject constructor() : } fun setHomeImgList() { - setHomeBannerState() - setEditorRecommendState() - setTodayTopRankingState() - - setState(currentUiState.copy(homeStatus = HomeContract.HomeStatus.Success)) - } - - private fun setHomeBannerState() { - setState(currentUiState.copy(bannerImgList = mockBannerItem)) - } - - private fun setEditorRecommendState() { - setState(currentUiState.copy(editorRecommendedList = mockEditorRecommendedItem)) - } - - private fun setTodayTopRankingState() { - setState(currentUiState.copy(todayTopRankingList = mockTodayTopRankingItem)) + setState( + currentUiState.copy( + homeStatus = HomeContract.HomeStatus.Success, + bannerImgList = mockBannerItem, + editorRecommendedList = mockEditorRecommendedItem, + todayTopRankingList = mockTodayTopRankingItem + ) + ) } } \ No newline at end of file From 2e3b9bef365202a4d8b18c6183b118eed37c6204 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Nov 2024 10:43:41 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[chore]=20#6=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/sopt/and/presentation/ui/my/MyViewModel.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/org/sopt/and/presentation/ui/my/MyViewModel.kt b/app/src/main/java/org/sopt/and/presentation/ui/my/MyViewModel.kt index b12ef0b..bbccbab 100644 --- a/app/src/main/java/org/sopt/and/presentation/ui/my/MyViewModel.kt +++ b/app/src/main/java/org/sopt/and/presentation/ui/my/MyViewModel.kt @@ -9,7 +9,5 @@ import javax.inject.Inject class MyViewModel @Inject constructor( private val localDataSource: WaveLocalDataSource ) : ViewModel() { - fun getLocalUserMail(): String { - return localDataSource.userEmail - } + fun getLocalUserMail(): String = localDataSource.userEmail } \ No newline at end of file