Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

알림페이지 알림 타입 추가 #231

Merged
merged 4 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -760,3 +760,16 @@ fun CloseCircleIcon(
colorFilter = colorFilter,
)
}

@Composable
fun MegaphoneIcon(
modifier: Modifier = Modifier,
colorFilter: ColorFilter? = null,
) {
Image(
modifier = modifier,
painter = painterResource(id = R.drawable.ic_megaphone),
contentDescription = "",
colorFilter = colorFilter,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class NotificationDto(
@Json(name = "_id") val id: String?,
@Json(name = "title") val title: String = "",
@Json(name = "message") val message: String,
@Json(name = "created_at") val createdAt: String,
@Json(name = "type") val type: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.paging.LoadState
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.items
import com.wafflestudio.snutt2.R
import com.wafflestudio.snutt2.components.compose.*
import com.wafflestudio.snutt2.lib.data.SNUTTStringUtils.getNotificationTime
Expand Down Expand Up @@ -48,48 +49,45 @@ fun NotificationPage() {
when {
refreshState is LoadState.NotLoading && appendState.endOfPaginationReached && notificationList.itemCount < 1 -> NotificationPlaceholder()
refreshState is LoadState.Error -> NotificationError()
else -> LazyColumn {
items(notificationList.itemCount) { index ->
NotificationItem(notificationList[index])
else -> LazyColumn(
modifier = Modifier.padding(horizontal = 9.dp),
) {
items(notificationList) {
it?.let { NotificationItem(it) }
Comment on lines -51 to +56
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

편안~

}
}
}
}
}

@Composable
fun NotificationItem(info: NotificationDto?) {
fun NotificationItem(info: NotificationDto) {
val context = LocalContext.current
Row(modifier = Modifier.padding(horizontal = 15.dp, vertical = 10.dp)) {
when (info?.type) {
Row(modifier = Modifier.padding(horizontal = 15.dp, vertical = 15.dp)) {
when (info.type) {
0 -> WarningIcon(modifier = Modifier.size(20.dp), colorFilter = ColorFilter.tint(SNUTTColors.Black900))
1 -> CalendarIcon(modifier = Modifier.size(20.dp), colorFilter = ColorFilter.tint(SNUTTColors.Black900))
2 -> RefreshIcon(modifier = Modifier.size(20.dp), colorFilter = ColorFilter.tint(SNUTTColors.Black900))
3 -> TrashIcon(modifier = Modifier.size(20.dp), colorFilter = ColorFilter.tint(SNUTTColors.Black900))
4 -> NotificationIcon(modifier = Modifier.size(20.dp), colorFilter = ColorFilter.tint(SNUTTColors.Black900))
5 -> PeopleIcon(modifier = Modifier.size(20.dp), colorFilter = ColorFilter.tint(SNUTTColors.Black900))
else -> MegaphoneIcon(modifier = Modifier.size(20.dp), colorFilter = ColorFilter.tint(SNUTTColors.Black900))
}
Spacer(modifier = Modifier.width(10.dp))
Column {
Row(modifier = Modifier.fillMaxWidth()) {
when (info?.type) {
0 -> stringResource(id = R.string.notifications_noti_announce)
1 -> stringResource(id = R.string.notifications_noti_add)
2 -> stringResource(id = R.string.notifications_noti_update)
3 -> stringResource(id = R.string.notifications_noti_delete)
else -> null
}?.let {
Text(text = it, style = SNUTTTypography.h4)
}
Text(text = info.title, style = SNUTTTypography.h4)
Spacer(modifier = Modifier.weight(1f))
Text(
text = if (info != null) getNotificationTime(context, info) else "-",
text = getNotificationTime(context, info),
style = SNUTTTypography.body2.copy(color = SNUTTColors.Gray600),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
Spacer(modifier = Modifier.height(7.dp))
Text(
text = info?.message ?: "",
text = info.message,
style = SNUTTTypography.body2,
)
}
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/res/drawable/ic_megaphone.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:pathData="M4.25,13.5C4.25,12.533 5.034,11.75 6,11.75H8.75V18.25H6C5.034,18.25 4.25,17.466 4.25,16.5V13.5ZM6,13.25C5.862,13.25 5.75,13.362 5.75,13.5V16.5C5.75,16.638 5.862,16.75 6,16.75H7.25V13.25H6Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M22.75,13.5V16.5C23.054,16.272 23.25,15.909 23.25,15.5V14.5C23.25,14.091 23.054,13.728 22.75,13.5ZM22,17.5V18.25C23.519,18.25 24.75,17.019 24.75,15.5V14.5C24.75,12.981 23.519,11.75 22,11.75V12.5H21.25V17.5H22Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M4.892,16.75H8.177L9.605,17.464L11.729,23.411C12.136,24.551 11.291,25.75 10.081,25.75H9.677C8.961,25.75 8.318,25.314 8.052,24.65L4.892,16.75ZM7.108,18.25L9.445,24.093C9.483,24.188 9.575,24.25 9.677,24.25H10.081C10.254,24.25 10.375,24.079 10.316,23.916L8.395,18.536L7.823,18.25H7.108Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M21.25,8.467C21.25,8.291 21.073,8.17 20.909,8.235L8.75,13.011V16.989L20.909,21.765C21.073,21.83 21.25,21.709 21.25,21.533V8.467ZM20.36,6.838C21.508,6.387 22.75,7.234 22.75,8.467V21.533C22.75,22.766 21.508,23.613 20.36,23.162L7.25,18.011V11.989L20.36,6.838Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
</vector>
Loading