Skip to content
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

Fix for issue #24 #25

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fragula-core/api/fragula-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ public final class com/fragula2/FragulaNavHostFragment : androidx/navigation/fra
public static final field Companion Lcom/fragula2/FragulaNavHostFragment$Companion;
public fun <init> ()V
public static final fun findSwipeController (Landroidx/fragment/app/Fragment;)Lcom/fragula2/animation/SwipeController;
public fun onCreate (Landroid/os/Bundle;)V
public fun onInflate (Landroid/content/Context;Landroid/util/AttributeSet;Landroid/os/Bundle;)V
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import android.view.View
import androidx.activity.OnBackPressedDispatcherOwner
import androidx.core.content.res.use
import androidx.fragment.app.Fragment
import androidx.navigation.NavHostController
Expand All @@ -46,6 +47,14 @@ class FragulaNavHostFragment : NavHostFragment() {
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
/* Set onBackPressedDispatcher for NavController to handle back button events,
as the code to set it was removed in Navigation 2.6.0. */
val onBackPressedDispatcher = (context as OnBackPressedDispatcherOwner).onBackPressedDispatcher
navController.setOnBackPressedDispatcher(onBackPressedDispatcher)
massivemadness marked this conversation as resolved.
Show resolved Hide resolved
}

override fun onCreateNavHostController(navHostController: NavHostController) {
super.onCreateNavHostController(navHostController)
navHostController.navigatorProvider += SwipeBackNavigator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class SwipeBackFragment : Fragment(R.layout.fragment_swipeback), Navigable, Swip
}

private fun restoreBackStack() {
viewPager?.currentItem = navController?.backQueue.orEmpty()
viewPager?.currentItem = navController?.currentBackStack?.value.orEmpty()
.filter { it.destination is SwipeBackDestination }
.also { navBackStackAdapter?.addAll(it) }
.size
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ compose-ui = "1.4.3"
compose-compiler = "1.4.5"
accompanist = "0.28.0"
lifecycle = "2.6.1"
navigation = "2.5.3"
navigation = "2.6.0"
junit = "4.13.2"
junit-ext = "1.1.5"
test-runner = "1.5.2"
Expand Down