refactor(commons): migrate from Moko to Compose Multiplatform Resources
Remove Moko Resources dependency that blocks AGP 9.0 migration. Migrate to built-in Compose Multiplatform Resources which is compatible with the new KMP Android plugin. - Remove moko-resources plugin and libraries from commons module - Move strings.xml from moko-resources/ to composeResources/values/ - Update imports from SharedRes.strings.* to Res.string.* - Add compose.components.resources dependency to desktopApp - Configure resource package as com.vitorpamplona.amethyst.commons.resources Closes #1675 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+10
-6
@@ -34,8 +34,12 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vitorpamplona.amethyst.commons.SharedRes
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
import com.vitorpamplona.amethyst.commons.resources.Res
|
||||
import com.vitorpamplona.amethyst.commons.resources.action_refresh
|
||||
import com.vitorpamplona.amethyst.commons.resources.action_try_again
|
||||
import com.vitorpamplona.amethyst.commons.resources.error_loading_feed
|
||||
import com.vitorpamplona.amethyst.commons.resources.feed_empty
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
|
||||
/**
|
||||
* A centered loading state with a progress indicator and message.
|
||||
@@ -71,7 +75,7 @@ fun EmptyState(
|
||||
onRefresh: (() -> Unit)? = null,
|
||||
refreshLabel: String? = null,
|
||||
) {
|
||||
val actualRefreshLabel = refreshLabel ?: stringResource(SharedRes.strings.action_refresh)
|
||||
val actualRefreshLabel = refreshLabel ?: stringResource(Res.string.action_refresh)
|
||||
|
||||
Column(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
@@ -110,7 +114,7 @@ fun ErrorState(
|
||||
onRetry: (() -> Unit)? = null,
|
||||
retryLabel: String? = null,
|
||||
) {
|
||||
val actualRetryLabel = retryLabel ?: stringResource(SharedRes.strings.action_try_again)
|
||||
val actualRetryLabel = retryLabel ?: stringResource(Res.string.action_try_again)
|
||||
|
||||
Column(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
@@ -140,7 +144,7 @@ fun FeedEmptyState(
|
||||
title: String? = null,
|
||||
onRefresh: (() -> Unit)? = null,
|
||||
) {
|
||||
val actualTitle = title ?: stringResource(SharedRes.strings.feed_empty)
|
||||
val actualTitle = title ?: stringResource(Res.string.feed_empty)
|
||||
|
||||
EmptyState(
|
||||
title = actualTitle,
|
||||
@@ -158,7 +162,7 @@ fun FeedErrorState(
|
||||
modifier: Modifier = Modifier,
|
||||
onRetry: (() -> Unit)? = null,
|
||||
) {
|
||||
val formattedMessage = stringResource(SharedRes.strings.error_loading_feed).format(errorMessage)
|
||||
val formattedMessage = stringResource(Res.string.error_loading_feed).format(errorMessage)
|
||||
|
||||
ErrorState(
|
||||
message = formattedMessage,
|
||||
|
||||
+14
-8
@@ -28,8 +28,14 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vitorpamplona.amethyst.commons.SharedRes
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
import com.vitorpamplona.amethyst.commons.resources.Res
|
||||
import com.vitorpamplona.amethyst.commons.resources.screen_messages_description
|
||||
import com.vitorpamplona.amethyst.commons.resources.screen_messages_title
|
||||
import com.vitorpamplona.amethyst.commons.resources.screen_notifications_description
|
||||
import com.vitorpamplona.amethyst.commons.resources.screen_notifications_title
|
||||
import com.vitorpamplona.amethyst.commons.resources.screen_search_description
|
||||
import com.vitorpamplona.amethyst.commons.resources.screen_search_title
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
|
||||
/**
|
||||
* Generic placeholder screen with title and description.
|
||||
@@ -60,8 +66,8 @@ fun PlaceholderScreen(
|
||||
@Composable
|
||||
fun SearchPlaceholder(modifier: Modifier = Modifier) {
|
||||
PlaceholderScreen(
|
||||
title = stringResource(SharedRes.strings.screen_search_title),
|
||||
description = stringResource(SharedRes.strings.screen_search_description),
|
||||
title = stringResource(Res.string.screen_search_title),
|
||||
description = stringResource(Res.string.screen_search_description),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
@@ -72,8 +78,8 @@ fun SearchPlaceholder(modifier: Modifier = Modifier) {
|
||||
@Composable
|
||||
fun MessagesPlaceholder(modifier: Modifier = Modifier) {
|
||||
PlaceholderScreen(
|
||||
title = stringResource(SharedRes.strings.screen_messages_title),
|
||||
description = stringResource(SharedRes.strings.screen_messages_description),
|
||||
title = stringResource(Res.string.screen_messages_title),
|
||||
description = stringResource(Res.string.screen_messages_description),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
@@ -84,8 +90,8 @@ fun MessagesPlaceholder(modifier: Modifier = Modifier) {
|
||||
@Composable
|
||||
fun NotificationsPlaceholder(modifier: Modifier = Modifier) {
|
||||
PlaceholderScreen(
|
||||
title = stringResource(SharedRes.strings.screen_notifications_title),
|
||||
description = stringResource(SharedRes.strings.screen_notifications_description),
|
||||
title = stringResource(Res.string.screen_notifications_title),
|
||||
description = stringResource(Res.string.screen_notifications_description),
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user