Skip to content

Commit a1e7b95

Browse files
Merge pull request #29 from CodandoTV/feature/Navigation
Feature/navigation
2 parents 0b62c88 + 0e219f6 commit a1e7b95

File tree

32 files changed

+408
-16
lines changed

32 files changed

+408
-16
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies {
1414
implementation(project(Dependencies.Module.feature_list_streams))
1515
implementation(project(Dependencies.Module.core_networking))
1616
implementation(project(Dependencies.Module.core_shared_ui))
17+
implementation(project(Dependencies.Module.core_navigation))
1718
implementation(Dependencies.Koin.koin)
1819
Dependencies.Kotlin.list.forEach { implementation(it) }
1920
Dependencies.Support.list.forEach { implementation(it) }

app/src/main/java/com/codandotv/streamplayerapp/MainActivity.kt

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,44 @@ package com.codandotv.streamplayerapp
33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6-
import com.codandotv.streamplayerapp.screens.SplashScreen
76

7+
import androidx.compose.foundation.layout.Box
8+
import androidx.compose.foundation.layout.padding
9+
import androidx.compose.material3.ExperimentalMaterial3Api
10+
import androidx.compose.material3.Scaffold
11+
import androidx.compose.runtime.Composable
12+
import androidx.compose.ui.Modifier
13+
import androidx.navigation.compose.rememberNavController
14+
import com.codandotv.streamplayerapp.core_navigation.bottomnavigation.StreamPlayerBottomNavigation
15+
import com.codandotv.streamplayerapp.core_navigation.helper.currentRoute
16+
import com.codandotv.streamplayerapp.core_navigation.routes.SplashRoutes
17+
import com.codandotv.streamplayerapp.core_shared_ui.theme.StreamPlayerTheme
18+
import com.codandotv.streamplayerapp.navigation.NavigationGraph
819
class MainActivity : ComponentActivity() {
920
override fun onCreate(savedInstanceState: Bundle?) {
1021
super.onCreate(savedInstanceState)
22+
setContent {
23+
StreamPlayerApp()
24+
}
25+
}
26+
}
27+
28+
@OptIn(ExperimentalMaterial3Api::class)
29+
@Composable
30+
fun StreamPlayerApp() {
31+
StreamPlayerTheme {
32+
val navController = rememberNavController()
1133

12-
setContent{
13-
SplashScreen()
34+
Scaffold(
35+
bottomBar = {
36+
if (currentRoute(navController = navController) != SplashRoutes.Splash) {
37+
StreamPlayerBottomNavigation(navController = navController)
38+
}
39+
}
40+
) { innerPadding ->
41+
Box(Modifier.padding(innerPadding)) {
42+
NavigationGraph(navController = navController)
43+
}
1444
}
1545
}
1646
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.codandotv.streamplayerapp.navigation
2+
3+
import androidx.compose.foundation.layout.Column
4+
import androidx.compose.material3.Text
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.ui.graphics.Color
7+
import androidx.navigation.NavGraphBuilder
8+
import androidx.navigation.NavHostController
9+
import androidx.navigation.compose.NavHost
10+
import androidx.navigation.compose.composable
11+
import com.codandotv.streamplayerapp.core_navigation.routes.BottomNavRoutes
12+
import com.codandotv.streamplayerapp.core_navigation.routes.SplashRoutes
13+
import com.codandotv.streamplayerapp.feature_list_streams.presentation.navigation.listStreamsNavGraph
14+
import com.codandotv.streamplayerapp.splah.presentation.navigation.splashNavGraph
15+
16+
@Composable
17+
fun NavigationGraph(navController: NavHostController) {
18+
NavHost(navController = navController, startDestination = SplashRoutes.Splash) {
19+
splashNavGraph(navController = navController)
20+
listStreamsNavGraph(navController = navController)
21+
temporaryFun(BottomNavRoutes.GAMES)
22+
temporaryFun(BottomNavRoutes.NEWS)
23+
temporaryFun(BottomNavRoutes.SCENES)
24+
temporaryFun(BottomNavRoutes.DOWNLOADS)
25+
}
26+
}
27+
28+
fun NavGraphBuilder.temporaryFun(route: String) {
29+
composable(route = route) {
30+
example(route)
31+
}
32+
}
33+
34+
@Composable
35+
fun example(route: String) {
36+
Text(text = route, color = Color.White)
37+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.codandotv.streamplayerapp.splah.presentation.navigation
2+
3+
import androidx.navigation.NavGraphBuilder
4+
import androidx.navigation.NavHostController
5+
import androidx.navigation.compose.composable
6+
import com.codandotv.streamplayerapp.core_navigation.routes.BottomNavRoutes
7+
import com.codandotv.streamplayerapp.core_navigation.routes.SplashRoutes
8+
import com.codandotv.streamplayerapp.splah.presentation.screens.SplashScreen
9+
10+
fun NavGraphBuilder.splashNavGraph(navController: NavHostController) {
11+
composable(SplashRoutes.Splash) {
12+
SplashScreen(
13+
onAnimationFinished = { navController.navigate(BottomNavRoutes.HOME) }
14+
)
15+
}
16+
}

app/src/main/java/com/codandotv/streamplayerapp/screens/SplashScreen.kt renamed to app/src/main/java/com/codandotv/streamplayerapp/splah/presentation/screens/SplashScreen.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.codandotv.streamplayerapp.screens
1+
package com.codandotv.streamplayerapp.splah.presentation.screens
22

33
import androidx.compose.foundation.background
44
import androidx.compose.foundation.layout.Box
@@ -17,7 +17,9 @@ import com.airbnb.lottie.compose.rememberLottieComposition
1717
import com.codandotv.streamplayerapp.core_shared_ui.R
1818

1919
@Composable
20-
fun SplashScreen() {
20+
fun SplashScreen(
21+
onAnimationFinished: () -> Unit
22+
) {
2123
Column(
2224
modifier = Modifier.fillMaxSize()
2325
) {
@@ -31,7 +33,7 @@ fun SplashScreen() {
3133
val logoAnimationState = animateLottieCompositionAsState(composition = composition)
3234
LottieAnimation(composition = composition, progress = { logoAnimationState.progress })
3335
if (logoAnimationState.isAtEnd && logoAnimationState.isPlaying) {
34-
println("faz alguma coisa")
36+
onAnimationFinished()
3537
}
3638
}
3739
}
@@ -40,5 +42,5 @@ fun SplashScreen() {
4042
@Composable
4143
@Preview
4244
fun SplashScreenPreview() {
43-
SplashScreen()
45+
SplashScreen(onAnimationFinished = {})
4446
}

buildSrc/src/main/java/Dependencies.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ object Dependencies {
1313
const val core_networking = ":core-networking"
1414
const val core_shared_ui = ":core-shared-ui"
1515
const val feature_list_streams = ":feature-list-streams"
16+
const val core_navigation = ":core-navigation"
1617
}
1718

1819
val modules: List<String> by lazy {
@@ -145,14 +146,16 @@ object Dependencies {
145146
"androidx.activity:activity-compose:${Versions.composeActivity}"
146147
const val composeUITooling = "androidx.compose.ui:ui-tooling"
147148
const val composeMaterial3 = "androidx.compose.material3:material3:${Versions.composeMaterial3Version}"
149+
const val composeNavigation = "androidx.navigation:navigation-compose:${Versions.composeNavigationVersion}"
148150

149151
override val list: List<String>
150152
get() = listOf(
151153
Compose.composeUI,
152154
Compose.coposeUIToolingPreview,
153155
Compose.composeActivityCompose,
154156
Compose.composeUITooling,
155-
Compose.composeMaterial3
157+
Compose.composeMaterial3,
158+
Compose.composeNavigation
156159
)
157160
}
158161
}

buildSrc/src/main/java/Versions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ object Versions {
3131
const val composeCompilerVersion = "1.4.2"
3232
const val composeMaterial3Version = "1.0.1"
3333
const val composeActivity = "1.5.0"
34+
const val composeNavigationVersion = "2.5.3"
3435

3536
const val coilVersion = "2.3.0"
3637

core-navigation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

core-navigation/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@file:Suppress("UnstableApiUsage")
2+
android {
3+
namespace = "${Config.packageName}core_navigation"
4+
5+
buildFeatures {
6+
compose = true
7+
}
8+
9+
composeOptions {
10+
kotlinCompilerExtensionVersion = Versions.composeCompilerVersion
11+
}
12+
}
13+
14+
dependencies {
15+
Dependencies.Kotlin.list.forEach { implementation(it) }
16+
Dependencies.Compose.list.forEach { implementation(it) }
17+
implementation(platform(Dependencies.Compose.composeBomVersion))
18+
}

core-navigation/consumer-rules.pro

Whitespace-only changes.

0 commit comments

Comments
 (0)