1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-3601 Widgets | Fix | Fix missing args issue (#2365)

This commit is contained in:
Evgenii Kozlov 2025-04-28 16:31:56 +02:00
parent bcbb8368e7
commit 2649a50cfa
12 changed files with 52 additions and 28 deletions

View file

@ -15,6 +15,7 @@ import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment
import com.anytypeio.anytype.ui.date.DateObjectFragment
import com.anytypeio.anytype.ui.editor.EditorFragment
import com.anytypeio.anytype.ui.editor.EditorModalFragment
import com.anytypeio.anytype.ui.home.HomeScreenFragment
import com.anytypeio.anytype.ui.multiplayer.ShareSpaceFragment
import com.anytypeio.anytype.ui.primitives.CreateTypeFragment
import com.anytypeio.anytype.ui.primitives.ObjectTypeFieldsFragment
@ -150,17 +151,26 @@ class Navigator : AppNavigation {
)
}
override fun exit() {
override fun exit(space: Id) {
val popped = navController?.popBackStack()
if (popped == false) {
navController?.navigate(R.id.homeScreen)
navController?.navigate(
R.id.homeScreen,
HomeScreenFragment.args(space = space)
)
}
}
override fun exitToDesktop() {
val popped = navController?.popBackStack(R.id.homeScreen, false)
override fun exitToDesktop(space: Id) {
val popped = navController?.popBackStack(R
.id.homeScreen,
false
)
if (popped == false) {
navController?.navigate(R.id.homeScreen)
navController?.navigate(
R.id.homeScreen,
HomeScreenFragment.args(space = space)
)
}
}

View file

@ -32,6 +32,7 @@ import com.anytypeio.anytype.feature_allcontent.ui.AllContentWrapperScreen
import com.anytypeio.anytype.presentation.navigation.NavPanelState
import com.anytypeio.anytype.presentation.widgets.collection.Subscription
import com.anytypeio.anytype.ui.base.navigation
import com.anytypeio.anytype.ui.home.HomeScreenFragment
import com.anytypeio.anytype.ui.multiplayer.ShareSpaceFragment
import com.anytypeio.anytype.ui.objects.creation.ObjectTypeSelectionFragment
import com.anytypeio.anytype.ui.objects.types.pickers.ObjectTypeSelectionListener
@ -280,8 +281,12 @@ class AllContentFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
onBackClicked = vm::onBackClicked,
moveToBin = vm::proceedWithMoveToBin,
onBackLongClicked = {
// Currently not used.
runCatching {
findNavController().navigate(R.id.actionExitToSpaceWidgets)
findNavController().navigate(
R.id.actionExitToSpaceWidgets,
HomeScreenFragment.args(space = space)
)
}.onFailure {
Timber.e(it, "Error while opening space switcher from all-content screen")
}

View file

@ -46,8 +46,8 @@ class NavigationRouter(
target = command.target,
space = command.space
)
is AppNavigation.Command.Exit -> navigation.exit()
is AppNavigation.Command.ExitToDesktop -> navigation.exitToDesktop()
is AppNavigation.Command.Exit -> navigation.exit(command.space)
is AppNavigation.Command.ExitToDesktop -> navigation.exitToDesktop(command.space)
is AppNavigation.Command.ExitToVault -> navigation.exitToVault()
is AppNavigation.Command.ExitToSpaceHome -> navigation.exitToSpaceHome()
is AppNavigation.Command.OpenGlobalSearch -> navigation.openGlobalSearch(

View file

@ -37,6 +37,7 @@ import com.anytypeio.anytype.feature_date.ui.DateMainScreen
import com.anytypeio.anytype.feature_date.viewmodel.DateObjectCommand
import com.anytypeio.anytype.feature_date.viewmodel.DateObjectVmParams
import com.anytypeio.anytype.ui.base.navigation
import com.anytypeio.anytype.ui.home.HomeScreenFragment
import com.anytypeio.anytype.ui.objects.creation.ObjectTypeSelectionFragment
import com.anytypeio.anytype.ui.objects.types.pickers.ObjectTypeSelectionListener
import com.anytypeio.anytype.ui.profile.ParticipantFragment
@ -159,7 +160,10 @@ class DateObjectFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
DateObjectCommand.ExitToSpaceWidgets -> {
runCatching {
findNavController().navigate(R.id.actionExitToSpaceWidgets)
findNavController().navigate(
R.id.actionExitToSpaceWidgets,
HomeScreenFragment.args(space = space)
)
}.onFailure {
Timber.e(it, "Error while opening space switcher from all-content screen")
}

View file

@ -1051,7 +1051,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
is Command.AlertDialog -> {
if (childFragmentManager.findFragmentByTag(TAG_ALERT) == null) {
AlertUpdateAppFragment().apply {
onCancel = { navigation().exit() }
onCancel = { navigation().exit(space) }
}.showChildFragment(TAG_ALERT)
} else {
// Do nothing

View file

@ -94,7 +94,7 @@ class RemoteFilesManageFragment : BaseBottomSheetComposeFragment() {
space = command.space,
target = command.target
)
is CollectionViewModel.Command.ToDesktop -> navigation.exitToDesktop()
is CollectionViewModel.Command.ToDesktop -> navigation.exitToDesktop(space)
is CollectionViewModel.Command.ToSearch -> {
// Do nothing.
}
@ -127,7 +127,7 @@ class RemoteFilesManageFragment : BaseBottomSheetComposeFragment() {
}
private fun exit() {
navigation.exit()
navigation.exit(space)
}
private fun launchObjectSet(target: Id, space: Id) {

View file

@ -28,6 +28,7 @@ import com.anytypeio.anytype.presentation.widgets.collection.Subscription
import com.anytypeio.anytype.presentation.widgets.collection.SubscriptionMapper
import com.anytypeio.anytype.ui.base.navigation
import com.anytypeio.anytype.ui.dashboard.DeleteAlertFragment
import com.anytypeio.anytype.ui.home.HomeScreenFragment
import com.anytypeio.anytype.ui.multiplayer.ShareSpaceFragment
import com.anytypeio.anytype.ui.objects.creation.ObjectTypeSelectionFragment
import com.anytypeio.anytype.ui.objects.types.pickers.ObjectTypeSelectionListener
@ -104,7 +105,7 @@ class CollectionFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
target = command.target,
space = command.space
)
is Command.ToDesktop -> navigation.exitToDesktop()
is Command.ToDesktop -> navigation.exitToDesktop(space = space)
is Command.ToSearch -> navigation.openGlobalSearch(
space = command.space
)
@ -113,7 +114,10 @@ class CollectionFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
}
is Command.ExitToSpaceWidgets -> {
runCatching {
findNavController().navigate(R.id.actionExitToSpaceWidgets)
findNavController().navigate(
R.id.actionExitToSpaceWidgets,
HomeScreenFragment.args(space = space)
)
}.onFailure {
Timber.e(it, "Error while opening space switcher from full-screen widget")
}
@ -169,7 +173,7 @@ class CollectionFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
}
private fun exit() {
navigation.exit()
navigation.exit(space)
}
private fun launchObjectSet(target: Id, space: Id) {

View file

@ -1256,8 +1256,8 @@ class EditorViewModel(
private fun exitBack() {
when (session.value) {
Session.ERROR -> navigate(EventWrapper(AppNavigation.Command.Exit))
Session.IDLE -> navigate(EventWrapper(AppNavigation.Command.Exit))
Session.ERROR -> navigate(EventWrapper(AppNavigation.Command.Exit(vmParams.space.id)))
Session.IDLE -> navigate(EventWrapper(AppNavigation.Command.Exit(vmParams.space.id)))
Session.OPEN -> {
viewModelScope.launch {
closePage.async(
@ -1266,10 +1266,10 @@ class EditorViewModel(
vmParams.space
)
).fold(
onSuccess = { navigate(EventWrapper(AppNavigation.Command.Exit)) },
onSuccess = { navigate(EventWrapper(AppNavigation.Command.Exit(vmParams.space.id))) },
onFailure = {
Timber.e(it, "Error while closing document: $context")
navigate(EventWrapper(AppNavigation.Command.Exit))
navigate(EventWrapper(AppNavigation.Command.Exit(vmParams.space.id)))
}
)
}

View file

@ -54,8 +54,8 @@ interface AppNavigation {
fun launchCollections(subscription: Subscription, space: Id)
fun launchObjectSet(target: Id, space: Id)
fun exit()
fun exitToDesktop()
fun exit(space: Id)
fun exitToDesktop(space: Id)
fun exitToVault()
fun exitToSpaceHome()
fun openGlobalSearch(space: Id)
@ -76,8 +76,9 @@ interface AppNavigation {
sealed class Command {
data object Exit : Command()
data object ExitToDesktop : Command()
@Deprecated("To be deleted. Too generic and confusing.")
data class Exit(val space: Id) : Command()
data class ExitToDesktop(val space: Id) : Command()
data object ExitToVault : Command()
data object ExitToSpaceHome : Command()
data class OpenObject(val target: Id, val space: Id) : Command()

View file

@ -290,7 +290,7 @@ open class ObjectSearchViewModel(
)
override fun onDialogCancelled() {
navigation.postValue(EventWrapper(AppNavigation.Command.Exit))
navigation.postValue(EventWrapper(AppNavigation.Command.Exit(vmParams.space.id)))
}
companion object {

View file

@ -574,7 +574,7 @@ class ObjectSetViewModel(
}
Error.NotFoundObject -> {
toast(TOAST_SET_NOT_EXIST).also {
dispatch(AppNavigation.Command.Exit)
dispatch(AppNavigation.Command.Exit(vmParams.space.id))
}
}
}
@ -929,10 +929,10 @@ class ObjectSetViewModel(
space = vmParams.space
)
).fold(
onSuccess = { dispatch(AppNavigation.Command.Exit) },
onSuccess = { dispatch(AppNavigation.Command.Exit(vmParams.space.id)) },
onFailure = {
Timber.e(it, "Error while closing object set: ${vmParams.ctx}").also {
dispatch(AppNavigation.Command.Exit)
dispatch(AppNavigation.Command.Exit(vmParams.space.id))
}
}
)

View file

@ -612,7 +612,7 @@ open class EditorViewModelTest {
testObserver
.assertHasValue()
.assertValue { value -> value.peekContent() == AppNavigation.Command.Exit }
.assertValue { value -> value.peekContent() == AppNavigation.Command.Exit(spaceId.id) }
}
@Test