mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2916 App | Tech | Prepare staging release (#1666)
Co-authored-by: Konstantin Ivanov <54908981+konstantiniiv@users.noreply.github.com>
This commit is contained in:
parent
14af7b40c1
commit
b78e3e4d0d
203 changed files with 2606 additions and 1726 deletions
|
@ -34,6 +34,7 @@ import androidx.core.graphics.toColorInt
|
|||
import coil.compose.rememberAsyncImagePainter
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_ui.R
|
||||
import com.anytypeio.anytype.core_ui.features.SpaceIconView
|
||||
import com.anytypeio.anytype.core_ui.foundation.Dragger
|
||||
import com.anytypeio.anytype.core_ui.foundation.noRippleThrottledClickable
|
||||
import com.anytypeio.anytype.core_ui.views.Title3
|
||||
|
@ -129,11 +130,13 @@ private fun SpaceItem(space: GallerySpaceView, onSpaceClick: (GallerySpaceView)
|
|||
.noRippleThrottledClickable { onSpaceClick(space) },
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
SpaceIcon(
|
||||
SpaceIconView(
|
||||
icon = space.icon,
|
||||
modifier = Modifier
|
||||
.size(48.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
modifier = Modifier,
|
||||
mainSize = 48.dp,
|
||||
onSpaceIconClick = {
|
||||
// Do nothing
|
||||
}
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier
|
||||
|
@ -146,45 +149,6 @@ private fun SpaceItem(space: GallerySpaceView, onSpaceClick: (GallerySpaceView)
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SpaceIcon(
|
||||
icon: SpaceIconView,
|
||||
modifier: Modifier
|
||||
) {
|
||||
when (icon) {
|
||||
is SpaceIconView.Image -> {
|
||||
Image(
|
||||
painter = rememberAsyncImagePainter(
|
||||
model = icon.url,
|
||||
error = painterResource(id = R.drawable.ic_home_widget_space)
|
||||
),
|
||||
contentDescription = "Custom image space icon",
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = modifier
|
||||
.clip(RoundedCornerShape(4.dp))
|
||||
)
|
||||
}
|
||||
|
||||
is SpaceIconView.Gradient -> {
|
||||
val gradient = Brush.radialGradient(
|
||||
colors = listOf(
|
||||
Color(icon.from.toColorInt()),
|
||||
Color(icon.to.toColorInt())
|
||||
)
|
||||
)
|
||||
Box(
|
||||
modifier = modifier
|
||||
.clip(CircleShape)
|
||||
.background(gradient)
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
// Draw nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
private fun GallerySpacesScreenPreview() {
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.domain.base.fold
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.gallery_experience.DownloadGalleryManifest
|
||||
import com.anytypeio.anytype.domain.gallery_experience.ImportExperience
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
|
@ -27,7 +28,6 @@ import com.anytypeio.anytype.gallery_experience.models.GalleryInstallationNaviga
|
|||
import com.anytypeio.anytype.gallery_experience.models.GalleryInstallationSpacesState
|
||||
import com.anytypeio.anytype.gallery_experience.models.GalleryInstallationState
|
||||
import com.anytypeio.anytype.gallery_experience.models.GallerySpaceView
|
||||
import com.anytypeio.anytype.presentation.spaces.SelectSpaceViewModel.Companion.MAX_SPACE_COUNT
|
||||
import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider
|
||||
import com.anytypeio.anytype.presentation.spaces.spaceIcon
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
@ -45,7 +45,8 @@ class GalleryInstallationViewModel(
|
|||
private val urlBuilder: UrlBuilder,
|
||||
private val spaceGradientProvider: SpaceGradientProvider,
|
||||
private val userPermissionProvider: UserPermissionProvider,
|
||||
private val eventProcessChannel: EventProcessImportChannel
|
||||
private val eventProcessChannel: EventProcessImportChannel,
|
||||
private val configStorage: ConfigStorage
|
||||
) : ViewModel() {
|
||||
|
||||
val mainState = MutableStateFlow<GalleryInstallationState>(GalleryInstallationState.Loading)
|
||||
|
@ -83,26 +84,33 @@ class GalleryInstallationViewModel(
|
|||
|
||||
fun onInstallClicked() {
|
||||
viewModelScope.launch {
|
||||
getSpaceViews.async(Unit).fold(
|
||||
onSuccess = { spaces ->
|
||||
Timber.d("GetSpaceViews success, spaceViews: $spaces")
|
||||
val filteredSpaces = filterSpacesByPermissions(spaces)
|
||||
spacesViewState.value = GalleryInstallationSpacesState(
|
||||
spaces = filteredSpaces.map {
|
||||
it.toView(urlBuilder, spaceGradientProvider)
|
||||
},
|
||||
isNewButtonVisible = filteredSpaces.size < MAX_SPACE_COUNT
|
||||
)
|
||||
command.emit(GalleryInstallationNavigation.Spaces)
|
||||
},
|
||||
onFailure = { error ->
|
||||
Timber.e(error, "GetSpaceViews failed")
|
||||
errorState.emit("Get Spaces error: ${error.message}")
|
||||
}
|
||||
)
|
||||
analytics.sendEvent(
|
||||
eventName = EventsDictionary.clickGalleryInstall
|
||||
)
|
||||
val techSpace = configStorage.getOrNull()?.techSpace
|
||||
if (techSpace != null) {
|
||||
getSpaceViews.async(
|
||||
SpaceId(techSpace)
|
||||
).fold(
|
||||
onSuccess = { spaces ->
|
||||
Timber.d("GetSpaceViews success, spaceViews: $spaces")
|
||||
val filteredSpaces = filterSpacesByPermissions(spaces)
|
||||
spacesViewState.value = GalleryInstallationSpacesState(
|
||||
spaces = filteredSpaces.map {
|
||||
it.toView(urlBuilder, spaceGradientProvider)
|
||||
},
|
||||
isNewButtonVisible = true
|
||||
)
|
||||
command.emit(GalleryInstallationNavigation.Spaces)
|
||||
},
|
||||
onFailure = { error ->
|
||||
Timber.e(error, "GetSpaceViews failed")
|
||||
errorState.emit("Get Spaces error: ${error.message}")
|
||||
}
|
||||
)
|
||||
analytics.sendEvent(
|
||||
eventName = EventsDictionary.clickGalleryInstall
|
||||
)
|
||||
} else {
|
||||
Timber.e("Tech space not found during gallery installation")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.gallery_experience.viewmodel
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.gallery_experience.DownloadGalleryManifest
|
||||
import com.anytypeio.anytype.domain.gallery_experience.ImportExperience
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
|
@ -23,7 +24,8 @@ class GalleryInstallationViewModelFactory @Inject constructor(
|
|||
private val urlBuilder: UrlBuilder,
|
||||
private val spaceGradientProvider: SpaceGradientProvider,
|
||||
private val userPermissionProvider: UserPermissionProvider,
|
||||
private val eventProcessChannel: EventProcessImportChannel
|
||||
private val eventProcessChannel: EventProcessImportChannel,
|
||||
private val configStorage: ConfigStorage
|
||||
) : ViewModelProvider.Factory {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
|
@ -37,7 +39,8 @@ class GalleryInstallationViewModelFactory @Inject constructor(
|
|||
spaceGradientProvider = spaceGradientProvider,
|
||||
createSpace = createSpace,
|
||||
userPermissionProvider = userPermissionProvider,
|
||||
eventProcessChannel = eventProcessChannel
|
||||
eventProcessChannel = eventProcessChannel,
|
||||
configStorage = configStorage
|
||||
) as T
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue