Update dialog content
This commit is contained in:
parent
af5521f6bb
commit
5a1ff33a46
8 changed files with 83 additions and 91 deletions
|
|
@ -13,8 +13,8 @@ import androidx.compose.runtime.rememberUpdatedState
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import com.pixelized.biblib.ui.old.composable.dialog.ErrorCard
|
||||
import com.pixelized.biblib.ui.old.composable.dialog.LoadingCard
|
||||
import com.pixelized.biblib.ui.composable.dialog.ErrorCard
|
||||
import com.pixelized.biblib.ui.composable.dialog.LoadingCard
|
||||
|
||||
sealed class StateUio<T> {
|
||||
class Progress<T>(val progress: Float? = null) : StateUio<T>()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.pixelized.biblib.ui.old.composable.dialog
|
||||
package com.pixelized.biblib.ui.composable.dialog
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import android.content.res.Configuration.UI_MODE_NIGHT_NO
|
||||
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.MaterialTheme
|
||||
|
|
@ -16,10 +15,10 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
import com.pixelized.biblib.utils.exception.NoBearerException
|
||||
import com.pixelized.biblib.utils.extention.bibLib
|
||||
|
||||
|
||||
@Composable
|
||||
|
|
@ -28,25 +27,29 @@ fun ErrorCard(
|
|||
message: String = stringResource(id = R.string.error_generic),
|
||||
exception: Exception? = null,
|
||||
) {
|
||||
Card(elevation = 8.dp, modifier = modifier) {
|
||||
Card(
|
||||
modifier = modifier,
|
||||
elevation = MaterialTheme.bibLib.dimen.dialog.elevation,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.width(250.dp)
|
||||
.padding(32.dp)
|
||||
.padding(MaterialTheme.bibLib.dimen.medium)
|
||||
.sizeIn(
|
||||
minWidth = MaterialTheme.bibLib.dimen.dialog.minWidth,
|
||||
minHeight = MaterialTheme.bibLib.dimen.dialog.minHeight,
|
||||
),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.width(64.dp)
|
||||
.height(64.dp)
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(bottom = 16.dp),
|
||||
modifier = Modifier.size(MaterialTheme.bibLib.dimen.dialog.iconSize),
|
||||
tint = MaterialTheme.colors.error,
|
||||
imageVector = Icons.Sharp.ErrorOutline,
|
||||
contentDescription = "error"
|
||||
contentDescription = null
|
||||
)
|
||||
if (message.isNotEmpty()) {
|
||||
Text(
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
modifier = Modifier.padding(top = MaterialTheme.bibLib.dimen.medium),
|
||||
style = MaterialTheme.typography.body1,
|
||||
textAlign = TextAlign.Center,
|
||||
text = message
|
||||
|
|
@ -54,9 +57,7 @@ fun ErrorCard(
|
|||
}
|
||||
if (exception != null) {
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.padding(top = 8.dp)
|
||||
.align(Alignment.CenterHorizontally),
|
||||
modifier = Modifier.padding(top = MaterialTheme.bibLib.dimen.small),
|
||||
style = MaterialTheme.typography.caption,
|
||||
textAlign = TextAlign.Center,
|
||||
text = exception.message ?: exception::class.java.simpleName
|
||||
|
|
@ -66,18 +67,11 @@ fun ErrorCard(
|
|||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
@Preview(uiMode = UI_MODE_NIGHT_NO)
|
||||
@Preview(uiMode = UI_MODE_NIGHT_YES)
|
||||
private fun ErrorCardLightPreview() {
|
||||
BibLibTheme(darkTheme = false) {
|
||||
ErrorCard(exception = NoBearerException())
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun ErrorCardDarkPreview() {
|
||||
BibLibTheme(darkTheme = true) {
|
||||
BibLibTheme {
|
||||
ErrorCard(exception = NoBearerException())
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package com.pixelized.biblib.ui.old.composable.dialog
|
||||
package com.pixelized.biblib.ui.composable.dialog
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.CircularProgressIndicator
|
||||
import androidx.compose.material.MaterialTheme
|
||||
|
|
@ -13,7 +12,6 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
import com.pixelized.biblib.utils.extention.bibLib
|
||||
|
|
@ -25,30 +23,34 @@ fun LoadingCard(
|
|||
progress: Float? = null,
|
||||
message: String? = null,
|
||||
) {
|
||||
Card(elevation = 8.dp, modifier = modifier) {
|
||||
Card(
|
||||
modifier = modifier,
|
||||
elevation = MaterialTheme.bibLib.dimen.dialog.elevation,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.width(250.dp)
|
||||
.padding(32.dp)
|
||||
.padding(MaterialTheme.bibLib.dimen.medium)
|
||||
.sizeIn(
|
||||
minWidth = MaterialTheme.bibLib.dimen.dialog.minWidth,
|
||||
minHeight = MaterialTheme.bibLib.dimen.dialog.minHeight,
|
||||
),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
if (progress == null) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(bottom = MaterialTheme.bibLib.dimen.medium)
|
||||
modifier = Modifier.size(MaterialTheme.bibLib.dimen.dialog.iconSize)
|
||||
)
|
||||
} else {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(bottom = MaterialTheme.bibLib.dimen.medium),
|
||||
modifier = Modifier.size(MaterialTheme.bibLib.dimen.dialog.iconSize),
|
||||
progress = progress,
|
||||
)
|
||||
}
|
||||
if (message?.isNotEmpty() == true) {
|
||||
val typography = MaterialTheme.typography
|
||||
Text(
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
modifier = Modifier.padding(top = MaterialTheme.bibLib.dimen.medium),
|
||||
style = typography.body1,
|
||||
textAlign = TextAlign.Center,
|
||||
text = message
|
||||
|
|
@ -58,22 +60,13 @@ fun LoadingCard(
|
|||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun LoadingCardLightPreview() {
|
||||
BibLibTheme(darkTheme = false) {
|
||||
BibLibTheme {
|
||||
LoadingCard(
|
||||
message = stringResource(id = R.string.loading_authentication)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun LoadingCardDarkPreview() {
|
||||
BibLibTheme(darkTheme = true) {
|
||||
LoadingCard(
|
||||
message = stringResource(id = R.string.loading_book)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
package com.pixelized.biblib.ui.old.composable.dialog
|
||||
package com.pixelized.biblib.ui.composable.dialog
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.MaterialTheme
|
||||
|
|
@ -16,9 +14,9 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
import com.pixelized.biblib.utils.extention.bibLib
|
||||
|
||||
|
||||
@Composable
|
||||
|
|
@ -26,28 +24,32 @@ fun SuccessCard(
|
|||
modifier: Modifier = Modifier,
|
||||
message: String? = null,
|
||||
) {
|
||||
Card(elevation = 8.dp, modifier = modifier) {
|
||||
Card(
|
||||
modifier = modifier,
|
||||
elevation = MaterialTheme.bibLib.dimen.dialog.elevation,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.width(250.dp)
|
||||
.padding(32.dp)
|
||||
.padding(MaterialTheme.bibLib.dimen.medium)
|
||||
.sizeIn(
|
||||
minWidth = MaterialTheme.bibLib.dimen.dialog.minWidth,
|
||||
minHeight = MaterialTheme.bibLib.dimen.dialog.minHeight,
|
||||
),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.width(64.dp)
|
||||
.height(64.dp)
|
||||
.align(Alignment.CenterHorizontally),
|
||||
modifier = Modifier.size(MaterialTheme.bibLib.dimen.dialog.iconSize),
|
||||
tint = MaterialTheme.colors.primary,
|
||||
imageVector = Icons.Sharp.Done,
|
||||
contentDescription = "error"
|
||||
contentDescription = null,
|
||||
)
|
||||
val typography = MaterialTheme.typography
|
||||
if (message != null) {
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(top = 16.dp),
|
||||
style = typography.body1,
|
||||
.padding(top = MaterialTheme.bibLib.dimen.medium),
|
||||
style = MaterialTheme.typography.body1,
|
||||
textAlign = TextAlign.Center,
|
||||
text = message
|
||||
)
|
||||
|
|
@ -56,18 +58,11 @@ fun SuccessCard(
|
|||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun SuccessLightPreview() {
|
||||
BibLibTheme(darkTheme = false) {
|
||||
SuccessCard(message = stringResource(id = R.string.success_authentication))
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun SuccessDarkPreview() {
|
||||
BibLibTheme(darkTheme = true) {
|
||||
BibLibTheme {
|
||||
SuccessCard(message = stringResource(id = R.string.success_authentication))
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ class LauncherViewModel @Inject constructor() : ViewModel() {
|
|||
|
||||
init {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
delay(3000)
|
||||
delay(1500)
|
||||
_isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ import androidx.compose.ui.window.DialogProperties
|
|||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.network.client.IBibLibClient.Companion.REGISTER_URL
|
||||
import com.pixelized.biblib.ui.old.composable.dialog.ErrorCard
|
||||
import com.pixelized.biblib.ui.old.composable.dialog.LoadingCard
|
||||
import com.pixelized.biblib.ui.old.composable.dialog.SuccessCard
|
||||
import com.pixelized.biblib.ui.composable.dialog.ErrorCard
|
||||
import com.pixelized.biblib.ui.composable.dialog.LoadingCard
|
||||
import com.pixelized.biblib.ui.composable.dialog.SuccessCard
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
import com.pixelized.biblib.ui.old.viewmodel.authentication.AuthenticationViewModel
|
||||
import com.pixelized.biblib.ui.old.viewmodel.authentication.IAuthenticationViewModel
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
|||
import com.pixelized.biblib.BuildConfig
|
||||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.ui.old.composable.dialog.CrossFadeOverlay
|
||||
import com.pixelized.biblib.ui.old.composable.dialog.ErrorCard
|
||||
import com.pixelized.biblib.ui.composable.dialog.ErrorCard
|
||||
import com.pixelized.biblib.ui.theme.animation.Animation
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
import com.pixelized.biblib.ui.old.viewmodel.authentication.AuthenticationViewModel
|
||||
|
|
|
|||
|
|
@ -14,4 +14,14 @@ data class BibLibDimen(
|
|||
val medium: Dp = 16.dp,
|
||||
val large: Dp = 32.dp,
|
||||
val extraLarge: Dp = 64.dp,
|
||||
val dialog: Dialog = Dialog()
|
||||
) {
|
||||
@Stable
|
||||
@Immutable
|
||||
data class Dialog(
|
||||
val elevation: Dp = 4.dp,
|
||||
val minWidth: Dp = 240.dp,
|
||||
val minHeight: Dp = 120.dp,
|
||||
val iconSize: Dp = 52.dp,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue