diff --git a/app/src/main/java/com/techlads/composetv/favorites/SearchScreen.kt b/app/src/main/java/com/techlads/composetv/favorites/SearchScreen.kt new file mode 100644 index 0000000..8a7837e --- /dev/null +++ b/app/src/main/java/com/techlads/composetv/favorites/SearchScreen.kt @@ -0,0 +1,23 @@ +package com.techlads.composetv.favorites + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview + +@Composable +fun FavoritesScreen(){ + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(text = "Favorites") + } +} + + +@Preview +@Composable +fun FavoritesScreenPrev() { + FavoritesScreen() +} \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/home/HomeNestedScreen.kt b/app/src/main/java/com/techlads/composetv/home/HomeNestedScreen.kt new file mode 100644 index 0000000..ad5f3f2 --- /dev/null +++ b/app/src/main/java/com/techlads/composetv/home/HomeNestedScreen.kt @@ -0,0 +1,16 @@ +package com.techlads.composetv.home + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import com.techlads.composetv.hero.HeroItem +import com.techlads.composetv.home.carousel.HomeCarousel + +@Composable +fun HomeNestedScreen(){ + Column(Modifier.fillMaxSize()) { + HeroItem() + HomeCarousel(Modifier.weight(1f)) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/home/HomeScreenContent.kt b/app/src/main/java/com/techlads/composetv/home/HomeScreenContent.kt index 28ee03a..50b7d21 100644 --- a/app/src/main/java/com/techlads/composetv/home/HomeScreenContent.kt +++ b/app/src/main/java/com/techlads/composetv/home/HomeScreenContent.kt @@ -1,5 +1,6 @@ package com.techlads.composetv.home +import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.runtime.Composable @@ -7,12 +8,17 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview +import com.google.accompanist.navigation.animation.rememberAnimatedNavController import com.techlads.composetv.home.navigation.NestedHomeNavigation import com.techlads.composetv.leftmenu.LeftMenu import com.techlads.composetv.leftmenu.data.MenuData +@OptIn(ExperimentalAnimationApi::class) @Composable fun HomeScreenContent() { + + val navController = rememberAnimatedNavController() + val isExpanded = remember { mutableStateOf(false) } @@ -27,9 +33,10 @@ fun HomeScreenContent() { isExpanded.value = !isExpanded.value && isSelected } ) { - + navController.navigate(it.id) } - NestedHomeNavigation() + + NestedHomeNavigation(navController) } } diff --git a/app/src/main/java/com/techlads/composetv/home/MenuData.kt b/app/src/main/java/com/techlads/composetv/home/MenuData.kt deleted file mode 100644 index 0b08d06..0000000 --- a/app/src/main/java/com/techlads/composetv/home/MenuData.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.techlads.composetv.home - -import com.techlads.composetv.leftmenu.model.MenuItem -import compose.icons.LineAwesomeIcons -import compose.icons.lineawesomeicons.* - -object MenuData { - val menuItems = listOf( - MenuItem("", "Home", LineAwesomeIcons.HomeSolid), - MenuItem("", "Search", LineAwesomeIcons.SearchSolid), - MenuItem("", "Movies", LineAwesomeIcons.VideoSolid), - MenuItem("", "Songs", LineAwesomeIcons.MusicSolid), - MenuItem("", "Favorites", LineAwesomeIcons.HeartSolid), - ) -} \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/home/navigation/NestedHomeNavigation.kt b/app/src/main/java/com/techlads/composetv/home/navigation/NestedHomeNavigation.kt index 4ba1813..cf7a425 100644 --- a/app/src/main/java/com/techlads/composetv/home/navigation/NestedHomeNavigation.kt +++ b/app/src/main/java/com/techlads/composetv/home/navigation/NestedHomeNavigation.kt @@ -1,23 +1,19 @@ package com.techlads.composetv.home.navigation -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview -import com.techlads.composetv.hero.HeroItem -import com.techlads.composetv.home.carousel.HomeCarousel +import androidx.navigation.NavHostController +import com.google.accompanist.navigation.animation.rememberAnimatedNavController @Composable -fun NestedHomeNavigation() { - Column(Modifier.fillMaxSize()) { - HeroItem() - HomeCarousel(Modifier.weight(1f)) - } +fun NestedHomeNavigation(navController: NavHostController) { + NestedHomeScreenNavigation(navController) } +@OptIn(ExperimentalAnimationApi::class) @Preview @Composable fun NestedHomeNavigationPrev() { - NestedHomeNavigation() + NestedHomeNavigation(rememberAnimatedNavController()) } \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/home/navigation/NestedHomeScreenNavigation.kt b/app/src/main/java/com/techlads/composetv/home/navigation/NestedHomeScreenNavigation.kt new file mode 100644 index 0000000..91d4a08 --- /dev/null +++ b/app/src/main/java/com/techlads/composetv/home/navigation/NestedHomeScreenNavigation.kt @@ -0,0 +1,64 @@ +package com.techlads.composetv.home.navigation + +import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.runtime.Composable +import androidx.navigation.NavHostController +import com.google.accompanist.navigation.animation.AnimatedNavHost +import com.google.accompanist.navigation.animation.composable +import com.techlads.composetv.favorites.FavoritesScreen +import com.techlads.composetv.home.HomeNestedScreen +import com.techlads.composetv.movies.MoviesScreen +import com.techlads.composetv.navigation.tabEnterTransition +import com.techlads.composetv.navigation.tabExitTransition +import com.techlads.composetv.search.SearchScreen +import com.techlads.composetv.settings.SettingsScreen +import com.techlads.composetv.songs.SongsScreen + +@OptIn(ExperimentalAnimationApi::class) +@Composable +fun NestedHomeScreenNavigation(navController: NavHostController) { + AnimatedNavHost(navController = navController, startDestination = NestedScreens.Home.title) { + // e.g will add auth routes here if when we will extend project + composable( + NestedScreens.Home.title, + enterTransition = { tabEnterTransition() }, + exitTransition = { tabExitTransition() }) { + HomeNestedScreen() + } + + composable( + NestedScreens.Search.title, + enterTransition = { tabEnterTransition() }, + exitTransition = { tabExitTransition() }) { + SearchScreen() + } + + composable( + NestedScreens.Movies.title, + enterTransition = { tabEnterTransition() }, + exitTransition = { tabExitTransition() }) { + MoviesScreen() + } + + composable( + NestedScreens.Songs.title, + enterTransition = { tabEnterTransition() }, + exitTransition = { tabExitTransition() }) { + SongsScreen() + } + + composable( + NestedScreens.Favorites.title, + enterTransition = { tabEnterTransition() }, + exitTransition = { tabExitTransition() }) { + FavoritesScreen() + } + + composable( + NestedScreens.Settings.title, + enterTransition = { tabEnterTransition() }, + exitTransition = { tabExitTransition() }) { + SettingsScreen() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/home/navigation/NestedScreens.kt b/app/src/main/java/com/techlads/composetv/home/navigation/NestedScreens.kt new file mode 100644 index 0000000..3555782 --- /dev/null +++ b/app/src/main/java/com/techlads/composetv/home/navigation/NestedScreens.kt @@ -0,0 +1,10 @@ +package com.techlads.composetv.home.navigation + +sealed class NestedScreens(val title: String) { + object Home : NestedScreens("home") + object Search : NestedScreens("search") + object Movies : NestedScreens("movies") + object Songs : NestedScreens("songs") + object Favorites : NestedScreens("favourites") + object Settings : NestedScreens("settings") +} \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/leftmenu/LeftMenu.kt b/app/src/main/java/com/techlads/composetv/leftmenu/LeftMenu.kt index 6798a10..e9b3881 100644 --- a/app/src/main/java/com/techlads/composetv/leftmenu/LeftMenu.kt +++ b/app/src/main/java/com/techlads/composetv/leftmenu/LeftMenu.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.techlads.composetv.home.navigation.NestedScreens import com.techlads.composetv.leftmenu.model.MenuItem import compose.icons.LineAwesomeIcons import compose.icons.lineawesomeicons.CogSolid @@ -63,7 +64,7 @@ fun LeftMenu( ) Spacer(modifier = Modifier.weight(1f)) LeftMenuItem( - menuItem = MenuItem("", "Settings", LineAwesomeIcons.CogSolid), + menuItem = MenuItem(NestedScreens.Settings.title, "Settings", LineAwesomeIcons.CogSolid), modifier = Modifier.fillMaxWidth(), expanded = isExpanded, onMenuFocused = onMenuFocused, diff --git a/app/src/main/java/com/techlads/composetv/leftmenu/data/MenuData.kt b/app/src/main/java/com/techlads/composetv/leftmenu/data/MenuData.kt index 066a98d..bfef518 100644 --- a/app/src/main/java/com/techlads/composetv/leftmenu/data/MenuData.kt +++ b/app/src/main/java/com/techlads/composetv/leftmenu/data/MenuData.kt @@ -1,15 +1,16 @@ package com.techlads.composetv.leftmenu.data +import com.techlads.composetv.home.navigation.NestedScreens.* import com.techlads.composetv.leftmenu.model.MenuItem import compose.icons.LineAwesomeIcons import compose.icons.lineawesomeicons.* object MenuData { val menuItems = listOf( - MenuItem("", "Home", LineAwesomeIcons.HomeSolid), - MenuItem("", "Search", LineAwesomeIcons.SearchSolid), - MenuItem("", "Movies", LineAwesomeIcons.VideoSolid), - MenuItem("", "Songs", LineAwesomeIcons.MusicSolid), - MenuItem("", "Favorites", LineAwesomeIcons.HeartSolid), + MenuItem(Home.title, "Home", LineAwesomeIcons.HomeSolid), + MenuItem(Search.title, "Search", LineAwesomeIcons.SearchSolid), + MenuItem(Movies.title, "Movies", LineAwesomeIcons.VideoSolid), + MenuItem(Songs.title, "Songs", LineAwesomeIcons.MusicSolid), + MenuItem(Favorites.title, "Favorites", LineAwesomeIcons.HeartSolid), ) } \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/movies/MoviesScreen.kt b/app/src/main/java/com/techlads/composetv/movies/MoviesScreen.kt new file mode 100644 index 0000000..fd31ce0 --- /dev/null +++ b/app/src/main/java/com/techlads/composetv/movies/MoviesScreen.kt @@ -0,0 +1,23 @@ +package com.techlads.composetv.movies + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview + +@Composable +fun MoviesScreen(){ + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(text = "Movies") + } +} + + +@Preview +@Composable +fun MoviesScreenPrev() { + MoviesScreen() +} \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/navigation/AppNavigation.kt b/app/src/main/java/com/techlads/composetv/navigation/AppNavigation.kt index a7f9960..7cd58eb 100644 --- a/app/src/main/java/com/techlads/composetv/navigation/AppNavigation.kt +++ b/app/src/main/java/com/techlads/composetv/navigation/AppNavigation.kt @@ -46,11 +46,11 @@ fun AppNavigation(navController: NavHostController) { } } -private fun tabExitTransition( +fun tabExitTransition( duration: Int = 500 ) = fadeOut(tween(duration / 2, easing = LinearEasing)) -private fun tabEnterTransition( +fun tabEnterTransition( duration: Int = 500, delay: Int = duration - 350 ) = fadeIn(tween(duration, duration - delay)) diff --git a/app/src/main/java/com/techlads/composetv/search/SearchScreen.kt b/app/src/main/java/com/techlads/composetv/search/SearchScreen.kt new file mode 100644 index 0000000..ec0d710 --- /dev/null +++ b/app/src/main/java/com/techlads/composetv/search/SearchScreen.kt @@ -0,0 +1,23 @@ +package com.techlads.composetv.search + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview + +@Composable +fun SearchScreen(){ + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(text = "Search") + } +} + + +@Preview +@Composable +fun SearchScreenPrev() { + SearchScreen() +} \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/settings/SearchScreen.kt b/app/src/main/java/com/techlads/composetv/settings/SearchScreen.kt new file mode 100644 index 0000000..9c02bf2 --- /dev/null +++ b/app/src/main/java/com/techlads/composetv/settings/SearchScreen.kt @@ -0,0 +1,23 @@ +package com.techlads.composetv.settings + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview + +@Composable +fun SettingsScreen(){ + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(text = "Settings") + } +} + + +@Preview +@Composable +fun SettingsScreenPrev() { + SettingsScreen() +} \ No newline at end of file diff --git a/app/src/main/java/com/techlads/composetv/songs/SearchScreen.kt b/app/src/main/java/com/techlads/composetv/songs/SearchScreen.kt new file mode 100644 index 0000000..67a9328 --- /dev/null +++ b/app/src/main/java/com/techlads/composetv/songs/SearchScreen.kt @@ -0,0 +1,23 @@ +package com.techlads.composetv.songs + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview + +@Composable +fun SongsScreen(){ + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(text = "Songs") + } +} + + +@Preview +@Composable +fun SongsScreenPrev() { + SongsScreen() +} \ No newline at end of file