From d5c378f22d0f50668f1ecbcfc4005aed612e39c4 Mon Sep 17 00:00:00 2001 From: Shreyas Patil Date: Sun, 15 Dec 2024 18:09:37 +0530 Subject: [PATCH 1/5] Fix: Fixed FollowButton colorscheme --- .../android/ui/screens/profile/BaseProfileScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/profile/BaseProfileScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/profile/BaseProfileScreen.kt index d98213695..e49ee5f53 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/profile/BaseProfileScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/profile/BaseProfileScreen.kt @@ -194,8 +194,8 @@ fun BaseProfileScreen( modifier = Modifier, isFollowedState = uiState.listensTabUiState.isFollowing, buttonColor = lb_purple, - followedStateTextColor = new_app_bg_light, - unfollowedStateTextColor = ListenBrainzTheme.colorScheme.text, + followedStateTextColor = ListenBrainzTheme.colorScheme.text, + unfollowedStateTextColor = new_app_bg_light, onClick = { if (uiState.listensTabUiState.isFollowing) { onUnfollowClick(username ?: "") From ec0342728986023db112c17ad234166d53d10905 Mon Sep 17 00:00:00 2001 From: Shreyas Patil Date: Sun, 15 Dec 2024 19:38:09 +0530 Subject: [PATCH 2/5] Fix: Fixed similar artists text color --- .../android/ui/screens/profile/listens/ListensScreen.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt index 9c77045e7..d956a3632 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt @@ -389,7 +389,7 @@ private fun BuildSimilarArtists(similarArtists: List, onArtistClick: (St similarArtists.size > 5 -> { val topSimilarArtists = similarArtists.take(5) val text = buildAnnotatedString { - withStyle(style = SpanStyle(color = white)) { + withStyle(style = SpanStyle(color = lb_purple_night)) { append("You both listen to ") } topSimilarArtists.forEachIndexed { index, artist -> @@ -401,10 +401,13 @@ private fun BuildSimilarArtists(similarArtists: List, onArtistClick: (St } pop() if (index < topSimilarArtists.size - 1) { - append(", ") + withStyle(style = SpanStyle(color = lb_purple_night)) { + append(", ") + } + } } - withStyle(style = SpanStyle(color = white)) { + withStyle(style = SpanStyle(color = lb_purple_night)) { append(" and more.") } } From 157b627ed8a81d563ee93abc3ce951b7d639af50 Mon Sep 17 00:00:00 2001 From: Shreyas Patil Date: Wed, 18 Dec 2024 00:50:21 +0530 Subject: [PATCH 3/5] Fix: Fixed FollowButton state management --- .../android/viewmodel/UserViewModel.kt | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/listenbrainz/android/viewmodel/UserViewModel.kt b/app/src/main/java/org/listenbrainz/android/viewmodel/UserViewModel.kt index af5261b55..20c06dd35 100644 --- a/app/src/main/java/org/listenbrainz/android/viewmodel/UserViewModel.kt +++ b/app/src/main/java/org/listenbrainz/android/viewmodel/UserViewModel.kt @@ -68,27 +68,42 @@ class UserViewModel @Inject constructor( return similarArtists.distinct() } - fun followUser(username: String?){ - if(username.isNullOrEmpty()) return - viewModelScope.launch (ioDispatcher) { - listenStateFlow.value = listenStateFlow.value.copy(isFollowing = true) + fun followUser(username: String?) { + if (username.isNullOrEmpty()) return + updateFollowState(username, true) + + viewModelScope.launch(ioDispatcher) { val result = socialRepository.followUser(username) if (result.status == Resource.Status.FAILED) { - listenStateFlow.value = listenStateFlow.value.copy(isFollowing = false) + updateFollowState(username, false) } } } - fun unfollowUser(username: String?){ - if(username.isNullOrEmpty()) return + fun unfollowUser(username: String?) { + if (username.isNullOrEmpty()) return + updateFollowState(username, false) + viewModelScope.launch(ioDispatcher) { - listenStateFlow.value = listenStateFlow.value.copy(isFollowing = false) val result = socialRepository.unfollowUser(username) if (result.status == Resource.Status.FAILED) { - listenStateFlow.value = listenStateFlow.value.copy(isFollowing = true) + updateFollowState(username, true) } } + } + private fun updateFollowState(username: String, isFollowing: Boolean) { + val updatedFollowers = listenStateFlow.value.followers?.map { (user, status) -> + if (user == username) user to isFollowing else user to status + } + val updatedFollowing = listenStateFlow.value.following?.map { (user, status) -> + if (user == username) user to isFollowing else user to status + } + listenStateFlow.value = listenStateFlow.value.copy( + followers = updatedFollowers, + following = updatedFollowing, + isFollowing = isFollowing + ) } suspend fun getUserDataFromRemote( From 8f4fc3fd56d1607825324fa7eaa7076acadd63f1 Mon Sep 17 00:00:00 2001 From: Shreyas Patil Date: Tue, 24 Dec 2024 17:57:04 +0530 Subject: [PATCH 4/5] Fix: Changed FollowButton in ListensScreen --- .../screens/profile/listens/ListensScreen.kt | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt index d956a3632..ba0e4bed2 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt @@ -68,6 +68,7 @@ import org.listenbrainz.android.model.TrackMetadata import org.listenbrainz.android.model.feed.ReviewEntityType import org.listenbrainz.android.model.user.Artist import org.listenbrainz.android.ui.components.ErrorBar +import org.listenbrainz.android.ui.components.FollowButton import org.listenbrainz.android.ui.components.ListenCardSmallDefault import org.listenbrainz.android.ui.components.SimilarUserCard import org.listenbrainz.android.ui.components.SuccessBar @@ -84,6 +85,7 @@ import org.listenbrainz.android.ui.theme.app_bg_mid import org.listenbrainz.android.ui.theme.compatibilityMeterColor import org.listenbrainz.android.ui.theme.lb_purple import org.listenbrainz.android.ui.theme.lb_purple_night +import org.listenbrainz.android.ui.theme.new_app_bg_light import org.listenbrainz.android.util.Utils.getCoverArtUrl import org.listenbrainz.android.viewmodel.FeedViewModel import org.listenbrainz.android.viewmodel.ListensViewModel @@ -737,29 +739,19 @@ private fun FollowCard(username: String?, onFollowButtonClick: (String?, Boolean goToUserPage(username) } ) - TextButton( - onClick = { - onFollowButtonClick(username, followStatus) - }, colors = ButtonDefaults.buttonColors( - containerColor = when (followStatus) { - true -> ListenBrainzTheme.colorScheme.followingButtonColor - false -> lb_purple - } - ), modifier = Modifier - .width(90.dp) - .height(40.dp), shape = RoundedCornerShape(10.dp), - border = ListenBrainzTheme.colorScheme.followingButtonBorder - ) { - Text( - when (followStatus) { - true -> "Following" - false -> "Follow" - }, color = when(followStatus){ - true -> ListenBrainzTheme.colorScheme.followerCardTextColor - false -> Color.White + Box(){ + FollowButton( + modifier = Modifier, + isFollowedState = followStatus, + buttonColor = lb_purple, + followedStateTextColor = ListenBrainzTheme.colorScheme.text, + unfollowedStateTextColor = new_app_bg_light, + onClick = { + onFollowButtonClick(username, followStatus) } ) } + } } } From 63c60483744c89abae0c5b317d889c4e53026e4a Mon Sep 17 00:00:00 2001 From: Jasjeet Singh <98077881+07jasjeet@users.noreply.github.com> Date: Fri, 27 Dec 2024 16:27:58 +0530 Subject: [PATCH 5/5] Update app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt --- .../android/ui/screens/profile/listens/ListensScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt b/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt index ba0e4bed2..3a9866f80 100644 --- a/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt +++ b/app/src/main/java/org/listenbrainz/android/ui/screens/profile/listens/ListensScreen.kt @@ -744,7 +744,7 @@ private fun FollowCard(username: String?, onFollowButtonClick: (String?, Boolean modifier = Modifier, isFollowedState = followStatus, buttonColor = lb_purple, - followedStateTextColor = ListenBrainzTheme.colorScheme.text, + followedStateTextColor = ListenBrainzTheme.colorScheme.lbSignature, unfollowedStateTextColor = new_app_bg_light, onClick = { onFollowButtonClick(username, followStatus)