Skip to content

Commit

Permalink
Implement DM icon on ProfileScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarIlic committed Nov 13, 2023
1 parent 15e6238 commit a8bedc6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ private fun NavGraphBuilder.profile(
onPostQuoteClick = { preFillContent -> navController.navigateToNoteEditor(preFillContent) },
onProfileClick = { profileId -> navController.navigateToProfile(profileId = profileId) },
onEditProfileClick = { navController.navigateToEditProfile() },
onMessageClick = { profileId -> navController.navigateToChat(profileId = profileId) },
onHashtagClick = { hashtag -> navController.navigateToExploreFeed(query = hashtag) },
onWalletUnavailable = { navController.navigateToWallet() },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ContentCopy
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
Expand All @@ -58,6 +61,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
Expand Down Expand Up @@ -100,6 +104,7 @@ import net.primal.android.core.compose.icons.primaliconpack.ContextMuteUser
import net.primal.android.core.compose.icons.primaliconpack.ContextShare
import net.primal.android.core.compose.icons.primaliconpack.Key
import net.primal.android.core.compose.icons.primaliconpack.Link
import net.primal.android.core.compose.icons.primaliconpack.Message
import net.primal.android.core.compose.icons.primaliconpack.More
import net.primal.android.core.compose.icons.primaliconpack.UserFeedAdd
import net.primal.android.core.compose.isEmpty
Expand Down Expand Up @@ -129,6 +134,7 @@ fun ProfileScreen(
onPostQuoteClick: (String) -> Unit,
onProfileClick: (String) -> Unit,
onEditProfileClick: () -> Unit,
onMessageClick: (String) -> Unit,
onHashtagClick: (String) -> Unit,
onWalletUnavailable: () -> Unit,
) {
Expand All @@ -144,6 +150,7 @@ fun ProfileScreen(
onPostQuoteClick = onPostQuoteClick,
onProfileClick = onProfileClick,
onEditProfileClick = onEditProfileClick,
onMessageClick = onMessageClick,
onHashtagClick = onHashtagClick,
onWalletUnavailable = onWalletUnavailable,
eventPublisher = { viewModel.setEvent(it) },
Expand All @@ -160,6 +167,7 @@ fun ProfileScreen(
onPostQuoteClick: (String) -> Unit,
onProfileClick: (String) -> Unit,
onEditProfileClick: () -> Unit,
onMessageClick: (String) -> Unit,
onHashtagClick: (String) -> Unit,
onWalletUnavailable: () -> Unit,
eventPublisher: (ProfileContract.UiEvent) -> Unit,
Expand Down Expand Up @@ -326,12 +334,15 @@ fun ProfileScreen(
profileDetails = state.profileDetails,
profileStats = state.profileStats,
onEditProfileClick = onEditProfileClick,
onMessageClick = {
onMessageClick(state.profileId)
},
onFollow = {
eventPublisher(ProfileContract.UiEvent.FollowAction(state.profileId))
},
onUnfollow = {
eventPublisher(ProfileContract.UiEvent.UnfollowAction(state.profileId))
}
},
)

if (state.isProfileMuted) {
Expand Down Expand Up @@ -599,6 +610,7 @@ private fun UserProfileDetails(
profileDetails: ProfileDetailsUi? = null,
profileStats: ProfileStatsUi? = null,
onEditProfileClick: () -> Unit,
onMessageClick: () -> Unit,
onFollow: () -> Unit,
onUnfollow: () -> Unit,
) {
Expand All @@ -616,6 +628,7 @@ private fun UserProfileDetails(
isFollowed = isFollowed,
isActiveUser = isActiveUser,
onEditProfileClick = onEditProfileClick,
onMessageClick = onMessageClick,
onFollow = onFollow,
onUnfollow = onUnfollow,
)
Expand Down Expand Up @@ -752,6 +765,7 @@ private fun ProfileActions(
isFollowed: Boolean,
isActiveUser: Boolean,
onEditProfileClick: () -> Unit,
onMessageClick: () -> Unit,
onFollow: () -> Unit,
onUnfollow: () -> Unit,
) {
Expand All @@ -764,6 +778,11 @@ private fun ProfileActions(
.background(AppTheme.colorScheme.surfaceVariant),
horizontalArrangement = Arrangement.End,
) {
ActionButton(
onClick = onMessageClick,
iconVector = PrimalIcons.Message,
)

if (!isActiveUser) {
when (isFollowed) {
true -> UnfollowButton(onClick = onUnfollow)
Expand All @@ -778,6 +797,30 @@ private fun ProfileActions(
}
}

@Composable
fun ActionButton(
iconVector: ImageVector,
onClick: () -> Unit,
contentDescription: String? = null,
) {
IconButton(
modifier = Modifier
.padding(horizontal = 8.dp)
.size(36.dp),
onClick = onClick,
colors = IconButtonDefaults.iconButtonColors(
containerColor = AppTheme.extraColorScheme.surfaceVariantAlt1,
contentColor = AppTheme.colorScheme.onSurface,
),
) {
Icon(
modifier = Modifier.padding(all = 2.dp),
imageVector = iconVector,
contentDescription = contentDescription,
)
}
}

@Composable
fun FollowButton(
onClick: () -> Unit,
Expand Down Expand Up @@ -988,6 +1031,7 @@ fun PreviewProfileScreen() {
onPostQuoteClick = {},
onProfileClick = {},
onEditProfileClick = {},
onMessageClick = {},
onHashtagClick = {},
onWalletUnavailable = {},
eventPublisher = {},
Expand Down

0 comments on commit a8bedc6

Please sign in to comment.