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 successMsgId : Int? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.coroutines.delay
import org.listenbrainz.android.ui.theme.ListenBrainzTheme
import org.listenbrainz.android.R

@Composable
fun SuccessBar(
resId : Int?,
onMessageShown: () -> Unit,
snackbarState : SnackbarHostState
) {
val context = LocalContext.current;
LaunchedEffect(resId) {
if (resId != null) {
delay(4000)
onMessageShown()
}
}

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

@Preview
@Preview(uiMode = UI_MODE_NIGHT_YES)
@Composable
private fun SuccessBarPreview() {
ListenBrainzTheme {
SuccessBar(resId = R.string.about_title , onMessageShown = {} , snackbarState = SnackbarHostState())
}
}
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