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

Nutri Capture - ์ฝ”๋“œ ์ •๋ฆฌ

interfacer_han 2025. 1. 29. 16:52

#1 ๊ฐœ์š”

์ฝ”๋“œ ์ตœ์ ํ™”๋ฅผ ํ•˜๊ธฐ ์•ž์„œ ๋‹น์žฅ ํ•„์š”์—†๋Š”, ๊ณ„๋ฅต๊ณผ๋„ ๊ฐ™์€ ์ฝ”๋“œ ์ „๋ถ€ ์ œ๊ฑฐํ–ˆ๋‹ค. ์ผ๋ก  ๋จธ์Šคํฌ์˜ ์‚ฌ๊ณ ๋ฒ•์— ์˜ํ•˜๋ฉด, "์ด๊ฑด ๊ฒฐ๊ตญ ๋‹ค์‹œ ๋„ฃ์–ด์•ผ ํ•  ๊ฒƒ ๊ฐ™์€๋ฐ?"๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์ง€ ์•Š์œผ๋ฉด ์ถฉ๋ถ„ํžˆ ์ œ๊ฑฐํ•˜์ง€ ์•Š์€ ๊ฒƒ์ด๋ฏ€๋กœ ์ •๋ง ์ฒ ์ €ํ•˜๊ฒŒ ์ œ๊ฑฐํ–ˆ๋‹ค.

 

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

#2-1 ์œ„์ž„ ํ”„๋กœํผํ‹ฐ

 

[Kotlin] ์œ„์ž„ ํ”„๋กœํผํ‹ฐ (Delegated properties)

#1 Delegated properties#1-1 ๊ฐœ์š” Delegated properties | Kotlin kotlinlang.org์œ„์ž„ ํ”„๋กœํผํ‹ฐ๋Š”, getter์™€ setter ๋กœ์ง์„ ๋‹ค๋ฅธ ํด๋ž˜์Šค์— ์œ„์ž„(delegate)ํ•˜๋Š” ์ฝ”ํ‹€๋ฆฐ ํ”„๋กœํผํ‹ฐ๋ฅผ ์˜๋ฏธํ•œ๋‹ค. ๋ณธ ๊ฒŒ์‹œ๊ธ€์—์„œ๋Š” ์œ„์ž„ ํ”„๋กœํผ

kenel.tistory.com

์œ„์™€ ๊ฐ™์ด ์œ„์ž„ ํ”„๋กœํผํ‹ฐ์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•ด๋†“๊ณ  ์ •์ž‘ ํ”„๋กœ์ ํŠธ์—๋Š” ์ ์šฉ์„ ํ•˜์ง€ ์•Š์•˜์—ˆ๋‹ค. ์ด์ œ๋ผ๋„ ์ ์šฉํ•œ๋‹ค.

 

#2-2 ์œ„์ž„ ํ”„๋กœํผํ‹ฐ ์‚ฌ์šฉ

// in NutrientScreen.kt

val inputtedText = remember { mutableStateOf("") }

์ด ์ฝ”๋“œ๋ฅผ

 

import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue

var inputtedText by remember { mutableStateOf("") }

์œ„์™€ ๊ฐ™์ด ๋ณ€๊ฒฝํ–ˆ๋‹ค.

 

#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