Skip to content

Instantly share code, notes, and snippets.

@LargeTest
@RunWith(AndroidJUnit4::class)
class SignInActivityTest123 {
@Rule
@JvmField
var mActivityTestRule = ActivityTestRule(SignInActivity::class.java)
@Test
fun signInActivityTest123() {
val appCompatEditText = onView(
allOf(withId(R.id.email),
dependencies {
...
implementation 'androidx.compose:compose-compiler:0.1.0-dev04'
implementation 'androidx.compose:compose-runtime:0.1.0-dev04'
implementation 'androidx.ui:ui-layout:0.1.0-dev04'
implementation 'androidx.ui:ui-framework:0.1.0-dev04'
implementation 'androidx.ui:ui-layout:0.1.0-dev04'
implementation 'androidx.ui:ui-foundation:0.1.0-dev04'
implementation 'androidx.ui:ui-animation:0.1.0-dev04'
implementation 'androidx.ui:ui-tooling:0.1.0-dev04'
android {
...
composeOptions {
kotlinCompilerExtensionVersion "0.1.0-dev04"
}
}
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Text(text = "Hello, World")
}
}
}
data class CoffeeDrink(
val name: String,
@DrawableRes val imageUrl: Int,
val description: String,
val ingredients: String
)
fun getCoffeeDrinks(): List<CoffeeDrink> {
return listOf(
CoffeeDrink(
name = "Americano",
imageUrl = R.drawable.americano_small,
ingredients = "Espresso, Water"
),
CoffeeDrink(
name = "Cappuccino",
imageUrl = R.drawable.cappuccino_small,
@Composable
fun CoffeeDrinkCard(
coffeeDrink: CoffeeDrinkModel
) {
Row {
Container(modifier = LayoutSize(80.dp), alignment = Alignment.Center) {
DrawImage(image = imageResource(coffeeDrink.imageUrl))
}
Container(
alignment = Alignment.TopLeft,
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
CoffeeDrinksList(coffeeDrinks)
}
}
@Composable
fun CoffeeDrinkList(
coffeeDrinks: List<CoffeeDrink>
@AlexZhukovich
AlexZhukovich / gist:084fcf7d89e1080d574b62eb25b5a79b
Created February 7, 2020 12:17
Jetpack Compose - combine composable functions
@Composable
fun CoffeeDrinkCard(
coffeeDrink: CoffeeDrinkModel
) {
MaterialTheme {
Column {
Row {
CoffeeDrinkLogo(id = coffeeDrink.imageUrl)
Container(alignment = Alignment.TopLeft,modifier = LayoutFlexible(1f)) {
Column {