mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2731 Vault | Enhancement | Fix app navigation (#1593)
This commit is contained in:
parent
0d4acf417f
commit
50702931e6
9 changed files with 70 additions and 41 deletions
|
@ -136,7 +136,7 @@ class Navigator : AppNavigation {
|
|||
}
|
||||
|
||||
override fun exitToVault() {
|
||||
val popped = navController?.popBackStack(R.id.vaultScreen, false)
|
||||
val popped = navController?.popBackStack(R.id.vaultScreen, true)
|
||||
if (popped == false) {
|
||||
navController?.navigate(R.id.vaultScreen)
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.anytypeio.anytype.presentation.home.HomeScreenViewModel.Navigation
|
|||
import com.anytypeio.anytype.presentation.widgets.DropDownMenuAction
|
||||
import com.anytypeio.anytype.ui.base.navigation
|
||||
import com.anytypeio.anytype.ui.gallery.GalleryInstallationFragment
|
||||
import com.anytypeio.anytype.ui.library.LibraryFragment
|
||||
import com.anytypeio.anytype.ui.multiplayer.RequestJoinSpaceFragment
|
||||
import com.anytypeio.anytype.ui.multiplayer.ShareSpaceFragment
|
||||
import com.anytypeio.anytype.ui.objects.creation.SelectObjectTypeFragment
|
||||
|
@ -352,7 +353,14 @@ class HomeScreenFragment : BaseComposeFragment() {
|
|||
)
|
||||
}
|
||||
is Navigation.OpenLibrary -> runCatching {
|
||||
navigation().openLibrary(destination.space)
|
||||
runCatching {
|
||||
findNavController().navigate(
|
||||
R.id.libraryFragment,
|
||||
args = LibraryFragment.args(destination.space)
|
||||
)
|
||||
}.onFailure { e ->
|
||||
Timber.e(e, "Error while opening space library from widgets")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import com.anytypeio.anytype.ui.relations.RelationCreateFromScratchForObjectFrag
|
|||
import com.anytypeio.anytype.ui.relations.RelationEditFragment
|
||||
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
||||
import com.anytypeio.anytype.ui.settings.typography
|
||||
import com.anytypeio.anytype.ui.spaces.SelectSpaceFragment
|
||||
import com.anytypeio.anytype.ui.types.create.CreateObjectTypeFragment
|
||||
import com.anytypeio.anytype.ui.types.create.REQUEST_CREATE_OBJECT
|
||||
import com.anytypeio.anytype.ui.types.edit.REQUEST_KEY_MODIFY_TYPE
|
||||
|
@ -51,6 +50,7 @@ import com.anytypeio.anytype.ui.types.edit.TypeEditFragment
|
|||
import com.google.accompanist.pager.ExperimentalPagerApi
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import timber.log.Timber
|
||||
|
||||
class LibraryFragment : BaseComposeFragment() {
|
||||
|
||||
|
@ -162,11 +162,15 @@ class LibraryFragment : BaseComposeFragment() {
|
|||
)
|
||||
)
|
||||
}
|
||||
is LibraryViewModel.Navigation.SelectSpace -> {
|
||||
findNavController().navigate(
|
||||
R.id.selectSpaceScreen,
|
||||
args = SelectSpaceFragment.args(exitHomeWhenSpaceIsSelected = true)
|
||||
)
|
||||
is LibraryViewModel.Navigation.ExitToVault -> {
|
||||
runCatching {
|
||||
findNavController().popBackStack(
|
||||
R.id.vaultScreen,
|
||||
true
|
||||
)
|
||||
}.onFailure { e ->
|
||||
Timber.e(e, "Error while exiting to vault from space library")
|
||||
}
|
||||
}
|
||||
|
||||
is LibraryViewModel.Navigation.OpenSetOrCollection -> {
|
||||
|
|
|
@ -81,21 +81,24 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>(R.layout.fragment_spl
|
|||
|
||||
private fun observe(command: SplashViewModel.Command) {
|
||||
when (command) {
|
||||
is SplashViewModel.Command.NavigateToDashboard -> {
|
||||
try {
|
||||
is SplashViewModel.Command.NavigateToWidgets -> {
|
||||
runCatching {
|
||||
findNavController().navigate(
|
||||
R.id.action_splashScreen_to_homeScreen,
|
||||
resId = R.id.actionOpenVaultFromSplash,
|
||||
args = HomeScreenFragment.args(command.deeplink)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Error while opening dashboard from splash screen")
|
||||
toast("Error while navigating to desktop: ${e.message}")
|
||||
findNavController().navigate(
|
||||
R.id.actionOpenSpaceFromVault,
|
||||
args = HomeScreenFragment.args(command.deeplink)
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.e(it, "Error while navigating to widgets from splash")
|
||||
}
|
||||
}
|
||||
is SplashViewModel.Command.NavigateToVault -> {
|
||||
try {
|
||||
findNavController().navigate(
|
||||
R.id.action_splashScreen_to_vaultScreen,
|
||||
resId = R.id.actionOpenVaultFromSplash,
|
||||
args = HomeScreenFragment.args(command.deeplink)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
|
@ -104,24 +107,34 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>(R.layout.fragment_spl
|
|||
}
|
||||
}
|
||||
is SplashViewModel.Command.NavigateToObject -> {
|
||||
findNavController().navigate(R.id.action_splashScreen_to_widgets)
|
||||
findNavController().navigate(
|
||||
R.id.objectNavigation,
|
||||
EditorFragment.args(
|
||||
ctx = command.id,
|
||||
space = command.space
|
||||
runCatching {
|
||||
findNavController().navigate(R.id.actionOpenVaultFromSplash)
|
||||
findNavController().navigate(R.id.actionOpenSpaceFromVault)
|
||||
findNavController().navigate(
|
||||
resId = R.id.objectNavigation,
|
||||
args = EditorFragment.args(
|
||||
ctx = command.id,
|
||||
space = command.space
|
||||
)
|
||||
)
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.e(it, "Error while navigating to object from splash")
|
||||
}
|
||||
}
|
||||
is SplashViewModel.Command.NavigateToObjectSet -> {
|
||||
findNavController().navigate(R.id.action_splashScreen_to_widgets)
|
||||
findNavController().navigate(
|
||||
R.id.dataViewNavigation,
|
||||
ObjectSetFragment.args(
|
||||
ctx = command.id,
|
||||
space = command.space
|
||||
runCatching {
|
||||
findNavController().navigate(R.id.actionOpenVaultFromSplash)
|
||||
findNavController().navigate(R.id.actionOpenSpaceFromVault)
|
||||
findNavController().navigate(
|
||||
resId = R.id.dataViewNavigation,
|
||||
args = ObjectSetFragment.args(
|
||||
ctx = command.id,
|
||||
space = command.space
|
||||
)
|
||||
)
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.e(it, "Error while navigating to set-or-collection from splash")
|
||||
}
|
||||
}
|
||||
is SplashViewModel.Command.NavigateToAuthStart -> {
|
||||
val intent = activity?.intent
|
||||
|
|
|
@ -57,7 +57,7 @@ class VaultFragment : BaseComposeFragment() {
|
|||
when (command) {
|
||||
is Command.EnterSpaceHomeScreen -> {
|
||||
runCatching {
|
||||
findNavController().navigate(R.id.openSpace)
|
||||
findNavController().navigate(R.id.actionOpenSpaceFromVault)
|
||||
}
|
||||
}
|
||||
is Command.CreateNewSpace -> {
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.anytypeio.anytype.ui.base.navigation
|
|||
import com.anytypeio.anytype.ui.dashboard.DeleteAlertFragment
|
||||
import com.anytypeio.anytype.ui.objects.creation.SelectObjectTypeFragment
|
||||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
|
||||
class CollectionFragment : BaseComposeFragment() {
|
||||
|
||||
|
@ -107,11 +108,14 @@ class CollectionFragment : BaseComposeFragment() {
|
|||
space = command.space
|
||||
)
|
||||
is Command.Vault -> {
|
||||
// DROID-2731 Fix navigation
|
||||
findNavController().navigate(
|
||||
R.id.vaultScreen,
|
||||
args = null
|
||||
)
|
||||
runCatching {
|
||||
findNavController().popBackStack(
|
||||
R.id.vaultScreen,
|
||||
true
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.e(it, "Error while exiting to vault")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@
|
|||
android:id="@+id/vaultScreen"
|
||||
android:name="com.anytypeio.anytype.ui.vault.VaultFragment">
|
||||
<action
|
||||
android:id="@+id/openSpace"
|
||||
android:id="@+id/actionOpenSpaceFromVault"
|
||||
app:destination="@id/homeScreen" />
|
||||
</fragment>
|
||||
|
||||
|
@ -282,7 +282,7 @@
|
|||
app:popUpTo="@+id/splashScreen"
|
||||
app:popUpToInclusive="true" />
|
||||
<action
|
||||
android:id="@+id/action_splashScreen_to_vaultScreen"
|
||||
android:id="@+id/actionOpenVaultFromSplash"
|
||||
app:destination="@id/vaultScreen"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
|
|
|
@ -192,7 +192,7 @@ class LibraryViewModel(
|
|||
is LibraryEvent.BottomMenu.Back -> navigate(Navigation.Back())
|
||||
is LibraryEvent.BottomMenu.Search -> navigate(Navigation.Search())
|
||||
is LibraryEvent.BottomMenu.CreateObject -> proceedWithCreateDoc()
|
||||
is LibraryEvent.BottomMenu.OpenProfile -> navigate(Navigation.SelectSpace)
|
||||
is LibraryEvent.BottomMenu.OpenProfile -> navigate(Navigation.ExitToVault)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ class LibraryViewModel(
|
|||
val view: LibraryView.MyRelationView
|
||||
) : Navigation()
|
||||
|
||||
object SelectSpace: Navigation()
|
||||
object ExitToVault: Navigation()
|
||||
|
||||
class Back : Navigation()
|
||||
|
||||
|
|
|
@ -265,7 +265,7 @@ class SplashViewModel(
|
|||
private suspend fun proceedWithDashboardNavigation(deeplink: String? = null) {
|
||||
val space = getLastOpenedSpace.async(Unit).getOrNull()
|
||||
if (space != null) {
|
||||
commands.emit(Command.NavigateToDashboard(deeplink))
|
||||
commands.emit(Command.NavigateToWidgets(deeplink))
|
||||
} else {
|
||||
commands.emit(Command.NavigateToVault(deeplink))
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ class SplashViewModel(
|
|||
}
|
||||
|
||||
sealed class Command {
|
||||
data class NavigateToDashboard(val deeplink: String? = null) : Command()
|
||||
data class NavigateToWidgets(val deeplink: String? = null) : Command()
|
||||
data class NavigateToVault(val deeplink: String? = null) : Command()
|
||||
data object NavigateToAuthStart : Command()
|
||||
data object NavigateToMigration: Command()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue