-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor Modular Navigation With Framework-Neutral APIs #854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dev-bilal-azzam
wants to merge
2
commits into
Rome-Squad:develop
Choose a base branch
from
dev-bilal-azzam:refactor/modular-navigation-with-framework-neutral-api
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| package com.giraffe.api.home | ||
|
|
||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import android.content.Context | ||
|
|
||
| interface HomeApi { | ||
|
|
||
| fun launchHome(context: Context) | ||
| fun navigateToExploreScreen() | ||
| @Composable | ||
| fun MainContainer() | ||
| } | ||
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
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
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
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
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
22 changes: 0 additions & 22 deletions
22
...hentication/src/main/java/com/giraffe/presentation/authentication/nav/routes/HomeRoute.kt
This file was deleted.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,11 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <application> | ||
| <activity | ||
| android:name=".navigation.main.HomeActivity" | ||
| android:exported="false" | ||
| android:label="@string/title_activity_home" | ||
| android:theme="@style/Theme.CineVerseApp" /> | ||
| </application> | ||
|
|
||
| </manifest> |
40 changes: 0 additions & 40 deletions
40
presentation/home/src/main/java/com/giraffe/presentation/home/navigation/HomeApiImp.kt
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
presentation/home/src/main/java/com/giraffe/presentation/home/navigation/api/HomeApiImp.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.giraffe.presentation.home.navigation.api | ||
|
|
||
| import android.app.Activity | ||
| import android.content.Context | ||
| import android.content.Intent | ||
| import androidx.navigation.NavHostController | ||
| import com.giraffe.api.home.HomeApi | ||
| import com.giraffe.presentation.home.navigation.main.HomeActivity | ||
| import com.giraffe.presentation.home.navigation.main.routes.navigateToExplore | ||
| import javax.inject.Inject | ||
|
|
||
| class HomeApiImp @Inject constructor() : HomeApi { | ||
| private var navController: NavHostController? = null | ||
|
|
||
| override fun launchHome(context: Context) { | ||
| val intent = Intent(context, HomeActivity::class.java) | ||
| context.startActivity(intent) | ||
| if (context is Activity) context.finish() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we dont need this line? |
||
| } | ||
|
|
||
| fun setNavController(navController: NavHostController) { | ||
| this.navController = navController | ||
| } | ||
|
|
||
| override fun navigateToExploreScreen() { | ||
| navController?.navigateToExplore() | ||
| } | ||
| } | ||
81 changes: 81 additions & 0 deletions
81
...entation/home/src/main/java/com/giraffe/presentation/home/navigation/main/HomeActivity.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package com.giraffe.presentation.home.navigation.main | ||
|
|
||
| import android.os.Bundle | ||
| import androidx.activity.ComponentActivity | ||
| import androidx.activity.SystemBarStyle | ||
| import androidx.activity.compose.setContent | ||
| import androidx.activity.enableEdgeToEdge | ||
| import androidx.activity.viewModels | ||
| import androidx.compose.runtime.LaunchedEffect | ||
| import androidx.compose.runtime.collectAsState | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.graphics.toArgb | ||
| import androidx.navigation.compose.rememberNavController | ||
| import com.giraffe.api.details.DetailsApi | ||
| import com.giraffe.api.explore.ExploreApi | ||
| import com.giraffe.api.home.HomeApi | ||
| import com.giraffe.api.profile.ProfileApi | ||
| import com.giraffe.designsystem.theme.CineVerseTheme | ||
| import com.giraffe.match.MatchApi | ||
| import com.giraffe.presentation.home.navigation.api.HomeApiImp | ||
| import com.giraffe.presentation.home.screen.home.HomeViewModel | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import jakarta.inject.Inject | ||
|
|
||
|
|
||
| @AndroidEntryPoint | ||
| class HomeActivity : ComponentActivity() { | ||
|
|
||
| @Inject | ||
| lateinit var detailsApi: DetailsApi | ||
|
|
||
| @Inject | ||
| lateinit var exploreApi: ExploreApi | ||
|
|
||
| @Inject | ||
| lateinit var profileApi: ProfileApi | ||
|
|
||
| @Inject | ||
| lateinit var matchApi: MatchApi | ||
|
|
||
| @Inject | ||
| lateinit var homeApi: HomeApi | ||
|
|
||
| private val viewModel: HomeViewModel by viewModels() | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
|
|
||
| setContent { | ||
| val navController = rememberNavController() | ||
| val state by viewModel.state.collectAsState() | ||
| val isDarkTheme = state.isDarkTheme | ||
|
|
||
| val systemBarsColor = if (isDarkTheme) | ||
| SystemBarStyle.dark(Color.Transparent.toArgb()) | ||
| else | ||
| SystemBarStyle.light( | ||
| Color.Transparent.toArgb(), | ||
| Color.Transparent.toArgb() | ||
| ) | ||
|
|
||
| enableEdgeToEdge(systemBarsColor, systemBarsColor) | ||
|
|
||
| LaunchedEffect(Unit) { | ||
| (homeApi as HomeApiImp).setNavController(navController) | ||
| } | ||
|
|
||
| CineVerseTheme(isDarkTheme = isDarkTheme) { | ||
|
|
||
| MainNavGraph( | ||
| navController = navController, | ||
| detailsApi = detailsApi, | ||
| exploreApi = exploreApi, | ||
| profileApi = profileApi, | ||
| matchApi = matchApi | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can inject the context directly into the
HomeApiImp