Coder Social home page Coder Social logo

Comments (4)

taehwandev avatar taehwandev commented on June 1, 2024

올려주신 코드의 Modifier는 적절한 방법이 아닙니다.

`fun BusinessCard(
modifier: Modifier
) {
Column() {
Column(
modifier = modifier.weight(7f)
) {
BusinessCardTop(
modifier = modifier
)
}

    Column(
        modifier = modifier.weight(3f)
    ) {
        BusinessCardInfo(
            modifier = modifier
        )
    }
}

} `

이렇게 하시면 modifier 의 속성을 외부에서 변경 시 모든 ui에 동일한 옵션이 적용됩니다.

Modifier는 그냥 객체를 생성하고 이걸 이용한 레이아웃의 뷰의 배경을 설정하거나 shape를 설정하거나 클릭을 처리합니다. 말그대로 뷰 별로 뷰의 속성을 말합니다.
이를 위 코드처럼 활용하시면 이미 적절한 UI가 노출되지 않습니다.
현재야 별 옵션이 없어서 그냥 넘어가겠지만

뷰 별로 설정을 추가할때마다 새로운 객체가 아니기때문에 옵션을 이어서 그대로 merge 합니다.

내부 코드를 살펴보시면 모두 다른 옵션을 제공해줌을 알 수 있습니다.

이는 객체로서의 옵션으로 접근하셔야 합니다.

from composecamp2022-for-beginners.

zkzkzhzj avatar zkzkzhzj commented on June 1, 2024

앗. 감사합니다
그렇다면 말씀하신 내용이 최상단에 속성값없는 의미없는 modifier 를 주어 넘겨주어 변수처럼 사용하는것 보단 말그대로 옵션의 의미로 중복된다면 만들어 넘겨주면 좋겠지만 그때 그때 선언하는게 좋다는 말씀이 맞으실까요?

Modifier 객체를 재사용시 메모리가 절약될까 싶어 잘못사용하고있었네요!
감사합니다

from composecamp2022-for-beginners.

taehwandev avatar taehwandev commented on June 1, 2024

보통 함수에 넘겨주는 Modifier는 해당 코드 내의 최상위 컨테이너에 대한 Modifier를 외부에서 추가로 정의 가능함을 말합니다.
만약 이를 수정하지 않도록 하려면 Modifier를 넘겨주지 않도록 만드시면 됩니다.
참고로 모든 코드에서 Modifier를 외부 주입하지 않아도 내부에서 새로운 Modifier를 생성하여 사용합니다.

참고로 이정도의 메모리는 유의미 하지 않습니다. 정말 필요한 부분의 메모리를 줄이는것이 최적화입니다. 이정도의 메모리는 필요한 부분에 대한 메모리일 뿐…

from composecamp2022-for-beginners.

zkzkzhzj avatar zkzkzhzj commented on June 1, 2024

바보같은 고민을 하고있었네요ㅜ.ㅜ
감사합니다! CS공부의 부족함을 느끼네요 하하

from composecamp2022-for-beginners.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.