mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3367 Primitives | Object icons (#2180)
This commit is contained in:
parent
ccbdc3c146
commit
b003a9e915
88 changed files with 632 additions and 1877 deletions
|
@ -21,6 +21,7 @@ import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
|||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
|
@ -68,6 +69,9 @@ class FilterListTest {
|
|||
@Mock
|
||||
lateinit var fieldParser: FieldParser
|
||||
|
||||
@Mock
|
||||
lateinit var storeOfObjectTypes: StoreOfObjectTypes
|
||||
|
||||
lateinit var updateDataViewViewer: UpdateDataViewViewer
|
||||
lateinit var searchObjects: SearchObjects
|
||||
lateinit var urlBuilder: UrlBuilder
|
||||
|
@ -93,7 +97,8 @@ class FilterListTest {
|
|||
analytics = analytics,
|
||||
storeOfRelations = storeOfRelations,
|
||||
objectSetDatabase = db,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ import com.anytypeio.anytype.di.feature.onboarding.signup.DaggerOnboardingMnemon
|
|||
import com.anytypeio.anytype.di.feature.onboarding.signup.DaggerOnboardingSoulCreationComponent
|
||||
import com.anytypeio.anytype.di.feature.participant.DaggerParticipantComponent
|
||||
import com.anytypeio.anytype.di.feature.relations.DaggerRelationCreateFromLibraryComponent
|
||||
import com.anytypeio.anytype.di.feature.relations.DaggerRelationEditComponent
|
||||
import com.anytypeio.anytype.di.feature.relations.LimitObjectTypeModule
|
||||
import com.anytypeio.anytype.di.feature.relations.RelationAddToDataViewModule
|
||||
import com.anytypeio.anytype.di.feature.relations.RelationAddToObjectModule
|
||||
|
@ -96,9 +95,6 @@ import com.anytypeio.anytype.di.feature.spaces.DaggerSpaceListComponent
|
|||
import com.anytypeio.anytype.di.feature.spaces.DaggerSpaceSettingsComponent
|
||||
import com.anytypeio.anytype.di.feature.templates.DaggerTemplateBlankComponent
|
||||
import com.anytypeio.anytype.di.feature.templates.DaggerTemplateSelectComponent
|
||||
import com.anytypeio.anytype.di.feature.types.DaggerCreateObjectTypeComponent
|
||||
import com.anytypeio.anytype.di.feature.types.DaggerTypeEditComponent
|
||||
import com.anytypeio.anytype.di.feature.types.DaggerTypeIconPickComponent
|
||||
import com.anytypeio.anytype.di.feature.vault.DaggerVaultComponent
|
||||
import com.anytypeio.anytype.di.feature.wallpaper.WallpaperSelectModule
|
||||
import com.anytypeio.anytype.di.feature.widgets.DaggerSelectWidgetSourceComponent
|
||||
|
@ -132,8 +128,6 @@ import com.anytypeio.anytype.presentation.sets.ObjectSetViewModel
|
|||
import com.anytypeio.anytype.presentation.settings.SpacesStorageViewModel
|
||||
import com.anytypeio.anytype.presentation.spaces.SpaceSettingsViewModel
|
||||
import com.anytypeio.anytype.presentation.widgets.collection.CollectionViewModel
|
||||
import com.anytypeio.anytype.ui.relations.RelationEditParameters
|
||||
import com.anytypeio.anytype.ui.types.edit.TypeEditParameters
|
||||
import com.anytypeio.anytype.ui.widgets.collection.DaggerCollectionComponent
|
||||
import timber.log.Timber
|
||||
|
||||
|
@ -802,36 +796,6 @@ class ComponentManager(
|
|||
.build()
|
||||
}
|
||||
|
||||
val createObjectTypeComponent = Component {
|
||||
DaggerCreateObjectTypeComponent
|
||||
.factory()
|
||||
.create(findComponentDependencies())
|
||||
}
|
||||
|
||||
val typeEditComponent = ComponentWithParams { params: TypeEditParameters ->
|
||||
DaggerTypeEditComponent.builder()
|
||||
.withId(params.id)
|
||||
.withName(params.name)
|
||||
.withIcon(params.icon)
|
||||
.withDependencies(findComponentDependencies())
|
||||
.build()
|
||||
}
|
||||
|
||||
val relationEditComponent = ComponentWithParams { params: RelationEditParameters ->
|
||||
DaggerRelationEditComponent.builder()
|
||||
.withId(params.id)
|
||||
.withName(params.name)
|
||||
.withIcon(params.icon)
|
||||
.withDependencies(findComponentDependencies())
|
||||
.build()
|
||||
}
|
||||
|
||||
val typeIconPickComponent = Component {
|
||||
DaggerTypeIconPickComponent
|
||||
.factory()
|
||||
.create(findComponentDependencies())
|
||||
}
|
||||
|
||||
val relationCreationFromLibraryComponent = Component {
|
||||
DaggerRelationCreateFromLibraryComponent
|
||||
.factory()
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
|||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
|
@ -77,4 +78,5 @@ interface BacklinkOrAddToObjectDependencies : ComponentDependencies {
|
|||
fun searchObjects(): SearchObjects
|
||||
fun dateProvider(): DateProvider
|
||||
fun fieldParser(): FieldParser
|
||||
fun storeOfObjectTypes(): StoreOfObjectTypes
|
||||
}
|
|
@ -6,6 +6,7 @@ import com.anytypeio.anytype.di.common.ComponentDependencies
|
|||
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
|
@ -44,6 +45,7 @@ interface LinkToObjectDependencies: ComponentDependencies {
|
|||
fun analyticSpaceHelperDelegate(): AnalyticSpaceHelperDelegate
|
||||
fun dateProvider(): DateProvider
|
||||
fun fieldParser(): FieldParser
|
||||
fun storeOfObjectTypes(): StoreOfObjectTypes
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,7 +62,8 @@ object LinkToObjectModule {
|
|||
searchObjects: SearchObjects,
|
||||
analytics: Analytics,
|
||||
analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): LinkToObjectViewModelFactory = LinkToObjectViewModelFactory(
|
||||
vmParams = vmParams,
|
||||
urlBuilder = urlBuilder,
|
||||
|
@ -68,6 +71,7 @@ object LinkToObjectModule {
|
|||
searchObjects = searchObjects,
|
||||
analytics = analytics,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
|||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
|
@ -42,6 +43,7 @@ interface MoveToDependencies : ComponentDependencies {
|
|||
fun analytics(): Analytics
|
||||
fun analyticSpaceHelperDelegate(): AnalyticSpaceHelperDelegate
|
||||
fun fieldParser(): FieldParser
|
||||
fun storeOfObjectTypes(): StoreOfObjectTypes
|
||||
}
|
||||
|
||||
@Module
|
||||
|
@ -57,7 +59,8 @@ object MoveToModule {
|
|||
searchObjects: SearchObjects,
|
||||
analytics: Analytics,
|
||||
analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): MoveToViewModelFactory = MoveToViewModelFactory(
|
||||
vmParams = vmParams,
|
||||
urlBuilder = urlBuilder,
|
||||
|
@ -65,6 +68,7 @@ object MoveToModule {
|
|||
searchObjects = searchObjects,
|
||||
analytics = analytics,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.anytypeio.anytype.analytics.base.Analytics
|
|||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
|
@ -43,7 +44,8 @@ object ViewerFilterModule {
|
|||
analytics: Analytics,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
db: ObjectSetDatabase,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): ViewerFilterViewModel.Factory = ViewerFilterViewModel.Factory(
|
||||
state = state,
|
||||
dispatcher = dispatcher,
|
||||
|
@ -52,7 +54,8 @@ object ViewerFilterModule {
|
|||
analytics = analytics,
|
||||
storeOfRelations = storeOfRelations,
|
||||
objectSetDatabase = db,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
package com.anytypeio.anytype.di.feature.relations
|
||||
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.presentation.relations.RelationEditViewModel
|
||||
import com.anytypeio.anytype.presentation.types.TypeIcon
|
||||
import com.anytypeio.anytype.presentation.types.TypeId
|
||||
import com.anytypeio.anytype.presentation.types.TypeName
|
||||
import com.anytypeio.anytype.ui.relations.RelationEditFragment
|
||||
import dagger.Binds
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@Component(
|
||||
dependencies = [RelationEditDependencies::class],
|
||||
modules = [
|
||||
RelationEditModule::class,
|
||||
RelationEditModule.Declarations::class
|
||||
]
|
||||
)
|
||||
@PerScreen
|
||||
interface RelationEditComponent {
|
||||
|
||||
@Component.Builder
|
||||
interface Builder {
|
||||
|
||||
@BindsInstance
|
||||
fun withName(@TypeName name: String): Builder
|
||||
|
||||
@BindsInstance
|
||||
fun withId(@TypeId id: String): Builder
|
||||
|
||||
@BindsInstance
|
||||
fun withIcon(@TypeIcon icon: Int): Builder
|
||||
|
||||
fun withDependencies(dependencies: RelationEditDependencies): Builder
|
||||
|
||||
fun build(): RelationEditComponent
|
||||
}
|
||||
|
||||
fun inject(fragment: RelationEditFragment)
|
||||
}
|
||||
|
||||
@Module
|
||||
object RelationEditModule {
|
||||
|
||||
@Module
|
||||
interface Declarations {
|
||||
|
||||
@PerScreen
|
||||
@Binds
|
||||
fun bindViewModelFactory(factory: RelationEditViewModel.Factory): ViewModelProvider.Factory
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface RelationEditDependencies : ComponentDependencies {
|
||||
fun blockRepository(): BlockRepository
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package com.anytypeio.anytype.di.feature.types
|
||||
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.types.CreateObjectType
|
||||
import com.anytypeio.anytype.domain.workspace.SpaceManager
|
||||
import com.anytypeio.anytype.emojifier.data.Emoji
|
||||
import com.anytypeio.anytype.emojifier.data.EmojiProvider
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.types.CreateObjectTypeViewModel
|
||||
import com.anytypeio.anytype.ui.types.create.CreateObjectTypeFragment
|
||||
import dagger.Binds
|
||||
import dagger.Component
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@Component(
|
||||
dependencies = [CreateObjectTypeDependencies::class],
|
||||
modules = [
|
||||
CreateObjectTypeModule::class,
|
||||
CreateObjectTypeModule.Declarations::class
|
||||
]
|
||||
)
|
||||
@PerScreen
|
||||
interface CreateObjectTypeComponent {
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
fun create(dependencies: CreateObjectTypeDependencies): CreateObjectTypeComponent
|
||||
}
|
||||
|
||||
fun inject(fragment: CreateObjectTypeFragment)
|
||||
}
|
||||
|
||||
@Module
|
||||
object CreateObjectTypeModule {
|
||||
|
||||
@Provides
|
||||
@PerScreen
|
||||
@JvmStatic
|
||||
fun provideEmojiProvider(): EmojiProvider = Emoji
|
||||
|
||||
@JvmStatic
|
||||
@PerScreen
|
||||
@Provides
|
||||
fun provideCreateTypeInteractor(
|
||||
blockRepository: BlockRepository,
|
||||
dispatchers: AppCoroutineDispatchers
|
||||
): CreateObjectType = CreateObjectType(blockRepository, dispatchers)
|
||||
|
||||
@Module
|
||||
interface Declarations {
|
||||
|
||||
@PerScreen
|
||||
@Binds
|
||||
fun bindViewModelFactory(factory: CreateObjectTypeViewModel.Factory): ViewModelProvider.Factory
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface CreateObjectTypeDependencies : ComponentDependencies {
|
||||
fun blockRepository(): BlockRepository
|
||||
fun dispatchers(): AppCoroutineDispatchers
|
||||
fun urlBuilder(): UrlBuilder
|
||||
fun analytics(): Analytics
|
||||
fun spaceManager(): SpaceManager
|
||||
fun analyticSpaceHelper(): AnalyticSpaceHelperDelegate
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package com.anytypeio.anytype.di.feature.types
|
||||
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.emojifier.data.Emoji
|
||||
import com.anytypeio.anytype.emojifier.data.EmojiProvider
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.types.TypeEditViewModel
|
||||
import com.anytypeio.anytype.presentation.types.TypeIcon
|
||||
import com.anytypeio.anytype.presentation.types.TypeId
|
||||
import com.anytypeio.anytype.presentation.types.TypeName
|
||||
import com.anytypeio.anytype.ui.types.edit.TypeEditFragment
|
||||
import dagger.Binds
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@Component(
|
||||
dependencies = [TypeEditDependencies::class],
|
||||
modules = [
|
||||
TypeEditModule::class,
|
||||
TypeEditModule.Declarations::class
|
||||
]
|
||||
)
|
||||
@PerScreen
|
||||
interface TypeEditComponent {
|
||||
|
||||
@Component.Builder
|
||||
interface Builder {
|
||||
|
||||
@BindsInstance
|
||||
fun withName(@TypeName name: String): Builder
|
||||
|
||||
@BindsInstance
|
||||
fun withId(@TypeId id: String): Builder
|
||||
|
||||
@BindsInstance
|
||||
fun withIcon(@TypeIcon icon: String): Builder
|
||||
|
||||
fun withDependencies(dependencies: TypeEditDependencies): Builder
|
||||
|
||||
fun build(): TypeEditComponent
|
||||
}
|
||||
|
||||
fun inject(fragment: TypeEditFragment)
|
||||
}
|
||||
|
||||
@Module
|
||||
object TypeEditModule {
|
||||
|
||||
@Provides
|
||||
@PerScreen
|
||||
@JvmStatic
|
||||
fun provideEmojiProvider(): EmojiProvider = Emoji
|
||||
|
||||
@Module
|
||||
interface Declarations {
|
||||
|
||||
@PerScreen
|
||||
@Binds
|
||||
fun bindViewModelFactory(factory: TypeEditViewModel.Factory): ViewModelProvider.Factory
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface TypeEditDependencies : ComponentDependencies {
|
||||
fun blockRepository(): BlockRepository
|
||||
fun urlBuilder(): UrlBuilder
|
||||
fun analytics(): Analytics
|
||||
fun analyticSpaceHelper(): AnalyticSpaceHelperDelegate
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package com.anytypeio.anytype.di.feature.types
|
||||
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.emojifier.data.Emoji
|
||||
import com.anytypeio.anytype.emojifier.data.EmojiProvider
|
||||
import com.anytypeio.anytype.emojifier.suggest.EmojiSuggester
|
||||
import com.anytypeio.anytype.presentation.types.icon_picker.TypeIconPickerViewModel
|
||||
import com.anytypeio.anytype.ui.types.picker.TypeIconPickFragment
|
||||
import dagger.Binds
|
||||
import dagger.Component
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@Component(
|
||||
dependencies = [TypeIconPickDependencies::class],
|
||||
modules = [
|
||||
TypeIconPickModule::class,
|
||||
TypeIconPickModule.Declarations::class
|
||||
]
|
||||
)
|
||||
@PerScreen
|
||||
interface TypeIconPickComponent {
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
fun create(dependencies: TypeIconPickDependencies): TypeIconPickComponent
|
||||
}
|
||||
|
||||
fun inject(fragment: TypeIconPickFragment)
|
||||
}
|
||||
|
||||
@Module
|
||||
object TypeIconPickModule {
|
||||
|
||||
@Provides
|
||||
@PerScreen
|
||||
@JvmStatic
|
||||
fun provideEmojiProvider(): EmojiProvider = Emoji
|
||||
|
||||
@Module
|
||||
interface Declarations {
|
||||
|
||||
@PerScreen
|
||||
@Binds
|
||||
fun bindViewModelFactory(factory: TypeIconPickerViewModel.Factory): ViewModelProvider.Factory
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface TypeIconPickDependencies : ComponentDependencies {
|
||||
fun emojiSuggester(): EmojiSuggester
|
||||
fun blockRepository(): BlockRepository
|
||||
}
|
|
@ -66,7 +66,8 @@ object SelectWidgetSourceModule {
|
|||
getObjectTypes: GetObjectTypes,
|
||||
dispatcher: Dispatcher<WidgetDispatchEvent>,
|
||||
analyticsHelper: AnalyticSpaceHelperDelegate,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): SelectWidgetSourceViewModel.Factory = SelectWidgetSourceViewModel.Factory(
|
||||
vmParams = vmParams,
|
||||
urlBuilder = urlBuilder,
|
||||
|
@ -75,6 +76,7 @@ object SelectWidgetSourceModule {
|
|||
getObjectTypes = getObjectTypes,
|
||||
dispatcher = dispatcher,
|
||||
analyticSpaceHelperDelegate = analyticsHelper,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
|
@ -3,7 +3,6 @@ package com.anytypeio.anytype.di.main
|
|||
import com.anytypeio.anytype.app.AndroidApplication
|
||||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||
import com.anytypeio.anytype.di.common.ComponentDependenciesKey
|
||||
import com.anytypeio.anytype.di.feature.EditTypePropertiesDependencies
|
||||
import com.anytypeio.anytype.di.feature.AllContentDependencies
|
||||
import com.anytypeio.anytype.di.feature.AppPreferencesDependencies
|
||||
import com.anytypeio.anytype.di.feature.BacklinkOrAddToObjectDependencies
|
||||
|
@ -11,6 +10,7 @@ import com.anytypeio.anytype.di.feature.CreateBookmarkSubComponent
|
|||
import com.anytypeio.anytype.di.feature.CreateObjectSubComponent
|
||||
import com.anytypeio.anytype.di.feature.DateObjectDependencies
|
||||
import com.anytypeio.anytype.di.feature.DebugSettingsSubComponent
|
||||
import com.anytypeio.anytype.di.feature.EditTypePropertiesDependencies
|
||||
import com.anytypeio.anytype.di.feature.EditorSubComponent
|
||||
import com.anytypeio.anytype.di.feature.KeychainPhraseSubComponent
|
||||
import com.anytypeio.anytype.di.feature.LinkToObjectDependencies
|
||||
|
@ -41,7 +41,6 @@ import com.anytypeio.anytype.di.feature.onboarding.signup.OnboardingMnemonicDepe
|
|||
import com.anytypeio.anytype.di.feature.onboarding.signup.OnboardingSoulCreationDependencies
|
||||
import com.anytypeio.anytype.di.feature.participant.ParticipantComponentDependencies
|
||||
import com.anytypeio.anytype.di.feature.relations.RelationCreateFromLibraryDependencies
|
||||
import com.anytypeio.anytype.di.feature.relations.RelationEditDependencies
|
||||
import com.anytypeio.anytype.di.feature.search.GlobalSearchDependencies
|
||||
import com.anytypeio.anytype.di.feature.settings.AboutAppDependencies
|
||||
import com.anytypeio.anytype.di.feature.settings.AppearanceDependencies
|
||||
|
@ -57,9 +56,6 @@ import com.anytypeio.anytype.di.feature.spaces.SpaceListDependencies
|
|||
import com.anytypeio.anytype.di.feature.spaces.SpaceSettingsDependencies
|
||||
import com.anytypeio.anytype.di.feature.templates.TemplateBlankDependencies
|
||||
import com.anytypeio.anytype.di.feature.templates.TemplateSelectDependencies
|
||||
import com.anytypeio.anytype.di.feature.types.CreateObjectTypeDependencies
|
||||
import com.anytypeio.anytype.di.feature.types.TypeEditDependencies
|
||||
import com.anytypeio.anytype.di.feature.types.TypeIconPickDependencies
|
||||
import com.anytypeio.anytype.di.feature.vault.VaultComponentDependencies
|
||||
import com.anytypeio.anytype.di.feature.wallpaper.WallpaperSelectSubComponent
|
||||
import com.anytypeio.anytype.di.feature.widgets.SelectWidgetSourceDependencies
|
||||
|
@ -99,11 +95,7 @@ interface MainComponent :
|
|||
AppearanceDependencies,
|
||||
HomeScreenDependencies,
|
||||
CollectionDependencies,
|
||||
CreateObjectTypeDependencies,
|
||||
TypeIconPickDependencies,
|
||||
TypeEditDependencies,
|
||||
RelationCreateFromLibraryDependencies,
|
||||
RelationEditDependencies,
|
||||
SplashDependencies,
|
||||
DeletedAccountDependencies,
|
||||
BacklinkOrAddToObjectDependencies,
|
||||
|
@ -187,31 +179,11 @@ abstract class ComponentDependenciesModule {
|
|||
@ComponentDependenciesKey(CollectionDependencies::class)
|
||||
abstract fun provideHomeWidgetDependencies(component: MainComponent): ComponentDependencies
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ComponentDependenciesKey(CreateObjectTypeDependencies::class)
|
||||
abstract fun provideTypeCreationDependencies(component: MainComponent): ComponentDependencies
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ComponentDependenciesKey(TypeEditDependencies::class)
|
||||
abstract fun provideTypeEditDependencies(component: MainComponent): ComponentDependencies
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ComponentDependenciesKey(TypeIconPickDependencies::class)
|
||||
abstract fun provideTypeIconPickDependencies(component: MainComponent): ComponentDependencies
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ComponentDependenciesKey(RelationCreateFromLibraryDependencies::class)
|
||||
abstract fun provideRelationCreateFromLibraryDependencies(component: MainComponent): ComponentDependencies
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ComponentDependenciesKey(RelationEditDependencies::class)
|
||||
abstract fun provideRelationEditDependencies(component: MainComponent): ComponentDependencies
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ComponentDependenciesKey(SplashDependencies::class)
|
||||
|
|
|
@ -20,15 +20,12 @@ import com.anytypeio.anytype.ui.primitives.ObjectTypeFieldsFragment
|
|||
import com.anytypeio.anytype.ui.profile.ParticipantFragment
|
||||
import com.anytypeio.anytype.ui.primitives.ObjectTypeFragment
|
||||
import com.anytypeio.anytype.ui.relations.RelationCreateFromScratchForObjectFragment
|
||||
import com.anytypeio.anytype.ui.relations.RelationEditFragment
|
||||
import com.anytypeio.anytype.ui.search.GlobalSearchFragment
|
||||
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
||||
import com.anytypeio.anytype.ui.settings.RemoteFilesManageFragment
|
||||
import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.TYPE_TEMPLATE_EDIT
|
||||
import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.TYPE_TEMPLATE_SELECT
|
||||
import com.anytypeio.anytype.ui.templates.TemplateSelectFragment
|
||||
import com.anytypeio.anytype.ui.types.create.CreateObjectTypeFragment
|
||||
import com.anytypeio.anytype.ui.types.edit.TypeEditFragment
|
||||
import com.anytypeio.anytype.ui.widgets.collection.CollectionFragment
|
||||
import timber.log.Timber
|
||||
|
||||
|
@ -286,27 +283,6 @@ class Navigator : AppNavigation {
|
|||
)
|
||||
}
|
||||
|
||||
override fun openTypeEditingScreen(id: Id, name: String, icon: String, readOnly: Boolean) {
|
||||
navController?.navigate(
|
||||
resId = R.id.openTypeEditingScreen,
|
||||
args = TypeEditFragment.args(
|
||||
typeName = name,
|
||||
id = id,
|
||||
iconUnicode = icon,
|
||||
readOnly = readOnly
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun openTypeCreationScreen(name: String) {
|
||||
navController?.navigate(
|
||||
resId = R.id.openTypeCreationScreen,
|
||||
args = CreateObjectTypeFragment.args(
|
||||
typeName = name
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun openRelationCreationScreen(id: Id, name: String, space: Id) {
|
||||
navController?.navigate(
|
||||
resId = R.id.openRelationCreationScreen,
|
||||
|
@ -318,23 +294,6 @@ class Navigator : AppNavigation {
|
|||
)
|
||||
}
|
||||
|
||||
override fun openRelationEditingScreen(
|
||||
typeName: String,
|
||||
id: Id,
|
||||
iconUnicode: Int,
|
||||
readOnly: Boolean
|
||||
) {
|
||||
navController?.navigate(
|
||||
resId = R.id.openRelationEditingScreen,
|
||||
args = RelationEditFragment.args(
|
||||
typeName = typeName,
|
||||
id = id,
|
||||
iconUnicode = iconUnicode,
|
||||
readOnly = readOnly
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun openDateObject(
|
||||
objectId: Id,
|
||||
space: Id
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.view.ViewGroup
|
|||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.fragment.compose.content
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
|
@ -16,7 +15,6 @@ import androidx.navigation.compose.NavHost
|
|||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.BuildConfig
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
|
@ -27,30 +25,19 @@ import com.anytypeio.anytype.core_utils.ext.toast
|
|||
import com.anytypeio.anytype.core_utils.insets.EDGE_TO_EDGE_MIN_SDK
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseComposeFragment
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.feature_allcontent.models.AllContentTab
|
||||
import com.anytypeio.anytype.feature_allcontent.presentation.AllContentViewModel
|
||||
import com.anytypeio.anytype.feature_allcontent.presentation.AllContentViewModelFactory
|
||||
import com.anytypeio.anytype.feature_allcontent.ui.AllContentNavigation.ALL_CONTENT_MAIN
|
||||
import com.anytypeio.anytype.feature_allcontent.ui.AllContentWrapperScreen
|
||||
import com.anytypeio.anytype.presentation.navigation.NavPanelState
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.widgets.collection.Subscription
|
||||
import com.anytypeio.anytype.ui.base.navigation
|
||||
import com.anytypeio.anytype.ui.multiplayer.ShareSpaceFragment
|
||||
import com.anytypeio.anytype.ui.objects.creation.ObjectTypeSelectionFragment
|
||||
import com.anytypeio.anytype.ui.objects.types.pickers.ObjectTypeSelectionListener
|
||||
import com.anytypeio.anytype.ui.profile.ParticipantFragment
|
||||
import com.anytypeio.anytype.ui.relations.REQUEST_KEY_MODIFY_RELATION
|
||||
import com.anytypeio.anytype.ui.relations.REQUEST_KEY_UNINSTALL_RELATION
|
||||
import com.anytypeio.anytype.ui.relations.REQUEST_UNINSTALL_RELATION_ARG_ID
|
||||
import com.anytypeio.anytype.ui.relations.REQUEST_UNINSTALL_RELATION_ARG_NAME
|
||||
import com.anytypeio.anytype.ui.search.GlobalSearchFragment
|
||||
import com.anytypeio.anytype.ui.settings.typography
|
||||
import com.anytypeio.anytype.ui.types.edit.REQUEST_KEY_MODIFY_TYPE
|
||||
import com.anytypeio.anytype.ui.types.edit.REQUEST_KEY_UNINSTALL_TYPE
|
||||
import com.anytypeio.anytype.ui.types.edit.REQUEST_UNINSTALL_TYPE_ARG_ICON
|
||||
import com.anytypeio.anytype.ui.types.edit.REQUEST_UNINSTALL_TYPE_ARG_ID
|
||||
import com.anytypeio.anytype.ui.types.edit.REQUEST_UNINSTALL_TYPE_ARG_NAME
|
||||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
|
||||
|
@ -63,35 +50,6 @@ class AllContentFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
|
|||
|
||||
private val space get() = argString(ARG_SPACE)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setFragmentResultListener(REQUEST_KEY_UNINSTALL_TYPE) { _, bundle ->
|
||||
val id = requireNotNull(bundle.getString(REQUEST_UNINSTALL_TYPE_ARG_ID))
|
||||
val name = requireNotNull(bundle.getString(REQUEST_UNINSTALL_TYPE_ARG_NAME))
|
||||
vm.uninstallObject(id, AllContentTab.TYPES, name)
|
||||
}
|
||||
setFragmentResultListener(REQUEST_KEY_MODIFY_TYPE) { _, bundle ->
|
||||
val id = requireNotNull(bundle.getString(REQUEST_UNINSTALL_TYPE_ARG_ID))
|
||||
val name = requireNotNull(bundle.getString(REQUEST_UNINSTALL_TYPE_ARG_NAME))
|
||||
val icon = requireNotNull(bundle.getString(REQUEST_UNINSTALL_TYPE_ARG_ICON))
|
||||
vm.updateObject(id, name, icon)
|
||||
}
|
||||
setFragmentResultListener(REQUEST_KEY_UNINSTALL_RELATION) { _, bundle ->
|
||||
val id = requireNotNull(bundle.getString(REQUEST_UNINSTALL_RELATION_ARG_ID))
|
||||
val name = requireNotNull(bundle.getString(REQUEST_UNINSTALL_RELATION_ARG_NAME))
|
||||
vm.uninstallObject(id, AllContentTab.RELATIONS, name)
|
||||
}
|
||||
setFragmentResultListener(REQUEST_KEY_MODIFY_RELATION) { _, bundle ->
|
||||
val id = requireNotNull(bundle.getString(REQUEST_UNINSTALL_RELATION_ARG_ID))
|
||||
val name = requireNotNull(bundle.getString(REQUEST_UNINSTALL_RELATION_ARG_NAME))
|
||||
vm.updateObject(
|
||||
id = id,
|
||||
name = name,
|
||||
icon = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
@ -218,14 +176,7 @@ class AllContentFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
|
|||
}
|
||||
|
||||
is AllContentViewModel.Command.OpenTypeCreation -> {
|
||||
runCatching {
|
||||
navigation().openTypeCreationScreen(
|
||||
name = ""
|
||||
)
|
||||
}.onFailure {
|
||||
toast("Failed to open type creation screen")
|
||||
Timber.e(it, "Failed to open type creation screen from all content")
|
||||
}
|
||||
//todo: implement new screen logic
|
||||
}
|
||||
|
||||
is AllContentViewModel.Command.OpenRelationCreation -> {
|
||||
|
@ -242,17 +193,7 @@ class AllContentFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
|
|||
}
|
||||
|
||||
is AllContentViewModel.Command.OpenRelationEditing -> {
|
||||
runCatching {
|
||||
navigation().openRelationEditingScreen(
|
||||
typeName = command.typeName,
|
||||
id = command.id,
|
||||
iconUnicode = command.iconUnicode,
|
||||
readOnly = command.readOnly
|
||||
)
|
||||
}.onFailure {
|
||||
toast("Failed to open relation editing screen")
|
||||
Timber.e(it, "Failed to open relation editing screen from all content")
|
||||
}
|
||||
//todo: implement new screen logic
|
||||
}
|
||||
is AllContentViewModel.Command.NavigateToDateObject -> {
|
||||
runCatching {
|
||||
|
@ -365,7 +306,7 @@ class AllContentFragment : BaseComposeFragment(), ObjectTypeSelectionListener {
|
|||
}
|
||||
|
||||
override fun onApplyWindowRootInsets(view: View) {
|
||||
if (BuildConfig.USE_EDGE_TO_EDGE && Build.VERSION.SDK_INT >= EDGE_TO_EDGE_MIN_SDK) {
|
||||
if (Build.VERSION.SDK_INT >= EDGE_TO_EDGE_MIN_SDK) {
|
||||
// Do nothing.
|
||||
} else {
|
||||
super.onApplyWindowRootInsets(view)
|
||||
|
|
|
@ -11,7 +11,6 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.fragment.compose.content
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
|
@ -39,9 +38,6 @@ import com.anytypeio.anytype.feature_object_type.viewmodel.ObjectTypeVMFactory
|
|||
import com.anytypeio.anytype.feature_object_type.viewmodel.ObjectTypeViewModel
|
||||
import com.anytypeio.anytype.ui.editor.EditorModalFragment
|
||||
import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.TYPE_TEMPLATE_EDIT
|
||||
import com.anytypeio.anytype.ui.types.picker.REQUEST_KEY_PICK_EMOJI
|
||||
import com.anytypeio.anytype.ui.types.picker.REQUEST_KEY_REMOVE_EMOJI
|
||||
import com.anytypeio.anytype.ui.types.picker.RESULT_EMOJI_UNICODE
|
||||
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
|
||||
import com.google.accompanist.navigation.material.rememberBottomSheetNavigator
|
||||
import javax.inject.Inject
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.anytypeio.anytype.ui.relations
|
||||
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.R
|
||||
|
@ -9,9 +8,9 @@ import com.anytypeio.anytype.core_models.Id
|
|||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.relations.RelationCreateFromLibraryViewModel
|
||||
import com.anytypeio.anytype.ui.types.create.REQUEST_CREATE_OBJECT
|
||||
import javax.inject.Inject
|
||||
|
||||
@Deprecated("to delete")
|
||||
class RelationCreateFromLibraryFragment : RelationCreateFromScratchBaseFragment() {
|
||||
|
||||
@Inject
|
||||
|
@ -26,8 +25,6 @@ class RelationCreateFromLibraryFragment : RelationCreateFromScratchBaseFragment(
|
|||
private fun onNavigation(navigationEvent: RelationCreateFromLibraryViewModel.Navigation) {
|
||||
when (navigationEvent) {
|
||||
is RelationCreateFromLibraryViewModel.Navigation.Back -> {
|
||||
setFragmentResult(REQUEST_CREATE_OBJECT, bundleOf())
|
||||
dismiss()
|
||||
}
|
||||
else -> {
|
||||
// do nothing
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.relations
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_ui.common.ComposeDialogView
|
||||
import com.anytypeio.anytype.core_utils.ext.argBoolean
|
||||
import com.anytypeio.anytype.core_utils.ext.argInt
|
||||
import com.anytypeio.anytype.core_utils.ext.argString
|
||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.relations.RelationEditViewModel
|
||||
import com.anytypeio.anytype.ui.settings.typography
|
||||
import com.anytypeio.anytype.ui.types.edit.REQUEST_UNINSTALL_TYPE_ARG_ID
|
||||
import com.anytypeio.anytype.ui.types.edit.REQUEST_UNINSTALL_TYPE_ARG_NAME
|
||||
import javax.inject.Inject
|
||||
|
||||
class RelationEditFragment: BaseBottomSheetComposeFragment() {
|
||||
|
||||
@Inject
|
||||
lateinit var factory: RelationEditViewModel.Factory
|
||||
|
||||
private val vm by viewModels<RelationEditViewModel> { factory }
|
||||
|
||||
private val id get() = argString(ARG_RELATION_EDIT_ID)
|
||||
private val name get() = argString(ARG_RELATION_EDIT_NAME)
|
||||
private val icon get() = argInt(ARG_RELATION_EDIT_UNICODE)
|
||||
private val readOnly get() = argBoolean(ARG_RELATION_EDIT_READONLY)
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
) = ComposeDialogView(
|
||||
context = requireContext(),
|
||||
dialog = requireDialog()
|
||||
).apply {
|
||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
setContent {
|
||||
MaterialTheme(typography = typography) {
|
||||
RelationEditScreen(
|
||||
vm = vm,
|
||||
preparedName = name,
|
||||
readOnly = readOnly
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
subscribe(vm.navigation) {
|
||||
when (it) {
|
||||
is RelationEditViewModel.Navigation.BackWithModify -> {
|
||||
setFragmentResult(
|
||||
REQUEST_KEY_MODIFY_RELATION, bundleOf(
|
||||
REQUEST_UNINSTALL_TYPE_ARG_ID to id,
|
||||
REQUEST_UNINSTALL_TYPE_ARG_NAME to it.name
|
||||
)
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
is RelationEditViewModel.Navigation.BackWithUninstall -> {
|
||||
setFragmentResult(
|
||||
REQUEST_KEY_UNINSTALL_RELATION, bundleOf(
|
||||
REQUEST_UNINSTALL_TYPE_ARG_ID to id,
|
||||
REQUEST_UNINSTALL_TYPE_ARG_NAME to name,
|
||||
)
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun injectDependencies() {
|
||||
componentManager().relationEditComponent.get(
|
||||
RelationEditParameters(id = id, name = name, icon = icon)
|
||||
).inject(this)
|
||||
}
|
||||
|
||||
override fun releaseDependencies() {
|
||||
componentManager().relationEditComponent.release()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun args(
|
||||
typeName: String,
|
||||
id: Id,
|
||||
iconUnicode: Int,
|
||||
readOnly: Boolean
|
||||
) = bundleOf(
|
||||
ARG_RELATION_EDIT_NAME to typeName,
|
||||
ARG_RELATION_EDIT_ID to id,
|
||||
ARG_RELATION_EDIT_UNICODE to iconUnicode,
|
||||
ARG_RELATION_EDIT_READONLY to readOnly
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class RelationEditParameters(
|
||||
val id: Id,
|
||||
val name: String,
|
||||
val icon: Int
|
||||
)
|
||||
|
||||
|
||||
const val REQUEST_KEY_UNINSTALL_RELATION = "request.relation_edit_uninstall"
|
||||
const val REQUEST_KEY_MODIFY_RELATION = "request.relation_edit_modify"
|
||||
const val REQUEST_UNINSTALL_RELATION_ARG_ID = "request.type_edit_uninstall_id"
|
||||
const val REQUEST_UNINSTALL_RELATION_ARG_NAME = "request.type_edit_uninstall_name"
|
||||
|
||||
private const val ARG_RELATION_EDIT_NAME = "arg.relation_edit_name"
|
||||
private const val ARG_RELATION_EDIT_ID = "arg.relation_edit_id"
|
||||
private const val ARG_RELATION_EDIT_UNICODE = "arg.relation_edit_unicode"
|
||||
private const val ARG_RELATION_EDIT_READONLY = "arg.relation_edit_readonly"
|
|
@ -1,232 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.relations
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.OutlinedTextField
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextRange
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_ui.foundation.Dragger
|
||||
import com.anytypeio.anytype.presentation.relations.RelationEditState
|
||||
import com.anytypeio.anytype.presentation.relations.RelationEditViewModel
|
||||
import com.anytypeio.anytype.core_ui.foundation.noRippleClickable
|
||||
import com.anytypeio.anytype.core_ui.views.BodyRegular
|
||||
import com.anytypeio.anytype.core_ui.views.Title1
|
||||
import com.anytypeio.anytype.core_ui.views.UXBody
|
||||
import com.anytypeio.anytype.ui.relations.TypeEditWidgetDefaults.OffsetX
|
||||
import com.anytypeio.anytype.ui.relations.TypeEditWidgetDefaults.PaddingStart
|
||||
import com.anytypeio.anytype.ui.relations.RelationScreenDefaults.PaddingBottom
|
||||
import com.anytypeio.anytype.ui.relations.RelationScreenDefaults.PaddingTop
|
||||
import com.anytypeio.anytype.ui.types.views.ImeOptions
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
@Composable
|
||||
fun RelationEditScreen(vm: RelationEditViewModel, preparedName: String, readOnly: Boolean) {
|
||||
|
||||
val state by vm.uiState.collectAsStateWithLifecycle()
|
||||
val inputValue = remember { mutableStateOf(preparedName) }
|
||||
val nameValid = remember { mutableStateOf(preparedName.trim().isNotEmpty()) }
|
||||
|
||||
Column(Modifier.padding(top = PaddingTop, bottom = PaddingBottom).height(132.dp)) {
|
||||
RelationEditHeader(vm = vm, readOnly = readOnly)
|
||||
RelationEditWidget(
|
||||
preparedString = inputValue,
|
||||
nameValid = nameValid,
|
||||
state = state,
|
||||
onImeDoneClick = {
|
||||
vm.updateRelationDetails(name = inputValue.value.trim())
|
||||
},
|
||||
imeOptions = ImeOptions.Done,
|
||||
shouldMoveCursor = preparedName.trim().isNotEmpty(),
|
||||
isEditable = readOnly.not()
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RelationEditHeader(
|
||||
vm: RelationEditViewModel,
|
||||
readOnly: Boolean
|
||||
) {
|
||||
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
Dragger(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(EditHeaderDefaults.Height)
|
||||
.padding(EditHeaderDefaults.PaddingValues)
|
||||
) {
|
||||
if (!readOnly) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
}
|
||||
Text(
|
||||
text = stringResource(id = R.string.relation_editing_title),
|
||||
color = colorResource(id = R.color.text_primary),
|
||||
style = Title1,
|
||||
)
|
||||
if (!readOnly) {
|
||||
Box(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.type_editing_uninstall),
|
||||
color = colorResource(id = R.color.palette_system_red),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.noRippleClickable { vm.uninstallRelation() },
|
||||
textAlign = TextAlign.End,
|
||||
style = UXBody
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RelationEditWidget(
|
||||
preparedString: MutableState<String>,
|
||||
nameValid: MutableState<Boolean>,
|
||||
state: RelationEditState,
|
||||
imeOptions: ImeOptions = ImeOptions.Default,
|
||||
onImeDoneClick: (name: String) -> Unit = {},
|
||||
shouldMoveCursor: Boolean,
|
||||
isEditable: Boolean = true
|
||||
) {
|
||||
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
val innerValue = remember {
|
||||
mutableStateOf(
|
||||
TextFieldValue(
|
||||
text = preparedString.value,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val cursorMoved = remember { mutableStateOf(false) }
|
||||
|
||||
OutlinedTextField(
|
||||
value = innerValue.value,
|
||||
onValueChange = {
|
||||
innerValue.value = it
|
||||
with(it.text.trim()) {
|
||||
preparedString.value = this
|
||||
nameValid.value = this.isNotEmpty()
|
||||
}
|
||||
},
|
||||
enabled = isEditable,
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester)
|
||||
.padding(start = PaddingStart)
|
||||
.offset(OffsetX)
|
||||
.onGloballyPositioned {
|
||||
focusRequester.requestFocus()
|
||||
if (shouldMoveCursor && cursorMoved.value.not()) {
|
||||
innerValue.value = TextFieldValue(
|
||||
text = preparedString.value,
|
||||
selection = TextRange(preparedString.value.length)
|
||||
)
|
||||
cursorMoved.value = true
|
||||
}
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = when (imeOptions) {
|
||||
ImeOptions.Default -> ImeAction.Default
|
||||
ImeOptions.Done -> ImeAction.Done
|
||||
}
|
||||
),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = {
|
||||
onImeDoneClick(innerValue.value.text)
|
||||
}
|
||||
),
|
||||
singleLine = true,
|
||||
placeholder = {
|
||||
Text(
|
||||
text = stringResource(id = R.string.type_creation_placeholder),
|
||||
color = colorResource(id = R.color.text_tertiary),
|
||||
style = BodyRegular
|
||||
)
|
||||
},
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(
|
||||
textColor = colorResource(id = R.color.text_primary),
|
||||
backgroundColor = Color.Transparent,
|
||||
disabledBorderColor = Color.Transparent,
|
||||
errorBorderColor = Color.Transparent,
|
||||
focusedBorderColor = Color.Transparent,
|
||||
unfocusedBorderColor = Color.Transparent,
|
||||
placeholderColor = colorResource(id = R.color.text_tertiary),
|
||||
cursorColor = colorResource(id = R.color.toolbar_section_tool)
|
||||
),
|
||||
leadingIcon = {
|
||||
if (state is RelationEditState.Data) {
|
||||
LeadingRelationIcon(icon = state.objectIcon)
|
||||
}
|
||||
},
|
||||
textStyle = BodyRegular
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun LeadingRelationIcon(
|
||||
@DrawableRes icon: Int,
|
||||
) {
|
||||
Image(modifier = Modifier, painter = painterResource(id = icon), contentDescription = "")
|
||||
}
|
||||
|
||||
|
||||
@Immutable
|
||||
private object TypeEditWidgetDefaults {
|
||||
val OffsetX = (-4).dp
|
||||
val PaddingStart = 6.dp
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private object EditHeaderDefaults {
|
||||
val Height = 54.dp
|
||||
val PaddingValues = PaddingValues(start = 12.dp, top = 18.dp, end = 16.dp, bottom = 12.dp)
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private object RelationScreenDefaults {
|
||||
val PaddingTop = 6.dp
|
||||
val PaddingBottom = 16.dp
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.create
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_ui.common.ComposeDialogView
|
||||
import com.anytypeio.anytype.core_utils.ext.argString
|
||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.core_utils.ext.toast
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.types.CreateObjectTypeViewModel
|
||||
import com.anytypeio.anytype.ui.settings.typography
|
||||
import com.anytypeio.anytype.ui.types.picker.REQUEST_KEY_PICK_EMOJI
|
||||
import com.anytypeio.anytype.ui.types.picker.REQUEST_KEY_REMOVE_EMOJI
|
||||
import com.anytypeio.anytype.ui.types.picker.RESULT_EMOJI_UNICODE
|
||||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
|
||||
class CreateObjectTypeFragment : BaseBottomSheetComposeFragment() {
|
||||
|
||||
@Inject
|
||||
lateinit var factory: CreateObjectTypeViewModel.Factory
|
||||
|
||||
private val vm by viewModels<CreateObjectTypeViewModel> { factory }
|
||||
|
||||
private val preparedName get() = argString(ARG_TYPE_NAME)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setFragmentResultListener(REQUEST_KEY_PICK_EMOJI) { _, bundle ->
|
||||
val res = requireNotNull(bundle.getString(RESULT_EMOJI_UNICODE))
|
||||
vm.setEmoji(res)
|
||||
}
|
||||
setFragmentResultListener(REQUEST_KEY_REMOVE_EMOJI) { _, bundle ->
|
||||
vm.removeEmoji()
|
||||
}
|
||||
}
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
) = ComposeDialogView(
|
||||
context = requireContext(),
|
||||
dialog = requireDialog()
|
||||
).apply {
|
||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
setContent {
|
||||
MaterialTheme(typography = typography) {
|
||||
TypeCreationScreen(vm, preparedName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
vm.onPreparedString(preparedName)
|
||||
subscribe(vm.navigation) {
|
||||
when (it) {
|
||||
is CreateObjectTypeViewModel.Navigation.BackWithCreatedType -> {
|
||||
setFragmentResult(REQUEST_CREATE_OBJECT, bundleOf())
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
is CreateObjectTypeViewModel.Navigation.SelectEmoji -> {
|
||||
runCatching {
|
||||
findNavController().navigate(
|
||||
R.id.openEmojiPicker, bundleOf(ARG_SHOW_REMOVE_BUTTON to it.showRemove)
|
||||
)
|
||||
}.onFailure {
|
||||
Timber.w("Error while opening emoji picker")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
subscribe(vm.toasts) { toast(it) }
|
||||
}
|
||||
|
||||
override fun injectDependencies() {
|
||||
componentManager().createObjectTypeComponent.get().inject(this)
|
||||
}
|
||||
|
||||
override fun releaseDependencies() {
|
||||
componentManager().createObjectTypeComponent.release()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun args(typeName: String) = bundleOf(ARG_TYPE_NAME to typeName)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private const val ARG_TYPE_NAME = "arg.type_name"
|
||||
private const val ARG_SHOW_REMOVE_BUTTON = "arg.type_show_remove"
|
||||
const val REQUEST_CREATE_OBJECT = "request.create_type"
|
|
@ -1,52 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.create
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anytypeio.anytype.presentation.types.CreateObjectTypeViewModel
|
||||
import com.anytypeio.anytype.ui.types.create.TypeScreenDefaults.PaddingBottom
|
||||
import com.anytypeio.anytype.ui.types.create.TypeScreenDefaults.PaddingTop
|
||||
import com.anytypeio.anytype.ui.types.views.TypeCreationHeader
|
||||
import com.anytypeio.anytype.ui.types.views.TypeEditWidget
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
@Composable
|
||||
fun TypeCreationScreen(vm: CreateObjectTypeViewModel, preparedName: String) {
|
||||
|
||||
val state by vm.uiState.collectAsStateWithLifecycle()
|
||||
val inputValue = remember { mutableStateOf(preparedName) }
|
||||
val nameValid = remember { mutableStateOf(preparedName.trim().isNotEmpty()) }
|
||||
|
||||
Column(Modifier.padding(top = PaddingTop, bottom = PaddingBottom).height(132.dp)) {
|
||||
TypeCreationHeader(
|
||||
vm = vm,
|
||||
nameValid = nameValid,
|
||||
inputValue = inputValue
|
||||
)
|
||||
TypeEditWidget(
|
||||
preparedString = inputValue,
|
||||
nameValid = nameValid,
|
||||
objectIcon = state.objectIcon,
|
||||
onLeadingIconClick = vm::openEmojiPicker,
|
||||
shouldMoveCursor = preparedName.trim().isNotEmpty(),
|
||||
onImeDoneClick = vm::createType,
|
||||
isReadOnly = false
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private object TypeScreenDefaults {
|
||||
val PaddingTop = 6.dp
|
||||
val PaddingBottom = 16.dp
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.edit
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_ui.common.ComposeDialogView
|
||||
import com.anytypeio.anytype.core_utils.ext.argBoolean
|
||||
import com.anytypeio.anytype.core_utils.ext.argString
|
||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.types.TypeEditViewModel
|
||||
import com.anytypeio.anytype.ui.settings.typography
|
||||
import com.anytypeio.anytype.ui.types.picker.REQUEST_KEY_PICK_EMOJI
|
||||
import com.anytypeio.anytype.ui.types.picker.REQUEST_KEY_REMOVE_EMOJI
|
||||
import com.anytypeio.anytype.ui.types.picker.RESULT_EMOJI_UNICODE
|
||||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
|
||||
class TypeEditFragment : BaseBottomSheetComposeFragment() {
|
||||
|
||||
@Inject
|
||||
lateinit var factory: TypeEditViewModel.Factory
|
||||
|
||||
private val vm by viewModels<TypeEditViewModel> { factory }
|
||||
|
||||
private val id get() = argString(ARG_TYPE_EDIT_ID)
|
||||
private val name get() = argString(ARG_TYPE_EDIT_NAME)
|
||||
private val icon get() = argString(ARG_TYPE_EDIT_UNICODE)
|
||||
private val readOnly get() = argBoolean(ARG_TYPE_EDIT_READONLY)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setFragmentResultListener(REQUEST_KEY_PICK_EMOJI) { _, bundle ->
|
||||
val res = requireNotNull(bundle.getString(RESULT_EMOJI_UNICODE))
|
||||
vm.setEmoji(res)
|
||||
}
|
||||
setFragmentResultListener(REQUEST_KEY_REMOVE_EMOJI) { _, _ ->
|
||||
vm.removeEmoji()
|
||||
}
|
||||
}
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
) = ComposeDialogView(
|
||||
context = requireContext(),
|
||||
dialog = requireDialog()
|
||||
).apply {
|
||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
setContent {
|
||||
MaterialTheme(typography = typography) {
|
||||
TypeEditScreen(
|
||||
vm = vm,
|
||||
preparedName = name,
|
||||
readOnly = readOnly
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
subscribe(vm.navigation) {
|
||||
when (it) {
|
||||
is TypeEditViewModel.Navigation.Back -> {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
is TypeEditViewModel.Navigation.SelectEmoji -> {
|
||||
runCatching {
|
||||
findNavController().navigate(R.id.openEmojiPicker)
|
||||
}.onFailure {
|
||||
Timber.w("Error while opening emoji picker")
|
||||
}
|
||||
}
|
||||
is TypeEditViewModel.Navigation.BackWithUninstall -> {
|
||||
setFragmentResult(
|
||||
REQUEST_KEY_UNINSTALL_TYPE, bundleOf(
|
||||
REQUEST_UNINSTALL_TYPE_ARG_ID to id,
|
||||
REQUEST_UNINSTALL_TYPE_ARG_NAME to name,
|
||||
)
|
||||
)
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
is TypeEditViewModel.Navigation.BackWithModify -> {
|
||||
setFragmentResult(
|
||||
REQUEST_KEY_MODIFY_TYPE, bundleOf(
|
||||
REQUEST_UNINSTALL_TYPE_ARG_ID to id,
|
||||
REQUEST_UNINSTALL_TYPE_ARG_NAME to it.typeName,
|
||||
REQUEST_UNINSTALL_TYPE_ARG_ICON to it.typeIcon
|
||||
)
|
||||
)
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
vm.onStart(isReadOnly = readOnly)
|
||||
}
|
||||
|
||||
override fun injectDependencies() {
|
||||
componentManager().typeEditComponent.get(
|
||||
TypeEditParameters(
|
||||
id = id,
|
||||
name = name,
|
||||
icon = icon
|
||||
)
|
||||
).inject(this)
|
||||
}
|
||||
|
||||
override fun releaseDependencies() {
|
||||
componentManager().typeEditComponent.release()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun args(
|
||||
typeName: String,
|
||||
id: Id,
|
||||
iconUnicode: String,
|
||||
readOnly: Boolean
|
||||
) = bundleOf(
|
||||
ARG_TYPE_EDIT_NAME to typeName,
|
||||
ARG_TYPE_EDIT_ID to id,
|
||||
ARG_TYPE_EDIT_UNICODE to iconUnicode,
|
||||
ARG_TYPE_EDIT_READONLY to readOnly
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class TypeEditParameters(
|
||||
val id: Id,
|
||||
val name: String,
|
||||
val icon: String
|
||||
)
|
||||
|
||||
const val REQUEST_KEY_UNINSTALL_TYPE = "request.type_edit_uninstall"
|
||||
const val REQUEST_KEY_MODIFY_TYPE = "request.type_edit_modify"
|
||||
const val REQUEST_UNINSTALL_TYPE_ARG_ID = "request.type_edit_uninstall_id"
|
||||
const val REQUEST_UNINSTALL_TYPE_ARG_NAME = "request.type_edit_uninstall_name"
|
||||
const val REQUEST_UNINSTALL_TYPE_ARG_ICON = "request.type_edit_uninstall_icon"
|
||||
|
||||
private const val ARG_TYPE_EDIT_NAME = "arg.type_edit_name"
|
||||
private const val ARG_TYPE_EDIT_ID = "arg.type_edit_id"
|
||||
private const val ARG_TYPE_EDIT_UNICODE = "arg.type_edit_unicode"
|
||||
private const val ARG_TYPE_EDIT_READONLY = "arg.type_edit_readonly"
|
|
@ -1,52 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.edit
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.types.TypeEditState
|
||||
import com.anytypeio.anytype.presentation.types.TypeEditViewModel
|
||||
import com.anytypeio.anytype.ui.types.edit.TypeScreenDefaults.PaddingBottom
|
||||
import com.anytypeio.anytype.ui.types.edit.TypeScreenDefaults.PaddingTop
|
||||
import com.anytypeio.anytype.ui.types.views.ImeOptions
|
||||
import com.anytypeio.anytype.ui.types.views.TypeEditHeader
|
||||
import com.anytypeio.anytype.ui.types.views.TypeEditWidget
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
@Composable
|
||||
fun TypeEditScreen(vm: TypeEditViewModel, preparedName: String, readOnly: Boolean) {
|
||||
|
||||
val state by vm.uiState.collectAsStateWithLifecycle()
|
||||
val inputValue = remember { mutableStateOf(preparedName) }
|
||||
val nameValid = remember { mutableStateOf(preparedName.trim().isNotEmpty()) }
|
||||
|
||||
Column(Modifier.padding(top = PaddingTop, bottom = PaddingBottom).height(132.dp)) {
|
||||
TypeEditHeader(vm = vm, readOnly)
|
||||
TypeEditWidget(
|
||||
preparedString = inputValue,
|
||||
nameValid = nameValid,
|
||||
objectIcon = (state as? TypeEditState.Data)?.objectIcon ?: ObjectIcon.None,
|
||||
onLeadingIconClick = vm::openEmojiPicker,
|
||||
onImeDoneClick = vm::updateObjectDetails,
|
||||
imeOptions = ImeOptions.Done,
|
||||
shouldMoveCursor = preparedName.trim().isNotEmpty(),
|
||||
isReadOnly = readOnly
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private object TypeScreenDefaults {
|
||||
val PaddingTop = 6.dp
|
||||
val PaddingBottom = 16.dp
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.picker
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.core_utils.ext.argBoolean
|
||||
import com.anytypeio.anytype.core_utils.ext.gone
|
||||
import com.anytypeio.anytype.core_utils.ext.setVisible
|
||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.types.icon_picker.TypeIconPickerViewModel
|
||||
import com.anytypeio.anytype.ui.editor.modals.IconPickerFragmentBase
|
||||
import javax.inject.Inject
|
||||
|
||||
class TypeIconPickFragment : IconPickerFragmentBase<Unit>() {
|
||||
|
||||
override val target: Unit = Unit
|
||||
|
||||
@Inject
|
||||
lateinit var factory: TypeIconPickerViewModel.Factory
|
||||
override val vm by viewModels<TypeIconPickerViewModel> { factory }
|
||||
|
||||
private val showRemoveButton
|
||||
get() = argBoolean(ARG_SHOW_REMOVE_BUTTON)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.bottomToolbar.gone()
|
||||
binding.btnRemoveIcon.setVisible(showRemoveButton)
|
||||
subscribe(vm.actions) {
|
||||
when (it) {
|
||||
is TypeIconPickerViewModel.EmojiPickerAction.RemoveEmoji -> {
|
||||
setFragmentResult(
|
||||
requestKey = REQUEST_KEY_REMOVE_EMOJI,
|
||||
result = bundleOf()
|
||||
)
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
is TypeIconPickerViewModel.EmojiPickerAction.SetEmoji -> {
|
||||
setFragmentResult(
|
||||
requestKey = REQUEST_KEY_PICK_EMOJI,
|
||||
result = bundleOf(
|
||||
RESULT_EMOJI_UNICODE to it.emojiUnicode
|
||||
)
|
||||
)
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
is TypeIconPickerViewModel.EmojiPickerAction.Idle -> {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun injectDependencies() {
|
||||
componentManager().typeIconPickComponent.get().inject(this)
|
||||
}
|
||||
|
||||
override fun releaseDependencies() {
|
||||
componentManager().typeIconPickComponent.release()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const val REQUEST_KEY_PICK_EMOJI = "request_key.pick_emoji"
|
||||
const val REQUEST_KEY_REMOVE_EMOJI = "request_key.remove_emoji"
|
||||
const val RESULT_EMOJI_UNICODE = "result.emoji_unicode"
|
||||
private const val ARG_SHOW_REMOVE_BUTTON = "arg.type_show_remove"
|
|
@ -1,78 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.views
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_ui.foundation.Dragger
|
||||
import com.anytypeio.anytype.core_ui.foundation.noRippleClickable
|
||||
import com.anytypeio.anytype.core_ui.views.Title1
|
||||
import com.anytypeio.anytype.core_ui.views.UXBody
|
||||
import com.anytypeio.anytype.presentation.types.CreateObjectTypeViewModel
|
||||
import com.anytypeio.anytype.ui.types.views.HeaderDefaults.ColorTextActive
|
||||
import com.anytypeio.anytype.ui.types.views.HeaderDefaults.ColorTextDisabled
|
||||
|
||||
@Composable
|
||||
fun TypeCreationHeader(
|
||||
vm: CreateObjectTypeViewModel,
|
||||
nameValid: MutableState<Boolean>,
|
||||
inputValue: MutableState<Id>,
|
||||
) {
|
||||
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
Dragger(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(HeaderDefaults.Height)
|
||||
.padding(HeaderDefaults.PaddingValues)
|
||||
) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Text(
|
||||
text = stringResource(id = R.string.type_creation_new_type),
|
||||
color = colorResource(id = R.color.text_primary),
|
||||
style = Title1,
|
||||
)
|
||||
Box(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.type_creation_done),
|
||||
color = colorResource(id = if (nameValid.value) ColorTextActive else ColorTextDisabled),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.noRippleClickable(enabled = nameValid.value) {
|
||||
vm.createType(inputValue.value)
|
||||
},
|
||||
textAlign = TextAlign.End,
|
||||
style = UXBody
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private object HeaderDefaults {
|
||||
val Height = 54.dp
|
||||
val PaddingValues = PaddingValues(start = 12.dp, top = 18.dp, end = 16.dp, bottom = 12.dp)
|
||||
const val ColorTextActive = R.color.text_primary
|
||||
const val ColorTextDisabled = R.color.text_secondary
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.views
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_ui.foundation.noRippleClickable
|
||||
import com.anytypeio.anytype.core_ui.widgets.ObjectIconWidget
|
||||
import com.anytypeio.anytype.core_utils.ext.dimen
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.ui.types.views.LeadingIconDefaults.OffsetX
|
||||
|
||||
@Composable
|
||||
fun LeadingIcon(
|
||||
icon: ObjectIcon,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
val modifier = Modifier
|
||||
.offset(x = OffsetX)
|
||||
.noRippleClickable { onClick() }
|
||||
when (icon) {
|
||||
is ObjectIcon.Basic.Emoji -> {
|
||||
AndroidView(
|
||||
modifier = modifier,
|
||||
factory = { ctx ->
|
||||
ObjectIconWidget(ctx).apply {
|
||||
setIvEmojiSize(
|
||||
ctx.dimen(R.dimen.dp_24).toInt()
|
||||
)
|
||||
}
|
||||
},
|
||||
update = { it.setIcon(icon) }
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
Image(
|
||||
modifier = modifier,
|
||||
painter = painterResource(
|
||||
id = R.drawable.ic_page_icon_picker_choose_emoji
|
||||
),
|
||||
contentDescription = "",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private object LeadingIconDefaults {
|
||||
val OffsetX = 4.dp
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.views
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_ui.foundation.Dragger
|
||||
import com.anytypeio.anytype.presentation.types.TypeEditViewModel
|
||||
import com.anytypeio.anytype.core_ui.foundation.noRippleClickable
|
||||
import com.anytypeio.anytype.core_ui.views.Title1
|
||||
import com.anytypeio.anytype.core_ui.views.UXBody
|
||||
|
||||
@Composable
|
||||
fun TypeEditHeader(
|
||||
vm: TypeEditViewModel,
|
||||
readOnly: Boolean
|
||||
) {
|
||||
|
||||
Column {
|
||||
|
||||
Box(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 6.dp)
|
||||
) {
|
||||
Dragger(modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(EditHeaderDefaults.PaddingValues)
|
||||
.height(EditHeaderDefaults.Height)
|
||||
) {
|
||||
if (!readOnly) {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
}
|
||||
Text(
|
||||
text = stringResource(id = R.string.type_editing_title),
|
||||
style = Title1,
|
||||
color = colorResource(id = R.color.text_primary)
|
||||
)
|
||||
if (!readOnly) {
|
||||
Box(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.type_editing_uninstall),
|
||||
color = colorResource(id = R.color.palette_system_red),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.noRippleClickable {
|
||||
vm.uninstallType()
|
||||
},
|
||||
textAlign = TextAlign.End,
|
||||
style = UXBody
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private object EditHeaderDefaults {
|
||||
val PaddingValues = PaddingValues(start = 12.dp, top = 6.dp, end = 16.dp, bottom = 12.dp)
|
||||
val Height = 48.dp
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package com.anytypeio.anytype.ui.types.views
|
||||
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.OutlinedTextField
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextRange
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_ui.views.BodyRegular
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.ui.types.views.TypeEditWidgetDefaults.OffsetX
|
||||
|
||||
|
||||
@Composable
|
||||
fun TypeEditWidget(
|
||||
preparedString: MutableState<String>,
|
||||
nameValid: MutableState<Boolean>,
|
||||
objectIcon: ObjectIcon,
|
||||
onLeadingIconClick: () -> Unit,
|
||||
imeOptions: ImeOptions = ImeOptions.Default,
|
||||
onImeDoneClick: (name: String) -> Unit = {},
|
||||
shouldMoveCursor: Boolean,
|
||||
isReadOnly: Boolean
|
||||
) {
|
||||
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
val innerValue = remember {
|
||||
mutableStateOf(
|
||||
TextFieldValue(
|
||||
text = preparedString.value,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val cursorMoved = remember { mutableStateOf(false) }
|
||||
|
||||
OutlinedTextField(
|
||||
value = innerValue.value,
|
||||
onValueChange = {
|
||||
innerValue.value = it
|
||||
with(it.text.trim()) {
|
||||
preparedString.value = this
|
||||
nameValid.value = this.isNotEmpty()
|
||||
}
|
||||
},
|
||||
enabled = !isReadOnly,
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester)
|
||||
.offset(OffsetX)
|
||||
.onGloballyPositioned {
|
||||
focusRequester.requestFocus()
|
||||
if (shouldMoveCursor && cursorMoved.value.not()) {
|
||||
innerValue.value = TextFieldValue(
|
||||
text = preparedString.value,
|
||||
selection = TextRange(preparedString.value.length)
|
||||
)
|
||||
cursorMoved.value = true
|
||||
}
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = when (imeOptions) {
|
||||
ImeOptions.Default -> ImeAction.Default
|
||||
ImeOptions.Done -> ImeAction.Done
|
||||
}
|
||||
),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = {
|
||||
onImeDoneClick(innerValue.value.text)
|
||||
}
|
||||
),
|
||||
singleLine = true,
|
||||
placeholder = {
|
||||
Text(
|
||||
text = stringResource(id = R.string.type_creation_placeholder),
|
||||
color = colorResource(id = R.color.text_tertiary),
|
||||
style = BodyRegular
|
||||
)
|
||||
},
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(
|
||||
textColor = colorResource(id = R.color.text_primary),
|
||||
backgroundColor = Color.Transparent,
|
||||
disabledBorderColor = Color.Transparent,
|
||||
errorBorderColor = Color.Transparent,
|
||||
focusedBorderColor = Color.Transparent,
|
||||
unfocusedBorderColor = Color.Transparent,
|
||||
placeholderColor = colorResource(id = R.color.text_tertiary),
|
||||
cursorColor = colorResource(id = R.color.toolbar_section_tool)
|
||||
),
|
||||
leadingIcon = {
|
||||
LeadingIcon(
|
||||
icon = objectIcon,
|
||||
onClick = onLeadingIconClick
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
enum class ImeOptions {
|
||||
Default,
|
||||
Done,
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private object TypeEditWidgetDefaults {
|
||||
val OffsetX = (-4).dp
|
||||
}
|
|
@ -324,4 +324,5 @@ fun CustomIconColor.colorRes() = when (this) {
|
|||
CustomIconColor.Sky -> R.color.palette_system_sky
|
||||
CustomIconColor.Teal -> R.color.palette_system_teal
|
||||
CustomIconColor.Green -> R.color.palette_system_green
|
||||
CustomIconColor.Transparent -> R.color.shape_transparent_primary
|
||||
}
|
|
@ -110,4 +110,13 @@ class DefaultStoreOfObjectTypes : StoreOfObjectTypes {
|
|||
override fun trackChanges(): Flow<TrackedEvent> = updates.onStart {
|
||||
emit(TrackedEvent.Init)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun StoreOfObjectTypes.getTypeOfObject(obj: ObjectWrapper.Basic): ObjectWrapper.Type? {
|
||||
val typeId = obj.type.firstOrNull()
|
||||
return if (typeId != null) {
|
||||
return get(typeId)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
|
@ -16,6 +16,8 @@ import com.anytypeio.anytype.core_models.primitives.SpaceId
|
|||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
import com.anytypeio.anytype.domain.all_content.RestoreAllContentState
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.feature_allcontent.presentation.AllContentViewModel.Companion.DEFAULT_INITIAL_TAB
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
|
@ -182,12 +184,13 @@ fun RestoreAllContentState.Response.Success.mapToSort(): ObjectsListSort {
|
|||
}
|
||||
}
|
||||
|
||||
fun ObjectWrapper.Basic.toAllContentItem(
|
||||
suspend fun ObjectWrapper.Basic.toAllContentItem(
|
||||
space: SpaceId,
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypes: List<ObjectWrapper.Type>,
|
||||
isOwnerOrEditor: Boolean,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): UiContentItem.Item {
|
||||
val obj = this
|
||||
val typeUrl = obj.getProperType()
|
||||
|
@ -207,7 +210,10 @@ fun ObjectWrapper.Basic.toAllContentItem(
|
|||
}
|
||||
}?.name,
|
||||
layout = layout,
|
||||
icon = obj.objectIcon(builder = urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
lastModifiedDate = DateParser.parse(obj.getValue(Relations.LAST_MODIFIED_DATE)) ?: 0L,
|
||||
createdDate = DateParser.parse(obj.getValue(Relations.CREATED_DATE)) ?: 0L,
|
||||
isPossibleToDelete = isOwnerOrEditor
|
||||
|
@ -229,7 +235,7 @@ fun ObjectWrapper.Type.toAllContentType(
|
|||
return UiContentItem.Type(
|
||||
id = obj.id,
|
||||
name = obj.name.orEmpty(),
|
||||
icon = obj.objectIcon(urlBuilder),
|
||||
icon = obj.objectIcon(),
|
||||
sourceObject = obj.map[SOURCE_OBJECT]?.toString(),
|
||||
uniqueKey = obj.uniqueKey,
|
||||
readOnly = obj.restrictions.contains(ObjectRestriction.DELETE) || !isOwnerOrEditor,
|
||||
|
|
|
@ -343,7 +343,8 @@ class AllContentViewModel(
|
|||
urlBuilder = urlBuilder,
|
||||
isOwnerOrEditor = isOwnerOrEditor,
|
||||
fieldParser = fieldParser,
|
||||
objectTypes = storeOfObjectTypes.getAll()
|
||||
objectTypes = storeOfObjectTypes.getAll(),
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
val result = when (activeSort) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.anytypeio.anytype.domain.multiplayer.ActiveSpaceMemberSubscriptionCon
|
|||
import com.anytypeio.anytype.domain.multiplayer.ActiveSpaceMemberSubscriptionContainer.Store
|
||||
import com.anytypeio.anytype.domain.multiplayer.SpaceViewSubscriptionContainer
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.feature_chats.BuildConfig
|
||||
import com.anytypeio.anytype.presentation.common.BaseViewModel
|
||||
import com.anytypeio.anytype.presentation.confgs.ChatConfig
|
||||
|
@ -241,7 +242,10 @@ class ChatViewModel @Inject constructor(
|
|||
ChatView.Message.Attachment.Link(
|
||||
target = attachment.target,
|
||||
wrapper = wrapper,
|
||||
icon = wrapper?.objectIcon(urlBuilder) ?: ObjectIcon.None,
|
||||
icon = wrapper?.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(wrapper)
|
||||
) ?: ObjectIcon.None,
|
||||
typeName = if (type != null)
|
||||
storeOfObjectTypes.get(type)?.name.orEmpty()
|
||||
else
|
||||
|
@ -603,7 +607,10 @@ class ChatViewModel @Inject constructor(
|
|||
ChatView.Message.ChatBoxAttachment.Existing.Link(
|
||||
target = wrapper.id,
|
||||
name = wrapper.name.orEmpty(),
|
||||
icon = wrapper.objectIcon(urlBuilder),
|
||||
icon = wrapper.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(wrapper)
|
||||
),
|
||||
typeName = if (type != null)
|
||||
storeOfObjectTypes.get(type)?.name.orEmpty()
|
||||
else
|
||||
|
|
|
@ -476,7 +476,8 @@ class DateObjectViewModel(
|
|||
urlBuilder = urlBuilder,
|
||||
objectTypes = storeOfObjectTypes.getAll(),
|
||||
fieldParser = fieldParser,
|
||||
isOwnerOrEditor = permission.value?.isOwnerOrEditor() == true
|
||||
isOwnerOrEditor = permission.value?.isOwnerOrEditor() == true,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
uiContentState.value = if (items.isEmpty()) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.anytypeio.anytype.presentation.templates.TemplateView
|
|||
fun ObjectWrapper.Basic.toTemplateView(
|
||||
objType: ObjectWrapper.Type,
|
||||
urlBuilder: UrlBuilder,
|
||||
coverImageHashProvider: CoverImageHashProvider,
|
||||
coverImageHashProvider: CoverImageHashProvider
|
||||
): TemplateView.Template {
|
||||
val coverContainer = if (coverType != CoverType.NONE) {
|
||||
BasicObjectCoverWrapper(this)
|
||||
|
@ -180,7 +180,7 @@ private suspend fun mapLimitObjectTypes(
|
|||
id = objType.id,
|
||||
key = objType.uniqueKey,
|
||||
title = fieldParser.getObjectName(objType),
|
||||
icon = objType.objectIcon(urlBuilder)
|
||||
icon = objType.objectIcon()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ class ObjectTypeViewModel(
|
|||
isEditable = objectPermissions.canEditDetails
|
||||
)
|
||||
uiIconState.value = UiIconState(
|
||||
icon = objType.objectIcon(urlBuilder),
|
||||
icon = objType.objectIcon(),
|
||||
isEditable = objectPermissions.canEditDetails
|
||||
)
|
||||
if (objectPermissions.canDelete) {
|
||||
|
|
|
@ -5281,8 +5281,7 @@ class EditorViewModel(
|
|||
isWithCollection = false,
|
||||
isWithBookmark = false,
|
||||
selectedTypes = emptyList(),
|
||||
excludeTypes = emptyList(),
|
||||
urlBuilder = urlBuilder
|
||||
excludeTypes = emptyList()
|
||||
)
|
||||
action.invoke(views)
|
||||
}
|
||||
|
@ -5298,14 +5297,16 @@ class EditorViewModel(
|
|||
ctx = vmParams.ctx,
|
||||
urlBuilder = urlBuilder,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
val recommendedRelationViews = objectViewDetails.getRecommendedRelations(
|
||||
ctx = vmParams.ctx,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser,
|
||||
urlBuilder = urlBuilder
|
||||
urlBuilder = urlBuilder,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
val update =
|
||||
(objectRelationViews + recommendedRelationViews).map { SlashRelationView.Item(it) }
|
||||
|
@ -6278,7 +6279,8 @@ class EditorViewModel(
|
|||
.toViews(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = storeOfObjectTypes.getAll(),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
controlPanelInteractor.onEvent(
|
||||
|
@ -6419,7 +6421,6 @@ class EditorViewModel(
|
|||
isWithCollection = true,
|
||||
isWithBookmark = false,
|
||||
excludeTypes = excludeTypes,
|
||||
urlBuilder = urlBuilder
|
||||
).filter {
|
||||
!excludeTypes.contains(it.key)
|
||||
}.map {
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.anytypeio.anytype.domain.primitives.FieldParser
|
|||
import com.anytypeio.anytype.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.ext.getTextAndMarks
|
||||
import com.anytypeio.anytype.presentation.extension.getBookmarkObject
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
|
@ -29,8 +30,8 @@ import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
|||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView.Appearance.InEditor
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView.Mode
|
||||
import com.anytypeio.anytype.presentation.editor.toggle.ToggleStateHolder
|
||||
import com.anytypeio.anytype.presentation.mapper.marks
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.mapper.marks
|
||||
import com.anytypeio.anytype.presentation.mapper.toFileView
|
||||
import com.anytypeio.anytype.presentation.mapper.toPictureView
|
||||
import com.anytypeio.anytype.presentation.mapper.toVideoView
|
||||
|
@ -101,7 +102,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
focus = focus,
|
||||
root = root,
|
||||
restrictions = restrictions,
|
||||
currentObject = obj
|
||||
currentObject = obj,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -622,7 +624,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
mode = mode,
|
||||
selection = selection,
|
||||
isPreviousBlockMedia = isPreviousBlockMedia,
|
||||
parentSchema = parentScheme
|
||||
parentSchema = parentScheme,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
)
|
||||
result.add(link)
|
||||
isPreviousBlockMedia = link is BlockView.LinkToObject.Default.Card
|
||||
|
@ -698,6 +701,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
urlBuilder = urlBuilder,
|
||||
schema = blockDecorationScheme,
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -709,6 +713,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
block = block,
|
||||
details = details,
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
if (featured.relations.isNotEmpty()) {
|
||||
|
@ -786,7 +791,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
content = content,
|
||||
details = details,
|
||||
selection = selection,
|
||||
schema = parentScheme
|
||||
schema = parentScheme,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -1406,14 +1412,15 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun title(
|
||||
private suspend fun title(
|
||||
mode: EditorMode,
|
||||
block: Block,
|
||||
content: Content.Text,
|
||||
root: Block,
|
||||
focus: Focus,
|
||||
restrictions: List<ObjectRestriction>,
|
||||
currentObject: ObjectWrapper.Basic?
|
||||
currentObject: ObjectWrapper.Basic?,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): BlockView.Title {
|
||||
|
||||
val focusTarget = focus.target
|
||||
|
@ -1497,6 +1504,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
ObjectType.Layout.VIDEO,
|
||||
ObjectType.Layout.AUDIO,
|
||||
ObjectType.Layout.PDF -> {
|
||||
val objType = storeOfObjectTypes.getTypeOfObject(currentObject)
|
||||
BlockView.Title.File(
|
||||
mode = Mode.READ,
|
||||
id = block.id,
|
||||
|
@ -1508,7 +1516,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
coverGradient = coverContainer.coverGradient,
|
||||
background = block.parseThemeBackgroundColor(),
|
||||
color = block.textColor(),
|
||||
icon = currentObject.objectIcon(builder = urlBuilder)
|
||||
icon = currentObject.objectIcon(builder = urlBuilder, objType = objType)
|
||||
)
|
||||
}
|
||||
ObjectType.Layout.IMAGE -> {
|
||||
|
@ -1576,7 +1584,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
mode: EditorMode,
|
||||
selection: Set<Id>,
|
||||
isPreviousBlockMedia: Boolean,
|
||||
parentSchema: NestedDecorationData
|
||||
parentSchema: NestedDecorationData,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): BlockView.LinkToObject {
|
||||
return if (obj == null || obj.isDeleted == true) {
|
||||
linkDeleted(
|
||||
|
@ -1605,7 +1614,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
mode = mode,
|
||||
selection = selection,
|
||||
isPreviousBlockMedia = isPreviousBlockMedia,
|
||||
parentSchema = parentSchema
|
||||
parentSchema = parentSchema,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1619,13 +1629,17 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
obj: ObjectWrapper.Basic,
|
||||
selection: Set<Id>,
|
||||
isPreviousBlockMedia: Boolean,
|
||||
parentSchema: NestedDecorationData
|
||||
parentSchema: NestedDecorationData,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): BlockView.LinkToObject.Default {
|
||||
val factory = LinkAppearanceFactory(content, obj.layout)
|
||||
val inEditorAppearance = factory.createInEditorLinkAppearance()
|
||||
val isCard = inEditorAppearance.isCard
|
||||
val objectIcon = if (inEditorAppearance.showIcon) {
|
||||
obj.objectIcon(urlBuilder)
|
||||
obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
)
|
||||
} else {
|
||||
ObjectIcon.None
|
||||
}
|
||||
|
@ -2023,7 +2037,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
details: ObjectViewDetails,
|
||||
urlBuilder: UrlBuilder,
|
||||
schema: NestedDecorationData,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): BlockView.Relation {
|
||||
val relationKey = content.key
|
||||
if (relationKey.isNullOrEmpty()) {
|
||||
|
@ -2041,7 +2056,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
details = details,
|
||||
values = values,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
return BlockView.Relation.Related(
|
||||
id = block.id,
|
||||
|
@ -2066,6 +2082,7 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
block: Block,
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): BlockView.FeaturedRelation {
|
||||
val obj = details.getObject(ctx)
|
||||
val featuredKeys = workaroundGlobalNameOrIdentityRelation(obj?.featuredRelations.orEmpty(), obj?.map.orEmpty())
|
||||
|
@ -2073,7 +2090,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
ctx = ctx,
|
||||
keys = featuredKeys,
|
||||
details = details,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
|
||||
).sortedByDescending { it.key == Relations.TYPE || it.key == Relations.GLOBAL_NAME || it.key == Relations.IDENTITY }
|
||||
return BlockView.FeaturedRelation(
|
||||
|
@ -2111,7 +2129,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
ctx: Id,
|
||||
keys: List<Key>,
|
||||
details: ObjectViewDetails,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectRelationView> = keys.mapNotNull { key ->
|
||||
when (key) {
|
||||
Relations.DESCRIPTION -> null
|
||||
|
@ -2143,7 +2162,8 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
values = values,
|
||||
urlBuilder = urlBuilder,
|
||||
isFeatured = true,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -2171,13 +2191,14 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun dataView(
|
||||
private suspend fun dataView(
|
||||
mode: EditorMode,
|
||||
block: Block,
|
||||
content: Content.DataView,
|
||||
details: ObjectViewDetails,
|
||||
selection: Set<Id>,
|
||||
schema: NestedDecorationData
|
||||
schema: NestedDecorationData,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): BlockView.DataView {
|
||||
val targetObjectId = content.targetObjectId
|
||||
val isCollection = content.isCollection
|
||||
|
@ -2218,7 +2239,10 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
isCollection = isCollection
|
||||
)
|
||||
}
|
||||
val icon = targetSet.objectIcon(urlBuilder)
|
||||
val icon = targetSet.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(targetSet)
|
||||
)
|
||||
val isSetNoQuery = targetSet.setOf.all { it.isBlank() }
|
||||
if (isSetNoQuery && !content.isCollection) {
|
||||
return BlockView.DataView.EmptyData(
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.anytypeio.anytype.core_models.ext.toFileObject
|
|||
import com.anytypeio.anytype.core_models.ext.toInternalFlagsObject
|
||||
import com.anytypeio.anytype.core_models.ext.toObject
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.objects.getProperType
|
||||
|
@ -57,7 +58,8 @@ suspend fun ObjectViewDetails.getObjRelationsViews(
|
|||
ctx: Id,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
fieldParser: FieldParser,
|
||||
urlBuilder: UrlBuilder
|
||||
urlBuilder: UrlBuilder,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectRelationView> {
|
||||
val currentObject = getObject(ctx)
|
||||
if (currentObject == null || !currentObject.isValid) return emptyList()
|
||||
|
@ -68,7 +70,8 @@ suspend fun ObjectViewDetails.getObjRelationsViews(
|
|||
values = currentObject.map,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
isFeatured = currentObject.featuredRelations.contains(it.key)
|
||||
isFeatured = currentObject.featuredRelations.contains(it.key),
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +80,8 @@ suspend fun ObjectViewDetails.getRecommendedRelations(
|
|||
ctx: Id,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
fieldParser: FieldParser,
|
||||
urlBuilder: UrlBuilder
|
||||
urlBuilder: UrlBuilder,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectRelationView> {
|
||||
val currentObject = getObject(ctx)
|
||||
if (currentObject == null || !currentObject.isValid) return emptyList()
|
||||
|
@ -97,7 +101,8 @@ suspend fun ObjectViewDetails.getRecommendedRelations(
|
|||
values = currentObject.map,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
isFeatured = currentObject.featuredRelations.contains(it.key)
|
||||
isFeatured = currentObject.featuredRelations.contains(it.key),
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.DVFilterCondition
|
|||
import com.anytypeio.anytype.core_models.DVSort
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.relations.toView
|
||||
|
@ -61,7 +62,8 @@ suspend fun List<DVFilter>.toView(
|
|||
storeOfObjects: ObjectStore,
|
||||
screenState: ViewerFilterViewModel.ScreenState,
|
||||
urlBuilder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<FilterView.Expression> = mapNotNull { filter ->
|
||||
val relation = storeOfRelations.getByKey(filter.relation)
|
||||
if (relation != null) {
|
||||
|
@ -70,7 +72,8 @@ suspend fun List<DVFilter>.toView(
|
|||
isInEditMode = screenState == ViewerFilterViewModel.ScreenState.EDIT,
|
||||
urlBuilder = urlBuilder,
|
||||
store = storeOfObjects,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
} else {
|
||||
Timber.w("Could not found relation: ${filter.relation} for filter: $filter")
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.anytypeio.anytype.domain.history.SetVersion
|
|||
import com.anytypeio.anytype.domain.history.ShowVersion
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.editor.render.DefaultBlockViewRenderer
|
||||
|
@ -26,7 +27,8 @@ class VersionHistoryVMFactory @Inject constructor(
|
|||
private val setVersion: SetVersion,
|
||||
private val renderer: DefaultBlockViewRenderer,
|
||||
private val setStateReducer: ObjectStateReducer,
|
||||
private val storeOfRelations: StoreOfRelations
|
||||
private val storeOfRelations: StoreOfRelations,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
@ -42,7 +44,8 @@ class VersionHistoryVMFactory @Inject constructor(
|
|||
renderer = renderer,
|
||||
setVersion = setVersion,
|
||||
setStateReducer = setStateReducer,
|
||||
storeOfRelations = storeOfRelations
|
||||
storeOfRelations = storeOfRelations,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) as T
|
||||
}
|
||||
}
|
|
@ -27,6 +27,8 @@ import com.anytypeio.anytype.domain.search.SearchObjects
|
|||
import com.anytypeio.anytype.presentation.editor.Editor.Mode
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel.Companion.INITIAL_INDENT
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.editor.render.BlockViewRenderer
|
||||
|
@ -69,7 +71,8 @@ class VersionHistoryViewModel(
|
|||
private val setVersion: SetVersion,
|
||||
private val renderer: DefaultBlockViewRenderer,
|
||||
private val setStateReducer: ObjectStateReducer,
|
||||
private val storeOfRelations: StoreOfRelations
|
||||
private val storeOfRelations: StoreOfRelations,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : ViewModel(), BlockViewRenderer by renderer {
|
||||
|
||||
private val _viewState = MutableStateFlow<VersionHistoryState>(VersionHistoryState.Loading)
|
||||
|
@ -311,12 +314,12 @@ class VersionHistoryViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleVersionsSuccess(versions: List<Version>, members: List<ObjectWrapper.Basic>) {
|
||||
private suspend fun handleVersionsSuccess(versions: List<Version>, members: List<ObjectWrapper.Basic>) {
|
||||
val groupedItems = groupItems(versions, members)
|
||||
_viewState.value = VersionHistoryState.Success(groups = groupedItems)
|
||||
}
|
||||
|
||||
private fun groupItems(
|
||||
private suspend fun groupItems(
|
||||
versions: List<Version>,
|
||||
spaceMembers: List<ObjectWrapper.Basic>,
|
||||
): List<VersionHistoryGroup> {
|
||||
|
@ -451,7 +454,7 @@ class VersionHistoryViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private fun List<List<Version>>.toGroupItems(
|
||||
private suspend fun List<List<Version>>.toGroupItems(
|
||||
spaceMembers: List<ObjectWrapper.Basic>
|
||||
): List<VersionHistoryGroup.Item> {
|
||||
return mapNotNull { versions ->
|
||||
|
@ -460,7 +463,8 @@ class VersionHistoryViewModel(
|
|||
val spaceMember = spaceMembers.find { it.id == spaceMemberId }
|
||||
?: return@mapNotNull null
|
||||
|
||||
val icon = spaceMember.objectIcon(urlBuilder)
|
||||
val objType = storeOfObjectTypes.getTypeOfObject(spaceMember)
|
||||
val icon = spaceMember.objectIcon(urlBuilder, objType)
|
||||
|
||||
val (latestVersionDate, latestVersionTime) = dateProvider.formatTimestampToDateAndTime(
|
||||
timestamp = latestVersion.timestamp.inMillis
|
||||
|
|
|
@ -505,7 +505,8 @@ class HomeScreenViewModel(
|
|||
&& view.source == widget.source
|
||||
} as? WidgetView.Tree
|
||||
},
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
is Widget.List -> if (BundledWidgetSourceIds.ids.contains(widget.source.id)) {
|
||||
ListWidgetContainer(
|
||||
|
@ -524,7 +525,8 @@ class HomeScreenViewModel(
|
|||
&& view.source == widget.source
|
||||
} as? WidgetView.ListOfObjects
|
||||
},
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
} else {
|
||||
DataViewListWidgetContainer(
|
||||
|
@ -544,7 +546,8 @@ class HomeScreenViewModel(
|
|||
} as? WidgetView.SetOfObjects
|
||||
},
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
is Widget.View -> {
|
||||
|
@ -566,7 +569,8 @@ class HomeScreenViewModel(
|
|||
} as? WidgetView.SetOfObjects
|
||||
},
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.anytypeio.anytype.domain.base.Resultat
|
|||
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
|
@ -27,7 +28,8 @@ class BackLinkOrAddToObjectViewModel(
|
|||
getObjectTypes: GetObjectTypes,
|
||||
analytics: Analytics,
|
||||
analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
) : ObjectSearchViewModel(
|
||||
vmParams = vmParams,
|
||||
urlBuilder = urlBuilder,
|
||||
|
@ -35,7 +37,8 @@ class BackLinkOrAddToObjectViewModel(
|
|||
searchObjects = searchObjects,
|
||||
analytics = analytics,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) {
|
||||
|
||||
private val _commands = MutableSharedFlow<Command>(replay = 0)
|
||||
|
|
|
@ -112,7 +112,8 @@ class LinkToObjectOrWebViewModel(
|
|||
obj.toLinkToObjectView(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = storeOfObjectTypes.getAll(),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
),
|
||||
LinkToItemView.Subheading.Actions,
|
||||
LinkToItemView.RemoveLink
|
||||
|
@ -133,7 +134,8 @@ class LinkToObjectOrWebViewModel(
|
|||
val objectViews = filteredSearchResponse.toLinkToView(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = storeOfObjectTypes.getAll(),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
val views = mutableListOf<LinkToItemView>()
|
||||
if (clipboardUrl != null && userInput.value.isBlank()) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.anytypeio.anytype.domain.search.SearchObjects
|
|||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
import com.anytypeio.anytype.presentation.navigation.DefaultObjectView
|
||||
import com.anytypeio.anytype.core_models.SupportedLayouts
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchViewModel
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
@ -25,7 +26,8 @@ class LinkToObjectViewModel(
|
|||
getObjectTypes: GetObjectTypes,
|
||||
analytics: Analytics,
|
||||
analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
) : ObjectSearchViewModel(
|
||||
vmParams = vmParams,
|
||||
urlBuilder = urlBuilder,
|
||||
|
@ -33,7 +35,8 @@ class LinkToObjectViewModel(
|
|||
searchObjects = searchObjects,
|
||||
analytics = analytics,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) {
|
||||
|
||||
val commands = MutableSharedFlow<Command>(replay = 0)
|
||||
|
|
|
@ -21,7 +21,8 @@ class LinkToObjectViewModelFactory(
|
|||
private val searchObjects: SearchObjects,
|
||||
private val analytics: Analytics,
|
||||
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
private val fieldParser: FieldParser
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
@ -33,7 +34,8 @@ class LinkToObjectViewModelFactory(
|
|||
searchObjects = searchObjects,
|
||||
analytics = analytics,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) as T
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +75,8 @@ class BackLinkOrAddToObjectViewModelFactory @Inject constructor(
|
|||
private val searchObjects: SearchObjects,
|
||||
private val analytics: Analytics,
|
||||
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
private val fieldParser: FieldParser
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
@ -85,7 +88,8 @@ class BackLinkOrAddToObjectViewModelFactory @Inject constructor(
|
|||
searchObjects = searchObjects,
|
||||
analytics = analytics,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) as T
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import com.anytypeio.anytype.domain.misc.UrlBuilder
|
|||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.presentation.editor.editor.Markup
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.mention.createMentionMarkup
|
||||
|
@ -597,7 +598,8 @@ suspend fun List<Id>.toGridRecordRows(
|
|||
columns: List<ColumnView>,
|
||||
builder: UrlBuilder,
|
||||
store: ObjectStore,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<Viewer.GridView.Row> {
|
||||
val rows = mutableListOf<Viewer.GridView.Row>()
|
||||
forEach { id ->
|
||||
|
@ -608,7 +610,8 @@ suspend fun List<Id>.toGridRecordRows(
|
|||
obj = record,
|
||||
store = store,
|
||||
builder = builder,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
rows.add(row)
|
||||
} else {
|
||||
|
@ -725,8 +728,7 @@ fun ColumnView.Format.toRelationFormat(): RelationFormat = when (this) {
|
|||
}
|
||||
|
||||
fun ObjectWrapper.Type.toObjectTypeView(
|
||||
selectedSources: List<Id> = emptyList(),
|
||||
urlBuilder: UrlBuilder
|
||||
selectedSources: List<Id> = emptyList()
|
||||
): ObjectTypeView =
|
||||
ObjectTypeView(
|
||||
id = id,
|
||||
|
@ -736,15 +738,15 @@ fun ObjectWrapper.Type.toObjectTypeView(
|
|||
isSelected = selectedSources.contains(id),
|
||||
defaultTemplate = defaultTemplateId,
|
||||
sourceObject = sourceObject,
|
||||
icon = objectIcon(urlBuilder)
|
||||
icon = objectIcon()
|
||||
)
|
||||
|
||||
fun List<ObjectWrapper.Type>.toTemplateObjectTypeViewItems(selectedType: Id, urlBuilder: UrlBuilder): List<TemplateObjectTypeView.Item> {
|
||||
return map {
|
||||
fun List<ObjectWrapper.Type>.toTemplateObjectTypeViewItems(selectedType: Id): List<TemplateObjectTypeView.Item> {
|
||||
return map { objType ->
|
||||
TemplateObjectTypeView.Item(
|
||||
type = it,
|
||||
isSelected = it.id == selectedType,
|
||||
icon = it.objectIcon(urlBuilder)
|
||||
type = objType,
|
||||
isSelected = objType.id == selectedType,
|
||||
icon = objType.objectIcon()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.anytypeio.anytype.core_models.SupportedLayouts
|
|||
import com.anytypeio.anytype.presentation.objects.custom_icon.CustomIcon
|
||||
import com.anytypeio.anytype.presentation.objects.custom_icon.CustomIconColor
|
||||
|
||||
fun ObjectWrapper.Basic.objectIcon(builder: UrlBuilder): ObjectIcon {
|
||||
fun ObjectWrapper.Basic.objectIcon(builder: UrlBuilder, objType: ObjectWrapper.Type? = null): ObjectIcon {
|
||||
|
||||
if (isDeleted == true) {
|
||||
return ObjectIcon.Deleted
|
||||
|
@ -65,6 +65,11 @@ fun ObjectWrapper.Type.objectIcon(builder: UrlBuilder): ObjectIcon {
|
|||
return layout.emptyType()
|
||||
}
|
||||
|
||||
fun ObjectWrapper.Type.objectIcon(): ObjectIcon {
|
||||
//todo next pr
|
||||
return ObjectIcon.None
|
||||
}
|
||||
|
||||
fun ObjectType.Layout?.emptyType(): ObjectIcon.Empty {
|
||||
if (this == null) {
|
||||
return ObjectIcon.Empty.Page
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
|||
import com.anytypeio.anytype.presentation.extension.sendAnalyticsSearchResultEvent
|
||||
import com.anytypeio.anytype.presentation.navigation.DefaultObjectView
|
||||
import com.anytypeio.anytype.core_models.SupportedLayouts
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.presentation.objects.toViews
|
||||
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
@ -41,7 +42,8 @@ class MoveToViewModel(
|
|||
private val getObjectTypes: GetObjectTypes,
|
||||
private val analytics: Analytics,
|
||||
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
private val fieldParser: FieldParser
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : ViewModel(), TextInputDialogBottomBehaviorApplier.OnDialogCancelListener,
|
||||
AnalyticSpaceHelperDelegate by analyticSpaceHelperDelegate {
|
||||
|
||||
|
@ -67,7 +69,8 @@ class MoveToViewModel(
|
|||
listOfObjects.getOrThrow().toViews(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = listOfTypes.getOrThrow(),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
|
@ -16,7 +17,8 @@ class MoveToViewModelFactory(
|
|||
private val searchObjects: SearchObjects,
|
||||
private val analytics: Analytics,
|
||||
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
private val fieldParser: FieldParser
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
@ -28,7 +30,8 @@ class MoveToViewModelFactory(
|
|||
searchObjects = searchObjects,
|
||||
analytics = analytics,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) as T
|
||||
}
|
||||
}
|
|
@ -70,10 +70,7 @@ interface AppNavigation {
|
|||
fun openTemplatesModal(typeId: Id)
|
||||
|
||||
fun openAllContent(space: Id)
|
||||
fun openTypeEditingScreen(id: Id, name: String, icon: String, readOnly: Boolean)
|
||||
fun openTypeCreationScreen(name: String)
|
||||
fun openRelationCreationScreen(id: Id, name: String, space: Id)
|
||||
fun openRelationEditingScreen(typeName: String, id: Id, iconUnicode: Int, readOnly: Boolean)
|
||||
|
||||
sealed class Command {
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import com.anytypeio.anytype.core_models.Relations
|
|||
import com.anytypeio.anytype.core_models.primitives.RelationKey
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
|
||||
|
@ -139,12 +141,13 @@ sealed class UiObjectsListItem {
|
|||
) : UiObjectsListItem()
|
||||
}
|
||||
|
||||
fun ObjectWrapper.Basic.toUiObjectsListItem(
|
||||
suspend fun ObjectWrapper.Basic.toUiObjectsListItem(
|
||||
space: SpaceId,
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypes: List<ObjectWrapper.Type>,
|
||||
fieldParser: FieldParser,
|
||||
isOwnerOrEditor: Boolean
|
||||
isOwnerOrEditor: Boolean,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): UiObjectsListItem {
|
||||
val obj = this
|
||||
val typeUrl = obj.getProperType()
|
||||
|
@ -163,17 +166,21 @@ fun ObjectWrapper.Basic.toUiObjectsListItem(
|
|||
}
|
||||
}?.name,
|
||||
layout = layout,
|
||||
icon = obj.objectIcon(builder = urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
isPossibleToDelete = isOwnerOrEditor
|
||||
)
|
||||
}
|
||||
|
||||
fun ObjectWrapper.Basic.toUiObjectsListItem(
|
||||
suspend fun ObjectWrapper.Basic.toUiObjectsListItem(
|
||||
space: SpaceId,
|
||||
urlBuilder: UrlBuilder,
|
||||
typeName: String?,
|
||||
fieldParser: FieldParser,
|
||||
isOwnerOrEditor: Boolean
|
||||
isOwnerOrEditor: Boolean,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): UiObjectsListItem {
|
||||
val obj = this
|
||||
val typeUrl = obj.getProperType()
|
||||
|
@ -184,7 +191,10 @@ fun ObjectWrapper.Basic.toUiObjectsListItem(
|
|||
type = typeUrl,
|
||||
typeName = typeName,
|
||||
layout = obj.layout,
|
||||
icon = obj.objectIcon(builder = urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
isPossibleToDelete = isOwnerOrEditor
|
||||
)
|
||||
}
|
|
@ -221,8 +221,7 @@ class ObjectTypeChangeViewModel(
|
|||
isWithBookmark = setup.isWithBookmark,
|
||||
excludeTypes = setup.excludeTypes,
|
||||
selectedTypes = setup.selectedTypes,
|
||||
useCustomComparator = false,
|
||||
urlBuilder = urlBuilder
|
||||
useCustomComparator = false
|
||||
).map {
|
||||
ObjectTypeItemView.Type(it)
|
||||
}
|
||||
|
@ -237,8 +236,7 @@ class ObjectTypeChangeViewModel(
|
|||
isWithBookmark = setup.isWithBookmark,
|
||||
excludeTypes = setup.excludeTypes,
|
||||
selectedTypes = setup.selectedTypes,
|
||||
useCustomComparator = false,
|
||||
urlBuilder = urlBuilder
|
||||
useCustomComparator = false
|
||||
).map {
|
||||
ObjectTypeItemView.Type(it)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ fun List<ObjectWrapper.Type>.getObjectTypeViewsForSBPage(
|
|||
excludeTypes: List<String> = emptyList(),
|
||||
selectedTypes: List<String> = emptyList(),
|
||||
useCustomComparator: Boolean = true,
|
||||
urlBuilder: UrlBuilder
|
||||
): List<ObjectTypeView> {
|
||||
val result = mutableListOf<ObjectTypeView>()
|
||||
forEach { obj ->
|
||||
|
@ -45,14 +44,14 @@ fun List<ObjectWrapper.Type>.getObjectTypeViewsForSBPage(
|
|||
}
|
||||
if (obj.uniqueKey == COLLECTION || obj.uniqueKey == SET) {
|
||||
if (isWithCollection) {
|
||||
val objTypeView = obj.toObjectTypeView(selectedTypes, urlBuilder)
|
||||
val objTypeView = obj.toObjectTypeView(selectedTypes)
|
||||
result.add(objTypeView)
|
||||
}
|
||||
return@forEach
|
||||
}
|
||||
if (obj.uniqueKey == BOOKMARK) {
|
||||
if (isWithBookmark) {
|
||||
val objTypeView = obj.toObjectTypeView(selectedTypes, urlBuilder)
|
||||
val objTypeView = obj.toObjectTypeView(selectedTypes)
|
||||
result.add(objTypeView)
|
||||
}
|
||||
return@forEach
|
||||
|
@ -60,7 +59,7 @@ fun List<ObjectWrapper.Type>.getObjectTypeViewsForSBPage(
|
|||
if (excludeTypes.contains(obj.id)) {
|
||||
return@forEach
|
||||
}
|
||||
val objTypeView = obj.toObjectTypeView(selectedTypes, urlBuilder)
|
||||
val objTypeView = obj.toObjectTypeView(selectedTypes)
|
||||
result.add(objTypeView)
|
||||
return@forEach
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import com.anytypeio.anytype.core_models.Struct
|
|||
import com.anytypeio.anytype.core_models.ext.isValidObject
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
|
@ -19,18 +21,19 @@ import timber.log.Timber
|
|||
* Mapper class for data class @see [com.anytypeio.anytype.presentation.sets.model.ObjectView]
|
||||
* that represents a view of an object in case of fields value.
|
||||
*/
|
||||
fun Struct.buildRelationValueObjectViews(
|
||||
suspend fun Struct.buildRelationValueObjectViews(
|
||||
relationKey: Key,
|
||||
details: ObjectViewDetails,
|
||||
builder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectView> {
|
||||
return this[relationKey]
|
||||
.asIdList()
|
||||
.mapNotNull { id ->
|
||||
details.getObject(id)
|
||||
?.takeIf { it.isValid }
|
||||
?.toObjectView(urlBuilder = builder, fieldParser = fieldParser)
|
||||
?.toObjectView(urlBuilder = builder, fieldParser = fieldParser, storeOfObjectTypes = storeOfObjectTypes)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +42,8 @@ suspend fun Struct.buildObjectViews(
|
|||
store: ObjectStore,
|
||||
builder: UrlBuilder,
|
||||
withIcon: Boolean = true,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectView> {
|
||||
return this.getOrDefault(columnKey, null)
|
||||
.asIdList()
|
||||
|
@ -51,7 +55,14 @@ suspend fun Struct.buildObjectViews(
|
|||
} else if (wrapper.isDeleted == true) {
|
||||
ObjectView.Deleted(id = id, name = fieldParser.getObjectName(wrapper))
|
||||
} else {
|
||||
val icon = if (withIcon) wrapper.objectIcon(builder) else ObjectIcon.None
|
||||
val icon = if (withIcon) {
|
||||
wrapper.objectIcon(
|
||||
builder = builder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(wrapper)
|
||||
)
|
||||
} else {
|
||||
ObjectIcon.None
|
||||
}
|
||||
ObjectView.Default(
|
||||
id = id,
|
||||
name = fieldParser.getObjectName(wrapper),
|
||||
|
@ -66,14 +77,15 @@ suspend fun ObjectWrapper.Basic.objects(
|
|||
relation: Id,
|
||||
urlBuilder: UrlBuilder,
|
||||
storeOfObjects: ObjectStore,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectView> {
|
||||
return map.getOrDefault(relation, null)
|
||||
.asIdList()
|
||||
.mapNotNull { id ->
|
||||
storeOfObjects.get(id)
|
||||
?.takeIf { it.isValid }
|
||||
?.toObjectView(urlBuilder, fieldParser)
|
||||
?.toObjectView(urlBuilder, fieldParser, storeOfObjectTypes)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,13 +93,14 @@ suspend fun ObjectWrapper.Relation.toObjects(
|
|||
value: Any?,
|
||||
store: ObjectStore,
|
||||
urlBuilder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectView> {
|
||||
return value.asIdList().mapNotNull { id ->
|
||||
val raw = store.get(id)?.map
|
||||
if (raw.isNullOrEmpty() || !raw.isValidObject()) null
|
||||
else {
|
||||
ObjectWrapper.Basic(raw).toObjectView(urlBuilder, fieldParser)
|
||||
ObjectWrapper.Basic(raw).toObjectView(urlBuilder, fieldParser, storeOfObjectTypes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,24 +120,29 @@ private fun Any?.asIdList(): List<Id> = when (this) {
|
|||
* Converts a Basic wrapper into an ObjectView.
|
||||
* isValid check performed already in the caller function.
|
||||
*/
|
||||
fun ObjectWrapper.Basic.toObjectView(
|
||||
suspend fun ObjectWrapper.Basic.toObjectView(
|
||||
urlBuilder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): ObjectView = if (isDeleted == true)
|
||||
ObjectView.Deleted(id = id, name = fieldParser.getObjectName(this))
|
||||
else toObjectViewDefault(urlBuilder, fieldParser)
|
||||
else toObjectViewDefault(urlBuilder, fieldParser, storeOfObjectTypes)
|
||||
|
||||
/**
|
||||
* Converts a non-deleted Basic wrapper into a Default ObjectView.
|
||||
* isValid check performed already in the caller function.
|
||||
*/
|
||||
fun ObjectWrapper.Basic.toObjectViewDefault(
|
||||
suspend fun ObjectWrapper.Basic.toObjectViewDefault(
|
||||
urlBuilder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): ObjectView.Default = ObjectView.Default(
|
||||
id = id,
|
||||
name = fieldParser.getObjectName(this),
|
||||
icon = objectIcon(urlBuilder),
|
||||
icon = objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(this)
|
||||
),
|
||||
types = type,
|
||||
isRelation = layout == ObjectType.Layout.RELATION
|
||||
)
|
|
@ -10,6 +10,7 @@ import com.anytypeio.anytype.core_models.Relations
|
|||
import com.anytypeio.anytype.core_utils.ext.typeOf
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.presentation.relations.model.DefaultObjectRelationValueView
|
||||
|
@ -24,7 +25,8 @@ suspend fun ObjectWrapper.Basic.values(
|
|||
settings: List<DVViewerRelation>,
|
||||
urlBuilder: UrlBuilder,
|
||||
storeOfObjects: ObjectStore,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<DefaultObjectRelationValueView> {
|
||||
val values = mutableListOf<DefaultObjectRelationValueView>()
|
||||
relations.forEach { relation ->
|
||||
|
@ -199,7 +201,8 @@ suspend fun ObjectWrapper.Basic.values(
|
|||
relation = relation.key,
|
||||
urlBuilder = urlBuilder,
|
||||
storeOfObjects = storeOfObjects,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
val value = if (objects.isEmpty()) {
|
||||
DefaultObjectRelationValueView.Empty(
|
||||
|
@ -229,14 +232,16 @@ suspend fun ObjectWrapper.Basic.relationsFilteredByHiddenAndDescription(
|
|||
settings: List<DVViewerRelation>,
|
||||
urlBuilder: UrlBuilder,
|
||||
storeOfObjects: ObjectStore,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<DefaultObjectRelationValueView> {
|
||||
return values(
|
||||
relations = relations.filter { it.isHidden != true && it.key != Relations.DESCRIPTION },
|
||||
settings = settings,
|
||||
urlBuilder = urlBuilder,
|
||||
storeOfObjects = storeOfObjects,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_utils.ext.readableFileSize
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.linking.LinkToItemView
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
|
@ -13,18 +15,25 @@ import com.anytypeio.anytype.presentation.navigation.DefaultObjectView
|
|||
import com.anytypeio.anytype.presentation.sets.filter.CreateFilterView
|
||||
import com.anytypeio.anytype.presentation.widgets.collection.CollectionView
|
||||
|
||||
fun List<ObjectWrapper.Basic>.toViews(
|
||||
suspend fun List<ObjectWrapper.Basic>.toViews(
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypes: List<ObjectWrapper.Type>,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<DefaultObjectView> = map { obj ->
|
||||
obj.toView(urlBuilder, objectTypes, fieldParser = fieldParser)
|
||||
obj.toView(
|
||||
urlBuilder,
|
||||
objectTypes,
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
fun ObjectWrapper.Basic.toView(
|
||||
suspend fun ObjectWrapper.Basic.toView(
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypes: List<ObjectWrapper.Type>,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): DefaultObjectView {
|
||||
val obj = this
|
||||
val (objTypeId, objTypeName) = fieldParser.getObjectTypeIdAndName(
|
||||
|
@ -39,7 +48,10 @@ fun ObjectWrapper.Basic.toView(
|
|||
type = objTypeId,
|
||||
typeName = objTypeName,
|
||||
layout = layout,
|
||||
icon = obj.objectIcon(urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
lastModifiedDate = DateParser.parseInMillis(obj.lastModifiedDate) ?: 0L,
|
||||
lastOpenedDate = DateParser.parseInMillis(obj.lastOpenedDate) ?: 0L,
|
||||
isFavorite = obj.isFavorite == true,
|
||||
|
@ -47,10 +59,11 @@ fun ObjectWrapper.Basic.toView(
|
|||
)
|
||||
}
|
||||
|
||||
fun List<ObjectWrapper.Basic>.toLinkToView(
|
||||
suspend fun List<ObjectWrapper.Basic>.toLinkToView(
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypes: List<ObjectWrapper.Type>,
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<LinkToItemView.Object> =
|
||||
this.mapIndexed { index, obj ->
|
||||
val typeUrl = obj.getProperType()
|
||||
|
@ -61,15 +74,19 @@ fun List<ObjectWrapper.Basic>.toLinkToView(
|
|||
subtitle = getProperTypeName(id = typeUrl, types = objectTypes),
|
||||
type = typeUrl,
|
||||
layout = layout,
|
||||
icon = obj.objectIcon(urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
position = index
|
||||
)
|
||||
}
|
||||
|
||||
fun ObjectWrapper.Basic.toLinkToObjectView(
|
||||
suspend fun ObjectWrapper.Basic.toLinkToObjectView(
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypes: List<ObjectWrapper.Type>,
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): LinkToItemView.LinkedTo.Object {
|
||||
val typeUrl = this.getProperType()
|
||||
val layout = this.getProperLayout()
|
||||
|
@ -79,15 +96,19 @@ fun ObjectWrapper.Basic.toLinkToObjectView(
|
|||
subtitle = getProperTypeName(id = typeUrl, types = objectTypes),
|
||||
type = typeUrl,
|
||||
layout = layout,
|
||||
icon = objectIcon(urlBuilder),
|
||||
icon = objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(this)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun List<ObjectWrapper.Basic>.toCreateFilterObjectView(
|
||||
suspend fun List<ObjectWrapper.Basic>.toCreateFilterObjectView(
|
||||
ids: List<*>? = null,
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypes: List<ObjectWrapper.Type>,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<CreateFilterView.Object> =
|
||||
this.map { obj ->
|
||||
CreateFilterView.Object(
|
||||
|
@ -97,7 +118,10 @@ fun List<ObjectWrapper.Basic>.toCreateFilterObjectView(
|
|||
types = objectTypes
|
||||
),
|
||||
name = fieldParser.getObjectName(obj),
|
||||
icon = obj.objectIcon(urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
isSelected = ids?.contains(obj.id) ?: false
|
||||
)
|
||||
}.sortedByDescending { it.isSelected }
|
||||
|
|
|
@ -136,7 +136,7 @@ class SelectObjectTypeViewModel(
|
|||
id = type.id,
|
||||
typeKey = type.uniqueKey,
|
||||
name = type.name.orEmpty(),
|
||||
icon = type.objectIcon(urlBuilder),
|
||||
icon = type.objectIcon(),
|
||||
isPinned = true,
|
||||
isFirstInSection = index == 0,
|
||||
isLastInSection = index == pinnedTypes.lastIndex,
|
||||
|
@ -155,7 +155,7 @@ class SelectObjectTypeViewModel(
|
|||
id = type.id,
|
||||
typeKey = type.uniqueKey,
|
||||
name = type.name.orEmpty(),
|
||||
icon = type.objectIcon(urlBuilder),
|
||||
icon = type.objectIcon(),
|
||||
isFirstInSection = index == 0,
|
||||
isLastInSection = index == pinnedTypes.lastIndex,
|
||||
isPinnable = true,
|
||||
|
@ -175,7 +175,7 @@ class SelectObjectTypeViewModel(
|
|||
id = type.id,
|
||||
typeKey = type.uniqueKey,
|
||||
name = type.name.orEmpty(),
|
||||
icon = type.objectIcon(urlBuilder),
|
||||
icon = type.objectIcon(),
|
||||
isPinnable = true,
|
||||
isFirstInSection = index == 0,
|
||||
isLastInSection = index == pinnedTypes.lastIndex,
|
||||
|
@ -193,7 +193,7 @@ class SelectObjectTypeViewModel(
|
|||
id = type.id,
|
||||
typeKey = type.uniqueKey,
|
||||
name = type.name.orEmpty(),
|
||||
icon = type.objectIcon(urlBuilder),
|
||||
icon = type.objectIcon(),
|
||||
isFromLibrary = true,
|
||||
isPinned = false,
|
||||
isPinnable = false,
|
||||
|
|
|
@ -17,7 +17,8 @@ enum class CustomIconColor(val rawValue: Int) {
|
|||
Blue(6),
|
||||
Sky(7),
|
||||
Teal(8),
|
||||
Green(9);
|
||||
Green(9),
|
||||
Transparent(10);
|
||||
|
||||
/**
|
||||
* Returns the icon option corresponding to this color.
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
|||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
|
||||
import com.anytypeio.anytype.presentation.extension.isValueRequired
|
||||
|
@ -82,7 +83,8 @@ suspend fun DVViewer.render(
|
|||
store: ObjectStore,
|
||||
objectOrderIds: List<Id> = emptyList(),
|
||||
storeOfRelations: StoreOfRelations,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): Viewer {
|
||||
return when (type) {
|
||||
DVViewerType.GRID -> {
|
||||
|
@ -92,7 +94,8 @@ suspend fun DVViewer.render(
|
|||
builder = builder,
|
||||
store = store,
|
||||
objectOrderIds = objectOrderIds,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
DVViewerType.GALLERY -> {
|
||||
|
@ -106,7 +109,8 @@ suspend fun DVViewer.render(
|
|||
objectStore = store,
|
||||
objectOrderIds = objectOrderIds,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
),
|
||||
title = name,
|
||||
largeCards = cardSize == DVViewerCardSize.LARGE
|
||||
|
@ -127,7 +131,8 @@ suspend fun DVViewer.render(
|
|||
urlBuilder = builder,
|
||||
store = store,
|
||||
objectOrderIds = objectOrderIds,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
),
|
||||
title = name
|
||||
)
|
||||
|
@ -141,7 +146,8 @@ suspend fun DVViewer.render(
|
|||
builder = builder,
|
||||
store = store,
|
||||
objectOrderIds = objectOrderIds,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
} else {
|
||||
Viewer.Unsupported(
|
||||
|
@ -177,7 +183,8 @@ private suspend fun DVViewer.buildGridView(
|
|||
builder: UrlBuilder,
|
||||
store: ObjectStore,
|
||||
objectOrderIds: List<Id>,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): Viewer {
|
||||
val vmap = viewerRelations.associateBy { it.key }
|
||||
val visibleRelations = dataViewRelations.filter { relation ->
|
||||
|
@ -195,7 +202,8 @@ private suspend fun DVViewer.buildGridView(
|
|||
columns = columns,
|
||||
builder = builder,
|
||||
store = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -486,7 +494,8 @@ suspend fun DVFilter.toView(
|
|||
relation: ObjectWrapper.Relation,
|
||||
isInEditMode: Boolean,
|
||||
urlBuilder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): FilterView.Expression = when (relation.format) {
|
||||
Relation.Format.SHORT_TEXT -> {
|
||||
FilterView.Expression.TextShort(
|
||||
|
@ -638,7 +647,8 @@ suspend fun DVFilter.toView(
|
|||
value = value,
|
||||
store = store,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
),
|
||||
format = relation.format.toView(),
|
||||
|
@ -668,7 +678,8 @@ suspend fun ObjectWrapper.Relation.toFilterValue(
|
|||
value: Any?,
|
||||
urlBuilder: UrlBuilder,
|
||||
store: ObjectStore,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes : StoreOfObjectTypes
|
||||
): FilterValue = when (this.format) {
|
||||
Relation.Format.SHORT_TEXT -> FilterValue.TextShort(toText(value))
|
||||
Relation.Format.LONG_TEXT -> FilterValue.Text(toText(value))
|
||||
|
@ -696,7 +707,8 @@ suspend fun ObjectWrapper.Relation.toFilterValue(
|
|||
value = value,
|
||||
store = store,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
FilterValue.Object(obj)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
|
||||
@Deprecated("Before Primitives, to delete")
|
||||
class RelationEditViewModel(
|
||||
@TypeId private val id: Id,
|
||||
@TypeName private val name: String,
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.anytypeio.anytype.domain.misc.UrlBuilder
|
|||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.presentation.extension.getOptionObject
|
||||
import com.anytypeio.anytype.presentation.extension.hasValue
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
|
@ -16,30 +17,33 @@ import com.anytypeio.anytype.presentation.sets.model.ColumnView
|
|||
import com.anytypeio.anytype.presentation.sets.model.Viewer
|
||||
import java.util.*
|
||||
|
||||
fun List<ObjectWrapper.Relation>.views(
|
||||
suspend fun List<ObjectWrapper.Relation>.views(
|
||||
details: ObjectViewDetails,
|
||||
values: Map<String, Any?>,
|
||||
urlBuilder: UrlBuilder,
|
||||
featured: List<Id> = emptyList(),
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectRelationView> = mapNotNull { relation ->
|
||||
relation.view(
|
||||
details = details,
|
||||
values = values,
|
||||
urlBuilder = urlBuilder,
|
||||
isFeatured = featured.contains(relation.key),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
fun Key.isSystemKey() : Boolean = Relations.systemRelationKeys.contains(this)
|
||||
|
||||
fun ObjectWrapper.Relation.view(
|
||||
suspend fun ObjectWrapper.Relation.view(
|
||||
details: ObjectViewDetails,
|
||||
values: Map<String, Any?>,
|
||||
urlBuilder: UrlBuilder,
|
||||
isFeatured: Boolean = false,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): ObjectRelationView {
|
||||
val relation = this
|
||||
return when (relation.format) {
|
||||
|
@ -48,7 +52,8 @@ fun ObjectWrapper.Relation.view(
|
|||
relationKey = relation.key,
|
||||
details = details,
|
||||
builder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
ObjectRelationView.Object(
|
||||
id = relation.id,
|
||||
|
|
|
@ -127,7 +127,8 @@ class RelationListViewModel(
|
|||
values = details.getObject(ctx)?.map.orEmpty(),
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
isFeatured = true
|
||||
isFeatured = true,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}.map {
|
||||
Model.Item(it, isLocal = false)
|
||||
|
@ -140,7 +141,8 @@ class RelationListViewModel(
|
|||
values = details.getObject(ctx)?.map.orEmpty(),
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
isFeatured = false
|
||||
isFeatured = false,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}.map {
|
||||
Model.Item(it, isLocal = false)
|
||||
|
@ -153,6 +155,7 @@ class RelationListViewModel(
|
|||
values = details.getObject(ctx)?.map.orEmpty(),
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}.map {
|
||||
Model.Item(it, isLocal = false)
|
||||
|
@ -165,6 +168,7 @@ class RelationListViewModel(
|
|||
values = details.getObject(ctx)?.map.orEmpty(),
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}.map {
|
||||
Model.Item(it, isLocal = true)
|
||||
|
@ -205,7 +209,8 @@ class RelationListViewModel(
|
|||
ctx = ctx,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser,
|
||||
urlBuilder = urlBuilder
|
||||
urlBuilder = urlBuilder,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).map { view ->
|
||||
Model.Item(
|
||||
view = view,
|
||||
|
@ -217,7 +222,8 @@ class RelationListViewModel(
|
|||
ctx = ctx,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser,
|
||||
urlBuilder = urlBuilder
|
||||
urlBuilder = urlBuilder,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).map { view ->
|
||||
Model.Item(
|
||||
view = view,
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.anytypeio.anytype.core_utils.ext.typeOf
|
|||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.presentation.extension.getObject
|
||||
import com.anytypeio.anytype.presentation.extension.getOptionObject
|
||||
import com.anytypeio.anytype.presentation.extension.getTypeObject
|
||||
|
@ -18,13 +19,14 @@ import com.anytypeio.anytype.presentation.objects.buildRelationValueObjectViews
|
|||
import com.anytypeio.anytype.presentation.sets.model.StatusView
|
||||
import com.anytypeio.anytype.presentation.sets.model.TagView
|
||||
|
||||
fun List<ObjectWrapper.Relation>.views(
|
||||
suspend fun List<ObjectWrapper.Relation>.views(
|
||||
context: Id,
|
||||
details: ObjectViewDetails,
|
||||
values: Map<String, Any?>,
|
||||
urlBuilder: UrlBuilder,
|
||||
featured: List<Id> = emptyList(),
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<ObjectRelationView> = mapNotNull { relation ->
|
||||
relation.view(
|
||||
context = context,
|
||||
|
@ -32,17 +34,19 @@ fun List<ObjectWrapper.Relation>.views(
|
|||
values = values,
|
||||
urlBuilder = urlBuilder,
|
||||
isFeatured = featured.contains(relation.key),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
fun ObjectWrapper.Relation.view(
|
||||
suspend fun ObjectWrapper.Relation.view(
|
||||
context: Id,
|
||||
details: ObjectViewDetails,
|
||||
values: Map<String, Any?>,
|
||||
urlBuilder: UrlBuilder,
|
||||
isFeatured: Boolean = false,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): ObjectRelationView? {
|
||||
val relation = this
|
||||
val relationFormat = relation.relationFormat
|
||||
|
@ -55,7 +59,8 @@ fun ObjectWrapper.Relation.view(
|
|||
relationKey = relation.key,
|
||||
details = details,
|
||||
builder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
ObjectRelationView.Object(
|
||||
id = relation.id,
|
||||
|
|
|
@ -185,7 +185,7 @@ class ObjectValueViewModel(
|
|||
objects: List<ObjectWrapper.Basic>,
|
||||
query: String = ""
|
||||
) {
|
||||
val views = mapObjects(ids, objects, query, fieldParser = fieldParser)
|
||||
val views = mapObjects(ids, objects, query, fieldParser, storeOfObjectTypes)
|
||||
viewState.value = if (views.isNotEmpty()) {
|
||||
ObjectValueViewState.Content(
|
||||
isEditableRelation = isEditableRelation,
|
||||
|
@ -222,7 +222,8 @@ class ObjectValueViewModel(
|
|||
ids: List<Id>,
|
||||
objects: List<ObjectWrapper.Basic>,
|
||||
query: String,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes : StoreOfObjectTypes
|
||||
): List<ObjectValueItem.Object> = objects.mapNotNull { obj ->
|
||||
if (!obj.isValid) return@mapNotNull null
|
||||
if (query.isNotBlank() && obj.name?.contains(query, true) == false) return@mapNotNull null
|
||||
|
@ -233,7 +234,8 @@ class ObjectValueViewModel(
|
|||
view = obj.toView(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = storeOfObjectTypes.getAll(),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
),
|
||||
isSelected = isSelected,
|
||||
number = number,
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.anytypeio.anytype.domain.base.fold
|
|||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.RestoreGlobalSearchHistory
|
||||
import com.anytypeio.anytype.domain.search.SearchWithMeta
|
||||
|
@ -559,7 +560,10 @@ suspend fun Command.SearchWithMeta.Result.view(
|
|||
val meta = metas.firstOrNull()
|
||||
return GlobalSearchItemView(
|
||||
id = obj,
|
||||
icon = wrapper.objectIcon(urlBuilder),
|
||||
icon = wrapper.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(wrapper)
|
||||
),
|
||||
links = wrapper.links,
|
||||
backlinks = wrapper.backlinks,
|
||||
space = SpaceId(requireNotNull(wrapper.spaceId)),
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.anytypeio.anytype.domain.base.getOrThrow
|
|||
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
||||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
|
@ -47,7 +48,8 @@ open class ObjectSearchViewModel(
|
|||
private val getObjectTypes: GetObjectTypes,
|
||||
private val analytics: Analytics,
|
||||
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
private val fieldParser: FieldParser
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : ViewStateViewModel<ObjectSearchView>(),
|
||||
SupportNavigation<EventWrapper<AppNavigation.Command>>,
|
||||
TextInputDialogBottomBehaviorApplier.OnDialogCancelListener,
|
||||
|
@ -79,7 +81,8 @@ open class ObjectSearchViewModel(
|
|||
listOfObjects.getOrThrow().toViews(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = listOfTypes.getOrThrow(),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ import com.anytypeio.anytype.core_models.Url
|
|||
import com.anytypeio.anytype.core_utils.ext.typeOf
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverView
|
||||
|
@ -32,7 +34,8 @@ suspend fun DVViewer.buildGalleryViews(
|
|||
objectStore: ObjectStore,
|
||||
objectOrderIds: List<Id>,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<Viewer.GalleryView.Item> {
|
||||
|
||||
val filteredRelations = viewerRelations.mapNotNull { setting ->
|
||||
|
@ -60,7 +63,8 @@ suspend fun DVViewer.buildGalleryViews(
|
|||
filteredRelations = filteredRelations,
|
||||
isLargeSize = true,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
} else {
|
||||
obj.mapToDefaultItem(
|
||||
|
@ -69,7 +73,8 @@ suspend fun DVViewer.buildGalleryViews(
|
|||
viewerRelations = viewerRelations,
|
||||
store = objectStore,
|
||||
filteredRelations = filteredRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +87,8 @@ private suspend fun ObjectWrapper.Basic.mapToDefaultItem(
|
|||
viewerRelations: List<DVViewerRelation>,
|
||||
store: ObjectStore,
|
||||
filteredRelations: List<ObjectWrapper.Relation>,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): Viewer.GalleryView.Item {
|
||||
val obj = this
|
||||
return Viewer.GalleryView.Item.Default(
|
||||
|
@ -92,11 +98,15 @@ private suspend fun ObjectWrapper.Basic.mapToDefaultItem(
|
|||
urlBuilder = urlBuilder,
|
||||
settings = viewerRelations,
|
||||
storeOfObjects = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).setTypeRelationIconsAsNone(),
|
||||
hideIcon = hideIcon,
|
||||
name = fieldParser.getObjectName(obj),
|
||||
icon = obj.objectIcon(urlBuilder)
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -108,7 +118,8 @@ private suspend fun ObjectWrapper.Basic.mapToCoverItem(
|
|||
filteredRelations: List<ObjectWrapper.Relation>,
|
||||
isLargeSize: Boolean,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): Viewer.GalleryView.Item {
|
||||
val obj = this
|
||||
|
||||
|
@ -130,11 +141,15 @@ private suspend fun ObjectWrapper.Basic.mapToCoverItem(
|
|||
urlBuilder = urlBuilder,
|
||||
settings = dvViewer.viewerRelations,
|
||||
storeOfObjects = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).setTypeRelationIconsAsNone(),
|
||||
hideIcon = dvViewer.hideIcon,
|
||||
name = fieldParser.getObjectName(obj),
|
||||
icon = obj.objectIcon(urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
cover = cover,
|
||||
fitImage = dvViewer.coverFit,
|
||||
isLargeSize = isLargeSize
|
||||
|
|
|
@ -7,6 +7,8 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.relationsFilteredByHiddenAndDescription
|
||||
|
@ -19,7 +21,8 @@ suspend fun DVViewer.buildListViews(
|
|||
urlBuilder: UrlBuilder,
|
||||
store: ObjectStore,
|
||||
objectOrderIds: List<Id>,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<Viewer.ListView.Item> {
|
||||
val items = objects.mapNotNull { id ->
|
||||
val obj = store.get(id)
|
||||
|
@ -38,10 +41,14 @@ suspend fun DVViewer.buildListViews(
|
|||
urlBuilder = urlBuilder,
|
||||
settings = viewerRelations,
|
||||
storeOfObjects = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).setTypeRelationIconsAsNone(),
|
||||
name = fieldParser.getObjectName(obj),
|
||||
icon = obj.objectIcon(urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
description = description,
|
||||
hideIcon = hideIcon
|
||||
)
|
||||
|
@ -59,7 +66,8 @@ suspend fun DVViewer.buildListViews(
|
|||
urlBuilder = urlBuilder,
|
||||
settings = viewerRelations,
|
||||
storeOfObjects = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).setTypeRelationIconsAsNone(),
|
||||
name = fieldParser.getObjectName(obj),
|
||||
done = obj.done == true,
|
||||
|
@ -79,10 +87,14 @@ suspend fun DVViewer.buildListViews(
|
|||
urlBuilder = urlBuilder,
|
||||
settings = viewerRelations,
|
||||
storeOfObjects = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).setTypeRelationIconsAsNone(),
|
||||
name = fieldParser.getObjectName(obj),
|
||||
icon = obj.objectIcon(urlBuilder),
|
||||
icon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
description = description,
|
||||
hideIcon = hideIcon
|
||||
)
|
||||
|
|
|
@ -63,11 +63,12 @@ import com.anytypeio.anytype.presentation.sets.viewer.ViewerView
|
|||
import com.anytypeio.anytype.presentation.templates.TemplateView
|
||||
import timber.log.Timber
|
||||
|
||||
fun ObjectState.DataView.featuredRelations(
|
||||
suspend fun ObjectState.DataView.featuredRelations(
|
||||
ctx: Id,
|
||||
urlBuilder: UrlBuilder,
|
||||
relations: List<ObjectWrapper.Relation>,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
): BlockView.FeaturedRelation? {
|
||||
val block = blocks.find { it.content is Block.Content.FeaturedRelations }
|
||||
if (block != null) {
|
||||
|
@ -81,7 +82,8 @@ fun ObjectState.DataView.featuredRelations(
|
|||
details = details,
|
||||
relations = relations,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
)
|
||||
return BlockView.FeaturedRelation(
|
||||
|
@ -125,13 +127,14 @@ fun ObjectState.DataView.header(
|
|||
}
|
||||
}
|
||||
|
||||
private fun ObjectState.DataView.mapFeaturedRelations(
|
||||
private suspend fun ObjectState.DataView.mapFeaturedRelations(
|
||||
ctx: Id,
|
||||
keys: List<String>?,
|
||||
details: ObjectViewDetails,
|
||||
relations: List<ObjectWrapper.Relation>,
|
||||
urlBuilder: UrlBuilder,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
): List<ObjectRelationView> {
|
||||
val currentObject = details.getObject(ctx) ?: return emptyList()
|
||||
val featuredRelationsIds = currentObject.featuredRelations
|
||||
|
@ -185,7 +188,13 @@ private fun ObjectState.DataView.mapFeaturedRelations(
|
|||
val isReadOnly = wrapper?.relationReadonlyValue == true
|
||||
|
||||
val sources = if (isValid && !isDeleted) {
|
||||
listOf(wrapper.toObjectViewDefault(urlBuilder = urlBuilder, fieldParser = fieldParser))
|
||||
listOf(
|
||||
wrapper.toObjectViewDefault(
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
|
@ -215,7 +224,8 @@ private fun ObjectState.DataView.mapFeaturedRelations(
|
|||
values = currentObject.map,
|
||||
urlBuilder = urlBuilder,
|
||||
isFeatured = true,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,8 @@ class ObjectSetViewModel(
|
|||
ctx = vmParams.ctx,
|
||||
urlBuilder = urlBuilder,
|
||||
relations = storeOfRelations.getAll(),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
_header.value = state.header(
|
||||
ctx = vmParams.ctx,
|
||||
|
@ -712,7 +713,8 @@ class ObjectSetViewModel(
|
|||
dataViewRelations = relations,
|
||||
store = objectStore,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
when {
|
||||
|
@ -786,7 +788,8 @@ class ObjectSetViewModel(
|
|||
dataViewRelations = relations,
|
||||
store = objectStore,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
when {
|
||||
|
@ -834,7 +837,8 @@ class ObjectSetViewModel(
|
|||
store = objectStore,
|
||||
objectOrderIds = objectOrderIds,
|
||||
storeOfRelations = storeOfRelations,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -2230,7 +2234,7 @@ class ObjectSetViewModel(
|
|||
onSuccess = { types ->
|
||||
val list = buildList {
|
||||
add(TemplateObjectTypeView.Search)
|
||||
addAll(types.toTemplateObjectTypeViewItems(selectedType, urlBuilder))
|
||||
addAll(types.toTemplateObjectTypeViewItems(selectedType))
|
||||
}
|
||||
typeTemplatesWidgetState.value = widgetState.copy(objectTypes = list)
|
||||
},
|
||||
|
|
|
@ -9,12 +9,14 @@ import com.anytypeio.anytype.core_models.Struct
|
|||
import com.anytypeio.anytype.core_utils.ext.typeOf
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.number.NumberParser
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.core_models.ObjectViewDetails
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.presentation.extension.getFileObject
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
import com.anytypeio.anytype.presentation.objects.buildObjectViews
|
||||
import com.anytypeio.anytype.presentation.relations.getDateRelationFormat
|
||||
import com.anytypeio.anytype.presentation.sets.model.CellView
|
||||
|
@ -31,7 +33,8 @@ suspend fun List<ColumnView>.buildGridRow(
|
|||
obj: ObjectWrapper.Basic,
|
||||
builder: UrlBuilder,
|
||||
store: ObjectStore,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): Viewer.GridView.Row {
|
||||
|
||||
val type = obj.type.firstOrNull()
|
||||
|
@ -40,7 +43,10 @@ suspend fun List<ColumnView>.buildGridRow(
|
|||
val image = obj.iconImage
|
||||
val done = obj.done
|
||||
val layout = obj.layout
|
||||
val objectIcon = obj.objectIcon(builder)
|
||||
val objectIcon = obj.objectIcon(
|
||||
builder = builder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
)
|
||||
|
||||
val cells = mutableListOf<CellView>()
|
||||
this.map { column ->
|
||||
|
@ -61,7 +67,8 @@ suspend fun List<ColumnView>.buildGridRow(
|
|||
builder = builder,
|
||||
store = store,
|
||||
withIcon = false,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
cells.add(
|
||||
CellView.Object(
|
||||
|
@ -171,7 +178,8 @@ suspend fun List<ColumnView>.buildGridRow(
|
|||
columnKey = column.key,
|
||||
builder = builder,
|
||||
store = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
CellView.Object(
|
||||
id = obj.id,
|
||||
|
|
|
@ -99,7 +99,8 @@ open class FilterViewModel(
|
|||
condition = condition?.condition,
|
||||
index = filterIndex,
|
||||
viewerId = viewerId,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +138,8 @@ open class FilterViewModel(
|
|||
condition = conditionState.value?.condition,
|
||||
index = filterIndex,
|
||||
viewerId = viewerId,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
} else {
|
||||
Timber.e("Couldn't find relation in StoreOfRelations by relationKey:[$relationKey]")
|
||||
|
@ -231,7 +233,8 @@ open class FilterViewModel(
|
|||
viewerId: Id,
|
||||
condition: Viewer.Filter.Condition?,
|
||||
index: Int?,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
) {
|
||||
if (condition == null || !condition.hasValue()) {
|
||||
filterValueState.value = null
|
||||
|
@ -249,7 +252,8 @@ open class FilterViewModel(
|
|||
value = null,
|
||||
urlBuilder = urlBuilder,
|
||||
store = objectSetDatabase.store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
proceedWithFilterValueList(
|
||||
relation = relation,
|
||||
|
@ -264,7 +268,8 @@ open class FilterViewModel(
|
|||
value = filter.value,
|
||||
urlBuilder = urlBuilder,
|
||||
store = objectSetDatabase.store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
proceedWithFilterValueList(
|
||||
relation = relation,
|
||||
|
@ -408,7 +413,8 @@ open class FilterViewModel(
|
|||
ids = ids,
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = objectTypes,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).also {
|
||||
optionCountState.value = it.count { view -> view.isSelected }
|
||||
}
|
||||
|
@ -443,7 +449,8 @@ open class FilterViewModel(
|
|||
ids = ids,
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = objectTypes,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
).also {
|
||||
optionCountState.value = it.count { view -> view.isSelected }
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.anytypeio.anytype.core_models.*
|
|||
import com.anytypeio.anytype.domain.base.fold
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.DataViewState
|
||||
|
@ -36,7 +37,8 @@ class ViewerFilterViewModel(
|
|||
private val storeOfRelations: StoreOfRelations,
|
||||
private val db: ObjectSetDatabase,
|
||||
private val analytics: Analytics,
|
||||
private val fieldParser: FieldParser
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : BaseListViewModel<FilterView>() {
|
||||
|
||||
val screenState = MutableStateFlow(ScreenState.LIST)
|
||||
|
@ -69,7 +71,8 @@ class ViewerFilterViewModel(
|
|||
storeOfObjects = db.store,
|
||||
screenState = screenState.value,
|
||||
urlBuilder = urlBuilder,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +224,8 @@ class ViewerFilterViewModel(
|
|||
private val analytics: Analytics,
|
||||
private val storeOfRelations: StoreOfRelations,
|
||||
private val objectSetDatabase: ObjectSetDatabase,
|
||||
private val fieldParser: FieldParser
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes
|
||||
) : ViewModelProvider.Factory {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
|
@ -233,7 +237,8 @@ class ViewerFilterViewModel(
|
|||
analytics = analytics,
|
||||
storeOfRelations = storeOfRelations,
|
||||
db = objectSetDatabase,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) as T
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import kotlinx.coroutines.flow.stateIn
|
|||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
@Deprecated("Before Primitives, to delete")
|
||||
class CreateObjectTypeViewModel(
|
||||
private val createObjectType: CreateObjectType,
|
||||
private val urlBuilder: UrlBuilder,
|
||||
|
|
|
@ -23,6 +23,7 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
|
||||
@Deprecated("Before Primitives, to delete")
|
||||
class TypeEditViewModel(
|
||||
private val urlBuilder: UrlBuilder,
|
||||
private val id: Id,
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.anytypeio.anytype.presentation.picker.IconPickerViewModel
|
|||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
@Deprecated("Before Primitives, to delete")
|
||||
class TypeIconPickerViewModel(
|
||||
provider: EmojiProvider,
|
||||
suggester: EmojiSuggester,
|
||||
|
|
|
@ -15,7 +15,9 @@ import com.anytypeio.anytype.domain.library.StoreSearchParams
|
|||
import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.`object`.GetObject
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.presentation.BuildConfig
|
||||
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||
|
@ -45,6 +47,7 @@ class DataViewListWidgetContainer(
|
|||
private val coverImageHashProvider: CoverImageHashProvider,
|
||||
private val storeOfRelations: StoreOfRelations,
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes,
|
||||
isSessionActive: Flow<Boolean>,
|
||||
onRequestCache: () -> WidgetView.SetOfObjects? = { null },
|
||||
) : WidgetContainer {
|
||||
|
@ -190,14 +193,16 @@ class DataViewListWidgetContainer(
|
|||
obj = obj,
|
||||
activeView = view,
|
||||
params = params,
|
||||
target = target
|
||||
target = target,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
} else {
|
||||
defaultWidgetSubscribe(
|
||||
obj = obj,
|
||||
activeView = view,
|
||||
params = params,
|
||||
isCompact = isCompact
|
||||
isCompact = isCompact,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
@ -225,7 +230,8 @@ class DataViewListWidgetContainer(
|
|||
obj: ObjectView,
|
||||
activeView: Id?,
|
||||
target: Block.Content.DataView.Viewer,
|
||||
params: StoreSearchParams
|
||||
params: StoreSearchParams,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): Flow<WidgetView.Gallery> {
|
||||
return storage.subscribeWithDependencies(params).map { response ->
|
||||
val objects = resolveObjectOrder(
|
||||
|
@ -245,7 +251,8 @@ class DataViewListWidgetContainer(
|
|||
obj = obj,
|
||||
objectIcon = if (withIcon) {
|
||||
obj.objectIcon(
|
||||
builder = urlBuilder
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
)
|
||||
} else {
|
||||
ObjectIcon.None
|
||||
|
@ -284,7 +291,8 @@ class DataViewListWidgetContainer(
|
|||
obj: ObjectView,
|
||||
activeView: Id?,
|
||||
params: StoreSearchParams,
|
||||
isCompact: Boolean
|
||||
isCompact: Boolean,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): Flow<WidgetView> {
|
||||
return storage.subscribe(params).map { results ->
|
||||
val objects = resolveObjectOrder(
|
||||
|
@ -299,7 +307,10 @@ class DataViewListWidgetContainer(
|
|||
elements = objects.map { obj ->
|
||||
WidgetView.SetOfObjects.Element(
|
||||
obj = obj,
|
||||
objectIcon = obj.objectIcon(builder = urlBuilder),
|
||||
objectIcon = obj.objectIcon(
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
name = WidgetView.Name.Default(
|
||||
prettyPrintName = fieldParser.getObjectName(obj)
|
||||
)
|
||||
|
|
|
@ -14,6 +14,8 @@ import com.anytypeio.anytype.domain.library.StoreSearchParams
|
|||
import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectWatcher
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.spaces.GetSpaceView
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
|
@ -39,6 +41,7 @@ class ListWidgetContainer(
|
|||
private val objectWatcher: ObjectWatcher,
|
||||
private val getSpaceView: GetSpaceView,
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes,
|
||||
isSessionActive: Flow<Boolean>,
|
||||
onRequestCache: () -> WidgetView.ListOfObjects? = { null }
|
||||
) : WidgetContainer {
|
||||
|
@ -105,7 +108,8 @@ class ListWidgetContainer(
|
|||
.sortedBy { obj -> order[obj.id] }
|
||||
.take(resolveLimit())
|
||||
,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +132,8 @@ class ListWidgetContainer(
|
|||
).map { objects ->
|
||||
buildWidgetViewWithElements(
|
||||
objects = objects,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +142,8 @@ class ListWidgetContainer(
|
|||
storage.subscribe(buildParams()).map { objects ->
|
||||
buildWidgetViewWithElements(
|
||||
objects = objects,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -145,9 +151,10 @@ class ListWidgetContainer(
|
|||
}
|
||||
}
|
||||
|
||||
private fun buildWidgetViewWithElements(
|
||||
private suspend fun buildWidgetViewWithElements(
|
||||
objects: List<ObjectWrapper.Basic>,
|
||||
fieldParser: FieldParser
|
||||
fieldParser: FieldParser,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
) = WidgetView.ListOfObjects(
|
||||
id = widget.id,
|
||||
source = widget.source,
|
||||
|
@ -156,7 +163,8 @@ class ListWidgetContainer(
|
|||
WidgetView.ListOfObjects.Element(
|
||||
obj = obj,
|
||||
objectIcon = obj.objectIcon(
|
||||
builder = urlBuilder
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
name = buildWidgetName(
|
||||
obj = obj,
|
||||
|
|
|
@ -5,12 +5,12 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.domain.base.Resultat
|
||||
import com.anytypeio.anytype.domain.base.fold
|
||||
import com.anytypeio.anytype.domain.base.getOrDefault
|
||||
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.analytics.AnalyticSpaceHelperDelegate
|
||||
|
@ -37,6 +37,7 @@ class SelectWidgetSourceViewModel(
|
|||
private val analytics: Analytics,
|
||||
private val dispatcher: Dispatcher<WidgetDispatchEvent>,
|
||||
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes,
|
||||
fieldParser: FieldParser
|
||||
) : ObjectSearchViewModel(
|
||||
vmParams = vmParams,
|
||||
|
@ -45,7 +46,8 @@ class SelectWidgetSourceViewModel(
|
|||
getObjectTypes = getObjectTypes,
|
||||
analytics = analytics,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) {
|
||||
|
||||
val isDismissed = MutableStateFlow(false)
|
||||
|
@ -267,7 +269,8 @@ class SelectWidgetSourceViewModel(
|
|||
private val analytics: Analytics,
|
||||
private val dispatcher: Dispatcher<WidgetDispatchEvent>,
|
||||
private val analyticSpaceHelperDelegate: AnalyticSpaceHelperDelegate,
|
||||
private val fieldParser: FieldParser
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes,
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
@ -280,7 +283,8 @@ class SelectWidgetSourceViewModel(
|
|||
getObjectTypes = getObjectTypes,
|
||||
dispatcher = dispatcher,
|
||||
analyticSpaceHelperDelegate = analyticSpaceHelperDelegate,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
) as T
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import com.anytypeio.anytype.domain.library.StoreSearchByIdsParams
|
|||
import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.ObjectWatcher
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.getTypeOfObject
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.spaces.GetSpaceView
|
||||
import com.anytypeio.anytype.presentation.mapper.objectIcon
|
||||
|
@ -35,6 +37,7 @@ class TreeWidgetContainer(
|
|||
private val objectWatcher: ObjectWatcher,
|
||||
private val getSpaceView: GetSpaceView,
|
||||
private val fieldParser: FieldParser,
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes,
|
||||
isSessionActive: Flow<Boolean>,
|
||||
onRequestCache: () -> WidgetView.Tree? = { null }
|
||||
) : WidgetContainer {
|
||||
|
@ -120,7 +123,8 @@ class TreeWidgetContainer(
|
|||
expanded = paths,
|
||||
path = widget.id + SEPARATOR + widget.source.id + SEPARATOR,
|
||||
data = data,
|
||||
rootLimit = rootLevelLimit
|
||||
rootLimit = rootLevelLimit,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
),
|
||||
name = WidgetView.Name.Bundled(source = source)
|
||||
)
|
||||
|
@ -160,7 +164,8 @@ class TreeWidgetContainer(
|
|||
expanded = paths,
|
||||
path = widget.id + SEPARATOR + widget.source.id + SEPARATOR,
|
||||
data = data,
|
||||
rootLimit = WidgetConfig.NO_LIMIT
|
||||
rootLimit = WidgetConfig.NO_LIMIT,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
),
|
||||
name = WidgetView.Name.Default(
|
||||
prettyPrintName = fieldParser.getObjectName(source.obj)
|
||||
|
@ -253,13 +258,14 @@ class TreeWidgetContainer(
|
|||
}
|
||||
}.distinct()
|
||||
|
||||
private fun buildTree(
|
||||
private suspend fun buildTree(
|
||||
links: List<Id>,
|
||||
expanded: List<TreePath>,
|
||||
level: Int,
|
||||
path: TreePath,
|
||||
data: Map<Id, ObjectWrapper.Basic>,
|
||||
rootLimit: Int
|
||||
rootLimit: Int,
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): List<WidgetView.Tree.Element> = buildList {
|
||||
links.forEachIndexed { index, link ->
|
||||
// Applying limit only for root level:
|
||||
|
@ -281,7 +287,8 @@ class TreeWidgetContainer(
|
|||
currentLinkPath = currentLinkPath
|
||||
),
|
||||
objectIcon = obj.objectIcon(
|
||||
builder = urlBuilder
|
||||
builder = urlBuilder,
|
||||
objType = storeOfObjectTypes.getTypeOfObject(obj)
|
||||
),
|
||||
indent = level,
|
||||
path = path + link,
|
||||
|
@ -299,7 +306,8 @@ class TreeWidgetContainer(
|
|||
expanded = expanded,
|
||||
path = currentLinkPath + SEPARATOR,
|
||||
data = data,
|
||||
rootLimit = rootLimit
|
||||
rootLimit = rootLimit,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -347,7 +347,12 @@ class CollectionViewModel(
|
|||
}
|
||||
|
||||
val views = filteredResults
|
||||
.toViews(urlBuilder = urlBuilder, objectTypes = types, fieldParser = fieldParser)
|
||||
.toViews(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = types,
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
.map { ObjectView(it) }
|
||||
.tryAddSections()
|
||||
|
||||
|
@ -416,7 +421,7 @@ class CollectionViewModel(
|
|||
Timber.e(it, "Error in favorites subscription flow")
|
||||
}
|
||||
|
||||
private fun prepareFavorites(
|
||||
private suspend fun prepareFavorites(
|
||||
favoritesObj: CoreObjectView,
|
||||
objs: List<ObjectWrapper.Basic>,
|
||||
query: String,
|
||||
|
@ -430,7 +435,7 @@ class CollectionViewModel(
|
|||
val name = fieldParser.getObjectName(obj)
|
||||
name.lowercase().contains(query.lowercase(), true)
|
||||
}
|
||||
.toViews(urlBuilder, types, fieldParser)
|
||||
.toViews(urlBuilder, types, fieldParser, storeOfObjectTypes)
|
||||
.map { FavoritesView(it, favs[it.id]?.blockId ?: "") }
|
||||
}
|
||||
|
||||
|
|
|
@ -369,10 +369,11 @@ class EditorSlashWidgetClicksTest: EditorPresentationTestSetup() {
|
|||
id = type1.id,
|
||||
key = type1.uniqueKey,
|
||||
name = type1.name.orEmpty(),
|
||||
icon = ObjectIcon.Basic.Emoji(
|
||||
unicode = type1.iconEmoji.orEmpty(),
|
||||
emptyState = ObjectIcon.Empty.ObjectType
|
||||
),
|
||||
icon = ObjectIcon.None,
|
||||
// ObjectIcon.Basic.Emoji(
|
||||
// unicode = type1.iconEmoji.orEmpty(),
|
||||
// emptyState = ObjectIcon.Empty.ObjectType
|
||||
// ),
|
||||
description = type1.description,
|
||||
)
|
||||
),
|
||||
|
@ -382,10 +383,11 @@ class EditorSlashWidgetClicksTest: EditorPresentationTestSetup() {
|
|||
key = type2.uniqueKey,
|
||||
name = type2.name.orEmpty(),
|
||||
description = type2.description,
|
||||
icon = ObjectIcon.Basic.Emoji(
|
||||
unicode = type2.iconEmoji.orEmpty(),
|
||||
emptyState = ObjectIcon.Empty.ObjectType
|
||||
),
|
||||
icon = ObjectIcon.None,
|
||||
// ObjectIcon.Basic.Emoji(
|
||||
// unicode = type2.iconEmoji.orEmpty(),
|
||||
// emptyState = ObjectIcon.Empty.ObjectType
|
||||
// ),
|
||||
)
|
||||
),
|
||||
SlashItem.ObjectType(
|
||||
|
@ -394,10 +396,11 @@ class EditorSlashWidgetClicksTest: EditorPresentationTestSetup() {
|
|||
key = type3.uniqueKey,
|
||||
name = type3.name.orEmpty(),
|
||||
description = type3.description,
|
||||
icon = ObjectIcon.Basic.Emoji(
|
||||
unicode = type3.iconEmoji.orEmpty(),
|
||||
emptyState = ObjectIcon.Empty.ObjectType
|
||||
),
|
||||
icon = ObjectIcon.None,
|
||||
// ObjectIcon.Basic.Emoji(
|
||||
// unicode = type3.iconEmoji.orEmpty(),
|
||||
// emptyState = ObjectIcon.Empty.ObjectType
|
||||
// ),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -471,10 +471,11 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
key = type1.uniqueKey,
|
||||
name = type1.name.orEmpty(),
|
||||
description = type1.description,
|
||||
icon = ObjectIcon.Basic.Emoji(
|
||||
unicode = type1.iconEmoji.orEmpty(),
|
||||
emptyState = ObjectIcon.Empty.ObjectType
|
||||
),
|
||||
icon = ObjectIcon.None
|
||||
// ObjectIcon.Basic.Emoji(
|
||||
// unicode = type1.iconEmoji.orEmpty(),
|
||||
// emptyState = ObjectIcon.Empty.ObjectType
|
||||
// ),
|
||||
)
|
||||
),
|
||||
SlashItem.ObjectType(
|
||||
|
@ -483,10 +484,11 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
key = type2.uniqueKey,
|
||||
name = type2.name.orEmpty(),
|
||||
description = type2.description,
|
||||
icon = ObjectIcon.Basic.Emoji(
|
||||
unicode = type2.iconEmoji.orEmpty(),
|
||||
emptyState = ObjectIcon.Empty.ObjectType
|
||||
),
|
||||
icon = ObjectIcon.None
|
||||
// ObjectIcon.Basic.Emoji(
|
||||
// unicode = type2.iconEmoji.orEmpty(),
|
||||
// emptyState = ObjectIcon.Empty.ObjectType
|
||||
// ),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -1515,10 +1517,11 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
key = type1.uniqueKey.orEmpty(),
|
||||
name = type1.name.orEmpty(),
|
||||
description = type1.description,
|
||||
icon = ObjectIcon.Basic.Emoji(
|
||||
unicode = type1.iconEmoji.orEmpty(),
|
||||
emptyState = ObjectIcon.Empty.ObjectType
|
||||
),
|
||||
icon = ObjectIcon.None
|
||||
// ObjectIcon.Basic.Emoji(
|
||||
// unicode = type1.iconEmoji.orEmpty(),
|
||||
// emptyState = ObjectIcon.Empty.ObjectType
|
||||
// ),
|
||||
)
|
||||
),
|
||||
SlashItem.ObjectType(
|
||||
|
@ -1527,10 +1530,11 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
key = type2.uniqueKey.orEmpty(),
|
||||
name = type2.name.orEmpty(),
|
||||
description = type2.description,
|
||||
icon = ObjectIcon.Basic.Emoji(
|
||||
unicode = type2.iconEmoji.orEmpty(),
|
||||
emptyState = ObjectIcon.Empty.ObjectType
|
||||
),
|
||||
icon = ObjectIcon.None
|
||||
// ObjectIcon.Basic.Emoji(
|
||||
// unicode = type2.iconEmoji.orEmpty(),
|
||||
// emptyState = ObjectIcon.Empty.ObjectType
|
||||
// ),
|
||||
)
|
||||
),
|
||||
SlashItem.ObjectType(
|
||||
|
@ -1539,10 +1543,11 @@ class EditorSlashWidgetFilterTest : EditorPresentationTestSetup() {
|
|||
key = type3.uniqueKey.orEmpty(),
|
||||
name = type3.name.orEmpty(),
|
||||
description = type3.description,
|
||||
icon = ObjectIcon.Basic.Emoji(
|
||||
unicode = type3.iconEmoji.orEmpty(),
|
||||
emptyState = ObjectIcon.Empty.ObjectType
|
||||
),
|
||||
icon = ObjectIcon.None
|
||||
// ObjectIcon.Basic.Emoji(
|
||||
// unicode = type3.iconEmoji.orEmpty(),
|
||||
// emptyState = ObjectIcon.Empty.ObjectType
|
||||
// ),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.anytypeio.anytype.domain.history.ShowVersion
|
|||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.LocaleProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.workspace.SpaceManager
|
||||
|
@ -95,6 +96,9 @@ class VersionHistoryViewModelTest {
|
|||
@Mock
|
||||
lateinit var storeOfRelations: StoreOfRelations
|
||||
|
||||
@Mock
|
||||
lateinit var storeOfObjectTypes: StoreOfObjectTypes
|
||||
|
||||
@Mock
|
||||
lateinit var coverImageHashProvider: CoverImageHashProvider
|
||||
|
||||
|
@ -545,6 +549,7 @@ class VersionHistoryViewModelTest {
|
|||
showVersion = showVersion,
|
||||
setStateReducer = DefaultObjectStateReducer(),
|
||||
storeOfRelations = storeOfRelations,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
)
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import com.anytypeio.anytype.domain.misc.DateProvider
|
|||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.GetDateObjectByTimestamp
|
||||
import com.anytypeio.anytype.domain.objects.ObjectWatcher
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParserImpl
|
||||
import com.anytypeio.anytype.domain.resources.StringResourceProvider
|
||||
|
@ -75,6 +76,9 @@ class TreeWidgetContainerTest {
|
|||
@Mock
|
||||
lateinit var dateProvider: DateProvider
|
||||
|
||||
@Mock
|
||||
lateinit var storeOfObjectTypes: StoreOfObjectTypes
|
||||
|
||||
@Mock
|
||||
lateinit var getDateObjectByTimestamp: GetDateObjectByTimestamp
|
||||
|
||||
|
@ -123,7 +127,8 @@ class TreeWidgetContainerTest {
|
|||
isSessionActive = flowOf(true),
|
||||
objectWatcher = objectWatcher,
|
||||
getSpaceView = getSpaceView,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
stubObjectSearch(
|
||||
|
@ -200,7 +205,8 @@ class TreeWidgetContainerTest {
|
|||
isSessionActive = flowOf(true),
|
||||
objectWatcher = objectWatcher,
|
||||
getSpaceView = getSpaceView,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
stubObjectSearch(
|
||||
|
@ -292,7 +298,8 @@ class TreeWidgetContainerTest {
|
|||
isSessionActive = flowOf(true),
|
||||
objectWatcher = objectWatcher,
|
||||
getSpaceView = getSpaceView,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
stubObjectSearch(
|
||||
|
@ -480,7 +487,8 @@ class TreeWidgetContainerTest {
|
|||
isSessionActive = flowOf(true),
|
||||
objectWatcher = objectWatcher,
|
||||
getSpaceView = getSpaceView,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
stubObjectSearch(
|
||||
|
@ -550,7 +558,8 @@ class TreeWidgetContainerTest {
|
|||
isSessionActive = flowOf(true),
|
||||
objectWatcher = objectWatcher,
|
||||
getSpaceView = getSpaceView,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
stubObjectSearch(
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.anytypeio.anytype.domain.debugging.Logger
|
|||
import com.anytypeio.anytype.domain.misc.DateProvider
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.GetDateObjectByTimestamp
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParserImpl
|
||||
import com.anytypeio.anytype.domain.resources.StringResourceProvider
|
||||
|
@ -14,6 +15,7 @@ import com.anytypeio.anytype.presentation.objects.toViews
|
|||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
|
@ -38,6 +40,9 @@ class ObjectWrapperExtensionsKtTest {
|
|||
@Mock
|
||||
lateinit var stringResourceProvider: StringResourceProvider
|
||||
|
||||
@Mock
|
||||
lateinit var storeOfObjectTypes: StoreOfObjectTypes
|
||||
|
||||
lateinit var fieldParser: FieldParser
|
||||
|
||||
val URL = "anytype.io/"
|
||||
|
@ -98,7 +103,7 @@ class ObjectWrapperExtensionsKtTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should map to view with snippet as name when layout is note`() {
|
||||
fun `should map to view with snippet as name when layout is note`() = runTest {
|
||||
|
||||
val imageHash = "ycd79"
|
||||
|
||||
|
@ -116,7 +121,8 @@ class ObjectWrapperExtensionsKtTest {
|
|||
val result = listOf(obj).toViews(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = listOf(),
|
||||
fieldParser
|
||||
fieldParser,
|
||||
storeOfObjectTypes
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
|
@ -126,7 +132,7 @@ class ObjectWrapperExtensionsKtTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should map to view with name as name when layout is not note`() {
|
||||
fun `should map to view with name as name when layout is not note`() = runTest {
|
||||
|
||||
val imageHash = "ycd79"
|
||||
|
||||
|
@ -144,7 +150,8 @@ class ObjectWrapperExtensionsKtTest {
|
|||
val result = listOf(obj).toViews(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = listOf(),
|
||||
fieldParser
|
||||
fieldParser,
|
||||
storeOfObjectTypes
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
|
@ -154,7 +161,7 @@ class ObjectWrapperExtensionsKtTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should map to view proper snippet max 30 characters`() {
|
||||
fun `should map to view proper snippet max 30 characters`() = runTest {
|
||||
|
||||
val obj = ObjectWrapper.Basic(
|
||||
mapOf(
|
||||
|
@ -173,7 +180,8 @@ class ObjectWrapperExtensionsKtTest {
|
|||
val result = listOf(obj).toViews(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypes = listOf(),
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.anytypeio.anytype.domain.misc.DateProvider
|
|||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.GetDateObjectByTimestamp
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParser
|
||||
import com.anytypeio.anytype.domain.primitives.FieldParserImpl
|
||||
import com.anytypeio.anytype.domain.resources.StringResourceProvider
|
||||
|
@ -53,6 +54,9 @@ class TagAndStatusTests {
|
|||
@Mock
|
||||
lateinit var stringResourceProvider: StringResourceProvider
|
||||
|
||||
@Mock
|
||||
lateinit var storeOfObjectTypes: StoreOfObjectTypes
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
@ -156,7 +160,8 @@ class TagAndStatusTests {
|
|||
builder = UrlBuilder(gateway),
|
||||
showIcon = false,
|
||||
store = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
val expected = Viewer.GridView.Row(
|
||||
|
@ -293,7 +298,8 @@ class TagAndStatusTests {
|
|||
builder = UrlBuilder(gateway),
|
||||
showIcon = false,
|
||||
store = store,
|
||||
fieldParser = fieldParser
|
||||
fieldParser = fieldParser,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
val expected = Viewer.GridView.Row(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue