• a

    allan.conda

    1 year ago
    Trying to annotate with data classes with
    @Immutable
    and read this bit:
    data
     classes that only contain 
    val
     properties that do not have custom getters can safely be marked as Immutable if the types of properties are either primitive types or also Immutable:
    And then looked at compose-samples
    @Immutable
    data class Episode(
        @PrimaryKey @ColumnInfo(name = "uri") val uri: String,
        @ColumnInfo(name = "podcast_uri") val podcastUri: String,
        @ColumnInfo(name = "title") val title: String,
        @ColumnInfo(name = "subtitle") val subtitle: String? = null,
        @ColumnInfo(name = "summary") val summary: String? = null,
        @ColumnInfo(name = "author") val author: String? = null,
        @ColumnInfo(name = "published") val published: OffsetDateTime,
        @ColumnInfo(name = "duration") val duration: Duration? = null
    )
    I have data classes with
    Date
    . Anyway it should still be safe to annotate as long as I’m sure it doesn’t get changed right? Also, I have states with single-time events:
    data class Event<out T>(val content: T) {
        var consumed: Boolean = false
            private set
    
        fun consume(): T? =
            if (consumed) {
                null
            } else {
                consumed = true
                content
            }
    }
    I guess I can’t use @Immutablefor such state classes…
    a
    1 replies
    Copy to Clipboard
  • popalay

    popalay

    1 year ago
    popalay
    1 replies
    Copy to Clipboard
  • fabio.carballo

    fabio.carballo

    1 year ago
    what is the best practice regarding the
    Component
    to use to just represent the
    background
    ? I understand the in MaterialTheme the
    Surface
    has a similar goal, but it takes by default the
    surfaceColor
    . In my case where I want the same practical use but so that the background color is always
    backgroundColor
    . From looking at usages, it seems only
    Scaffold
    actually uses this color, but internally still uses a
    Surface
    and changes the background color.
    fabio.carballo
    nickbutcher
    2 replies
    Copy to Clipboard
  • Javier

    Javier

    1 year ago
    @Ian Lake is there any more PR related with Navigation Args missing or the next snapshot will have Nav Args available?
    Javier
    i
    4 replies
    Copy to Clipboard
  • Mikael Alfredsson

    Mikael Alfredsson

    1 year ago
    I wanted to create a selfcontained “show version” component, simplest case would be like this
    @Composable
        fun versionText(){
            val versionName = packageManager.getPackageInfo(packageName, 0).versionName
            Text(text = versionName)
        }
    either this is the completely wrong way to do something like this, or I need some way to know if this composable is currently running in a preview, since the preview engine will not really show anything here (I think it even crashes silently somewhere)
    Mikael Alfredsson
    steelahhh
    4 replies
    Copy to Clipboard
  • alexandrepiveteau

    alexandrepiveteau

    1 year ago
    Hi ! Is there a way to apply a
    LinearGradient
    to a
    Text()
    composable ? I’ve looked a bit into the docs, but can only find usages of solid colors for text.
    alexandrepiveteau
    1 replies
    Copy to Clipboard
  • i

    Ian Lake

    1 year ago
    PSA for snapshot users: the main AndroidX build and the Compose build have recently been merged. This means that the
    /ui/
    part of your snapshot build URL should be removed and the URL should be in the format:
    maven { url '<https://androidx.dev/snapshots/builds/[buildId]/artifacts/repository>' }
    i
    2 replies
    Copy to Clipboard
  • i

    Ian Lake

    1 year ago
    PSA for Navigation snapshot users: the Compose Navigation artifact group+name has been changed. It is now
    androidx.navigation:navigation-compose:1.0.0-SNAPSHOT
    (using build IDs of 6910220 or higher - make sure to switch to the new snapshot URL format ^). Working towards the first alpha 🙂
    i
    bryansills
    +2
    11 replies
    Copy to Clipboard
  • bryansills

    bryansills

    1 year ago
    speaking of navigation, should something like this work?
    @Composable
    fun BasicNav() {
        var isLoggedIn by remember { mutableStateOf(false) }
        NavHost(startDestination = "Profile") {
            composable("Profile") { Profile(isLoggedIn) { isLoggedIn = !isLoggedIn } }
            composable("Dashboard") { Dashboard() }
            if (isLoggedIn) {
                composable("Scrollable") { Scrollable() }
            }
        }
    }
    (the lambda passed into
    Profile()
    ) is just connected to a
    Button
    to toggle the logged in state
    bryansills
    i
    5 replies
    Copy to Clipboard
  • dmnk_89

    dmnk_89

    1 year ago
    hi! Is there a simple way to make a
    OutlinedTextField
    non editable? So that it like gray and doesn't show keyboard when focused.
    dmnk_89
    Siyamed
    +1
    3 replies
    Copy to Clipboard