Skip to content

Commit

Permalink
[UI/#63] AlarmListDropDownMenu 컴포넌트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
DongChyeon committed Feb 2, 2025
1 parent 5792a8c commit c766403
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_edit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M3.333,5C3.333,4.54 3.706,4.167 4.166,4.167H13.333C13.793,4.167 14.166,4.54 14.166,5C14.166,5.461 13.793,5.834 13.333,5.834H4.166C3.706,5.834 3.333,5.461 3.333,5ZM3.333,8.334C3.333,7.873 3.706,7.5 4.166,7.5H10.833C11.293,7.5 11.666,7.873 11.666,8.334C11.666,8.794 11.293,9.167 10.833,9.167H4.166C3.706,9.167 3.333,8.794 3.333,8.334ZM4.166,10.834C3.706,10.834 3.333,11.207 3.333,11.667C3.333,12.127 3.706,12.5 4.166,12.5H7.5C7.96,12.5 8.333,12.127 8.333,11.667C8.333,11.207 7.96,10.834 7.5,10.834H4.166ZM14.457,7.957C14.733,7.665 15.106,7.5 15.496,7.5C15.689,7.5 15.88,7.541 16.058,7.619C16.236,7.697 16.398,7.812 16.534,7.957C16.671,8.102 16.779,8.274 16.853,8.463C16.926,8.652 16.964,8.855 16.964,9.06C16.964,9.265 16.926,9.467 16.853,9.657C16.779,9.846 16.671,10.018 16.534,10.163L11.007,16.032C10.939,16.104 10.854,16.156 10.761,16.181L8.992,16.65C8.811,16.698 8.62,16.642 8.488,16.502C8.357,16.362 8.304,16.159 8.349,15.967L8.791,14.088C8.814,13.989 8.863,13.899 8.931,13.827L14.457,7.957Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>
1 change: 1 addition & 0 deletions feature/home/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ dependencies {
implementation(libs.orbit.compose)
implementation(libs.orbit.viewmodel)
implementation(libs.androidx.material.android)
implementation(libs.androidx.annotation)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.yapp.home.component

import android.util.Log
import androidx.annotation.DrawableRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.yapp.designsystem.theme.OrbitTheme
import com.yapp.ui.extensions.customClickable
import feature.home.R

@Composable
private fun AlarmListDropDownMenu(
modifier: Modifier = Modifier,
expanded: Boolean,
onDismissRequest: () -> Unit,
onClickEdit: () -> Unit,
) {
DropdownMenu(
modifier = modifier.padding(6.dp),
expanded = expanded,
onDismissRequest = onDismissRequest,
containerColor = OrbitTheme.colors.gray_700,
shape = RoundedCornerShape(16.dp),
border = BorderStroke(1.dp, OrbitTheme.colors.gray_600),
) {
AlarmListDropDownMenuItem(
text = stringResource(id = R.string.alarm_list_bottom_sheet_menu_edit),
iconRes = core.designsystem.R.drawable.ic_edit,
) {
onClickEdit()
}
}
}

@Composable
private fun AlarmListDropDownMenuItem(
text: String,
@DrawableRes iconRes: Int,
onClick: () -> Unit,
) {
Row(
modifier = Modifier
.width(120.dp)
.customClickable(
onClick = onClick,
rippleEnabled = false,
)
.padding(
horizontal = 14.dp,
vertical = 8.dp,
),
horizontalArrangement = Arrangement.SpaceBetween,
) {
Text(
text = text,
style = OrbitTheme.typography.body1SemiBold,
color = OrbitTheme.colors.white,
)

Icon(
modifier = Modifier.size(20.dp),
painter = painterResource(id = iconRes),
contentDescription = "Icon",
tint = OrbitTheme.colors.white,
)
}
}

@Preview
@Composable
private fun AlarmListDropDownMenuPreview() {
var expanded by remember { mutableStateOf(false) }

OrbitTheme {
Box(
modifier = Modifier.fillMaxSize(),
) {
Box {
Button(
onClick = { expanded = true },
) {
Text("Show Menu")
}
AlarmListDropDownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
onClickEdit = {
Log.d("AlarmListDropDownMenu", "Edit Clicked")
},
)
}
}
}
}
1 change: 1 addition & 0 deletions feature/home/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
<string name="alarm_add_edit_delete">삭제</string>

<string name="alarm_list_bottom_sheet_title">알람</string>
<string name="alarm_list_bottom_sheet_menu_edit">편집</string>
</resources>
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ androidx-room = "2.6.1"

androidx-lifecycle = "2.8.7"

annotation = "1.9.1"

## Compose
compose-bom = "2024.11.00"
compose-navigation = "2.8.4"
Expand Down Expand Up @@ -100,6 +102,7 @@ androidx-room-runtime = { group = "androidx.room", name = "room-runtime", versio
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "androidx-room" }
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "androidx-room" }
androidx-room-paging = { group = "androidx.room", name = "room-paging", version.ref = "androidx-room" }
androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" }

## Compose Libraries
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
Expand Down

0 comments on commit c766403

Please sign in to comment.