-
Notifications
You must be signed in to change notification settings - Fork 2
[chore/#48] home 뷰 수정 #51
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
Changes from all commits
9dde444
dee5c12
4816e2a
37d9f17
811397f
f5cf2a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| package com.paw.key.presentation.ui.home | ||
|
|
||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| 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.width | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.collectAsState | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.vector.ImageVector | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.res.vectorResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.hilt.navigation.compose.hiltViewModel | ||
| import com.paw.key.R | ||
| import com.paw.key.core.designsystem.component.PawkeyButton | ||
| import com.paw.key.core.designsystem.theme.PawKeyTheme | ||
| import com.paw.key.core.util.noRippleClickable | ||
| import com.paw.key.presentation.ui.home.viewmodel.HomeViewModel | ||
| import com.paw.key.presentation.ui.signup.component.FormField | ||
| import com.paw.key.presentation.ui.signup.component.LocationButton | ||
| import com.paw.key.presentation.ui.signup.component.LocationList | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun PreviewHomeLocationSettingScreen() { | ||
| PawKeyTheme { | ||
| HomeLocationSettingScreen( | ||
| paddingValues = PaddingValues(), | ||
| navigateUp = {}, | ||
| navigateNext = {}, | ||
| navigateHomeLocationSetting = {} | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| fun HomeLocationSettingRoute( | ||
| paddingValues: PaddingValues, | ||
| navigateUp: () -> Unit, | ||
| navigateNext: () -> Unit, | ||
| navigateHomeLocationSetting: () -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| viewModel: HomeViewModel = hiltViewModel(), | ||
| ) { | ||
|
|
||
| HomeLocationSettingScreen( | ||
| paddingValues = paddingValues, | ||
| navigateUp = navigateUp, | ||
| navigateNext = navigateNext, | ||
| navigateHomeLocationSetting = navigateHomeLocationSetting, | ||
| modifier = modifier, | ||
| viewModel = viewModel | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| fun HomeLocationSettingScreen( | ||
| paddingValues: PaddingValues, | ||
| navigateUp: () -> Unit, | ||
| navigateNext: () -> Unit, | ||
| navigateHomeLocationSetting: () -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| viewModel: HomeViewModel = hiltViewModel(), | ||
| ) { | ||
| val state by viewModel.state.collectAsState() | ||
|
|
||
| Column( | ||
| modifier = modifier | ||
| .fillMaxSize() | ||
| .padding(horizontal = 16.dp) | ||
| ) { | ||
| Row( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .height(60.dp) | ||
| .padding(vertical = 16.dp), | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) | ||
| { | ||
| Icon( | ||
| imageVector = ImageVector.vectorResource(R.drawable.ic_arrow_left_black), | ||
| contentDescription = "뒤로가기", | ||
| modifier = Modifier | ||
| .noRippleClickable { navigateUp() } | ||
| ) | ||
| Box( | ||
| modifier = Modifier.weight(1f), | ||
| contentAlignment = Alignment.Center | ||
| ) { | ||
| Text( | ||
| text = "저장한 산책 루트", | ||
| style = PawKeyTheme.typography.body16Sb | ||
| ) | ||
| } | ||
| Spacer(modifier = Modifier.width(24.dp)) | ||
| } | ||
|
|
||
| Spacer(modifier = Modifier.height(24.dp)) | ||
|
|
||
| FormField( | ||
| label = stringResource(id = R.string.ic_onboarding_signup_main_location), | ||
| content = { | ||
| LocationButton( | ||
| isEnable = true, | ||
| location = "강남구", | ||
| onClick = { viewModel.toggleLocationMenu() } | ||
| ) | ||
| } | ||
| ) | ||
|
|
||
| Spacer(modifier = Modifier.height(46.dp)) | ||
|
|
||
| FormField( | ||
| label = stringResource(id = R.string.ic_onboarding_signup_sub_location), | ||
| content = { | ||
| if (state.isLocationMenuVisible) { | ||
| LocationList( | ||
| selected = state.selectedLocation, | ||
| locations = listOf("개포동", "논현동", "뭔동", "동동동", "스꾸삐", "4글자유"), | ||
|
Collaborator
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. 스꾸삐 먼가요 |
||
| onLocationSelected = { location -> | ||
| viewModel.selectLocation(location) | ||
| } | ||
| ) | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| Spacer(modifier = Modifier.weight(1f)) | ||
|
|
||
| val isFormValid = state.selectedLocation.isNotEmpty() | ||
|
Member
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. 이것도 상태에 관련된 내용이라 뷰모델에서 ㅎㅎ |
||
|
|
||
| PawkeyButton( | ||
| text = stringResource(id = R.string.ic_onboarding_signup_button), | ||
| enabled = isFormValid, | ||
| onClick = { | ||
| if (isFormValid) { | ||
|
Member
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. ? 무슨 용도죵 |
||
| } | ||
| } | ||
| ) | ||
|
|
||
| Spacer(modifier = Modifier.height(46.dp)) | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
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.
뷰모델을 파라미터로 넘길 경우 재사용성과 생명주기의 문제와 의존성 주입 원칙에 위배되기 때문에 state.~로 관찰한 값을 넘겨주세요
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.
엇...어엇.. 공부하겠습니다