Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOBILE-188/Features such as recommend,review in profile screen #366

Merged
Merged
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.listenbrainz.android.model

data class SocialUiState(
val error: ResponseError? = null
val error: ResponseError? = null,
val successMsg : String? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.listenbrainz.android.ui.components

import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.expandVertically
import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.listenbrainz.android.model.ResponseError
import org.listenbrainz.android.ui.theme.ListenBrainzTheme


@Composable
fun SuccessBar(
message : String?,
onMessageShown: () -> Unit,
snackbarState : SnackbarHostState
) {
LaunchedEffect(message) {
if (message != null) {
delay(4000)
onMessageShown()
}
}

AnimatedVisibility(
visible = message != null,
enter = expandVertically(),
exit = shrinkVertically()
) {
LaunchedEffect(key1 = message){
if(message != null){
snackbarState.showSnackbar(message)
}
}
}
}

@Preview
@Preview(uiMode = UI_MODE_NIGHT_YES)
@Composable
private fun SuccessBarPreview() {
ListenBrainzTheme {
ErrorBar(error = ResponseError.NETWORK_ERROR) {}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.listenbrainz.android.ui.navigation

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavController
Expand All @@ -20,6 +21,7 @@ fun AppNavigation(
navController: NavController = rememberNavController(),
scrollRequestState: Boolean,
onScrollToTop: (suspend () -> Unit) -> Unit,
snackbarState : SnackbarHostState
) {
NavHost(
navController = navController as NavHostController,
Expand All @@ -38,7 +40,8 @@ fun AppNavigation(
composable(route = AppNavigationItem.Profile.route){
ProfileScreen(
onScrollToTop = onScrollToTop,
scrollRequestState = scrollRequestState
scrollRequestState = scrollRequestState,
snackbarState = snackbarState
)
}
composable(route = AppNavigationItem.Settings.route){
Expand Down
Loading
Loading