FR localization.
This commit is contained in:
parent
3137c358c7
commit
689e0a90e5
4 changed files with 35 additions and 286 deletions
|
|
@ -1,242 +0,0 @@
|
|||
package com.pixelized.biblib.ui.old.composable.screen
|
||||
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
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.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
|
||||
import com.pixelized.biblib.ui.old.viewmodel.authentication.IAuthenticationViewModel
|
||||
import com.pixelized.biblib.ui.old.viewmodel.book.BooksViewModel
|
||||
import com.pixelized.biblib.ui.old.viewmodel.book.IBooksViewModel
|
||||
import com.pixelized.biblib.ui.old.viewmodel.navigation.INavigationViewModel
|
||||
import com.pixelized.biblib.ui.old.viewmodel.navigation.INavigationViewModel.Navigable.Screen
|
||||
import com.pixelized.biblib.ui.old.viewmodel.navigation.NavigationViewModel
|
||||
import com.pixelized.biblib.ui.old.viewmodel.user.IUserViewModel
|
||||
import com.pixelized.biblib.ui.old.viewmodel.user.UserViewModel
|
||||
import kotlinx.coroutines.delay
|
||||
import java.util.*
|
||||
|
||||
private const val LAUNCH_EFFECT_ENTER = "LAUNCH_EFFECT_ENTER"
|
||||
private const val LAUNCH_EFFECT_EXIT = "LAUNCH_EFFECT_EXIT"
|
||||
private const val LAUNCH_EFFECT_BOOK = "LAUNCH_EFFECT_BOOK"
|
||||
private const val LAUNCH_EFFECT_USER = "LAUNCH_EFFECT_USER"
|
||||
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
fun SplashScreen(
|
||||
authenticationViewModel: IAuthenticationViewModel = viewModel<AuthenticationViewModel>(),
|
||||
bookViewModel: IBooksViewModel = viewModel<BooksViewModel>(),
|
||||
userViewModel: IUserViewModel = viewModel<UserViewModel>(),
|
||||
navigationViewModel: INavigationViewModel = viewModel<NavigationViewModel>(),
|
||||
initiallyVisible: Boolean = false,
|
||||
) {
|
||||
val authenticationState: IAuthenticationViewModel.State? by authenticationViewModel.state.observeAsState()
|
||||
val bookState by bookViewModel.state.observeAsState()
|
||||
val userState by userViewModel.state.observeAsState()
|
||||
|
||||
val contentVisibility = remember { mutableStateOf(false) }
|
||||
|
||||
// Content
|
||||
Content(
|
||||
visible = contentVisibility.value,
|
||||
initiallyVisible = initiallyVisible
|
||||
)
|
||||
|
||||
// Dialog
|
||||
AuthenticationError(
|
||||
state = authenticationState as? IAuthenticationViewModel.State.Error
|
||||
)
|
||||
BookError(
|
||||
state = bookState as? IBooksViewModel.State.Error
|
||||
)
|
||||
|
||||
HandleEnterAnimation(contentVisibility) {
|
||||
authenticationViewModel.autoLogin()
|
||||
}
|
||||
|
||||
(authenticationState as? IAuthenticationViewModel.State.Finished)?.let {
|
||||
if (it.logged) {
|
||||
LaunchedEffect(LAUNCH_EFFECT_BOOK) {
|
||||
bookViewModel.updateBooks()
|
||||
}
|
||||
(bookState as? IBooksViewModel.State.Finished)?.let {
|
||||
LaunchedEffect(LAUNCH_EFFECT_USER) {
|
||||
userViewModel.updateUser()
|
||||
}
|
||||
}
|
||||
(userState as? IUserViewModel.State.Finished)?.let {
|
||||
HandleExitAnimation(contentVisibility) {
|
||||
navigationViewModel.navigateTo(Screen.MainScreen)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
HandleExitAnimation(contentVisibility) {
|
||||
navigationViewModel.navigateTo(Screen.LoginScreen)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
private fun Content(
|
||||
duration: Int = Animation.LONG_DURATION,
|
||||
visible: Boolean = false,
|
||||
initiallyVisible: Boolean = false,
|
||||
) {
|
||||
val typography = MaterialTheme.typography
|
||||
|
||||
Surface {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.width(240.dp)
|
||||
.align(Alignment.Center)
|
||||
) {
|
||||
AnimatedVisibility(
|
||||
visible = visible,
|
||||
initiallyVisible = initiallyVisible,
|
||||
enter = fadeIn(animationSpec = tween(duration))
|
||||
+ slideInVertically(
|
||||
initialOffsetY = { height -> -height },
|
||||
animationSpec = tween(duration)
|
||||
),
|
||||
exit = fadeOut(animationSpec = tween(duration))
|
||||
+ slideOutVertically(
|
||||
targetOffsetY = { height -> -height },
|
||||
animationSpec = tween(duration)
|
||||
),
|
||||
) {
|
||||
Text(
|
||||
style = typography.h4,
|
||||
text = stringResource(id = R.string.splash_welcome)
|
||||
)
|
||||
}
|
||||
AnimatedVisibility(
|
||||
modifier = Modifier.align(Alignment.End),
|
||||
visible = visible,
|
||||
initiallyVisible = initiallyVisible,
|
||||
enter = fadeIn(animationSpec = tween(duration))
|
||||
+ slideInVertically(
|
||||
initialOffsetY = { height -> height },
|
||||
animationSpec = tween(duration)
|
||||
),
|
||||
exit = fadeOut(animationSpec = tween(duration))
|
||||
+ slideOutVertically(
|
||||
targetOffsetY = { height -> height },
|
||||
animationSpec = tween(duration)
|
||||
),
|
||||
) {
|
||||
Text(
|
||||
style = typography.h4,
|
||||
text = stringResource(id = R.string.app_name)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedVisibility(
|
||||
modifier = Modifier.align(Alignment.BottomEnd),
|
||||
visible = visible,
|
||||
initiallyVisible = initiallyVisible,
|
||||
enter = fadeIn(animationSpec = tween(duration)),
|
||||
exit = fadeOut(animationSpec = tween(duration)),
|
||||
) {
|
||||
Text(
|
||||
style = typography.caption,
|
||||
text = stringResource(
|
||||
R.string.app_version,
|
||||
BuildConfig.BUILD_TYPE.toUpperCase(Locale.getDefault()),
|
||||
BuildConfig.VERSION_NAME,
|
||||
BuildConfig.VERSION_CODE
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
private fun AuthenticationError(state: IAuthenticationViewModel.State.Error?) {
|
||||
CrossFadeOverlay(
|
||||
modifier = Modifier.clickable {},
|
||||
visible = state != null
|
||||
) {
|
||||
ErrorCard(
|
||||
message = stringResource(id = R.string.error_generic),
|
||||
exception = state?.exception
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
private fun BookError(state: IBooksViewModel.State.Error?) {
|
||||
CrossFadeOverlay(
|
||||
modifier = Modifier.clickable {},
|
||||
visible = state != null
|
||||
) {
|
||||
ErrorCard(
|
||||
message = stringResource(id = R.string.error_generic),
|
||||
exception = state?.exception
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HandleEnterAnimation(contentVisibility: MutableState<Boolean>, then: suspend () -> Unit) {
|
||||
LaunchedEffect(LAUNCH_EFFECT_ENTER) {
|
||||
delay(Animation.SHORT_DURATION.toLong())
|
||||
contentVisibility.value = true
|
||||
delay(Animation.LONG_DURATION.toLong() + Animation.SHORT_DURATION.toLong())
|
||||
then()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HandleExitAnimation(contentVisibility: MutableState<Boolean>, then: suspend () -> Unit) {
|
||||
LaunchedEffect(LAUNCH_EFFECT_EXIT) {
|
||||
contentVisibility.value = false
|
||||
delay(Animation.LONG_DURATION.toLong())
|
||||
then()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun SplashScreenPreview() {
|
||||
BibLibTheme(darkTheme = true) {
|
||||
val authenticationViewModel = IAuthenticationViewModel.Mock()
|
||||
val bookViewModel = IBooksViewModel.Mock()
|
||||
val navigation = INavigationViewModel.Mock()
|
||||
SplashScreen(
|
||||
authenticationViewModel = authenticationViewModel,
|
||||
bookViewModel = bookViewModel,
|
||||
navigationViewModel = navigation,
|
||||
initiallyVisible = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -286,10 +286,9 @@ private fun DetailScreenSendContent(
|
|||
modifier = modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.padding(
|
||||
vertical = MaterialTheme.bibLib.dimen.dp8,
|
||||
horizontal = MaterialTheme.bibLib.dimen.dp16,
|
||||
),
|
||||
modifier = Modifier
|
||||
.padding(top = MaterialTheme.bibLib.dimen.dp8)
|
||||
.padding(horizontal = MaterialTheme.bibLib.dimen.dp16),
|
||||
color = MaterialTheme.colors.primary,
|
||||
style = MaterialTheme.typography.caption,
|
||||
text = "Send this eBook to:",
|
||||
|
|
|
|||
|
|
@ -1,51 +1,44 @@
|
|||
<resources>
|
||||
<string name="app_name">BibLib</string>
|
||||
<string name="app_version">%1$s: %2$s - %3$d</string>
|
||||
|
||||
<!-- Actions -->
|
||||
|
||||
<string name="action_register">Register</string>
|
||||
<string name="action_login">Login</string>
|
||||
<string name="action_epub">EPUB</string>
|
||||
<string name="action_mobi">MOBI</string>
|
||||
<string name="action_send">SEND</string>
|
||||
<string name="action_google_sign_in">Sign in with</string>
|
||||
<string name="action_register">Création de compte</string>
|
||||
<string name="action_login">Se connecter</string>
|
||||
<string name="action_google_sign_in">Se connecter avec</string>
|
||||
|
||||
<!-- Bottom bar -->
|
||||
|
||||
<!-- <string name="menu_new">Nouveautés</string>-->
|
||||
<!-- <string name="menu_book">Livres</string>-->
|
||||
<!-- <string name="menu_series">Séries</string>-->
|
||||
<!-- <string name="menu_author">Auteurs</string>-->
|
||||
<!-- <string name="menu_tag">Étiquettes</string>-->
|
||||
<string name="menu_new">Nouveautés</string>
|
||||
<string name="menu_book">Livres</string>
|
||||
<string name="menu_series">Séries</string>
|
||||
<string name="menu_author">Auteurs</string>
|
||||
<string name="menu_tag">Étiquettes</string>
|
||||
|
||||
<!-- Dialogs -->
|
||||
|
||||
<string name="error_generic">Oops!</string>
|
||||
<string name="error_authentication">Oops, connection failed!</string>
|
||||
<string name="error_book">Oops! library download failed!</string>
|
||||
<string name="error_generic">Oups!</string>
|
||||
<string name="error_authentication">Oups, la connection a échoué !</string>
|
||||
<string name="error_book">Oups! le téléchargement de la librairy à échoué !</string>
|
||||
<string name="error_offline">Vous êtes hors ligne.</string>
|
||||
|
||||
<string name="loading_authentication">Entering the Imperial Library of Trantor.</string>
|
||||
<string name="loading_book">Downloading the Imperial Library of Trantor.</string>
|
||||
<string name="loading_authentication">Ouverture de BibLibrary.</string>
|
||||
<string name="loading_book">Téléchargement de BibLibrary.</string>
|
||||
|
||||
<string name="success_authentication">Authentication successful</string>
|
||||
<string name="success_authentication">Authentification réussit</string>
|
||||
<string name="success_book">Library successfully loaded</string>
|
||||
|
||||
<!-- Screens & pages -->
|
||||
|
||||
<string name="splash_welcome">Welcome to</string>
|
||||
<string name="authentication_title">Authentification à BibLib</string>
|
||||
<string name="authentication_login">Alias du compte</string>
|
||||
<string name="authentication_password">Mot de passe</string>
|
||||
<string name="authentication_credential_remember">Mémoriser mes identifiants</string>
|
||||
|
||||
<string name="authentication_title">Sign in to BibLib</string>
|
||||
<string name="authentication_login">Login</string>
|
||||
<string name="authentication_password">Password</string>
|
||||
<string name="authentication_credential_remember">Remember my credential</string>
|
||||
|
||||
<string name="detail_rating">Rating</string>
|
||||
<string name="detail_language">Language</string>
|
||||
<string name="detail_release">Release</string>
|
||||
<string name="detail_rating">Note</string>
|
||||
<string name="detail_language">Langue</string>
|
||||
<string name="detail_release">Publication</string>
|
||||
<string name="detail_genre">Genre</string>
|
||||
<string name="detail_series">Series</string>
|
||||
<string name="detail_series">Séries</string>
|
||||
<string name="detail_emails_title">Envoyer cet eBook à :</string>
|
||||
|
||||
<string name="not_implemented_yet">Not implemented yet.</string>
|
||||
</resources>
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
<resources>
|
||||
<string name="app_name">BibLib</string>
|
||||
<string name="app_version">%1$s: %2$s - %3$d</string>
|
||||
<string name="app_name" translatable="false">BibLibrary</string>
|
||||
<string name="app_version" translatable="false">%1$s: %2$s - %3$d</string>
|
||||
|
||||
<!-- Actions -->
|
||||
|
||||
<string name="action_register">Register</string>
|
||||
<string name="action_login">Login</string>
|
||||
<string name="action_epub">EPUB</string>
|
||||
<string name="action_mobi">MOBI</string>
|
||||
<string name="action_send">SEND</string>
|
||||
<string name="action_google_sign_in">Sign in with</string>
|
||||
<string name="action_epub" translatable="false" >EPUB</string>
|
||||
<string name="action_mobi" translatable="false" >MOBI</string>
|
||||
<string name="action_send" translatable="false" >SEND</string>
|
||||
|
||||
<!-- Menu item -->
|
||||
|
||||
|
|
@ -26,16 +26,14 @@
|
|||
<string name="error_book">Oops! library download failed!</string>
|
||||
<string name="error_offline">You are offline.</string>
|
||||
|
||||
<string name="loading_authentication">Entering the Imperial Library of Trantor.</string>
|
||||
<string name="loading_book">Downloading the Imperial Library of Trantor.</string>
|
||||
<string name="loading_authentication">Opening the BibLibrary.</string>
|
||||
<string name="loading_book">Downloading the BibLibrary.</string>
|
||||
|
||||
<string name="success_authentication">Authentication successful</string>
|
||||
<string name="success_book">Library successfully loaded</string>
|
||||
|
||||
<!-- Screens & pages -->
|
||||
|
||||
<string name="splash_welcome">Welcome to</string>
|
||||
|
||||
<string name="authentication_title">Sign in to BibLib</string>
|
||||
<string name="authentication_login">Login</string>
|
||||
<string name="authentication_password">Password</string>
|
||||
|
|
@ -46,6 +44,7 @@
|
|||
<string name="detail_release">Release</string>
|
||||
<string name="detail_genre">Genre</string>
|
||||
<string name="detail_series">Series</string>
|
||||
<string name="detail_emails_title">Send this eBook to:</string>
|
||||
|
||||
<string name="not_implemented_yet">Not implemented yet.</string>
|
||||
<string name="not_implemented_yet" translatable="false">Not implemented yet.</string>
|
||||
</resources>
|
||||
Loading…
Add table
Add a link
Reference in a new issue