-
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/week04 compose #6
base: develop-compose
Are you sure you want to change the base?
Conversation
๋ก๊ทธ์ธ ํ ๋ค๋น๊ฒ์ด์ ๋ฐ๋ก ๋ง์ดํ์ด์ง ์ด๋ ์ ์ธ์ ๋๊ฒจ์ฃผ์ง ์์์ ๊บผ์ง๋ ๋ฌธ์ ๋ทฐ๋ชจ๋ธ ์ด์ฉํด์ ํด๊ฒฐ
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.
์๊ณ ํ์ จ์ต๋๋ค!
popUpTo(Routes.Password.route) { | ||
inclusive = true | ||
} | ||
launchSingleTop = true |
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.
launchSingleTop = true
์ด ์ฝ๋๋ ์ด๋ค ์ผ์ ํ๋ ๊ฒ์ธ์ง ๊ถ๊ธํฉ๋๋ค!
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.
์ด๊ฑฐ ํด๋น ํ์ด์ง๋ฅผ ์คํ ๋งจ์๋ก ์ฌ๋ ค์ฃผ๋๊ฑฐ์์!
response: Response<ResponseLogInDto> | ||
) { | ||
if (response.isSuccessful) { | ||
val memberId = response.headers()["Location"]!!.toInt() |
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.
์ฌ๊ธฐ์ non-null ์ฐ์ฐ์๋ฅผ ์ฌ์ฉํ์ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค!
userId = response.body()!!.data.authenticationId | ||
userNickname = response.body()!!.data.nickname | ||
userPhone = response.body()!!.data.phone |
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.
๋ ์ฒ๋ฆฌ ๊ด๋ จํ์ฌ ์ข ๋ ์์ ํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํด๋ณด์๋ ๊ฒ์ ์ด๋จ๊น์?!
if (response.isSuccessful) { | ||
userId = response.body()!!.data.authenticationId | ||
userNickname = response.body()!!.data.nickname | ||
userPhone = response.body()!!.data.phone |
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.
response.body()์ ๋๋ฌด ๋ง์ด ์ ๊ทผํ๋ ๊ฒ ๊ฐ์ต๋๋ค! ์ค์ด๋ ๋ฐฉ๋ฒ์ ์์๊น์?
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.
์๋ ํ์ธ์ ๋ฏผ์๋. ์๋๋ก์ด๋ ํํธ ๋ช ์ OB ์ดํ์ฐ์ ๋๋ค. ๋ง๋์ ๋ฐ๊ฐ์ต๋๋ค.
์์ผ๋ก์ ๊ณผ์ ๋ค์ ๋ํ ์ฝ๋๋ฆฌ๋ทฐ๋ฅผ ๋งก๊ฒ ๋์์ต๋๋ค. ๊ณ ๋ฏผํด๋ณด์๋ค๊ฐ ๊ถ๊ธํ ์ ์ด ์์ผ์๋ฉด ์ง์ ๊ณต์ ๋ฐฉ/๋์ค์ฝ๋ ์ฐ๋ฝ ํด์ฃผ์ธ์. ๋๋ฉด/๋น๋๋ฉด ์์ ํ์์ผ๋ก ์ถ๊ฐ ํผ๋๋ฐฑ ๊ฐ๋ฅํฉ๋๋ค.
์ฐ์ ๊ณผ์ ์ด๋ ค์ฐ์ จ์ํ ๋ฐ ๋น ๋ฅด๊ฒ ๊ณผ์ ์ํํด์ฃผ์ ์ ๋๋ฌด ์ข์ต๋๋ค. ๊ด๋ จํด์ ์ถ๊ฐ์ ์ผ๋ก ํผ๋๋ฐฑ/์ง๋ฌธ ๋จ๊ธด ๊ฒ๋ค์ด ์์ต๋๋ค. ์ง๋ฌธ์ ๋จ๊ธด ๊ฒฝ์ฐ ์ฝ๋์ ๋ฌธ์ ๊ฐ ์์ด์ ์ง๋ฌธ์ด ๋จ๊ธด ๊ฒ์ด ์๋๊ณ ์ ๋ง ๋ฏผ์๋์ ์์ฑ ์๋๊ฐ ๊ถ๊ธํด์ ๋จ๊ธด ๊ฒ์ด๋ ์ด ์ ์ฐธ๊ณ ํด์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค.
์์ผ๋ก ์ ๋ถํ๋๋ฆฌ๊ฒ ์ต๋๋ค.
์ถ๊ฐ์ ์ผ๋ก ํ์ฌ ์ํ์ ๋ฐ๋ผ์ ํ๋ฉด์ ๊ทธ๋ฆฌ๋ ์ปดํฌ์ ๋ธ์ ๋ ๋๋ง ๊ณผ์ /์ํ๊ด๋ฆฌ/UI์ ViewModel์ ์ญํ ๋ถ๋ฆฌ์ ๋ํด ์ดํด๊ฐ ํ์ํ ๊ฒ ๊ฐ์ต๋๋ค. ํด๋น ๋ถ๋ถ์ ์ฝ๋๋ฉ ํน์ ์๋๋ก์ด๋ ๊ณต์ ์์ง์ ์ํ๋ค์ ํ์ธํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.
androidTestImplementation 'androidx.compose.ui:ui-test-junit4' | ||
debugImplementation 'androidx.compose.ui:ui-tooling' | ||
debugImplementation 'androidx.compose.ui:ui-test-manifest' | ||
implementation "androidx.navigation:navigation-compose:2.7.7" |
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.
์ค๋ณต์ ์ธ์ ๋๋ค.
fun BottomBar( | ||
navController: NavHostController, | ||
modifier: Modifier = Modifier, | ||
isLoggedIn: Boolean | ||
) { |
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.
Kotlin์์๋ ๋ชจ๋ ์ ํ์ ํจ๋ฌ๋ฏธํฐ(Optional Parameter, ๋ํดํธ ๊ฐ์ด ์ฃผ์ด์ง ํจ๋ฌ๋ฏธํฐ)๋ ํ์ ํจ๋ฌ๋ฏธํฐ ๋ค์ ๋ฐฐ์น๋์ด์ผํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ปดํฌ์ฆ์์๋ ๋ชจ๋ ์ ํ์ ํจ๋ฌ๋ฏธํฐ ์ ์ผ ์์ Modifier๊ฐ ๋ฐฐ์น๋์ด์ผ ํฉ๋๋ค...๋ผ๊ณ ์ฝ๋ฉ ์ปจ๋ฒค์ ์๋ ์ ํ ์์ต๋๋ค.
ํ์๋ ์๋์ง๋ง ๊ณตํต ๋ฃฐ์ ์ง์ผ๋ณด๋ฉด์ ์ฝ๋ ๊ฐ๋ ์ฑ ์ฌ๋ฆฌ๋ ๊ฒ์ ๋์์ด ๋ ์ ์์ ๊ฒ ๊ฐ์์ ๊ณต์ ๋๋ฆฝ๋๋ค.
fun BottomBar( | |
navController: NavHostController, | |
modifier: Modifier = Modifier, | |
isLoggedIn: Boolean | |
) { | |
fun BottomBar( | |
navController: NavHostController, | |
isLoggedIn: Boolean, | |
modifier: Modifier = Modifier, | |
) { |
if (isLoggedIn) { | ||
val navBackStackEntry by navController.currentBackStackEntryAsState() | ||
val currentRoute = navBackStackEntry?.destination?.route | ||
NavigationBar( | ||
modifier = modifier, | ||
containerColor = Color.LightGray, | ||
) { | ||
screens.forEach { screen -> | ||
|
||
NavigationBarItem( | ||
label = { | ||
Text(text = screen.title!!) | ||
}, | ||
icon = { | ||
Icon(imageVector = screen.icon!!, contentDescription = "") | ||
}, | ||
selected = currentRoute == screen.route, | ||
onClick = { | ||
navController.navigate(screen.route) | ||
}, | ||
colors = NavigationBarItemDefaults.colors( | ||
unselectedTextColor = Color.Gray, selectedTextColor = Color.White | ||
), | ||
) | ||
} | ||
} | ||
} |
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.
๋ง์ฝ ๋ฐํ ๋ฐ๊ฐ ๋ก๊ทธ์ธ๋ ์ํ ์ด์ธ์๋ ๋ณด์ฌ์ผ ํ๋ค๋ผ๋ ์๊ตฌ์ฌํญ ๋ณ๊ฒฝ์ด ๋ค์ด์ค๋ฉด ์ด๋ป๊ฒ ๋ ๊น์? ๊ทธ๋ฆฌ๊ณ ํน์ ์กฐ๊ฑด์์๋ ๋ณด์ด์ง ์์์ผ ํ๋ค๋ผ๋ ์กฐ๊ฑด์ด ์ถ๊ฐ๋๋ค๋ฉด์? ์ปดํฌ๋ํธ ๋จ์์ ์ด๋ฐ ์ฑ ๋ด ๊ธฐ๋ฅ ์๊ตฌ์ฌํญ๋ค์ ์์์ผ ํ ํ์๊ฐ ์์๊น์?
val screens = listOf( | ||
BottomNavItem.Home, BottomNavItem.Search, BottomNavItem.MyPage | ||
) |
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.
(์์ฃผ ์ฌ์ํ ๋ฆฌ๋ทฐ) ์ด ๋ฆฌ์คํธ๋ ์ปดํฌ์ ๋ธ ํจ์ ๊ทธ๋ ค์ง๋ ๋์ ๋จ ํ๋ฒ๋ง ํ ๋น ์ฐ์ฐ์ด ์คํ๋ ๊น์?
sealed class BottomNavItem( | ||
val route: String, | ||
val title: String? = null, | ||
val icon: ImageVector? = null | ||
) { | ||
data object Home : BottomNavItem( | ||
route = Routes.Home.route, | ||
title = "Home", | ||
icon = Icons.Default.Home | ||
) | ||
|
||
data object Search : BottomNavItem( | ||
route = Routes.Search.route, | ||
title = "Search", | ||
icon = Icons.Default.Search | ||
) | ||
|
||
data object MyPage : BottomNavItem( | ||
route = Routes.MyPage.route, | ||
title = "MyPage", | ||
icon = Icons.Default.Person | ||
) | ||
|
||
} |
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.
enum class๋ก๋ ๋ฐ๊ฟ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค.
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.
ํด๋น ๊ตฌ์กฐ๋ฅผ sealed๋ก ๋ง๋์ ์ด์ ๊ฐ ์์๊น์?
var previousPassword by remember { | ||
mutableStateOf("") | ||
} | ||
var newPassword by remember { | ||
mutableStateOf("") | ||
} | ||
var newPasswordCheck by remember { | ||
mutableStateOf("") | ||
} |
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.
๋ณ์๋ช ์ข์ต๋๋ค.
|
||
val navViewModel: NavViewModel = | ||
viewModel(viewModelStoreOwner = LocalNavGraphViewModelStoreOwner.current) | ||
val authService by lazy { ServicePool.authService } |
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.
ViewModel์ด ์ ์ธ๋์ด์๋๋ฐ, authService๋ฅผ ๋ทฐ๋จ์ ๋๊ณ ์จ ์ด์ ๊ฐ ์์๊น์? View์ ViewModel์ ์ด๋ ํ ์ญํ ์ ๋งก๊ณ ๊ตฌ๋ถ๋์ด์ผ ํ ๊น์?
fun changePassword(memberId: Int) { | ||
val passwordRequest = getPasswordRequestDto() | ||
authService.changePassword(memberId, passwordRequest) | ||
.enqueue(object : Callback<ResponseDto> { | ||
override fun onResponse( | ||
call: Call<ResponseDto>, | ||
response: Response<ResponseDto>, | ||
) { | ||
if (response.isSuccessful) { | ||
Toast.makeText( | ||
context, | ||
"๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ ์๋ฃ! ์ ๋น๋ฐ๋ฒํธ๋ก ๋ก๊ทธ์ธ ํ์ธ์", | ||
Toast.LENGTH_SHORT | ||
).show() | ||
navController.navigate(Routes.Login.route) { | ||
popUpTo(Routes.Login.route) { | ||
inclusive = true | ||
} | ||
launchSingleTop = true |
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.
์ด๋ฐ ๋ก์ง๋ค์ด ๋ทฐ์ ์์ผ๋ฉด ๋ทฐ๋ชจ๋ธ์ ๋ฐ๋ก ๊ตฌ๋ถํด๋ ํ์๊ฐ ์์๊น์?
) { | ||
|
||
var textId by remember { mutableStateOf("") } | ||
var textPw by remember { mutableStateOf("") } |
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.
์ถ์ฝ์ด ์ง์ํด์ฃผ์ธ์
val authService by lazy { ServicePool.authService } | ||
|
||
|
||
Log.d("MyPageScreen", "MyPageScreen start") |
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.
์ด ๋ก๊ทธ ๋จ ํ๋ฒ๋ง ์คํํ ๊น์?
๐ PR ์์ฝ
๐ฑ ์์ ํ ๋ด์ฉ
4์ฃผ์ฐจ compose ํ์๊ณผ์
๐ฑ PR ํฌ์ธํธ
API๋ฅผ ํตํด ํ์๊ฐ์ , ๋ก๊ทธ์ธ , ๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ ๊ตฌํ
๋ก๊ทธ์ธ์ด ๋๊ณ ๋๋ฉด ์ด์ ์คํ์ ์ง์ ๋ค๋ก๊ฐ๊ธฐ ๋ฒํผ ํด๋ฆญ์ ๋ก๊ทธ์ธ์ผ๋ก ๋์๊ฐ์ง ์๋๋ก ํจ
week04_compose.mp4