This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity(tableName = "tbl_shopping_item") | |
data class ShoppingItem( | |
@PrimaryKey(autoGenerate = true) | |
val id: Int = 0, | |
@ColumnInfo(name = "name") | |
var name: String, | |
@ColumnInfo(name = "is_ticked") | |
var isTicked: Boolean = false | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
compose_version = '1.0.1' | |
// Compose need to use Kotlin v 1.5.10 or more | |
kotlin_version = '1.5.21' | |
} | |
dependencies { | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun LoadingIndicator(modifier: Modifier = Modifier) { | |
Box(modifier = modifier.fillMaxWidth(), contentAlignment = Alignment.Center) { | |
CircularProgressIndicator(color = MaterialTheme.colors.primary) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun EmptyState(modifier: Modifier = Modifier) { | |
Box(modifier = modifier.fillMaxWidth(), contentAlignment = Alignment.Center) { | |
Text( | |
text = "Yah, belum ada item belanja!", | |
style = MaterialTheme.typography.h5, | |
textAlign = TextAlign.Center | |
) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ShoppingList( | |
shoppingItems: List<ShoppingItem>, | |
onToggleTickItem: (ShoppingItem) -> Unit, | |
onDeleteItem: (ShoppingItem) -> Unit, | |
modifier: Modifier = Modifier | |
) { | |
LazyColumn(modifier.padding(8.dp)) { | |
items( | |
items = shoppingItems, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun FormInputContainer( | |
onAddItem: (ShoppingItem) -> Unit | |
) { | |
var newItem by remember { mutableStateOf("") } | |
val focusManager = LocalFocusManager.current | |
Row( | |
modifier = Modifier | |
.fillMaxWidth(1f) |
OlderNewer