diff --git a/app/src/main/java/team/ppac/MainActivity.kt b/app/src/main/java/team/ppac/MainActivity.kt index dbd84a82..4d78c026 100644 --- a/app/src/main/java/team/ppac/MainActivity.kt +++ b/app/src/main/java/team/ppac/MainActivity.kt @@ -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 @@ -29,6 +30,9 @@ class MainActivity : ComponentActivity() { @Inject lateinit var settingNavigator: SettingNavigator + @Inject + lateinit var registerNavigator: RegisterNavigator + @Inject lateinit var analyticsHelper: AnalyticsHelper @@ -73,6 +77,9 @@ class MainActivity : ComponentActivity() { navigateToSetting = { settingNavigator.navigateFrom(this@MainActivity) }, + navigateToRegister = { + registerNavigator.navigateFrom(this@MainActivity) + } ) } } diff --git a/app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt b/app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt index f81e5b1e..3fdeadfb 100644 --- a/app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt +++ b/app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt @@ -27,6 +27,7 @@ fun FarmemeNavHost( navController: NavHostController, navigateToDetail: (String) -> Unit, navigateToSetting: () -> Unit, + navigateToRegister: () -> Unit, ) { NavHost( modifier = modifier, diff --git a/core/navigator/src/main/java/team/ppac/navigator/RegisterNavigator.kt b/core/navigator/src/main/java/team/ppac/navigator/RegisterNavigator.kt new file mode 100644 index 00000000..0738a5ce --- /dev/null +++ b/core/navigator/src/main/java/team/ppac/navigator/RegisterNavigator.kt @@ -0,0 +1,5 @@ +package team.ppac.navigator + +import team.ppac.navigator.base.Navigator + +interface RegisterNavigator : Navigator \ No newline at end of file diff --git a/feature/register/src/main/java/team/ppac/register/di/RegisterNavigatorModule.kt b/feature/register/src/main/java/team/ppac/register/di/RegisterNavigatorModule.kt new file mode 100644 index 00000000..39b7c174 --- /dev/null +++ b/feature/register/src/main/java/team/ppac/register/di/RegisterNavigatorModule.kt @@ -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 +} \ No newline at end of file diff --git a/feature/register/src/main/java/team/ppac/register/navigator/RegisterNavigatorImpl.kt b/feature/register/src/main/java/team/ppac/register/navigator/RegisterNavigatorImpl.kt new file mode 100644 index 00000000..2c08d855 --- /dev/null +++ b/feature/register/src/main/java/team/ppac/register/navigator/RegisterNavigatorImpl.kt @@ -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(intentBuilder)) + if (withFinish) activity.finish() + } + + override fun navigateResultLauncher( + launcher: ActivityResultLauncher, + activity: Activity, + intentBuilder: Intent.() -> Intent + ) { + launcher.launch(activity.getIntent(intentBuilder)) + } + + override fun navigateResultLauncher( + launcher: ActivityResultLauncher, + context: Context, + intentBuilder: Intent.() -> Intent + ) { + launcher.launch(context.getIntent(intentBuilder)) + } +} \ No newline at end of file