Create Composables with Jetpack Compose

Sep 10 2024 · Kotlin 1.9, Android 14, Android Studio Jellyfish | 2023.3.1

Lesson 03: Building Layout with Composables

Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this demo, you’ll use layout composables to build out the Github repo list UI.

val state by viewModel.state.observeAsState()  
Column(modifier = Modifier.padding(16.dp)) {  

}
import androidx.compose.ui.Modifier
import androidx.compose.runtime.getValue
import androidx.compose.ui.unit.dp
state?.forEach { repo ->
	//TODO add card UI
}
Box {
  Row(
    verticalAlignment = Alignment.CenterVertically,  
    modifier = Modifier.padding(16.dp)) {   
			AsyncImage(  
				modifier = Modifier  
				.size(75.dp)  
				.clip(CircleShape),  
				model = repo.owner.avatarUrl,  
						contentDescription = null
			)
  }
}
Column(  
	modifier = Modifier  
	.fillMaxWidth()  
	.padding(16.dp)
) {  
	
	Text(  
		text = repo.name,  
		fontSize = 16.sp,  
		fontWeight = FontWeight.SemiBold
	)  

	Spacer(modifier = Modifier.height(8.dp))  

	repo.description?.let { Text(text = it) }  
}
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction Next: Conclusion