-
-
Save yrezgui/26a1060d67bf0ec2a73fa12695166436 to your computer and use it in GitHub Desktop.
package com.example.compose.tutorial | |
object SampleData { | |
// Sample conversation data | |
val conversationSample = listOf( | |
Message( | |
"Colleague", | |
"Test...Test...Test..." | |
), | |
Message( | |
"Colleague", | |
"List of Android versions:\n" + | |
"Android KitKat (API 19)\n" + | |
"Android Lollipop (API 21)\n" + | |
"Android Marshmallow (API 23)\n" + | |
"Android Nougat (API 24)\n" + | |
"Android Oreo (API 26)\n" + | |
"Android Pie (API 28)\n" + | |
"Android 10 (API 29)\n" + | |
"Android 11 (API 30)\n" + | |
"Android 12 (API 31)\n" | |
), | |
Message( | |
"Colleague", | |
"I think Kotlin is my favorite programming language.\n" + | |
"It's so much fun!" | |
), | |
Message( | |
"Colleague", | |
"Searching for alternatives to XML layouts..." | |
), | |
Message( | |
"Colleague", | |
"Hey, take a look at Jetpack Compose, it's great!\n" + | |
"It's the Android's modern toolkit for building native UI." + | |
"It simplifies and accelerates UI development on Android." + | |
"Less code, powerful tools, and intuitive Kotlin APIs :)" | |
), | |
Message( | |
"Colleague", | |
"It's available from API 21+ :)" | |
), | |
Message( | |
"Colleague", | |
"Writing Kotlin for UI seems so natural, Compose where have you been all my life?" | |
), | |
Message( | |
"Colleague", | |
"Android Studio next version's name is Arctic Fox" | |
), | |
Message( | |
"Colleague", | |
"Android Studio Arctic Fox tooling for Compose is top notch ^_^" | |
), | |
Message( | |
"Colleague", | |
"I didn't know you can now run the emulator directly from Android Studio" | |
), | |
Message( | |
"Colleague", | |
"Compose Previews are great to check quickly how a composable layout looks like" | |
), | |
Message( | |
"Colleague", | |
"Previews are also interactive after enabling the experimental setting" | |
), | |
Message( | |
"Colleague", | |
"Have you tried writing build.gradle with KTS?" | |
), | |
) | |
} |
interesting ✨✨✨
I agree with your idea.
@j-m-hoffmann Thank you 👍
Does anyone know how to add 3 dots (...
) at the end of the line when not expanded?
I imagine this is hard because you'd have to know the last 3 chars shown on the line and then replace them with ...
and then ensure the line still displays them (didn't grow).
Or perhaps there's a better/idiomatic way to mark a message as incompletely-showing and thus in need of expansion?
Another,unrelated, thing:
EDIT: [SOLVED] by replacing remember
with rememberSaveable
yay!(thanks to this and this) // Does anyone know how to not lose the state of the expansion even though you scrolled away ? for example, expand the second entry then scroll to the bottom, then scroll back up, the second entry is no longer expanded! The state of isExpanded was lost and reset to false... This is rather unexpected (from the UI perspective)... (but of course code-wise it makes sense that the value false gets set when recomposition happens)
To import it right click in Project tab, Android selected in dropdown.
Right-click on
app > java > dev.yourname.composetutorial
thenNew > Kotlin Class/File
and just paste content from this gist.
thank for the screenshot and help. Also how do you have the package name dev.username.[something] I only have com.example.composetutorial
thanks very much.
thanks very much.
You're welcome, glad that my response helped out.
I agree with @j-m-hoffmann's approach of using Kotlin's
String Literals
.Less code and easier to read!