Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/#24-bottom-sheet
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/build.gradle.kts
  • Loading branch information
Hyobeen-Park committed Jan 16, 2025
2 parents b95f7b9 + d65e98d commit 2ec82e6
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ dependencies {
implementation(libs.timber)
implementation(libs.lottie)
implementation(libs.advanced.bottom.sheet)

implementation(libs.kotlinx.immutable)
}

ktlint {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.spoony.spoony.presentation.placeDetail.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.spoony.spoony.R
import com.spoony.spoony.core.designsystem.theme.SpoonyAndroidTheme
import com.spoony.spoony.core.util.extension.noRippleClickable
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.immutableListOf

@Composable
fun IconDropdownMenu(
menuItems: ImmutableList<String>,
onMenuItemClick: (String) -> Unit,
modifier: Modifier = Modifier
) {
var expanded by remember { mutableStateOf(false) }

Column(modifier = modifier.wrapContentSize(Alignment.TopEnd)) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.ic_menu_24),
contentDescription = null,
tint = SpoonyAndroidTheme.colors.gray500,
modifier = Modifier
.noRippleClickable {
expanded = !expanded
}
)
Spacer(modifier = Modifier.height(4.dp))
MaterialTheme(
shapes = MaterialTheme.shapes.copy(RoundedCornerShape(10.dp))
) {
DropdownMenu(
expanded = expanded,
modifier = Modifier
.background(
color = SpoonyAndroidTheme.colors.white,
shape = RoundedCornerShape(10.dp)
)
.padding(
vertical = 2.dp,
horizontal = 8.dp
),
onDismissRequest = { expanded = false }
) {
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
menuItems.forEach { menuItem ->
key(menuItem) {
Box(
modifier = Modifier
.widthIn(min = 91.dp)
.noRippleClickable {
onMenuItemClick(menuItem)
expanded = false
}
.padding(6.dp),
contentAlignment = Alignment.CenterStart
) {
Text(
text = menuItem,
style = SpoonyAndroidTheme.typography.caption1b,
color = SpoonyAndroidTheme.colors.gray900
)
}
}
}
}
}
}
}
}

@Preview
@Composable
private fun IconDropdownMenuOnePreview() {
val menuItems = immutableListOf("신고하기")
SpoonyAndroidTheme {
IconDropdownMenu(
menuItems = menuItems,
onMenuItemClick = { selectedItem ->
// selectedItem
}
)
}
}

@Preview
@Composable
private fun IconDropdownMenuTwoPreview() {
val menuItems = immutableListOf("신고하기", "수정하기")
SpoonyAndroidTheme {
IconDropdownMenu(
menuItems = menuItems,
onMenuItemClick = { selectedItem ->
// selectedItem
}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.spoony.spoony.presentation.placeDetail.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.spoony.spoony.core.designsystem.theme.SpoonyAndroidTheme

@Composable
fun UserProfileInfo(
imageUrl: String,
name: String,
location: String,
modifier: Modifier = Modifier
) {
val context = LocalContext.current

Row(
modifier = modifier,
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(14.dp)
) {
AsyncImage(
model = ImageRequest.Builder(context)
.data(imageUrl)
.crossfade(true)
.build(),
modifier = Modifier
.size(48.dp)
.clip(CircleShape)
.background(
color = SpoonyAndroidTheme.colors.gray500,
shape = CircleShape
),
contentScale = ContentScale.Crop,
contentDescription = null
)
Column {
Text(
text = name,
style = SpoonyAndroidTheme.typography.body2b,
color = SpoonyAndroidTheme.colors.black,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = location,
style = SpoonyAndroidTheme.typography.caption1m,
color = SpoonyAndroidTheme.colors.gray400,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
}

@Preview
@Composable
private fun UserProfileInfoPreview() {
SpoonyAndroidTheme {
UserProfileInfo(
imageUrl = "https://gratisography.com/wp-content/uploads/2024/10/gratisography-cool-cat-800x525.jpg",
name = "클레오가트라",
location = "마포구 수저"
)
}
}
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/ic_menu_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"
android:fillColor="#878A93"/>
<path
android:pathData="M12,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"
android:fillColor="#878A93"/>
<path
android:pathData="M12,20m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0"
android:fillColor="#878A93"/>
</vector>

0 comments on commit 2ec82e6

Please sign in to comment.