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:
parent
8b8c917e75
commit
6e0b6274bd
2 changed files with 35 additions and 8 deletions
|
@ -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"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue