Move TodoRow to a separate file
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
@@ -4,12 +4,12 @@ import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.foundation.Icon
|
||||
import androidx.compose.foundation.Text
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumnFor
|
||||
import androidx.compose.foundation.lazy.LazyItemScope
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.FloatingActionButton
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Scaffold
|
||||
import androidx.compose.material.TopAppBar
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ExposurePlus1
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -17,12 +17,10 @@ import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.setContent
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.ui.tooling.preview.Preview
|
||||
import dev.msfjarvis.todo.data.TodoItem
|
||||
import dev.msfjarvis.todo.ui.TodoRowItem
|
||||
import dev.msfjarvis.todo.ui.TodoTheme
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
@@ -60,24 +58,3 @@ fun TodoApp() {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun LazyItemScope.TodoRowItem(item: TodoItem) {
|
||||
Row(
|
||||
modifier = Modifier.padding(vertical = 8.dp).fillParentMaxWidth(),
|
||||
) {
|
||||
Card(
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
modifier = Modifier.fillParentMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
text = item.title,
|
||||
style = TextStyle(
|
||||
fontSize = 20.sp,
|
||||
textAlign = TextAlign.Center
|
||||
),
|
||||
modifier = Modifier.padding(16.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package dev.msfjarvis.todo.ui
|
||||
|
||||
import androidx.compose.foundation.Text
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyItemScope
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import dev.msfjarvis.todo.data.TodoItem
|
||||
|
||||
@Composable
|
||||
fun LazyItemScope.TodoRowItem(item: TodoItem) {
|
||||
Row(
|
||||
modifier = Modifier.padding(vertical = 8.dp).fillParentMaxWidth(),
|
||||
) {
|
||||
Card(
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
modifier = Modifier.fillParentMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
text = item.title,
|
||||
style = TextStyle(
|
||||
fontSize = 20.sp,
|
||||
textAlign = TextAlign.Center
|
||||
),
|
||||
modifier = Modifier.padding(16.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user