Skip to content

Commit

Permalink
Merge pull request #366 from pranavkonidena/MOB188/Social_Features_Pr…
Browse files Browse the repository at this point in the history
…ofile

MOBILE-188/Features such as recommend,review in profile screen
  • Loading branch information
akshaaatt authored Feb 21, 2024
2 parents f65d9b6 + 73ad09b commit dadf9bb
Show file tree
Hide file tree
Showing 11 changed files with 339 additions and 38 deletions.
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

0 comments on commit dadf9bb

Please sign in to comment.