Profile Details
Friends Profile Screen
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.rounded.Home
import androidx.compose.material.icons.rounded.LocationOn
import androidx.compose.material.icons.rounded.Star
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.composables.uripainter.rememberUriPainter
@Composable
fun ScreenFriendsProfile() {
@Composable
fun ProfileLabel(header: String, value: String, icon: ImageVector) {
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.padding(vertical = 8.dp)) {
Icon(icon, contentDescription = null)
Text(buildAnnotatedString {
append(header)
append(value)
addStyle(MaterialTheme.typography.bodyLarge.toSpanStyle(), header.length, header.length + value.length)
})
}
}
@Composable
fun FriendCard(onClick: () -> Unit, name: String, image: String) {
Card(
modifier = Modifier.width(132.dp).aspectRatio(3 / 4f)
.border(1.dp, MaterialTheme.colorScheme.onSurface.copy(0.12f), MaterialTheme.shapes.medium),
shape = MaterialTheme.shapes.medium,
onClick = onClick
) {
Box {
Image(
painter = rememberUriPainter(image),
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
contentDescription = "Profile photo",
)
Box(
Modifier.align(Alignment.BottomCenter).fillMaxWidth().height(64.dp).background(
Brush.verticalGradient(
listOf(
Color.Transparent,
Color.Black.copy(alpha = 0.33f),
)
)
)
)
Text(
name,
style = MaterialTheme.typography.bodyLarge,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
color = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.padding(16.dp).align(Alignment.BottomStart)
)
}
}
}
val listState = rememberLazyListState()
val hasScrolled by remember {
derivedStateOf {
listState.firstVisibleItemScrollOffset > 0
}
}
val appBarElevation by animateDpAsState(targetValue = if (hasScrolled) 4.dp else 0.dp)
Scaffold(
topBar = {
TopAppBar(modifier = Modifier.shadow(appBarElevation), navigationIcon = {
IconButton(onClick = { /*TODO*/ }) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Go back")
}
}, title = { }, actions = {
IconButton(onClick = { /*TODO*/ }) {
Icon(Icons.Default.MoreVert, contentDescription = "Menu")
}
})
}
) { padding ->
Box(modifier = Modifier.fillMaxWidth().padding(padding), contentAlignment = Alignment.TopCenter) {
LazyColumn(
modifier = Modifier.widthIn(max = 600.dp),
state = listState,
) {
item {
Column(Modifier.padding(horizontal = 16.dp)) {
Box {
Image(
painter = rememberUriPainter("https://images.unsplash.com/photo-1622763853951-ded5a33cb724"),
modifier = Modifier.fillMaxWidth().aspectRatio(16 / 9f).clip(
RoundedCornerShape(
topStart = MaterialTheme.shapes.medium.topStart,
topEnd = MaterialTheme.shapes.medium.topStart,
bottomStart = CornerSize(0.dp),
bottomEnd = CornerSize(0.dp)
)
),
contentScale = ContentScale.Crop,
contentDescription = "Profile photo",
)
Image(
painter = rememberUriPainter("https://images.unsplash.com/photo-1618189063538-57c32befeb38?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=512&q=80"),
modifier = Modifier.size(120.dp).offset(y = (60).dp).clip(CircleShape).shadow(10.dp)
.background(MaterialTheme.colorScheme.surface)
.border(4.dp, MaterialTheme.colorScheme.surface, CircleShape)
.align(Alignment.BottomCenter),
contentScale = ContentScale.Crop,
contentDescription = "Profile photo",
)
}
Spacer(Modifier.height(60.dp))
Text(
"Clawdia Purrington",
style = MaterialTheme.typography.headlineSmall,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(Modifier.height(12.dp))
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Button(
onClick = { /*TODO*/ },
modifier = Modifier.weight(1f),
shape = MaterialTheme.shapes.extraSmall
) {
Text("Add friend")
}
OutlinedButton(
onClick = { /*TODO*/ },
modifier = Modifier.weight(1f),
shape = MaterialTheme.shapes.extraSmall
) {
Text("Message")
}
}
Spacer(Modifier.height(12.dp))
}
}
item {
Column(Modifier.padding(horizontal = 16.dp)) {
CompositionLocalProvider(
LocalContentColor provides MaterialTheme.colorScheme.onSurface.copy(
0.66f
)
) {
ProfileLabel("Works at ", "Composables", Icons.Rounded.Star)
ProfileLabel("Lives in ", "London", Icons.Rounded.LocationOn)
ProfileLabel("From ", "Indonesia", Icons.Rounded.Home)
}
}
}
item {
HorizontalDivider(modifier = Modifier.padding(vertical = 16.dp))
}
item {
Column {
Column(Modifier.padding(horizontal = 16.dp)) {
Text("Friends", style = MaterialTheme.typography.headlineSmall)
Spacer(Modifier.height(4.dp))
Text("1,230 friends")
Spacer(Modifier.height(12.dp))
}
LazyRow(
horizontalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(horizontal = 16.dp)
) {
item {
FriendCard(
name = "Purrcy Jackson",
image = "https://images.unsplash.com/photo-1618189063538-57c32befeb38?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=512&q=80",
onClick = { /* TODO */ })
}
item {
FriendCard(
name = "Furrball Fawcett",
image = "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=256&q=80",
onClick = { /* TODO */ })
}
item {
FriendCard(
name = "Mittens Mewington",
image = "https://images.unsplash.com/photo-1492370284958-c20b15c692d2",
onClick = { /* TODO */ })
}
item {
FriendCard(
name = "Boris",
image = "https://images.unsplash.com/photo-1618189063538-57c32befeb38?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=512&q=80",
onClick = { /* TODO */ })
}
}
}
}
item {
Spacer(Modifier.height(40.dp))
}
}
}
}
}
Profile Details Screen 1
Profile Details Screen 2
Profile Details Screen 3
Profile Details Screen 4
Profile Details Screen 5
Explore other Jetpack Compose Blocks

Accordions
3 blocks

Autocomplete
4 blocks
Avatars
3 blocks

Bottom sheets
4 blocks

Button Groups
4 blocks

Buttons
7 blocks

Cards
11 blocks

Checkboxes
2 blocks

Chips
4 blocks

Date Pickers
5 blocks

Dialogs
4 blocks

Dropdown Menus
1 blocks

Expandable Lists
2 blocks

Feeds
2 blocks

Form Inputs
0 blocks

Forms
4 blocks

Grids
7 blocks

Horizontal Lists
2 blocks

Lists
6 blocks

Modal Bottom sheets
4 blocks

Music Playback
2 blocks

Radio Groups
2 blocks

Responsive Layouts
5 blocks

Search Bars
2 blocks

Social Share
1 blocks

Tables
8 blocks

Tabs
7 blocks

Text Fields
6 blocks

Toggles
3 blocks

Utilities
4 blocks

Accept Privacy
1 blocks

Chat
1 blocks

Forgot Password
1 blocks

Onboarding
3 blocks

Profile Details
6 blocks

Request Permission
1 blocks

Search
1 blocks

Settings
2 blocks

Sign In
1 blocks

Sign Up
1 blocks

Checkout Forms
2 blocks

Product Details
2 blocks

Product Filters
3 blocks

Product Lists
3 blocks

Product Reviews
5 blocks

Shopping Cart
3 blocks