Fix some small graphical issue.
This commit is contained in:
parent
a822d7f008
commit
35edef0d3a
7 changed files with 20 additions and 108 deletions
|
|
@ -1,6 +1,10 @@
|
|||
package com.pixelized.biblib.model
|
||||
|
||||
import java.util.*
|
||||
|
||||
data class Language (
|
||||
val id : String,
|
||||
val code: String,
|
||||
)
|
||||
) {
|
||||
val displayLanguage: String by lazy { Locale(code).displayLanguage }
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
|
|
@ -59,23 +60,24 @@ fun BookThumbnailComposable(
|
|||
modifier = modifier.clickable {
|
||||
onClick?.invoke(thumbnail)
|
||||
},
|
||||
elevation = 4.dp,
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
modifier = Modifier.height(96.dp),
|
||||
) {
|
||||
Image(
|
||||
contentModifier = Modifier
|
||||
.width(60.dp)
|
||||
.height(96.dp),
|
||||
.fillMaxHeight()
|
||||
.clip(RoundedCornerShape(4.dp)),
|
||||
placeHolder = painterResource(id = R.drawable.ic_launcher_foreground),
|
||||
contentScale = ContentScale.FillBounds,
|
||||
contentUrl = thumbnail.cover,
|
||||
colorFilter = if (MaterialTheme.colors.isLight) ColorFilter.tint(Teal200) else null,
|
||||
contentDescription = thumbnail.title
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(8.dp)
|
||||
modifier = Modifier.padding(8.dp).weight(1f)
|
||||
) {
|
||||
Text(
|
||||
style = typography.h6,
|
||||
|
|
@ -89,8 +91,7 @@ fun BookThumbnailComposable(
|
|||
overflow = TextOverflow.Ellipsis,
|
||||
softWrap = false,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Row {
|
||||
Row(modifier = Modifier.weight(1f), verticalAlignment = Alignment.Bottom) {
|
||||
Text(
|
||||
style = typography.caption,
|
||||
text = thumbnail.genre,
|
||||
|
|
@ -98,12 +99,6 @@ fun BookThumbnailComposable(
|
|||
softWrap = false,
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(
|
||||
style = typography.caption,
|
||||
text = thumbnail.series ?: "",
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
softWrap = false,
|
||||
)
|
||||
Spacer(
|
||||
modifier = Modifier
|
||||
.width(0.dp)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ fun HomePageComposable(
|
|||
LazyColumn(
|
||||
Modifier.scrollable(state = scrollableState, orientation = Orientation.Vertical),
|
||||
contentPadding = PaddingValues(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
state = lazyListState,
|
||||
) {
|
||||
items(lazyBooks) { thumbnail ->
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ data class BookThumbnailUio(
|
|||
val title: String,
|
||||
val author: String,
|
||||
val date: String,
|
||||
val series: String?,
|
||||
val isNew: Boolean,
|
||||
) {
|
||||
val cover: URL = URL("${THUMBNAIL_URL}/$id.jpg")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.pixelized.biblib.utils.injection.inject
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class BooksViewModel : ViewModel(), IBooksViewModel {
|
||||
|
|
@ -26,6 +27,8 @@ class BooksViewModel : ViewModel(), IBooksViewModel {
|
|||
private val client: IBibLibClient by inject()
|
||||
private val apiCache: IAPICacheRepository by inject()
|
||||
|
||||
private val formatter = SimpleDateFormat("MMMM yyyy", Locale.getDefault())
|
||||
|
||||
private val _state = MutableLiveData<IBooksViewModel.State>(IBooksViewModel.State.Initial)
|
||||
override val state: LiveData<IBooksViewModel.State> get() = _state
|
||||
|
||||
|
|
@ -104,8 +107,7 @@ class BooksViewModel : ViewModel(), IBooksViewModel {
|
|||
genre = genre?.joinToString { it.name } ?: "",
|
||||
title = title,
|
||||
author = author.joinToString { it.name },
|
||||
date = releaseDate.toString(),
|
||||
series = series?.name,
|
||||
date = formatter.format(releaseDate).capitalize(Locale.getDefault()),
|
||||
isNew = isNew,
|
||||
)
|
||||
|
||||
|
|
@ -115,8 +117,8 @@ class BooksViewModel : ViewModel(), IBooksViewModel {
|
|||
author = author.joinToString { it.name },
|
||||
genre = genre?.joinToString { it.name } ?: "",
|
||||
rating = rating?.toFloat() ?: 0.0f,
|
||||
language = language?.code?.let { Locale(it).language } ?: "",
|
||||
date = releaseDate.toString(),
|
||||
language = language?.displayLanguage?.capitalize(Locale.getDefault()) ?: "",
|
||||
date = formatter.format(releaseDate).capitalize(Locale.getDefault()),
|
||||
series = series?.name,
|
||||
description = synopsis ?: "",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
package com.pixelized.biblib.utils.extention
|
||||
|
||||
import com.pixelized.biblib.ui.data.BookThumbnailUio
|
||||
import com.pixelized.biblib.ui.data.BookUio
|
||||
|
||||
fun BookThumbnailUio.toBookUio(): BookUio {
|
||||
return BookUio(
|
||||
id = id,
|
||||
title = title,
|
||||
author = author,
|
||||
genre = genre,
|
||||
rating = 0f,
|
||||
language = "",
|
||||
date = date,
|
||||
series = series,
|
||||
description = "",
|
||||
)
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import com.pixelized.biblib.ui.data.BookThumbnailUio
|
|||
|
||||
|
||||
class BookThumbnailMock {
|
||||
|
||||
val bookThumbnail: BookThumbnailUio by lazy {
|
||||
BookThumbnailUio(
|
||||
id = 0,
|
||||
|
|
@ -12,76 +11,7 @@ class BookThumbnailMock {
|
|||
title = "Foundation",
|
||||
author = "Asimov",
|
||||
date = "1951",
|
||||
series = "Foundation - 1",
|
||||
isNew = false,
|
||||
)
|
||||
}
|
||||
|
||||
val bookThumbnails: List<BookThumbnailUio> by lazy {
|
||||
listOf(
|
||||
BookThumbnailUio(
|
||||
id = 112,
|
||||
title = "Prélude à Fondation",
|
||||
genre = "Sci-Fi",
|
||||
author = "Asimov",
|
||||
date = "1988",
|
||||
series = "Foundation - 1",
|
||||
isNew = false,
|
||||
),
|
||||
BookThumbnailUio(
|
||||
id = 78,
|
||||
title = "L'Aube de Fondation",
|
||||
genre = "Sci-Fi",
|
||||
author = "Asimov",
|
||||
date = "1993",
|
||||
series = "Foundation - 2",
|
||||
isNew = false,
|
||||
),
|
||||
BookThumbnailUio(
|
||||
id = 90,
|
||||
title = "Fondation",
|
||||
genre = "Sci-Fi",
|
||||
author = "Asimov",
|
||||
date = "1951",
|
||||
series = "Foundation - 3",
|
||||
isNew = false,
|
||||
),
|
||||
BookThumbnailUio(
|
||||
id = 184,
|
||||
title = "Fondation et Empire",
|
||||
genre = "Sci-Fi",
|
||||
author = "Asimov",
|
||||
date = "1952",
|
||||
series = "Foundation - 4",
|
||||
isNew = false,
|
||||
),
|
||||
BookThumbnailUio(
|
||||
id = 185,
|
||||
title = "Seconde Fondation",
|
||||
genre = "Sci-Fi",
|
||||
author = "Asimov",
|
||||
date = "1953",
|
||||
series = "Foundation - 5",
|
||||
isNew = false,
|
||||
),
|
||||
BookThumbnailUio(
|
||||
id = 119,
|
||||
title = "Fondation foudroyée",
|
||||
genre = "Sci-Fi",
|
||||
author = "Asimov",
|
||||
date = "1982",
|
||||
series = "Foundation - 6",
|
||||
isNew = false,
|
||||
),
|
||||
BookThumbnailUio(
|
||||
id = 163,
|
||||
title = "Terre et Fondation",
|
||||
genre = "Sci-Fi",
|
||||
author = "Asimov",
|
||||
date = "1986",
|
||||
series = "Foundation - 7",
|
||||
isNew = false,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue