Skip to content

Commit

Permalink
Merge pull request #140 from Automattic/hamorillo/139-unify-profile-c…
Browse files Browse the repository at this point in the history
…omponen-names

`gravatar-ui` - Unify profile component names
  • Loading branch information
hamorillo authored Apr 29, 2024
2 parents 6d53913 + 86ea70b commit d43fab0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ import com.gravatar.types.Email
import com.gravatar.ui.GravatarTheme
import com.gravatar.ui.components.LargeProfile
import com.gravatar.ui.components.LargeProfileSummary
import com.gravatar.ui.components.MiniProfileCard
import com.gravatar.ui.components.ProfileCard
import com.gravatar.ui.components.Profile
import com.gravatar.ui.components.ProfileSummary
import com.gravatar.ui.components.UserProfileState
import com.gravatar.ui.gravatarTheme
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -168,7 +168,7 @@ private enum class ThemeOptions {
}

@Composable
private fun ProfileCards(profileState: UserProfileState?, theme: ThemeOptions, error: String) {
private fun ProfileComponents(profileState: UserProfileState?, theme: ThemeOptions, error: String) {
val configuration = Configuration(LocalConfiguration.current).apply {
uiMode = when (theme) {
ThemeOptions.LIGHT -> Configuration.UI_MODE_NIGHT_NO
Expand All @@ -190,9 +190,9 @@ private fun ProfileCards(profileState: UserProfileState?, theme: ThemeOptions, e
// Show the profile card if we got a result and there is no error and it's not loading
if (error.isEmpty()) {
profileState?.let {
ProfileCard(it, defaultModifier)
Profile(it, defaultModifier)
Spacer(modifier = Modifier.height(16.dp))
MiniProfileCard(it, defaultModifier)
ProfileSummary(it, defaultModifier)
Spacer(modifier = Modifier.height(16.dp))
LargeProfile(it, defaultModifier)
Spacer(modifier = Modifier.height(16.dp))
Expand Down Expand Up @@ -301,7 +301,7 @@ private fun ProfileTab(modifier: Modifier = Modifier, onError: (String?, Throwab
}
}
Spacer(modifier = Modifier.height(16.dp))
ProfileCards(profileState, theme, error)
ProfileComponents(profileState, theme, error)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ import com.gravatar.ui.components.atomic.UserInfo
import com.gravatar.ui.components.atomic.ViewProfileButton

/**
* [ProfileCard] is a composable that displays a user's profile card.
* Given a [UserProfile], it displays a [ProfileCard] using the other atomic components provided within the SDK.
* [Profile] is a composable that displays a user's profile card.
* Given a [UserProfile], it displays a [Profile] using the other atomic components provided within the SDK.
*
* @param profile The user's profile information
* @param modifier Composable modifier
*/
@Composable
public fun ProfileCard(profile: UserProfile, modifier: Modifier = Modifier) {
ProfileCard(state = UserProfileState.Loaded(profile), modifier = modifier)
public fun Profile(profile: UserProfile, modifier: Modifier = Modifier) {
Profile(state = UserProfileState.Loaded(profile), modifier = modifier)
}

/**
* [ProfileCard] is a composable that displays a user's profile card.
* Given a [UserProfileState], it displays a [ProfileCard] or the skeleton if it's in a loading state.
* [Profile] is a composable that displays a user's profile card.
* Given a [UserProfileState], it displays a [Profile] or the skeleton if it's in a loading state.
*
* @param state The user's profile state
* @param modifier Composable modifier
*/
@Composable
public fun ProfileCard(state: UserProfileState, modifier: Modifier = Modifier) {
public fun Profile(state: UserProfileState, modifier: Modifier = Modifier) {
GravatarTheme {
Column(
modifier = modifier,
Expand Down Expand Up @@ -86,8 +86,8 @@ public fun ProfileCard(state: UserProfileState, modifier: Modifier = Modifier) {

@Preview
@Composable
private fun ProfileCardPreview() {
ProfileCard(
private fun ProfilePreview() {
Profile(
UserProfile(
hash = "1234567890",
displayName = "Dominique Doe",
Expand All @@ -111,6 +111,6 @@ private fun ProfileCardPreview() {
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun ProfileCardLoadingPreview() {
LoadingToLoadedStatePreview { ProfileCard(it) }
private fun ProfileLoadingPreview() {
LoadingToLoadedStatePreview { Profile(it) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ import com.gravatar.ui.components.atomic.Location
import com.gravatar.ui.components.atomic.ViewProfileButton

/**
* [MiniProfileCard] is a composable that displays a mini profile card.
* [ProfileSummary] is a composable that displays a mini profile card.
* Given a [UserProfile], it displays a mini profile card using the other atomic components provided within the SDK.
*
* @param profile The user's profile information
* @param modifier Composable modifier
*/
@Composable
public fun MiniProfileCard(profile: UserProfile, modifier: Modifier = Modifier) {
MiniProfileCard(state = UserProfileState.Loaded(profile), modifier = modifier)
public fun ProfileSummary(profile: UserProfile, modifier: Modifier = Modifier) {
ProfileSummary(state = UserProfileState.Loaded(profile), modifier = modifier)
}

/**
* [MiniProfileCard] is a composable that displays a mini profile card.
* [ProfileSummary] is a composable that displays a mini profile card.
* Given a [UserProfile], it displays a mini profile card using the other atomic components provided within the SDK.
*
* @param state The user's profile state
* @param modifier Composable modifier
*/
@Composable
public fun MiniProfileCard(state: UserProfileState, modifier: Modifier = Modifier) {
public fun ProfileSummary(state: UserProfileState, modifier: Modifier = Modifier) {
GravatarTheme {
Row(modifier = modifier) {
Avatar(
Expand Down Expand Up @@ -77,8 +77,8 @@ public fun MiniProfileCard(state: UserProfileState, modifier: Modifier = Modifie

@Preview
@Composable
private fun MiniProfileCardPreview() {
MiniProfileCard(
private fun ProfileSummaryPreview() {
ProfileSummary(
UserProfile(
"4539566a0223b11d28fc47c864336fa27b8fe49b5f85180178c9e3813e910d6a",
displayName = "John Doe",
Expand All @@ -90,6 +90,6 @@ private fun MiniProfileCardPreview() {
@Preview(uiMode = UI_MODE_NIGHT_NO)
@Preview(uiMode = UI_MODE_NIGHT_YES)
@Composable
private fun MiniProfileCardLoadingPreview() {
LoadingToLoadedStatePreview { MiniProfileCard(it) }
private fun ProfileSummaryLoadingPreview() {
LoadingToLoadedStatePreview { ProfileSummary(it) }
}

0 comments on commit d43fab0

Please sign in to comment.