mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-07 21:37:02 +09:00
DROID-2905 Navigation | Enhancement | Object type navigation (#2194)
This commit is contained in:
parent
9e809c7b8c
commit
9091ad57ee
16 changed files with 138 additions and 4 deletions
|
@ -100,6 +100,16 @@ class AllContentFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
|
|||
Timber.e(it, "Failed to open document from all content")
|
||||
}
|
||||
}
|
||||
is AllContentViewModel.Command.NavigateToObjectType -> {
|
||||
runCatching {
|
||||
navigation().openObjectType(
|
||||
objectId = command.id,
|
||||
space = command.space
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.e(it, "Failed to open object type object from all content")
|
||||
}
|
||||
}
|
||||
is AllContentViewModel.Command.OpenChat -> {
|
||||
runCatching {
|
||||
navigation().openChat(
|
||||
|
|
|
@ -61,6 +61,12 @@ class NavigationRouter(
|
|||
objectId = command.objectId,
|
||||
space = command.space
|
||||
)
|
||||
is AppNavigation.Command.OpenTypeObject -> {
|
||||
navigation.openObjectType(
|
||||
objectId = command.target,
|
||||
space = command.space
|
||||
)
|
||||
}
|
||||
is AppNavigation.Command.OpenParticipant -> navigation.openParticipantObject(
|
||||
objectId = command.objectId,
|
||||
space = command.space
|
||||
|
|
|
@ -118,6 +118,16 @@ class DateObjectFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
|
|||
Timber.e(it, "Failed to open a chat from all content")
|
||||
}
|
||||
}
|
||||
is DateObjectCommand.OpenType -> {
|
||||
runCatching {
|
||||
navigation().openObjectType(
|
||||
objectId = effect.target,
|
||||
space = effect.space.id
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.e(it, "Failed to open type object from data object")
|
||||
}
|
||||
}
|
||||
DateObjectCommand.OpenGlobalSearch -> {
|
||||
runCatching {
|
||||
findNavController().navigate(
|
||||
|
|
|
@ -453,6 +453,16 @@ class HomeScreenFragment : BaseComposeFragment(),
|
|||
Timber.e(e, "Error while opening participant from widgets")
|
||||
}
|
||||
}
|
||||
is Navigation.OpenType -> {
|
||||
runCatching {
|
||||
navigation().openObjectType(
|
||||
objectId = destination.target,
|
||||
space = destination.space
|
||||
)
|
||||
}.onFailure { e ->
|
||||
Timber.e(e, "Error while opening participant from widgets")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ import com.anytypeio.anytype.ui.multiplayer.ShareSpaceFragment
|
|||
import com.anytypeio.anytype.ui.multiplayer.SpaceJoinRequestFragment
|
||||
import com.anytypeio.anytype.ui.notifications.NotificationsFragment
|
||||
import com.anytypeio.anytype.ui.payments.MembershipFragment
|
||||
import com.anytypeio.anytype.ui.primitives.ObjectTypeFragment
|
||||
import com.anytypeio.anytype.ui.profile.ParticipantFragment
|
||||
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
||||
import com.anytypeio.anytype.ui.sharing.SharingFragment
|
||||
|
@ -347,6 +348,19 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), AppNavigation.Pr
|
|||
Timber.e(it, "Error while date object navigation")
|
||||
}
|
||||
}
|
||||
is OpenObjectNavigation.OpenType -> {
|
||||
runCatching {
|
||||
findNavController(R.id.fragment).navigate(
|
||||
resId = R.id.objectTypeScreen,
|
||||
args = ObjectTypeFragment.args(
|
||||
objectId = dest.target,
|
||||
space = dest.space
|
||||
)
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.e(it, "Error while opening object type in main activity")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.anytypeio.anytype.ui.base.navigation
|
|||
import com.anytypeio.anytype.ui.dashboard.DeleteAlertFragment
|
||||
import com.anytypeio.anytype.ui.settings.remote.RemoteFilesManageScreen
|
||||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
|
||||
class RemoteFilesManageFragment : BaseBottomSheetComposeFragment() {
|
||||
|
||||
|
@ -113,6 +114,9 @@ class RemoteFilesManageFragment : BaseBottomSheetComposeFragment() {
|
|||
is CollectionViewModel.Command.OpenParticipant -> {
|
||||
// Do nothing
|
||||
}
|
||||
is CollectionViewModel.Command.OpenTypeObject -> {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -198,6 +198,9 @@ class VaultFragment : BaseComposeFragment() {
|
|||
Timber.e(e, "Error while opening participant object from widgets")
|
||||
}
|
||||
}
|
||||
is Navigation.OpenType -> {
|
||||
Timber.e("Illegal command: type cannot be opened from vault")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,6 +128,16 @@ class CollectionFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
|
|||
Timber.e(e, "Error while opening date object from Collection screen")
|
||||
}
|
||||
}
|
||||
is Command.OpenTypeObject -> {
|
||||
runCatching {
|
||||
navigation().openObjectType(
|
||||
objectId = command.target,
|
||||
space = command.space
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.e(it, "Error while opening object type from expanded widget screen")
|
||||
}
|
||||
}
|
||||
is Command.OpenShareScreen -> {
|
||||
runCatching {
|
||||
findNavController().navigate(
|
||||
|
|
|
@ -752,6 +752,14 @@ class AllContentViewModel(
|
|||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenType -> {
|
||||
commands.emit(
|
||||
NavigateToObjectType(
|
||||
id = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1028,6 +1036,7 @@ class AllContentViewModel(
|
|||
sealed class Command {
|
||||
data class OpenChat(val target: Id, val space: Id) : Command()
|
||||
data class NavigateToEditor(val id: Id, val space: Id) : Command()
|
||||
data class NavigateToObjectType(val id: Id, val space: Id) : Command()
|
||||
data class NavigateToSetOrCollection(val id: Id, val space: Id) : Command()
|
||||
data class NavigateToBin(val space: Id) : Command()
|
||||
data class NavigateToParticipant(val objectId: Id, val space: Id) : Command()
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.primitives.SpaceId
|
|||
|
||||
sealed class DateObjectCommand {
|
||||
data class OpenChat(val target: Id, val space: SpaceId) : DateObjectCommand()
|
||||
data class OpenType(val target: Id, val space: SpaceId) : DateObjectCommand()
|
||||
data class NavigateToEditor(val id: Id, val space: SpaceId) : DateObjectCommand()
|
||||
data class NavigateToSetOrCollection(val id: Id, val space: SpaceId) : DateObjectCommand()
|
||||
data class NavigateToDateObject(val objectId: Id, val space: SpaceId) : DateObjectCommand()
|
||||
|
|
|
@ -666,7 +666,14 @@ class DateObjectViewModel(
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
is OpenObjectNavigation.OpenType -> {
|
||||
effects.emit(
|
||||
DateObjectCommand.OpenType(
|
||||
target = navigation.target,
|
||||
space = SpaceId(navigation.space)
|
||||
)
|
||||
)
|
||||
}
|
||||
OpenObjectNavigation.NonValidObject -> {
|
||||
Timber.e("Object id is missing")
|
||||
}
|
||||
|
|
|
@ -4532,6 +4532,16 @@ class EditorViewModel(
|
|||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenType -> {
|
||||
navigate(
|
||||
EventWrapper(
|
||||
OpenTypeObject(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1488,6 +1488,14 @@ class HomeScreenViewModel(
|
|||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenType -> {
|
||||
navigate(
|
||||
Navigation.OpenType(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2215,6 +2223,7 @@ class HomeScreenViewModel(
|
|||
data class OpenAllContent(val space: Id) : Navigation()
|
||||
data class OpenDateObject(val ctx: Id, val space: Id) : Navigation()
|
||||
data class OpenParticipant(val objectId: Id, val space: Id) : Navigation()
|
||||
data class OpenType(val target: Id, val space: Id) : Navigation()
|
||||
}
|
||||
|
||||
class Factory @Inject constructor(
|
||||
|
@ -2449,6 +2458,7 @@ sealed class OpenObjectNavigation {
|
|||
data class OpenChat(val target: Id, val space: Id): OpenObjectNavigation()
|
||||
data class OpenDateObject(val target: Id, val space: Id): OpenObjectNavigation()
|
||||
data class OpenParticipant(val target: Id, val space: Id): OpenObjectNavigation()
|
||||
data class OpenType(val target: Id, val space: Id) : OpenObjectNavigation()
|
||||
}
|
||||
|
||||
fun ObjectWrapper.Basic.navigation() : OpenObjectNavigation {
|
||||
|
@ -2508,6 +2518,12 @@ fun ObjectWrapper.Basic.navigation() : OpenObjectNavigation {
|
|||
space = requireNotNull(spaceId)
|
||||
)
|
||||
}
|
||||
ObjectType.Layout.OBJECT_TYPE -> {
|
||||
OpenObjectNavigation.OpenType(
|
||||
target = id,
|
||||
space = requireNotNull(spaceId)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
OpenObjectNavigation.UnexpectedLayoutError(layout)
|
||||
}
|
||||
|
|
|
@ -109,6 +109,12 @@ interface AppNavigation {
|
|||
val space: Id
|
||||
) : Command()
|
||||
|
||||
|
||||
data class OpenTypeObject(
|
||||
val target: Id,
|
||||
val space: Id
|
||||
) : Command()
|
||||
|
||||
data class OpenParticipant(
|
||||
val objectId: Id,
|
||||
val space: Id
|
||||
|
|
|
@ -329,6 +329,14 @@ class VaultViewModel(
|
|||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenType -> {
|
||||
navigate(
|
||||
OpenType(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,6 +406,7 @@ class VaultViewModel(
|
|||
data class OpenSet(val ctx: Id, val space: Id, val view: Id?) : Navigation()
|
||||
data class OpenDateObject(val ctx: Id, val space: Id) : Navigation()
|
||||
data class OpenParticipant(val ctx: Id, val space: Id) : Navigation()
|
||||
data class OpenType(val target: Id, val space: Id) : Navigation()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -934,7 +934,7 @@ class CollectionViewModel(
|
|||
when (val navigation = obj.navigation()) {
|
||||
is OpenObjectNavigation.OpenDataView -> {
|
||||
commands.emit(
|
||||
Command.LaunchObjectSet(
|
||||
LaunchObjectSet(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
|
@ -942,7 +942,7 @@ class CollectionViewModel(
|
|||
}
|
||||
is OpenObjectNavigation.OpenEditor -> {
|
||||
commands.emit(
|
||||
Command.LaunchDocument(
|
||||
LaunchDocument(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
|
@ -950,7 +950,7 @@ class CollectionViewModel(
|
|||
}
|
||||
is OpenObjectNavigation.OpenChat -> {
|
||||
commands.emit(
|
||||
Command.OpenChat(
|
||||
OpenChat(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
|
@ -970,6 +970,14 @@ class CollectionViewModel(
|
|||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenType -> {
|
||||
commands.emit(
|
||||
OpenTypeObject(
|
||||
target = navigation.target,
|
||||
space = navigation.space
|
||||
)
|
||||
)
|
||||
}
|
||||
is OpenObjectNavigation.OpenParticipant -> {
|
||||
commands.emit(
|
||||
OpenParticipant(
|
||||
|
@ -1082,6 +1090,7 @@ class CollectionViewModel(
|
|||
data class LaunchObjectSet(val target: Id, val space: Id) : Command()
|
||||
data class OpenChat(val target: Id, val space: Id) : Command()
|
||||
data class OpenDateObject(val target: Id, val space: Id) : Command()
|
||||
data class OpenTypeObject(val target: Id, val space: Id) : Command()
|
||||
data class OpenParticipant(val target: Id, val space: Id) : Command()
|
||||
data class OpenShareScreen(val space: SpaceId) : Command()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue