Add a sent success Toast

This commit is contained in:
Thomas Andres Gomez 2022-10-22 16:36:28 +02:00
parent 529431b4ee
commit b3f9da7dc7
4 changed files with 17 additions and 11 deletions

View file

@ -56,7 +56,6 @@ class BookDetailViewModel @Inject constructor(
Log.d("send", data.toString()) Log.d("send", data.toString())
} catch (exception: Exception) { } catch (exception: Exception) {
Log.d("send", exception.message, exception) Log.d("send", exception.message, exception)
_sendStatus.emit(false)
_error.emit(toSendBookUio(bookId = bookId, mail = email, format)) _error.emit(toSendBookUio(bookId = bookId, mail = email, format))
} }
} }

View file

@ -21,7 +21,6 @@ import com.pixelized.biblib.ui.theme.color.ShadowPalette
import com.pixelized.biblib.utils.extention.bibLib import com.pixelized.biblib.utils.extention.bibLib
import com.pixelized.biblib.utils.extention.showToast import com.pixelized.biblib.utils.extention.showToast
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.Serializable
@Stable @Stable
@Immutable @Immutable
@ -124,7 +123,7 @@ fun DetailScreen(
} }
if (detailState.bottomSheetState.isVisible || detailState.bottomSheetState.isAnimationRunning) { if (detailState.bottomSheetState.isVisible || detailState.bottomSheetState.isAnimationRunning) {
LaunchedEffect(key1 = "DetailScreenError") { LaunchedEffect(key1 = "DetailScreenError$bookId") {
detailViewModel.error.collect { detailViewModel.error.collect {
val result = snackBarHost.showSnackbar( val result = snackBarHost.showSnackbar(
message = context.getString(it.message), message = context.getString(it.message),
@ -145,14 +144,17 @@ fun DetailScreen(
} }
} }
LaunchedEffect(key1 = "") { LaunchedEffect(key1 = "DetailScreenSuccess:$bookId") {
detailViewModel.sendStatus.collect { detailViewModel.sendStatus.collect {
snackBarHost.showSnackbar(
message = context.getString(R.string.detail_send_success)
)
} }
} }
LaunchedEffect(key1 = bookId) { LaunchedEffect(key1 = bookId) {
bookId?.let { detailViewModel.getDetail(it) } bookId?.let { detailViewModel.getDetail(it) }
emailSheetState.hide()
} }
BackHandler(emailSheetState.isVisible || emailSheetState.isAnimationRunning) { BackHandler(emailSheetState.isVisible || emailSheetState.isAnimationRunning) {

View file

@ -47,7 +47,10 @@
<string name="detail_release">Publication</string> <string name="detail_release">Publication</string>
<string name="detail_genre">Genre</string> <string name="detail_genre">Genre</string>
<string name="detail_series">Séries</string> <string name="detail_series">Séries</string>
<string name="detail_emails_title">Envoyer cet eBook à :</string>
<string name="detail_option_mail">Envoyer cet eBook à :</string>
<string name="detail_option_format">Format de l\'eBook :</string>
<string name="detail_option_action">Envoyer</string>
<string name="detail_send_confirm_title">Envoyer sur votre Kindle</string> <string name="detail_send_confirm_title">Envoyer sur votre Kindle</string>
<string name="detail_send_confirm_description">Assurez-vous que votre Kindle dispose d\'une connexion Internet, que %1$s est un expéditeur approuvé et que l\'adresse e-mail suivante est correctement configurée sur votre compte Amazon.</string> <string name="detail_send_confirm_description">Assurez-vous que votre Kindle dispose d\'une connexion Internet, que %1$s est un expéditeur approuvé et que l\'adresse e-mail suivante est correctement configurée sur votre compte Amazon.</string>
@ -55,6 +58,7 @@
<string name="detail_send_confirm_help_url">https://www.amazon.fr/gp/help/customer/display.html?nodeId=G7NECT4B4ZWHQ8WV</string> <string name="detail_send_confirm_help_url">https://www.amazon.fr/gp/help/customer/display.html?nodeId=G7NECT4B4ZWHQ8WV</string>
<string name="detail_send_confirm_confirm_action">Oui</string> <string name="detail_send_confirm_confirm_action">Oui</string>
<string name="detail_send_confirm_cancel_action">Annuler</string> <string name="detail_send_confirm_cancel_action">Annuler</string>
<string name="detail_send_success">eBook envoyé avec succès</string>
<string name="search_title">Rechercher sur Biblib</string> <string name="search_title">Rechercher sur Biblib</string>
<string name="search_filter_title">Rechercher</string> <string name="search_filter_title">Rechercher</string>

View file

@ -9,9 +9,9 @@
<string name="action_register">Register</string> <string name="action_register">Register</string>
<string name="action_login">Login</string> <string name="action_login">Login</string>
<string name="action_google_sign_in">Sign in with</string> <string name="action_google_sign_in">Sign in with</string>
<string name="action_epub" translatable="false" >EPUB</string> <string name="action_epub" translatable="false">EPUB</string>
<string name="action_mobi" translatable="false" >MOBI</string> <string name="action_mobi" translatable="false">MOBI</string>
<string name="action_send" translatable="false" >SEND</string> <string name="action_send" translatable="false">SEND</string>
<!-- Menu item --> <!-- Menu item -->
@ -61,8 +61,8 @@
<string name="detail_series">Series</string> <string name="detail_series">Series</string>
<string name="detail_option_mail">Send this eBook to:</string> <string name="detail_option_mail">Send this eBook to:</string>
<string name="detail_option_format">Use this format:</string> <string name="detail_option_format">eBook format:</string>
<string name="detail_option_action">Confirm</string> <string name="detail_option_action">Send</string>
<string name="detail_send_confirm_title">Send to your Kindle</string> <string name="detail_send_confirm_title">Send to your Kindle</string>
<string name="detail_send_confirm_description">Make sure your Kindle has an internet connection, that %1$s is an approved expeditor and that the following email address is correctly set up on your Amazon Account.</string> <string name="detail_send_confirm_description">Make sure your Kindle has an internet connection, that %1$s is an approved expeditor and that the following email address is correctly set up on your Amazon Account.</string>
@ -70,6 +70,7 @@
<string name="detail_send_confirm_help_url">https://www.amazon.co.uk/gp/help/customer/display.html?nodeId=G7NECT4B4ZWHQ8WV</string> <string name="detail_send_confirm_help_url">https://www.amazon.co.uk/gp/help/customer/display.html?nodeId=G7NECT4B4ZWHQ8WV</string>
<string name="detail_send_confirm_confirm_action">Yes</string> <string name="detail_send_confirm_confirm_action">Yes</string>
<string name="detail_send_confirm_cancel_action">Cancel</string> <string name="detail_send_confirm_cancel_action">Cancel</string>
<string name="detail_send_success">eBook sent with success</string>
<string name="search_title">Search on Biblib</string> <string name="search_title">Search on Biblib</string>
<string name="search_filter_title">Search</string> <string name="search_filter_title">Search</string>