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

DROID-3399 Primitives | Provide type relations into Type DataView properties menu, button add (#2266)

This commit is contained in:
Konstantin Ivanov 2025-04-09 13:54:34 +02:00 committed by GitHub
parent 8b8c917e75
commit 6e0b6274bd
Signed by: github
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 8 deletions

View file

@ -107,14 +107,7 @@ class ObjectSetSettingsFragment : BaseBottomSheetFragment<FragmentViewerRelation
with(lifecycleScope) {
subscribe(binding.editBtn.clicks()) { vm.onEditButtonClicked() }
subscribe(binding.doneBtn.clicks()) { vm.onDoneButtonClicked() }
subscribe(binding.iconAdd.clicks()) {
RelationAddToDataViewFragment.new(
ctx = ctx,
dv = dv,
viewer = viewer,
space = space
).showChildFragment()
}
subscribe(binding.iconAdd.clicks()) { vm.onAddButtonClicked() }
subscribe(vm.commands) { command ->
when (command) {
is ObjectSetSettingsViewModel.Command.OpenTypePropertiesScreen -> {
@ -130,6 +123,22 @@ class ObjectSetSettingsFragment : BaseBottomSheetFragment<FragmentViewerRelation
)
}
}
ObjectSetSettingsViewModel.Command.OpenRelationAddToDataView -> {
runCatching {
RelationAddToDataViewFragment.new(
ctx = ctx,
dv = dv,
viewer = viewer,
space = space
).showChildFragment()
}.onFailure {
Timber.e(
it,
"Error while opening relation add to data view"
)
}
}
}
}
}

View file

@ -95,6 +95,23 @@ class ObjectSetSettingsViewModel(
}
}
fun onAddButtonClicked() {
val state = objectState.value.dataViewState() ?: return
when (state) {
is ObjectState.DataView.Collection, is ObjectState.DataView.Set -> {
viewModelScope.launch {
commands.emit(Command.OpenRelationAddToDataView)
}
}
is ObjectState.DataView.TypeSet -> {
viewModelScope.launch {
commands.emit(Command.OpenTypePropertiesScreen)
}
}
}
}
fun onDoneButtonClicked() {
screenState.value = ScreenState.LIST
}
@ -240,6 +257,7 @@ class ObjectSetSettingsViewModel(
sealed class Command {
data object OpenTypePropertiesScreen : Command()
data object OpenRelationAddToDataView : Command()
}
class Factory(