LicensesScreen: Highlighted and moved to the top ALL closed source libraries.

This commit is contained in:
acclorite 2024-07-13 15:14:29 +03:00
parent a0a7c3aa60
commit 26cc8a849d
4 changed files with 29 additions and 9 deletions

View file

@ -16,14 +16,17 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.aboutlibraries.ui.compose.m3.util.author import com.mikepenz.aboutlibraries.ui.compose.m3.util.author
import ua.acclorite.book_story.R
/** /**
* License Item. * License Item.
@ -53,18 +56,33 @@ fun LicenseItem(
text = library.name, text = library.name,
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
style = MaterialTheme.typography.titleLarge, style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface, color = if (library.openSource) MaterialTheme.colorScheme.onSurface
else MaterialTheme.colorScheme.error,
maxLines = 2, maxLines = 2,
overflow = TextOverflow.Ellipsis overflow = TextOverflow.Ellipsis
) )
library.artifactVersion?.let {
if (library.artifactVersion != null || !library.openSource) {
Spacer(modifier = Modifier.width(8.dp)) Spacer(modifier = Modifier.width(8.dp))
Text( Column(horizontalAlignment = Alignment.End) {
it, library.artifactVersion?.let {
style = MaterialTheme.typography.bodyMedium, Text(
color = MaterialTheme.colorScheme.onSurfaceVariant, it,
textAlign = TextAlign.Center style = MaterialTheme.typography.bodyMedium,
) color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center
)
}
if (!library.openSource) {
Text(
stringResource(id = R.string.error_closed_source),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center
)
}
}
} }
} }

View file

@ -36,7 +36,7 @@ class LicensesViewModel @Inject constructor(
_state.update { _state.update {
it.copy( it.copy(
licenses = licenses licenses = licenses.sortedBy { library -> library.openSource }
) )
} }
} }

View file

@ -123,6 +123,7 @@
<string name="error_could_not_download_language">Не вдалося завантажити мову.</string> <string name="error_could_not_download_language">Не вдалося завантажити мову.</string>
<string name="error_could_not_download_languages">Не вдалося завантажити мови.</string> <string name="error_could_not_download_languages">Не вдалося завантажити мови.</string>
<string name="error_could_not_reset_cover">Не вдалося скинути обкладинку.</string> <string name="error_could_not_reset_cover">Не вдалося скинути обкладинку.</string>
<string name="error_closed_source">Закритий код</string>
<!-- Is Empty messages --> <!-- Is Empty messages -->
<string name="browse_empty"> <string name="browse_empty">

View file

@ -142,6 +142,7 @@
<string name="error_could_not_download_language">Could not download language.</string> <string name="error_could_not_download_language">Could not download language.</string>
<string name="error_could_not_download_languages">Could not download languages.</string> <string name="error_could_not_download_languages">Could not download languages.</string>
<string name="error_could_not_reset_cover">Could not reset cover image.</string> <string name="error_could_not_reset_cover">Could not reset cover image.</string>
<string name="error_closed_source">Closed source</string>
<!-- Is Empty messages --> <!-- Is Empty messages -->
<string name="browse_empty"> <string name="browse_empty">