-
Notifications
You must be signed in to change notification settings - Fork 34
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
๐ 1๋จ๊ณ - ์ฅ๋ฐ๊ตฌ๋(์ํ ๋ชฉ๋ก) #79
base: dothebestmayb
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.
์ข
์ฑ๋ ์๋
ํ์ธ์! ์ฅ๋ฐ๊ตฌ๋ ๋ฏธ์
๋์ ์ ๋ถํ๋๋ฆฝ๋๋ค!
์ฅ๋ฐ๊ตฌ๋ ๋ฏธ์
1๋จ๊ณ๋ฅผ ์ ๊ตฌํํด์ฃผ์
์ ์ฝ๋ฉํธ ๋๋ฆด๊ฒ ๋ง์ด ์๋ค์!
์ ์ ๊ถ๊ธ์ฆ๊ณผ ์๊ฒฌ์ ๋ช๊ฐ์ง ๋จ๊ฒจ๋๋ฆฝ๋๋ค ใ
ใ
.padding(top = 8.dp, start = 4.dp) | ||
) | ||
Text( | ||
text = stringResource(R.string.product_price_format, priceFormat.format(product.price)), |
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.
10000 ์ด๋ผ๋ int๋ฅผ 10,000์ ์ด๋ผ๊ณ ๋ณ๊ฒฝํ๊ธฐ ์ํด์ NumberFormat ์ ์ฌ์ฉํ์ จ๋ค์!
์ ๋ ์ด๋ ๊ฒ ๊ฐ๋จํ๊ฒ ๋ณ๊ฒฝํ๋ ๊ฑฐ๋ผ๋ฉด Int -> String -> String์ผ๋ก ๋ณํํ๊ธฐ ๋ณด๋ค string resource์ ์ ์ธํ ๋ ํ๋ฒ์ formatting ๋๋๋ก ํด๋ณผ ๊ฒ ๊ฐ์์
์ ๋ฐฉ์์ด ์ ๋ต์ ์๋์ง๋ง ์ด๋ ๊ฒ ํ๋ ๋ฐฉ๋ฒ๋ ์๋ค ์ ๋๋ก ์ดํดํด์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค
string format ๊ด๋ จํด์ ๊ฒ์ํ์๋ฉด ์๋ฃ๊ฐ ๋ง์ด ์์๊บผ๋ผ์ ์ฐธ๊ณ ํด๋ณด๊ณ ๋ฐ์ํด๋ณด์๋ ๊ฒ๋ ์ข์ ๊ฒ ๊ฐ์์~
|
||
// viewModel์ด ์์ผ๋ฏ๋ก ์ฌ๊ธฐ์ ์์ดํ ๋ชฉ๋ก์ ๊ฐ์ ธ์จ๋ค. | ||
LaunchedEffect(true) { | ||
state = state.copy(isLoading = 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.
ProductListState์ isLoading์ด ๊ธฐ๋ณธ๊ฐ์ด true ์ธ๋ฐ LauncedEffect ๋ด๋ถ์์ true๋ก ์ด๊ธฐํ ํด์ฃผ์๋ ์ด์ ๊ฐ ์๋์ง ๊ถ๊ธํฉ๋๋ค
} | ||
|
||
// viewModel์ด ์์ผ๋ฏ๋ก ์ฌ๊ธฐ์ ์์ดํ ๋ชฉ๋ก์ ๊ฐ์ ธ์จ๋ค. | ||
LaunchedEffect(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.
์ ๋ ๋ณดํต 1ํ์ฑ์ผ๋ก ํ ๋ Unit์ ์ฌ์ฉํ๋ ํธ์ธ๋ฐ true์ธ Boolean๊ฐ์ ๋ฃ์ด์ฃผ์ ์ด์ ๊ฐ ๊ถ๊ธํด์
if (!state.isLoading) { | ||
ProductListScreen( | ||
state = state, | ||
modifier = modifier, | ||
) | ||
} |
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.
isLoading์ด true์ผ ๋ ์ผ์ด์ค๋ ์์ผ๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ์๋ฐ ์ด๋ป๊ฒ ์๊ฐํ์๋์?
if (showScrollToTopButton) { | ||
FloatingActionButton( | ||
modifier = Modifier | ||
.padding(bottom = 16.dp, end = 16.dp), | ||
onClick = { | ||
scope.launch { | ||
lazyState.animateScrollToItem(0) | ||
} | ||
}, | ||
containerColor = MaterialTheme.colorScheme.primary | ||
) { | ||
Icon( | ||
imageVector = Icons.Default.KeyboardArrowUp, | ||
contentDescription = null, | ||
) | ||
} | ||
} |
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๋ก visible์ฒ๋ฆฌ ํ๋ ๊ฒ ๋ณด๋ค AnimatedVisibility๋ผ๋ ๊ฒ์ ์ฐ๋ฉด ๋ ์์ฐ์ค๋ฝ๊ฒ ๋ง๋ค์ด ๋ณผ ์ ์์ ๊ฒ ๊ฐ์์!
// footer ์ฌ๋ฐฑ | ||
item { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(100.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.
์คํฌ๋ฃฐ ๋งจ ๋ง์ง๋ง์ ์ฌ๋ฐฑ์ ์ฃผ๊ณ ์ถ์ ๊ฑฐ๋ผ๋ฉด LazyVerticalGrid ํ๋ผ๋ฏธํฐ์ contentPadding์ ๋ฃ์ด์ค๋ ๋ ๊ฒ ๊ฐ์์! ํน์ ๋ค๋ฅธ ์๋๊ฐ ์๋ค๋ฉด ๋ง์ํด์ฃผ์ธ์~
|
๊ณ ๋ฏผํ ๋ด์ฉ๊ณผ ์ด๋ ๊ฒ ๊ตฌํํ ์ด์
์ฐธ๊ณ ์๋ฃ : https://www.youtube.com/watch?v=NKtMQd9Izcw