Skip to content

Instantly share code, notes, and snippets.

Created August 27, 2021 08:27
Show Gist options
  • Save philipplackner/3d3b900d2e9128a37d7d5e6e8fac9e4f to your computer and use it in GitHub Desktop.
Save philipplackner/3d3b900d2e9128a37d7d5e6e8fac9e4f to your computer and use it in GitHub Desktop.
1. hiltvm (applicable in top-level)
class $NAME$ @javax.inject.Inject constructor(
) : androidx.lifecycle.ViewModel() {
2. vmstatefunc (applicable in class)
private val _$NAME$ = androidx.compose.runtime.mutableStateOf<$TYPE$>($INITIAL_VALUE$)
val $NAME$: androidx.compose.runtime.State<$TYPE$> = _$NAME$
fun $FUNC$($PARAM$: $TYPE$) {
_$NAME$.value = $PARAM$
3. remstate (applicable in Kotlin except Comment)
var $NAME$ by androidx.compose.runtime.remember {
4. centerbox (applicable in Kotlin except Comment)
modifier = androidx.compose.ui.Modifier.fillMaxSize(),
contentAlignment = androidx.compose.ui.Alignment.Center
) {
5. iconbtn (applicable in Kotlin except Comment)
onClick = {
) {
imageVector = $ICON$,
contentDescription = $CONTENT_DESCRIPTION$
Copy link

Thanks, man it's awesome

Copy link


Copy link

wow, this is amazing. thanks man

Copy link

Thanks philip!

Copy link

thank you Philipp Lackner, this will be helpful for me

Copy link

Awesome! as always, Thank you so much.

Copy link

Thank you so much

Copy link

They are so awesome Philip! Thanks a lot.

Copy link

Estete9 commented Nov 13, 2021

This is great Philipp! thanks a bunch

Copy link

modifier = androidx.compose.ui.Modifier

For those who find it annoying to write modifier=Modifier me.

Copy link

jefisu commented Mar 5, 2022

Thanks, Philipp.

Copy link

tnku sir <3

Copy link

Thanks Philipp very very helpful

Copy link

Thanks! Very helpful

Copy link


Copy link


Copy link

Coolightman commented Nov 25, 2022

I added to compose also:
'fmh' -> modifier = androidx.compose.ui.Modifier.fillMaxHeight()
'fmw' -> modifier = androidx.compose.ui.Modifier.fillMaxWidth()
'fms' -> modifier = androidx.compose.ui.Modifier.fillMaxSize()
'mmm' -> modifier: androidx.compose.ui.Modifier = Modifier
'mm' -> modifier = androidx.compose.ui.Modifier.$FUN$

Copy link

Very Helpful. Thank you Philipp!

Copy link

kamdaou commented Feb 1, 2023

You're amazing Philipp! Thanks

Copy link

A Great Help. Thanks A Lot -_-

Copy link

Thanks Philipp!

Copy link

arohim commented Feb 14, 2024

Thank you. very handy tool!

Copy link

Amazing! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment