Break out TodoRowItem to a separate Composable

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-08-22 14:53:47 +05:30
parent 6558ec7909
commit af88005cb5
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -7,6 +7,7 @@ import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumnFor import androidx.compose.foundation.lazy.LazyColumnFor
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card import androidx.compose.material.Card
import androidx.compose.material.FloatingActionButton import androidx.compose.material.FloatingActionButton
@ -58,6 +59,14 @@ fun TodoApp() {
}, },
bodyContent = { bodyContent = {
LazyColumnFor(items = items, modifier = Modifier.padding(horizontal = 16.dp)) { todoItem -> LazyColumnFor(items = items, modifier = Modifier.padding(horizontal = 16.dp)) { todoItem ->
TodoRowItem(item = todoItem)
}
}
)
}
@Composable
fun LazyItemScope.TodoRowItem(item: TodoItem) {
Row( Row(
modifier = Modifier.padding(vertical = 8.dp).fillParentMaxWidth(), modifier = Modifier.padding(vertical = 8.dp).fillParentMaxWidth(),
) { ) {
@ -67,7 +76,7 @@ fun TodoApp() {
backgroundColor = Color.Black backgroundColor = Color.Black
) { ) {
Text( Text(
text = todoItem.title, text = item.title,
style = TextStyle( style = TextStyle(
color = Color.White, color = Color.White,
fontSize = 20.sp, fontSize = 20.sp,
@ -78,6 +87,3 @@ fun TodoApp() {
} }
} }
} }
}
)
}