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
|
package com.pixelized.biblib.model
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
data class Language (
|
data class Language (
|
||||||
val id : String,
|
val id : String,
|
||||||
val code: 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.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.ColorFilter
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
|
@ -59,23 +60,24 @@ fun BookThumbnailComposable(
|
||||||
modifier = modifier.clickable {
|
modifier = modifier.clickable {
|
||||||
onClick?.invoke(thumbnail)
|
onClick?.invoke(thumbnail)
|
||||||
},
|
},
|
||||||
|
elevation = 4.dp,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
modifier = Modifier.height(96.dp),
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
contentModifier = Modifier
|
contentModifier = Modifier
|
||||||
.width(60.dp)
|
.width(60.dp)
|
||||||
.height(96.dp),
|
.fillMaxHeight()
|
||||||
|
.clip(RoundedCornerShape(4.dp)),
|
||||||
placeHolder = painterResource(id = R.drawable.ic_launcher_foreground),
|
placeHolder = painterResource(id = R.drawable.ic_launcher_foreground),
|
||||||
|
contentScale = ContentScale.FillBounds,
|
||||||
contentUrl = thumbnail.cover,
|
contentUrl = thumbnail.cover,
|
||||||
colorFilter = if (MaterialTheme.colors.isLight) ColorFilter.tint(Teal200) else null,
|
colorFilter = if (MaterialTheme.colors.isLight) ColorFilter.tint(Teal200) else null,
|
||||||
contentDescription = thumbnail.title
|
contentDescription = thumbnail.title
|
||||||
)
|
)
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(8.dp).weight(1f)
|
||||||
.weight(1f)
|
|
||||||
.padding(8.dp)
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
style = typography.h6,
|
style = typography.h6,
|
||||||
|
|
@ -89,8 +91,7 @@ fun BookThumbnailComposable(
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
softWrap = false,
|
softWrap = false,
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Row(modifier = Modifier.weight(1f), verticalAlignment = Alignment.Bottom) {
|
||||||
Row {
|
|
||||||
Text(
|
Text(
|
||||||
style = typography.caption,
|
style = typography.caption,
|
||||||
text = thumbnail.genre,
|
text = thumbnail.genre,
|
||||||
|
|
@ -98,12 +99,6 @@ fun BookThumbnailComposable(
|
||||||
softWrap = false,
|
softWrap = false,
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(4.dp))
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
Text(
|
|
||||||
style = typography.caption,
|
|
||||||
text = thumbnail.series ?: "",
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
softWrap = false,
|
|
||||||
)
|
|
||||||
Spacer(
|
Spacer(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(0.dp)
|
.width(0.dp)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ fun HomePageComposable(
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
Modifier.scrollable(state = scrollableState, orientation = Orientation.Vertical),
|
Modifier.scrollable(state = scrollableState, orientation = Orientation.Vertical),
|
||||||
contentPadding = PaddingValues(16.dp),
|
contentPadding = PaddingValues(16.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
state = lazyListState,
|
state = lazyListState,
|
||||||
) {
|
) {
|
||||||
items(lazyBooks) { thumbnail ->
|
items(lazyBooks) { thumbnail ->
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ data class BookThumbnailUio(
|
||||||
val title: String,
|
val title: String,
|
||||||
val author: String,
|
val author: String,
|
||||||
val date: String,
|
val date: String,
|
||||||
val series: String?,
|
|
||||||
val isNew: Boolean,
|
val isNew: Boolean,
|
||||||
) {
|
) {
|
||||||
val cover: URL = URL("${THUMBNAIL_URL}/$id.jpg")
|
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.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class BooksViewModel : ViewModel(), IBooksViewModel {
|
class BooksViewModel : ViewModel(), IBooksViewModel {
|
||||||
|
|
@ -26,6 +27,8 @@ class BooksViewModel : ViewModel(), IBooksViewModel {
|
||||||
private val client: IBibLibClient by inject()
|
private val client: IBibLibClient by inject()
|
||||||
private val apiCache: IAPICacheRepository 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)
|
private val _state = MutableLiveData<IBooksViewModel.State>(IBooksViewModel.State.Initial)
|
||||||
override val state: LiveData<IBooksViewModel.State> get() = _state
|
override val state: LiveData<IBooksViewModel.State> get() = _state
|
||||||
|
|
||||||
|
|
@ -104,8 +107,7 @@ class BooksViewModel : ViewModel(), IBooksViewModel {
|
||||||
genre = genre?.joinToString { it.name } ?: "",
|
genre = genre?.joinToString { it.name } ?: "",
|
||||||
title = title,
|
title = title,
|
||||||
author = author.joinToString { it.name },
|
author = author.joinToString { it.name },
|
||||||
date = releaseDate.toString(),
|
date = formatter.format(releaseDate).capitalize(Locale.getDefault()),
|
||||||
series = series?.name,
|
|
||||||
isNew = isNew,
|
isNew = isNew,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -115,8 +117,8 @@ class BooksViewModel : ViewModel(), IBooksViewModel {
|
||||||
author = author.joinToString { it.name },
|
author = author.joinToString { it.name },
|
||||||
genre = genre?.joinToString { it.name } ?: "",
|
genre = genre?.joinToString { it.name } ?: "",
|
||||||
rating = rating?.toFloat() ?: 0.0f,
|
rating = rating?.toFloat() ?: 0.0f,
|
||||||
language = language?.code?.let { Locale(it).language } ?: "",
|
language = language?.displayLanguage?.capitalize(Locale.getDefault()) ?: "",
|
||||||
date = releaseDate.toString(),
|
date = formatter.format(releaseDate).capitalize(Locale.getDefault()),
|
||||||
series = series?.name,
|
series = series?.name,
|
||||||
description = synopsis ?: "",
|
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 {
|
class BookThumbnailMock {
|
||||||
|
|
||||||
val bookThumbnail: BookThumbnailUio by lazy {
|
val bookThumbnail: BookThumbnailUio by lazy {
|
||||||
BookThumbnailUio(
|
BookThumbnailUio(
|
||||||
id = 0,
|
id = 0,
|
||||||
|
|
@ -12,76 +11,7 @@ class BookThumbnailMock {
|
||||||
title = "Foundation",
|
title = "Foundation",
|
||||||
author = "Asimov",
|
author = "Asimov",
|
||||||
date = "1951",
|
date = "1951",
|
||||||
series = "Foundation - 1",
|
|
||||||
isNew = false,
|
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