Skip to content

Instantly share code, notes, and snippets.

@josh-Muleshi
Forked from philipplackner/LiveTemplates.txt
Last active October 27, 2021 09:52
Show Gist options
  • Save josh-Muleshi/8e60aa423b0d1c1c758b9468e7045b05 to your computer and use it in GitHub Desktop.
Save josh-Muleshi/8e60aa423b0d1c1c758b9468e7045b05 to your computer and use it in GitHub Desktop.
1. hiltvm (applicable in top-level)
@dagger.hilt.android.lifecycle.HiltViewModel
class $NAME$ @javax.inject.Inject constructor(
$PARAM$
) : androidx.lifecycle.ViewModel() {
$END$
}
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 {
androidx.compose.runtime.mutableStateOf($INITIAL_VALUE$)
}
4. centerbox (applicable in Kotlin except Comment)
androidx.compose.foundation.layout.Box(
modifier = androidx.compose.ui.Modifier.fillMaxSize(),
contentAlignment = androidx.compose.ui.Alignment.Center
) {
$END$
}
5. iconbtn (applicable in Kotlin except Comment)
androidx.compose.material.IconButton(
onClick = {
},
) {
androidx.compose.material.Icon(
imageVector = $ICON$,
contentDescription = $CONTENT_DESCRIPTION$
)
}
------------------------------------------------------------------------------------------------
6. navfun (applicable in Kotlin except Comment)
@androidx.compose.runtime.Composable
fun Navigation($PARAM$: $TYPE$) {
NavHost(navController = $TYPE$, startDestination = "$ROOT$"){
composable("$ROOT$"){
$CODE$
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment