Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Commit

Permalink
Merge pull request #78 from AnyGogin31/feature/localization-russian
Browse files Browse the repository at this point in the history
Feature/localization russian
  • Loading branch information
AnyGogin31 authored Dec 14, 2024
2 parents 0c51c6c + 7fdfe33 commit 26a53ad
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 37 deletions.
2 changes: 2 additions & 0 deletions core/desingsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ kotlin {

implementation(projects.core.navigation.navigationApi)

implementation(projects.resources)

implementation(libs.coil.compose)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import neilt.mobile.pixiv.resources.Res
import neilt.mobile.pixiv.resources.search_placeholder
import org.jetbrains.compose.resources.stringResource

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -88,7 +91,7 @@ fun SearchInput(
onSearch = onExecuteSearch,
expanded = isExpanded,
onExpandedChange = {},
placeholder = { Text("Search illustrations...") },
placeholder = { Text(text = stringResource(Res.string.search_placeholder)) },
)
},
expanded = isExpanded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.stringResource

fun LazyListScope.displaySettingsElements(
elements: List<SettingsElement>,
Expand Down Expand Up @@ -107,11 +108,11 @@ private fun SettingItemCard(
)
Column {
Text(
text = item.title,
text = stringResource(item.title),
style = MaterialTheme.typography.titleMedium,
)
Text(
text = item.subtitle,
text = stringResource(item.subtitle),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ package neilt.mobile.pixiv.desingsystem.components.settings

import androidx.compose.runtime.Stable
import androidx.compose.ui.graphics.vector.ImageVector
import org.jetbrains.compose.resources.StringResource

@Stable
sealed interface SettingsElement

data class SettingGroup(val items: List<SettingItem>) : SettingsElement

data class SettingItem(
val title: String,
val subtitle: String,
val title: StringResource,
val subtitle: StringResource,
val icon: ImageVector,
val onClick: () -> Unit = {},
) : SettingsElement
2 changes: 2 additions & 0 deletions features/auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ kotlin {

implementation(projects.features.main)

implementation(projects.resources)

implementation(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import neilt.mobile.pixiv.core.state.whenState
import neilt.mobile.pixiv.desingsystem.components.views.LoadingView
import neilt.mobile.pixiv.resources.Res
import neilt.mobile.pixiv.resources.error_back
import org.jetbrains.compose.resources.stringResource
import org.koin.compose.viewmodel.koinViewModel

@Composable
Expand Down Expand Up @@ -92,7 +95,7 @@ private fun ErrorView(
modifier = Modifier.padding(bottom = 16.dp),
)
Button(onClick = onBack) {
Text("Back")
Text(text = stringResource(Res.string.error_back))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import neilt.mobile.pixiv.resources.Res
import neilt.mobile.pixiv.resources.login_button
import neilt.mobile.pixiv.resources.login_title
import org.jetbrains.compose.resources.stringResource
import org.koin.compose.viewmodel.koinViewModel

@Composable
Expand All @@ -51,7 +55,7 @@ internal fun LoginView(
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = "Pixiv Authorization",
text = stringResource(Res.string.login_title),
style = MaterialTheme.typography.headlineMedium,
textAlign = TextAlign.Center,
modifier = Modifier.padding(bottom = 32.dp),
Expand All @@ -63,7 +67,7 @@ internal fun LoginView(
.fillMaxWidth()
.padding(horizontal = 16.dp),
) {
Text(text = "Login with Pixiv")
Text(text = stringResource(Res.string.login_button))
}
}
}
2 changes: 2 additions & 0 deletions features/illustration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ kotlin {
implementation(projects.core.desingsystem)
implementation(projects.core.state)

implementation(projects.resources)

implementation(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ import neilt.mobile.pixiv.core.state.whenState
import neilt.mobile.pixiv.desingsystem.components.views.ErrorView
import neilt.mobile.pixiv.desingsystem.components.views.LoadingView
import neilt.mobile.pixiv.domain.models.details.illustration.IllustrationDetails
import neilt.mobile.pixiv.resources.Res
import neilt.mobile.pixiv.resources.author_avatar
import neilt.mobile.pixiv.resources.views_and_bookmarks
import org.jetbrains.compose.resources.stringResource
import org.koin.compose.viewmodel.koinViewModel

@Composable
Expand Down Expand Up @@ -134,7 +138,7 @@ private fun IllustrationDetailsContent(
) {
AsyncImage(
model = illustration.user.profileImageUrl,
contentDescription = "Author avatar",
contentDescription = stringResource(Res.string.author_avatar),
modifier = Modifier.clip(CircleShape),
contentScale = ContentScale.Crop,
)
Expand All @@ -146,7 +150,11 @@ private fun IllustrationDetailsContent(
Spacer(modifier = Modifier.height(16.dp))

Text(
text = "Views: ${illustration.views}, Bookmarks: ${illustration.bookmarks}",
text = stringResource(
Res.string.views_and_bookmarks,
illustration.views,
illustration.bookmarks,
),
modifier = Modifier.padding(horizontal = 16.dp),
style = MaterialTheme.typography.bodyMedium,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import neilt.mobile.pixiv.core.state.LoadingState
import neilt.mobile.pixiv.core.state.ViewState
import neilt.mobile.pixiv.domain.repositories.details.illustration.IllustrationRepository
import neilt.mobile.pixiv.features.illustration.provider.ToastProvider
import neilt.mobile.pixiv.resources.Res
import neilt.mobile.pixiv.resources.toast_download_complete
import neilt.mobile.pixiv.resources.toast_downloading
import org.jetbrains.compose.resources.getString

internal class IllustrationDetailsViewModel(
private val illustrationRepository: IllustrationRepository,
Expand Down Expand Up @@ -69,9 +73,9 @@ internal class IllustrationDetailsViewModel(
}

viewModelScope.launch {
toastProvider.showToast("Downloading...")
toastProvider.showToast(getString(Res.string.toast_downloading))
illustrationRepository.downloadIllustration(url, fileName)
toastProvider.showToast("Download complete")
toastProvider.showToast(getString(Res.string.toast_download_complete))
}
}
}
2 changes: 2 additions & 0 deletions features/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ kotlin {

implementation(projects.features.illustration)

implementation(projects.resources)

implementation(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ import neilt.mobile.pixiv.desingsystem.components.views.ErrorView
import neilt.mobile.pixiv.desingsystem.components.views.LoadingView
import neilt.mobile.pixiv.domain.models.details.illustration.Tag
import neilt.mobile.pixiv.domain.models.home.Illustration
import neilt.mobile.pixiv.resources.Res
import neilt.mobile.pixiv.resources.illustration_description
import neilt.mobile.pixiv.resources.no_illustrations_found
import org.jetbrains.compose.resources.stringResource
import org.koin.compose.koinInject
import org.koin.compose.viewmodel.koinViewModel

Expand Down Expand Up @@ -101,7 +105,7 @@ internal fun HomeView(

state.whenStateExtended<List<Illustration>>(
onLoading = { LoadingView() },
onEmpty = { EmptyView(message = "No illustrations found") },
onEmpty = { EmptyView(message = stringResource(Res.string.no_illustrations_found)) },
onError = { ErrorView(message = it) },
onLoaded = {
IllustrationsGallery(
Expand Down Expand Up @@ -151,12 +155,14 @@ private fun IllustrationItem(
illustration: Illustration,
onClick: () -> Unit,
) {
val contentDescription = stringResource(Res.string.illustration_description, illustration.title)

Card(
modifier = modifier
.padding(contentPadding)
.fillMaxWidth()
.aspectRatio(.75f)
.semantics { contentDescription = "Illustration: ${illustration.title}" },
.semantics { this.contentDescription = contentDescription },
onClick = onClick,
) {
Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ import neilt.mobile.pixiv.desingsystem.components.views.ErrorView
import neilt.mobile.pixiv.desingsystem.components.views.LoadingView
import neilt.mobile.pixiv.domain.models.profile.Profile
import neilt.mobile.pixiv.domain.models.profile.UserDetail
import neilt.mobile.pixiv.resources.Res
import neilt.mobile.pixiv.resources.profile_birth_date
import neilt.mobile.pixiv.resources.profile_followers
import neilt.mobile.pixiv.resources.profile_image_description
import neilt.mobile.pixiv.resources.profile_job
import neilt.mobile.pixiv.resources.profile_region
import neilt.mobile.pixiv.resources.twitter_handle
import neilt.mobile.pixiv.resources.website_button
import org.jetbrains.compose.resources.stringResource
import org.koin.compose.viewmodel.koinViewModel

@Composable
Expand Down Expand Up @@ -88,7 +97,7 @@ private fun ProfileContent(userDetail: UserDetail) {
Row(verticalAlignment = Alignment.CenterVertically) {
AsyncImage(
model = user.profileImageUrls,
contentDescription = "Profile Image",
contentDescription = stringResource(Res.string.profile_image_description),
modifier = Modifier
.size(72.dp)
.clip(CircleShape),
Expand Down Expand Up @@ -129,13 +138,13 @@ private fun ProfileContent(userDetail: UserDetail) {
Row {
profile.twitterAccount?.let {
TextButton(onClick = { /* Open Twitter */ }) {
Text("Twitter: @$it")
Text(text = stringResource(Res.string.twitter_handle, it))
}
}
Spacer(modifier = Modifier.width(8.dp))
profile.webpage?.let {
TextButton(onClick = { /* Open webpage */ }) {
Text("Website")
Text(text = stringResource(Res.string.website_button))
}
}
}
Expand All @@ -145,10 +154,22 @@ private fun ProfileContent(userDetail: UserDetail) {
@Composable
fun ProfileInfoSection(profile: Profile) {
Column {
ProfileInfoItem(label = "Birth Date", value = profile.birthDay)
ProfileInfoItem(label = "Region", value = profile.region)
ProfileInfoItem(label = "Job", value = profile.job)
ProfileInfoItem(label = "Followers", value = profile.totalFollowUsers.toString())
ProfileInfoItem(
label = stringResource(Res.string.profile_birth_date),
value = profile.birthDay,
)
ProfileInfoItem(
label = stringResource(Res.string.profile_region),
value = profile.region,
)
ProfileInfoItem(
label = stringResource(Res.string.profile_job),
value = profile.job,
)
ProfileInfoItem(
label = stringResource(Res.string.profile_followers),
value = profile.totalFollowUsers.toString(),
)
}
}

Expand Down
2 changes: 2 additions & 0 deletions features/settings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ kotlin {
implementation(projects.core.navigation.navigationApi)
implementation(projects.core.state)

implementation(projects.resources)

implementation(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
Expand Down
Loading

0 comments on commit 26a53ad

Please sign in to comment.