mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 06:47:02 +05:30
Break out TodoRowItem to a separate Composable
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
6558ec7909
commit
af88005cb5
1 changed files with 25 additions and 19 deletions
|
@ -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,
|
||||||
|
@ -77,7 +86,4 @@ fun TodoApp() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue