This file contains hidden or 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 | |
| private fun AnimeCard(animeModel: AnimeModel) { | |
| Card( | |
| shape = RoundedCornerShape(8.dp), | |
| modifier = Modifier | |
| .fillMaxWidth() | |
| .padding(8.dp, 4.dp), | |
| elevation = 8.dp, | |
| backgroundColor = if (animeModel.majorColor.isEmpty()) MaterialTheme.colors.primary | |
| else Color(android.graphics.Color.parseColor(animeModel.majorColor)) |
This file contains hidden or 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
| data class AnimeModel( | |
| val id: Int, | |
| val title: String, | |
| val coverImage: String, | |
| val majorColor: String, | |
| val genres: List<String>, | |
| val averageScore: Int | |
| ) |
This file contains hidden or 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 MainViewModel : ViewModel() { | |
| private val _count = MutableStateFlow(0) | |
| val count get() = _count.asStateFlow() | |
| init { | |
| _count.value = 0 | |
| } | |
| fun increase() { | |
| _count.value = _count.value.inc() |
This file contains hidden or 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 MainActivity : AppCompatActivity() { | |
| private val viewModel by viewModels<MainViewModel>() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContent { | |
| val count by viewModel.count.collectAsState() | |
| MdcTheme { |
This file contains hidden or 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 MainViewModel : ViewModel() { | |
| private val _count = MutableStateFlow(0) | |
| val count get() = _count.asStateFlow() | |
| init { | |
| _count.value = 0 | |
| } | |
| fun increase() { | |
| _count.value = _count.value.inc() |
This file contains hidden or 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 MainActivity : AppCompatActivity() { | |
| private lateinit var binding: ActivityMainBinding | |
| private val viewModel by viewModels<MainViewModel>() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| binding = ActivityMainBinding.inflate(layoutInflater) |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:gravity="center_vertical" | |
| android:orientation="horizontal" | |
| android:paddingHorizontal="16dp" | |
| tools:context=".MainActivity"> |
This file contains hidden or 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
| ... | |
| dependencies { | |
| ... | |
| classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1' | |
| } | |
| ... |
This file contains hidden or 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
| plugins { | |
| id 'com.android.application' | |
| id 'kotlin-android' | |
| id 'kotlin-kapt' | |
| id 'dagger.hilt.android.plugin' | |
| id("com.apollographql.apollo").version("2.5.10") | |
| } | |
| def apollo_version = "2.5.10" |
This file contains hidden or 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
| data class PokemonCardDetailViewState ( | |
| var data: PokemonCard? | |
| ) |
NewerOlder