This is an Android application that fetches and displays trending anime information using the Kitsu API. The app includes a splash screen, an onboarding screen, and uses the MVVM architecture. It also incorporates shared elements for smooth transitions between screens.
- Fetches trending anime information from the Kitsu API
- Splash screen
- Onboarding screen
- MVVM architecture
- Shared element transitions
- Jetpack Compose
- Kitsu API
- Hilt for Dependency Injection
- Coil for image loading
- kotlinx.serialization for navigation
- Android Studio
- Kotlin
-
Clone the repository:
git clone https://github.com/Bhavyansh03-tech/Anime_App.git
-
Open the project in Android Studio.
-
Build the project and run it on an emulator or a physical device.
AnimeViewModel
is responsible for fetching anime details and holding the data for AnimeScreen
.
@HiltViewModel
class AnimeViewModel @Inject constructor(
private val api: KitsuRepository
) : ViewModel() {
private var _anime = MutableStateFlow<AnimeData?>(null)
val anime = _anime.asStateFlow()
fun fetchAnime(id: Int) {
viewModelScope.launch {
_anime.update { api.getAnime(id) }
}
}
}
TrendingAnimeViewModel
is responsible for fetching anime details and holding the data for TrendingAnimeListScreen
.
@HiltViewModel
class TrendingAnimeViewModel @Inject constructor(
private val repository: KitsuRepository
) : ViewModel() {
private var _animeData = MutableStateFlow<List<AnimeData>>(emptyList())
val animeData = _animeData.asStateFlow()
init {
viewModelScope.launch {
_animeData.update { repository.getTrendingAnime() }
}
}
}
NavGraph SetUp
@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
fun NavGraph(
startDestination: Screens
) {
val navController = rememberNavController()
SharedTransitionLayout {
NavHost(
navController = navController,
startDestination = startDestination
) {
navigation<Screens.AppStartNavigation>(
startDestination = Screens.OnboardingScreen
){
composable<Screens.OnboardingScreen>{
// Initializing the view model :->
val viewModel = hiltViewModel<OnboardingViewModel>()
// Calling Onboarding Screen :->
OnboardingScreen(
event = viewModel::onEvent
)
}
}
navigation<Screens.HomeNavigator>(
startDestination = Screens.HomeScreen
) {
composable<Screens.HomeScreen> {
TrendingAnimeListScreen(
onAnimeClick = { coverImage, id ->
navController.navigate(
Screens.AnimeScreen(id.toString(), coverImage.toString())
)
},
animatedVisibilityScope = this
)
}
composable<Screens.AnimeScreen> {
val args = it.toRoute<Screens.AnimeScreen>()
AnimeScreen(
id = args.id.toInt(),
coverImage = args.coverImage,
animatedVisibilityScope = this
)
}
}
}
}
}
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Create a new Pull Request.
For questions or feedback, please contact @Bhavyansh03-tech on GitHub or connect with me on LinkedIn.