Skip to content

Instantly share code, notes, and snippets.

@yaraki
Created March 5, 2021 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaraki/7c7e9b3cc146d375cb6b1cc75fe778cd to your computer and use it in GitHub Desktop.
Save yaraki/7c7e9b3cc146d375cb6b1cc75fe778cd to your computer and use it in GitHub Desktop.
Common interface for Spacers in Column and Row
package com.example.android.codelab.animationdemo.ui
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@Composable
fun ColumnScope.Gap(height: Dp) = Spacer(modifier = Modifier.height(height))
@Composable
fun RowScope.Gap(width: Dp) = Spacer(modifier = Modifier.width(width))
@Composable
fun Usage() {
Column {
Text("A")
Gap(8.dp)
Text("B")
Gap(8.dp)
Row {
Text("C")
Gap(24.dp)
Text("D")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment