mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3589 Type screen | Fix | Back navigation (#2336)
This commit is contained in:
parent
526284ef95
commit
5581e08abf
10 changed files with 68 additions and 45 deletions
|
@ -4,9 +4,9 @@ import com.anytypeio.anytype.core_models.Id
|
|||
|
||||
sealed class FieldEvent {
|
||||
|
||||
data object OnEditPropertyScreenDismiss : FieldEvent()
|
||||
data object OnDismissScreen : FieldEvent()
|
||||
|
||||
data object OnBackClick : FieldEvent()
|
||||
data object OnEditPropertyScreenDismiss : FieldEvent()
|
||||
|
||||
data class OnFieldItemClick(val item: UiFieldsListItem) : FieldEvent()
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.anytypeio.anytype.feature_object_type.fields.ui
|
||||
|
||||
import android.os.Build
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
|
@ -86,6 +87,7 @@ import kotlinx.coroutines.delay
|
|||
import sh.calvin.reorderable.ReorderableItem
|
||||
import sh.calvin.reorderable.ReorderableLazyListState
|
||||
import sh.calvin.reorderable.rememberReorderableLazyListState
|
||||
import timber.log.Timber
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
|
@ -121,6 +123,11 @@ fun FieldsMainScreen(
|
|||
}
|
||||
}
|
||||
|
||||
BackHandler(enabled = true) {
|
||||
Timber.d("Back pressed on Properties Screen")
|
||||
fieldEvent.invoke(FieldEvent.OnDismissScreen)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.nestedScroll(rememberNestedScrollInteropConnection())
|
||||
|
@ -136,7 +143,7 @@ fun FieldsMainScreen(
|
|||
uiTitleState = uiTitleState,
|
||||
uiIconState = uiIconState,
|
||||
onBackClick = {
|
||||
fieldEvent(OnBackClick)
|
||||
fieldEvent(FieldEvent.OnDismissScreen)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.anytypeio.anytype.feature_object_type.ui
|
|||
|
||||
import com.anytypeio.anytype.core_models.ObjectType.Layout
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceSyncAndP2PStatusState
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.custom_icon.CustomIconColor
|
||||
import com.anytypeio.anytype.presentation.templates.TemplateView
|
||||
|
||||
|
@ -43,7 +42,7 @@ sealed class TypeEvent {
|
|||
//endregion
|
||||
|
||||
data object OnLayoutButtonClick : TypeEvent()
|
||||
data object OnFieldsButtonClick : TypeEvent()
|
||||
data object OnPropertiesButtonClick : TypeEvent()
|
||||
data object OnTemplatesButtonClick : TypeEvent()
|
||||
|
||||
//region Icon picker
|
||||
|
|
|
@ -29,10 +29,6 @@ sealed class ObjectTypeCommand {
|
|||
val spaceId: Id
|
||||
) : ObjectTypeCommand()
|
||||
|
||||
data object OpenTypePropertiesListScreen : ObjectTypeCommand()
|
||||
|
||||
data object CloseFieldsScreen : ObjectTypeCommand()
|
||||
|
||||
data class OpenAddNewPropertyScreen(val typeId: Id, val space: Id) : ObjectTypeCommand()
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ fun HorizontalButtons(
|
|||
if (uiPropertiesButtonState is UiPropertiesButtonState.Visible) {
|
||||
Row(
|
||||
modifier = modifierButton.noRippleThrottledClickable {
|
||||
onTypeEvent(TypeEvent.OnFieldsButtonClick)
|
||||
onTypeEvent(TypeEvent.OnPropertiesButtonClick)
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
|
|
|
@ -175,6 +175,8 @@ class ObjectTypeViewModel(
|
|||
private val _objectTypeConflictingFieldIds = MutableStateFlow<List<Id>>(emptyList())
|
||||
//endregion
|
||||
|
||||
val showPropertiesScreen = MutableStateFlow<Boolean>(false)
|
||||
|
||||
val commands = MutableSharedFlow<ObjectTypeCommand>()
|
||||
|
||||
//region INIT AND LIFE CYCLE
|
||||
|
@ -473,10 +475,8 @@ class ObjectTypeViewModel(
|
|||
fun onTypeEvent(event: TypeEvent) {
|
||||
Timber.d("onTypeEvent: $event")
|
||||
when (event) {
|
||||
TypeEvent.OnFieldsButtonClick -> {
|
||||
viewModelScope.launch {
|
||||
commands.emit(ObjectTypeCommand.OpenTypePropertiesListScreen)
|
||||
}
|
||||
TypeEvent.OnPropertiesButtonClick -> {
|
||||
showPropertiesScreen.value = true
|
||||
viewModelScope.launch {
|
||||
sendAnalyticsShowObjectTypeScreen(
|
||||
analytics = analytics,
|
||||
|
@ -551,7 +551,7 @@ class ObjectTypeViewModel(
|
|||
|
||||
TypeEvent.OnBackClick -> {
|
||||
viewModelScope.launch {
|
||||
commands.emit(ObjectTypeCommand.Back)
|
||||
commands.emit(Back)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,10 +817,9 @@ class ObjectTypeViewModel(
|
|||
}
|
||||
|
||||
is FieldEvent.EditProperty -> proceedWithEditPropertyEvent(event)
|
||||
FieldEvent.OnBackClick -> {
|
||||
viewModelScope.launch {
|
||||
commands.emit(ObjectTypeCommand.CloseFieldsScreen)
|
||||
}
|
||||
|
||||
FieldEvent.OnDismissScreen -> {
|
||||
showPropertiesScreen.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue