From 689e0a90e59cf4483335d79eb6e530758ff0201c Mon Sep 17 00:00:00 2001 From: Thomas Andres Gomez Date: Thu, 30 Jun 2022 16:14:20 +0200 Subject: [PATCH] FR localization. --- .../ui/old/composable/screen/SplashScreen.kt | 242 ------------------ .../biblib/ui/screen/detail/DetailScreen.kt | 7 +- app/src/main/res/values-fr/strings.xml | 53 ++-- app/src/main/res/values/strings.xml | 19 +- 4 files changed, 35 insertions(+), 286 deletions(-) delete mode 100644 app/src/main/java/com/pixelized/biblib/ui/old/composable/screen/SplashScreen.kt diff --git a/app/src/main/java/com/pixelized/biblib/ui/old/composable/screen/SplashScreen.kt b/app/src/main/java/com/pixelized/biblib/ui/old/composable/screen/SplashScreen.kt deleted file mode 100644 index eb544e0..0000000 --- a/app/src/main/java/com/pixelized/biblib/ui/old/composable/screen/SplashScreen.kt +++ /dev/null @@ -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(), - bookViewModel: IBooksViewModel = viewModel(), - userViewModel: IUserViewModel = viewModel(), - navigationViewModel: INavigationViewModel = viewModel(), - 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, 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, 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 - ) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/pixelized/biblib/ui/screen/detail/DetailScreen.kt b/app/src/main/java/com/pixelized/biblib/ui/screen/detail/DetailScreen.kt index 996b73d..d6416b3 100644 --- a/app/src/main/java/com/pixelized/biblib/ui/screen/detail/DetailScreen.kt +++ b/app/src/main/java/com/pixelized/biblib/ui/screen/detail/DetailScreen.kt @@ -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:", diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index c4beb8c..b36b4fb 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -1,51 +1,44 @@ - BibLib - %1$s: %2$s - %3$d - Register - Login - EPUB - MOBI - SEND - Sign in with + Création de compte + Se connecter + Se connecter avec - - - - - + Nouveautés + Livres + Séries + Auteurs + Étiquettes - Oops! - Oops, connection failed! - Oops! library download failed! + Oups! + Oups, la connection a échoué ! + Oups! le téléchargement de la librairy à échoué ! Vous êtes hors ligne. - Entering the Imperial Library of Trantor. - Downloading the Imperial Library of Trantor. + Ouverture de BibLibrary. + Téléchargement de BibLibrary. - Authentication successful + Authentification réussit Library successfully loaded - Welcome to + Authentification à BibLib + Alias du compte + Mot de passe + Mémoriser mes identifiants - Sign in to BibLib - Login - Password - Remember my credential - - Rating - Language - Release + Note + Langue + Publication Genre - Series + Séries + Envoyer cet eBook à : - Not implemented yet. \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b688fc5..d9634dd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,15 +1,15 @@ - BibLib - %1$s: %2$s - %3$d + BibLibrary + %1$s: %2$s - %3$d Register Login - EPUB - MOBI - SEND Sign in with + EPUB + MOBI + SEND @@ -26,16 +26,14 @@ Oops! library download failed! You are offline. - Entering the Imperial Library of Trantor. - Downloading the Imperial Library of Trantor. + Opening the BibLibrary. + Downloading the BibLibrary. Authentication successful Library successfully loaded - Welcome to - Sign in to BibLib Login Password @@ -46,6 +44,7 @@ Release Genre Series + Send this eBook to: - Not implemented yet. + Not implemented yet. \ No newline at end of file