App 개발 일지/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