-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] 7주차 필수 과제 #14
base: develop
Are you sure you want to change the base?
[FEAT] 7주차 필수 과제 #14
Changes from all commits
e4fffc5
0fc3fbb
29ca5b1
6fea541
2ccb568
3190f39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저 이제 발견했는데요 파일명에 오타있음!!ㅋㅋㅋㅋ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.sopt.and.presentation.home | ||
|
||
import org.sopt.and.presentation.util.base.UiEvent | ||
import org.sopt.and.presentation.util.base.UiSideEffect | ||
import org.sopt.and.presentation.util.base.UiState | ||
|
||
class HomeContract { | ||
data class HomeUIState( | ||
val genreList: List<String> = listOf(), | ||
val mainBannerList: List<Int> = listOf(), | ||
val editorRecommendList: List<Int> = listOf(), | ||
val top20List: List<Int> = listOf() | ||
) : UiState | ||
|
||
sealed interface HomeSideEffect : UiSideEffect | ||
|
||
sealed class HomeEvent : UiEvent | ||
Comment on lines
+15
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 효빈님께도 드린 질문인데, 만약 sideeffect와 event가 없더라도 만들어두는게 좋을까요 ? 저는 안만들어서 .. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package org.sopt.and.presentation.home | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.ScrollState | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
|
@@ -24,6 +25,7 @@ import androidx.compose.material.icons.filled.Settings | |
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
|
@@ -34,20 +36,32 @@ import androidx.compose.ui.text.font.FontWeight | |
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.lifecycle.viewmodel.compose.viewModel | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import org.sopt.and.R | ||
import org.sopt.and.presentation.home.component.ContentLazyList | ||
import org.sopt.and.presentation.home.component.MainBannerPager | ||
import org.sopt.and.presentation.home.component.Top20LazyList | ||
|
||
|
||
@Composable | ||
fun HomeScreen(modifier: Modifier = Modifier) { | ||
val homeViewModel = viewModel<HomeViewModel>() | ||
|
||
val uiState = homeViewModel.uiState | ||
fun HomeRoute( | ||
viewModel: HomeViewModel = hiltViewModel() | ||
) { | ||
val uiState by viewModel.uiState.collectAsStateWithLifecycle() | ||
val scrollState = rememberScrollState() | ||
|
||
HomeScreen( | ||
uiState = uiState, | ||
scrollState = scrollState, | ||
) | ||
} | ||
|
||
@Composable | ||
fun HomeScreen( | ||
uiState: HomeContract.HomeUIState, | ||
scrollState: ScrollState, | ||
modifier: Modifier = Modifier | ||
) { | ||
Column( | ||
modifier = modifier | ||
.fillMaxSize() | ||
|
@@ -87,7 +101,7 @@ fun HomeScreen(modifier: Modifier = Modifier) { | |
modifier = Modifier.fillMaxWidth(), | ||
horizontalArrangement = Arrangement.SpaceBetween | ||
) { | ||
items(uiState.value.genreList) { genre -> | ||
items(uiState.genreList) { genre -> | ||
Text( | ||
text = genre, | ||
color = colorResource(R.color.gray_a3), | ||
|
@@ -98,18 +112,18 @@ fun HomeScreen(modifier: Modifier = Modifier) { | |
|
||
Spacer(Modifier.height(20.dp)) | ||
|
||
MainBannerPager(uiState.value.mainBannerList) | ||
MainBannerPager(uiState.mainBannerList) | ||
|
||
Spacer(Modifier.height(20.dp)) | ||
|
||
RecommendedContent(stringResource(R.string.home_editor_recommend_content), true) { | ||
ContentLazyList(uiState.value.editorRecomendList) | ||
ContentLazyList(uiState.editorRecommendList) | ||
} | ||
|
||
Spacer(Modifier.height(20.dp)) | ||
|
||
RecommendedContent(stringResource(R.string.home_today_top20), false) { | ||
Top20LazyList(uiState.value.top20List) | ||
Top20LazyList(uiState.top20List) | ||
} | ||
} | ||
} | ||
|
@@ -149,6 +163,6 @@ fun RecommendedContent( | |
@Preview | ||
@Composable | ||
private fun HomeScreenPreview() { | ||
HomeScreen() | ||
HomeRoute() | ||
Comment on lines
-152
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 변경하신 이유가 있나요? |
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.sopt.and.presentation.login | ||
|
||
import androidx.annotation.StringRes | ||
import org.sopt.and.presentation.util.base.UiEvent | ||
import org.sopt.and.presentation.util.base.UiSideEffect | ||
import org.sopt.and.presentation.util.base.UiState | ||
|
||
class LogInContract { | ||
data class LoginUiState( | ||
val isPasswordVisible: Boolean = false, | ||
val emailValue: String = "", | ||
val passwordValue: String = "" | ||
) : UiState | ||
|
||
sealed interface LogInSideEffect : UiSideEffect { | ||
data object NavigateToHome : LogInSideEffect | ||
data object NavigateToSignUp : LogInSideEffect | ||
data class ShowToast(@StringRes val message: Int) : LogInSideEffect | ||
data class ShowSnackBar(@StringRes val message: Int) : LogInSideEffect | ||
} | ||
|
||
sealed class LogInEvent : UiEvent { | ||
data class OnEmailValueChanged(val emailValue: String) : LogInEvent() | ||
data class OnPasswordValueChanged(val passwordValue: String) : LogInEvent() | ||
data object OnPasswordVisibleButtonClicked : LogInEvent() | ||
data object OnLogInButtonClicked : LogInEvent() | ||
data object OnSignUpButtonClicked : LogInEvent() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toast와 serverToast를 무슨 차이일까요 ?