Skip to content

Commit

Permalink
Issues boostcampwm-2022#287 feat: intro, main 화면 전환 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
audxo112 committed Feb 28, 2023
1 parent 2accfca commit 24a4fc2
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 19 deletions.
9 changes: 6 additions & 3 deletions app/src/main/java/com/lighthouse/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.databinding.DataBindingUtil
import androidx.navigation.fragment.NavHostFragment
import com.lighthouse.beep.R
import com.lighthouse.beep.databinding.ActivityMainBinding
import com.lighthouse.features.common.ext.repeatOnStarted
Expand All @@ -25,13 +26,15 @@ class MainActivity : AppCompatActivity() {
}

private fun setUpIsLogin() {
// val navController = findNavController(R.id.fcv)
val navHostFragment = supportFragmentManager.findFragmentById(R.id.fcv) as NavHostFragment
val navController = navHostFragment.navController
navController.popBackStack()
repeatOnStarted {
viewModel.isLogin().collect { isLogin ->
if (isLogin) {
// navController.navigate()
navController.navigate(R.id.action_global_main_graph)
} else {
// navController.navigate()
navController.navigate(R.id.action_global_intro_graph)
}
}
}
Expand Down
21 changes: 20 additions & 1 deletion app/src/main/res/navigation/main_graph.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_graph">
android:id="@+id/main_graph"
app:startDestination="@id/main_nav_graph">

<include
android:id="@+id/main_nav_graph"
app:graph="@navigation/main_nav_graph" />

<include
android:id="@+id/intro_nav_graph"
app:graph="@navigation/intro_nav_graph" />

<action
android:id="@+id/action_global_main_graph"
app:destination="@id/main_nav_graph"
app:popUpTo="@id/intro_nav_graph"
app:popUpToInclusive="true"/>

<action
android:id="@+id/action_global_intro_graph"
app:destination="@id/intro_nav_graph"
app:popUpTo="@id/main_nav_graph"
app:popUpToInclusive="true"/>
</navigation>
2 changes: 0 additions & 2 deletions features/ui-intro/src/main/res/values/navigation.xml

This file was deleted.

3 changes: 3 additions & 0 deletions features/ui-main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ dependencies {
implementation(projects.common)
implementation(projects.commonAndroid)
implementation(projects.uiCommon)
implementation(projects.uiGifticonlist)
implementation(projects.uiHome)
implementation(projects.uiSetting)

implementation(libs.androidX.core.ktx)
implementation(libs.androidX.appcompat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.lighthouse.core.android.utils.permission.StoragePermissionManager
import com.lighthouse.core.android.utils.permission.core.permissions
import com.lighthouse.features.common.binding.viewBindings
Expand All @@ -30,12 +28,12 @@ class MainContainerFragment : Fragment(R.layout.fragment_main_container) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

setUpBottomNavigation()
// setUpBottomNavigation()
}

private fun setUpBottomNavigation() {
val navHostFragment = childFragmentManager.findFragmentById(R.id.fcv) as NavHostFragment
val navController = navHostFragment.navController
binding.bnv.setupWithNavController(navController)
// val navHostFragment = childFragmentManager.findFragmentById(R.id.fcv_main) as NavHostFragment
// val navController = navHostFragment.navController
// binding.bnv.setupWithNavController(navController)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
android:fitsSystemWindows="true">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv"
android:id="@+id/fcv_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:navGraph="@navigation/main_container_nav_graph"
app:layout_constraintBottom_toTopOf="@id/bnv"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
6 changes: 3 additions & 3 deletions features/ui-main/src/main/res/menu/menu_navigation.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_list"
android:id="@+id/gifticon_list_nav_graph"
android:icon="@drawable/ic_menu_list"
android:title="@string/menu_list"/>

<item
android:id="@+id/menu_home"
android:id="@+id/home_nav_graph"
android:icon="@drawable/ic_menu_home"
android:title="@string/menu_home"/>

<item
android:id="@+id/menu_setting"
android:id="@+id/setting_nav_graph"
android:icon="@drawable/ic_menu_setting"
android:title="@string/menu_setting"/>
</menu>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_container_nav_graph"
app:startDestination="@id/home_nav_graph">

<include
android:id="@+id/gifticon_list_nav_graph"
app:graph="@navigation/gifticon_list_nav_graph" />

<include
android:id="@+id/home_nav_graph"
app:graph="@navigation/home_nav_graph" />

<include
android:id="@+id/setting_nav_graph"
app:graph="@navigation/setting_nav_graph" />
</navigation>
6 changes: 3 additions & 3 deletions features/ui-main/src/main/res/navigation/main_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_nav_graph"
app:startDestination="@id/main_container_fragment">
app:startDestination="@id/fragment_main_container">

<fragment
android:id="@+id/main_container_fragment"
android:name="com.lighthouse.features.main.ui.MainContainerFragment" />
android:id="@+id/fragment_main_container"
android:name="com.lighthouse.features.main.ui.MainContainerFragment"/>
</navigation>

0 comments on commit 24a4fc2

Please sign in to comment.