Skip to content

Commit 39aa274

Browse files
Fix: Fix blank space in LargeProfile without description (#211)
* Make LargeProfile responsive when the description is empty * Update the Profile code when the description is empty * Record the updated screenshot base line * Add back the deprecated annotation to the preview composable * Record the updated screenshot base line
1 parent 7e3f0df commit 39aa274

5 files changed

Lines changed: 43 additions & 8 deletions

File tree

0 Bytes
Loading
0 Bytes
Loading

gravatar-ui/src/main/java/com/gravatar/ui/components/LargeProfile.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,41 @@ private fun LargeProfilePreview() {
189189
)
190190
}
191191

192+
@Preview(showBackground = true)
193+
@Composable
194+
private fun LargeProfileWithoutDescriptionPreview() {
195+
LargeProfile(
196+
defaultProfile(
197+
hash = "1234567890",
198+
displayName = "Dominique Doe",
199+
jobTitle = "Farmer",
200+
company = "Farmers United",
201+
location = "Crac'h, France",
202+
pronouns = "They/Them",
203+
verifiedAccounts = listOf(
204+
VerifiedAccount {
205+
serviceType = "mastodon"
206+
serviceLabel = "Mastodon"
207+
serviceIcon = URI("https://example.com")
208+
url = URI("https://mastodon.social/@ddoe")
209+
},
210+
VerifiedAccount {
211+
serviceType = "tumblr"
212+
serviceLabel = "Tumblr"
213+
serviceIcon = URI("https://example.com")
214+
url = URI("https://ddoe.tumblr.com")
215+
},
216+
VerifiedAccount {
217+
serviceType = "wordpress"
218+
serviceLabel = "WordPress"
219+
serviceIcon = URI("https://example.com")
220+
url = URI("https://ddoe.wordpress.com")
221+
},
222+
),
223+
),
224+
)
225+
}
226+
192227
// TODO Make this preview internal in a future major release
193228
@Deprecated(
194229
"This function is deprecated and will be removed in a future release.",

gravatar-ui/src/main/java/com/gravatar/ui/components/Profile.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ public fun Profile(
9292
)
9393
}
9494
}
95-
if (state.isAboutMeVisible()) {
96-
Spacer(modifier = Modifier.height(16.dp))
97-
AboutMe(state = state, skeletonModifier = Modifier.fillMaxWidth(0.8f))
98-
}
95+
AboutMe(
96+
state = state,
97+
modifier = Modifier.padding(top = 16.dp),
98+
skeletonModifier = Modifier.padding(top = 16.dp).fillMaxWidth(0.8f),
99+
)
99100
Spacer(modifier = Modifier.height(4.dp))
100101
Row(
101102
modifier = Modifier.fillMaxWidth(),
@@ -149,9 +150,6 @@ public fun Profile(state: ComponentState<LegacyProfile>, modifier: Modifier = Mo
149150
Profile(state = state.toApi2ComponentStateProfile(), modifier = modifier)
150151
}
151152

152-
private fun ComponentState<Profile>.isAboutMeVisible(): Boolean =
153-
this is ComponentState.Loaded && loadedValue.description.isNotEmpty() || this is ComponentState.Loading
154-
155153
@Preview
156154
@Composable
157155
private fun ProfilePreview() {

gravatar-ui/src/main/java/com/gravatar/ui/components/atomic/AboutMe.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public fun AboutMe(
8585
}
8686

8787
is ComponentState.Loaded -> {
88-
AboutMe(state.loadedValue, modifier, textStyle, content)
88+
if (state.loadedValue.description.isNotBlank()) {
89+
AboutMe(state.loadedValue, modifier, textStyle, content)
90+
}
8991
}
9092

9193
ComponentState.Empty -> {

0 commit comments

Comments
 (0)