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
<?php | |
use Illuminate\Support\Facades\Schema; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class UpdateUsersTable extends Migration | |
{ | |
/** | |
* Run the migrations. |
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
<?php | |
use Illuminate\Database\Seeder; | |
use Illuminate\Support\Facades\Hash; | |
use App\Models\User; | |
class DatabaseSeeder extends Seeder | |
{ | |
/** | |
* Seed the application's database. |
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
/** Launcher activity **/ | |
package id.widiarifki.kitsu.presentation | |
import android.os.Bundle | |
import androidx.navigation.fragment.NavHostFragment | |
import androidx.navigation.ui.setupWithNavController | |
import com.google.android.material.bottomnavigation.BottomNavigationView | |
import dagger.hilt.android.AndroidEntryPoint | |
import id.widiarifki.kitsu.R | |
import id.widiarifki.kitsu.base.ui.activity.NonBindingActivity |
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
package app.pengadaan.helper | |
import android.graphics.Rect | |
import android.view.View | |
import androidx.recyclerview.widget.GridLayoutManager | |
import androidx.recyclerview.widget.LinearLayoutManager | |
import androidx.recyclerview.widget.RecyclerView | |
import androidx.recyclerview.widget.StaggeredGridLayoutManager | |
import kotlin.math.roundToInt |
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
class ShoppingListActivity : ComponentActivity() { | |
private val viewModel by viewModels<ShoppingListViewModel>() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
// observeAsState() hanya bisa dipanggil dari fungsi Composable | |
// tujuannya a/ utk mengobserve LiveData dan direpresentasikan ke dalam State | |
val shoppingItemsState = viewModel.shoppingItems.observeAsState(listOf()) |
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 ShoppingListScreen( | |
isLoading: Boolean, | |
shoppingItems: List<ShoppingItem>, | |
onAddItem: (ShoppingItem) -> Unit, | |
onToggleTickItem: (ShoppingItem) -> Unit, | |
onDeleteItem: (ShoppingItem) -> Unit | |
) { | |
// Content Container |
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
class ShoppingListViewModel( | |
private val repository: ShoppingItemRepository = ShoppingItemRepository() | |
) : ViewModel() { | |
// variables that hold state | |
var isLoading by mutableStateOf(true) | |
val shoppingItems: LiveData<List<ShoppingItem>> = getItems() | |
private fun getItems(): LiveData<List<ShoppingItem>> { | |
isLoading = true |
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
android { | |
// your other configuration.. | |
buildFeatures { | |
// enable jetpack compose in the module | |
compose true | |
} | |
// target Java compiler to Java 8 | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 |
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
@OptIn(ExperimentalMaterialApi::class) | |
@Composable | |
fun ShoppingItemCard( | |
shoppingItem: ShoppingItem, | |
onToggleTickItem: (ShoppingItem) -> Unit, | |
onDeleteItem: (ShoppingItem) -> Unit | |
) { | |
val swiperState = rememberDismissState( | |
confirmStateChange = { dismissValue -> | |
val isItemDismissed = dismissValue == DismissValue.DismissedToEnd |
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
@Preview(showBackground = true) | |
@Composable | |
fun PreviewShoppingListScreen() { | |
val previewItems = List(10) { index -> | |
ShoppingItem(id = index, name = "Item Preview $index") | |
} | |
MaterialTheme { | |
ShoppingListScreen( | |
isLoading = true, |
OlderNewer