Coder Social home page Coder Social logo

Comments (13)

ouattararomuald avatar ouattararomuald commented on July 4, 2024 5

Personally I use show() and hide() respectively for visibility = View.VISIBLE and visibility = View.INVISIBLE. For View.GONE what comes to my mind is gone() or disappear().

from android-ktx.

romainguy avatar romainguy commented on July 4, 2024 3

There is already a pending PR for these

from android-ktx.

JakeWharton avatar JakeWharton commented on July 4, 2024 3

Here's my take: https://github.com/android/android-ktx/compare/jakew/visibility-properties/2018-02-06

I'm not really a fan of the function approach to setting this state because it makes the code more verbose when dealing with booleans from a model or other conditional logic.

from android-ktx.

rock3r avatar rock3r commented on July 4, 2024 2

I sometimes add and use isVisible/isInvisible/isGone too

from android-ktx.

AkshayChordiya avatar AkshayChordiya commented on July 4, 2024 2

We can have:

fun View.visible() {
    visibility = View.VISIBLE
}

fun View.invisible() {
    visibility = View.INVISIBLE
}

fun View.gone() {
    visibility = View.GONE
}

If these look good then I can make a PR.

from android-ktx.

abbath0767 avatar abbath0767 commented on July 4, 2024

#137 - is first feature what i make in kotlin and use still now. I think they have almost every project and then they just have to be)

from android-ktx.

chrisbanes avatar chrisbanes commented on July 4, 2024

@ouattararomuald You're in for a bad time with show() and hide() on FloatingActionButton.

from android-ktx.

abbath0767 avatar abbath0767 commented on July 4, 2024

Here #146 variant of @ouattararomuald. I use the same naming for current extensions

from android-ktx.

ouattararomuald avatar ouattararomuald commented on July 4, 2024

@chrisbanes Thanks for pointing this out

from android-ktx.

romainguy avatar romainguy commented on July 4, 2024

@JakeWharton I like this property based approach. It also solves the naming problem with gone.

from android-ktx.

chrisbanes avatar chrisbanes commented on July 4, 2024

+1 to properties.

from android-ktx.

tiembo avatar tiembo commented on July 4, 2024

👍 for properties

from android-ktx.

abbath0767 avatar abbath0767 commented on July 4, 2024

Oh, i pushed new commit with solved problems after review from @JakeWharton. But i see new nice idea - change 6 functions to 3 properties. And i see what community likes the idea...

from android-ktx.

Related Issues (20)

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.