mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3601 App | Fix | Release 10 stabilization, part 1 (#2353)
This commit is contained in:
parent
b4af608604
commit
61435c2a91
5 changed files with 68 additions and 38 deletions
|
@ -13,6 +13,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
|
@ -26,6 +27,7 @@ import com.anytypeio.anytype.core_ui.views.PreviewTitle2Medium
|
|||
import com.anytypeio.anytype.core_ui.views.Relations2
|
||||
import com.anytypeio.anytype.feature_chats.R
|
||||
import com.anytypeio.anytype.presentation.spaces.SpaceIconView
|
||||
import timber.log.Timber
|
||||
|
||||
@Composable
|
||||
fun HomeScreenToolbar(
|
||||
|
@ -84,16 +86,24 @@ fun HomeScreenToolbar(
|
|||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
|
||||
val context = LocalContext.current
|
||||
val locale = context.resources.configuration.locales[0]
|
||||
val text = if (locale != null && membersCount > 0) {
|
||||
pluralStringResource(
|
||||
id = R.plurals.multiplayer_number_of_space_members,
|
||||
membersCount,
|
||||
membersCount,
|
||||
membersCount
|
||||
)
|
||||
} else {
|
||||
if (locale == null) {
|
||||
Timber.e("Error getting the locale")
|
||||
}
|
||||
stringResource(id = R.string.three_dots_text_placeholder)
|
||||
}
|
||||
|
||||
Text(
|
||||
text = if (membersCount > 0 ) {
|
||||
pluralStringResource(
|
||||
id = R.plurals.multiplayer_number_of_space_members,
|
||||
membersCount,
|
||||
membersCount,
|
||||
membersCount
|
||||
)
|
||||
} else
|
||||
stringResource(id = R.string.three_dots_text_placeholder),
|
||||
text = text,
|
||||
style = Relations2,
|
||||
color = colorResource(R.color.transparent_active),
|
||||
modifier = Modifier
|
||||
|
|
|
@ -11,6 +11,7 @@ import androidx.compose.material.Text
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
|
@ -28,6 +29,7 @@ import com.anytypeio.anytype.core_ui.foundation.noRippleClickable
|
|||
import com.anytypeio.anytype.core_ui.views.PreviewTitle2Medium
|
||||
import com.anytypeio.anytype.core_ui.views.Relations3
|
||||
import com.anytypeio.anytype.presentation.spaces.SpaceIconView
|
||||
import timber.log.Timber
|
||||
|
||||
|
||||
@Composable
|
||||
|
@ -105,15 +107,21 @@ fun SpaceWidgetCard(
|
|||
DEFAULT_SPACE_TYPE -> stringResource(id = R.string.space_type_default_space)
|
||||
PRIVATE_SPACE_TYPE -> stringResource(id = R.string.space_type_private_space)
|
||||
SHARED_SPACE_TYPE -> {
|
||||
if (membersCount > 0 ) {
|
||||
val context = LocalContext.current
|
||||
val locale = context.resources.configuration.locales[0]
|
||||
if (locale != null && membersCount > 0) {
|
||||
pluralStringResource(
|
||||
id = R.plurals.multiplayer_number_of_space_members,
|
||||
membersCount,
|
||||
membersCount,
|
||||
membersCount
|
||||
)
|
||||
} else
|
||||
} else {
|
||||
if (locale == null) {
|
||||
Timber.e("Error getting the locale")
|
||||
}
|
||||
stringResource(id = R.string.three_dots_text_placeholder)
|
||||
}
|
||||
}
|
||||
else -> stringResource(id = R.string.space_type_unknown)
|
||||
}
|
||||
|
|
|
@ -497,11 +497,19 @@ fun Editable.proceedWithSettingMentionSpan(
|
|||
}
|
||||
is Markup.Mark.Mention.ObjectType -> {
|
||||
val (drawableRes, tint) = mark.icon.getDrawableAndTintColor(context)
|
||||
val drawable = ContextCompat.getDrawable(context, drawableRes)?.mutate()
|
||||
if (drawable != null) {
|
||||
DrawableCompat.setTint(drawable, tint)
|
||||
|
||||
val baseDrawable = when {
|
||||
drawableRes == 0 -> null
|
||||
else -> try {
|
||||
context.drawable(drawableRes).mutate().apply {
|
||||
DrawableCompat.setTint(this, tint)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
val finalDrawable = drawable ?: ContextCompat.getDrawable(context, R.drawable.ic_empty_state_type)
|
||||
|
||||
val finalDrawable = baseDrawable ?: context.drawable(R.drawable.ic_empty_state_type)
|
||||
setSpan(
|
||||
MentionSpan(
|
||||
onImageResourceReady = onImageReady,
|
||||
|
|
|
@ -104,9 +104,6 @@ import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUI
|
|||
import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUIAction
|
||||
import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUIAction.TemplateClick
|
||||
import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUIAction.TypeClick
|
||||
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
|
||||
import com.bumptech.glide.integration.compose.GlideImage
|
||||
import com.bumptech.glide.integration.compose.placeholder
|
||||
import kotlin.math.roundToInt
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -575,7 +572,6 @@ private fun ColumnScope.TemplateHeaderBasic(item: TemplateView.Template) {
|
|||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalGlideComposeApi::class)
|
||||
@Composable
|
||||
private fun ColumnScope.TemplateHeaderProfile(item: TemplateView.Template) {
|
||||
if (item.isCoverPresent()) {
|
||||
|
@ -593,7 +589,6 @@ private fun ColumnScope.TemplateHeaderProfile(item: TemplateView.Template) {
|
|||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalGlideComposeApi::class)
|
||||
@Composable
|
||||
private fun ProfileIcon(
|
||||
modifier: Modifier = Modifier,
|
||||
|
@ -608,8 +603,8 @@ private fun ProfileIcon(
|
|||
)
|
||||
) {
|
||||
if (item.image != null) {
|
||||
GlideImage(
|
||||
model = item.image,
|
||||
Image(
|
||||
painter = rememberAsyncImagePainter(model = item.image),
|
||||
contentDescription = "Custom image template's icon",
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
|
@ -638,7 +633,6 @@ private fun ColumnScope.TemplateHeaderTask(item: TemplateView.Template) {
|
|||
TemplateItemTodoTitle(text = item.name)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalGlideComposeApi::class)
|
||||
@Composable
|
||||
private fun TemplateItemIconOrImage(
|
||||
item: TemplateView.Template,
|
||||
|
@ -654,9 +648,12 @@ private fun TemplateItemIconOrImage(
|
|||
shape = RoundedCornerShape(5.dp)
|
||||
)
|
||||
) {
|
||||
GlideImage(
|
||||
model = it,
|
||||
failure = placeholder(painterResource(id = R.drawable.ic_home_widget_space)),
|
||||
Image(
|
||||
painter = rememberAsyncImagePainter(
|
||||
model = it,
|
||||
fallback = painterResource(id = R.drawable.ic_home_widget_space),
|
||||
error = painterResource(id = R.drawable.ic_home_widget_space)
|
||||
),
|
||||
contentDescription = "Custom image template's icon",
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
|
@ -690,7 +687,6 @@ private fun TemplateItemIconOrImage(
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalGlideComposeApi::class)
|
||||
@Composable
|
||||
private fun TemplateItemCoverAndIcon(item: TemplateView.Template) {
|
||||
Box(
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package com.anytypeio.anytype.payments.mapping
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import com.anytypeio.anytype.core_ui.R
|
||||
import com.anytypeio.anytype.payments.models.PeriodDescription
|
||||
import com.anytypeio.anytype.payments.models.PeriodUnit
|
||||
import com.anytypeio.anytype.payments.models.TierPeriod
|
||||
import java.time.Period
|
||||
import timber.log.Timber
|
||||
|
||||
fun String.parsePeriod(): PeriodDescription? {
|
||||
return try {
|
||||
|
@ -24,18 +26,24 @@ fun String.parsePeriod(): PeriodDescription? {
|
|||
|
||||
@Composable
|
||||
fun LocalizedPeriodString(desc: PeriodDescription?): String {
|
||||
desc ?: return ""
|
||||
val quantityStringId = when (desc.unit) {
|
||||
PeriodUnit.YEARS -> R.plurals.period_years
|
||||
PeriodUnit.MONTHS -> R.plurals.period_months
|
||||
PeriodUnit.DAYS -> R.plurals.period_days
|
||||
PeriodUnit.WEEKS -> R.plurals.period_weeks
|
||||
val context = LocalContext.current
|
||||
val localeList = context.resources.configuration.locales
|
||||
if (!localeList.isEmpty && desc != null) {
|
||||
val quantityStringId = when (desc.unit) {
|
||||
PeriodUnit.YEARS -> R.plurals.period_years
|
||||
PeriodUnit.MONTHS -> R.plurals.period_months
|
||||
PeriodUnit.DAYS -> R.plurals.period_days
|
||||
PeriodUnit.WEEKS -> R.plurals.period_weeks
|
||||
}
|
||||
return pluralStringResource(
|
||||
id = quantityStringId,
|
||||
count = desc.amount,
|
||||
formatArgs = arrayOf(desc.amount)
|
||||
)
|
||||
} else {
|
||||
Timber.e("Error getting the locale or desc is null")
|
||||
return ""
|
||||
}
|
||||
return pluralStringResource(
|
||||
id = quantityStringId,
|
||||
count = desc.amount,
|
||||
formatArgs = arrayOf(desc.amount)
|
||||
)
|
||||
}
|
||||
|
||||
fun TierPeriod.toPeriodDescription(): PeriodDescription {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue