๊ฐœ๋ฐœ ์ผ์ง€ ๐Ÿ’ป/Nutri Capture

Nutri Capture ํ”„๋ก ํŠธ์—”๋“œ - windowInsetsPadding()

interfacer_han 2025. 1. 29. 21:25

#1 ๋ฌธ์ œ ์ƒํ™ฉ

Scaffold์˜ bottomBar ์†์— Row(). ๊ทธ Row() ์†์— TextField()๊ฐ€ ์žˆ๋Š” ๊ตฌ์กฐ๋‹ค. TextField()๋ฅผ ํด๋ฆญํ•˜๋ฉด ์†Œํ”„ํŠธํ‚ค๋ณด๋“œ๊ฐ€ Row() ์ง์ „๊นŒ์ง€ ์˜ฌ๋ผ์˜ค๋Š” ๊ฑธ ์˜๋„ํ–ˆ์œผ๋‚˜, ์‹ค์ œ๋กœ๋Š” Row()์˜ ์˜์—ญ์„ ์นจ๋ฒ”ํ•˜์—ฌ TextField() ์ง์ „๊นŒ์ง€ ์˜ฌ๋ผ์˜จ๋‹ค.

 

#2 ์ฝ”๋“œ ์Šค๋‹ˆํŽซ

Scaffold(
    modifier = Modifier
        .fillMaxSize()
        .windowInsetsPadding(WindowInsets.ime), // <- ์ถ”๊ฐ€!
    bottomBar = {
        ...
    }
) { ...
    ...
}

Modifier์—  windowInsetsPadding()์„ ์ถ”๊ฐ€ํ•˜๋ฉด, ์‹œ์Šคํ…œ UI (์—ฌ๊ธฐ์„œ๋Š” ime(๊ฐ€์ƒํ‚ค๋ณด๋“œ)) ์˜์—ญ์— ๊ฐ€๋ ค์ง€์ง€ ์•Š๊ฒŒ ๋œ๋‹ค. ์ฃผ์˜ํ•  ์ ์€, windowInsetsPadding()์„ ๋ฐ˜๋“œ์‹œ Scaffold ์ž์ฒด์˜ Modifier์— ์ ์šฉํ•ด์•ผํ•œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ๊ฐ€๋ น, bottomBar ์† BottomAppBar()์˜ Modifier์— ์ ์šฉํ•œ๋‹ค๋“ ๊ฐ€ํ•˜๋ฉด ์ œ๋Œ€๋กœ ์ ์šฉ๋˜์ง€ ์•Š๊ณ  ๊ดด์ƒํ•œ ํ™”๋ฉด์ด ์ถœ๋ ฅ๋œ๋‹ค.

 

#3 ์™„์„ฑ๋œ ์•ฑ

#3-1 ์Šคํฌ๋ฆฐ์ƒท

 

#3-2 ์ด ๊ฒŒ์‹œ๊ธ€ ์‹œ์ ์˜ Commit

 

GitHub - Kanmanemone/nutri-capture-new

Contribute to Kanmanemone/nutri-capture-new development by creating an account on GitHub.

github.com

 

#3-3 ๋ณธ ํ”„๋กœ์ ํŠธ์˜ ๊ฐ€์žฅ ์ตœ์‹  Commit

 

GitHub - Kanmanemone/nutri-capture-new

Contribute to Kanmanemone/nutri-capture-new development by creating an account on GitHub.

github.com