Skip to content

Commit

Permalink
[Feat] Navigator 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ze-zeh committed Sep 21, 2024
1 parent 4dae0c6 commit 1752e3f
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/team/ppac/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import team.ppac.navigation.FarmemeNavHost
import team.ppac.navigation.component.FarmemeBottomBar
import team.ppac.navigation.navigateToTopLevelDestination
import team.ppac.navigator.DetailNavigator
import team.ppac.navigator.RegisterNavigator
import team.ppac.navigator.SettingNavigator
import javax.inject.Inject

Expand All @@ -29,6 +30,9 @@ class MainActivity : ComponentActivity() {
@Inject
lateinit var settingNavigator: SettingNavigator

@Inject
lateinit var registerNavigator: RegisterNavigator

@Inject
lateinit var analyticsHelper: AnalyticsHelper

Expand Down Expand Up @@ -73,6 +77,9 @@ class MainActivity : ComponentActivity() {
navigateToSetting = {
settingNavigator.navigateFrom(this@MainActivity)
},
navigateToRegister = {
registerNavigator.navigateFrom(this@MainActivity)
}
)
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fun FarmemeNavHost(
navController: NavHostController,
navigateToDetail: (String) -> Unit,
navigateToSetting: () -> Unit,
navigateToRegister: () -> Unit,
) {
NavHost(
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.ppac.navigator

import team.ppac.navigator.base.Navigator

interface RegisterNavigator : Navigator
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package team.ppac.register.di

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.scopes.ActivityScoped
import team.ppac.navigator.RegisterNavigator
import team.ppac.register.navigator.RegisterNavigatorImpl

@Module
@InstallIn(ActivityComponent::class)
internal abstract class RegisterNavigatorModule {
@Binds
@ActivityScoped
abstract fun bindRegisterNavigator(impl: RegisterNavigatorImpl): RegisterNavigator
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package team.ppac.register.navigator

import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.result.ActivityResultLauncher
import team.ppac.common.android.extension.getIntent
import team.ppac.navigator.RegisterNavigator
import team.ppac.register.RegisterActivity
import javax.inject.Inject

class RegisterNavigatorImpl @Inject constructor() : RegisterNavigator {
override fun navigateFrom(
activity: Activity,
intentBuilder: Intent.() -> Intent,
withFinish: Boolean
) {
activity.startActivity(activity.getIntent<RegisterActivity>(intentBuilder))
if (withFinish) activity.finish()
}

override fun navigateResultLauncher(
launcher: ActivityResultLauncher<Intent>,
activity: Activity,
intentBuilder: Intent.() -> Intent
) {
launcher.launch(activity.getIntent<RegisterActivity>(intentBuilder))
}

override fun navigateResultLauncher(
launcher: ActivityResultLauncher<Intent>,
context: Context,
intentBuilder: Intent.() -> Intent
) {
launcher.launch(context.getIntent<RegisterActivity>(intentBuilder))
}
}

0 comments on commit 1752e3f

Please sign in to comment.