Skip to content
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
28 changes: 13 additions & 15 deletions core/ui/src/main/res/drawable/core_ui_bell.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 홈 탑바 알림함 아이콘 (#2321). 옆의 설정 아이콘(core_ui_settings)과 같은 18dp·선 굵기 1.5dp·반투명 검정 선이다. -->
<!-- 홈 탑바 알림함 아이콘 (#2321). Figma 「bell 1」 그대로다. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="18dp"
android:viewportWidth="24"
android:viewportHeight="24">
android:viewportWidth="18"
android:viewportHeight="18">
<path
android:pathData="M18,8A6,6 0,0 0,6 8C6,15 3,17 3,17H21C21,17 18,15 18,8Z"
android:strokeAlpha="0.5"
android:strokeLineJoin="round"
android:pathData="M13.5 6C13.5 4.80653 13.0259 3.66193 12.182 2.81802C11.3381 1.97411 10.1935 1.5 9 1.5C7.80653 1.5 6.66193 1.97411 5.81802 2.81802C4.97411 3.66193 4.5 4.80653 4.5 6C4.5 11.25 2.25 12.75 2.25 12.75H15.75C15.75 12.75 13.5 11.25 13.5 6Z"
android:strokeColor="#757575"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
<path
android:pathData="M13.73,21A2,2 0,0 1,10.27 21"
android:strokeAlpha="0.5"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="#00000000"/>
<path
android:pathData="M10.2975 15.75C10.1656 15.9773 9.97638 16.166 9.74867 16.2971C9.52096 16.4283 9.26278 16.4973 9 16.4973C8.73722 16.4973 8.47904 16.4283 8.25133 16.2971C8.02362 16.166 7.83436 15.9773 7.7025 15.75"
android:strokeColor="#757575"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#000000"
android:strokeLineCap="round"/>
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="#00000000"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package com.afternote.feature.home.presentation.notification

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.afternote.core.domain.repository.notification.NotificationInboxItem
import com.afternote.core.ui.modifierextention.bottomBorder
import com.afternote.core.ui.theme.AfternoteDesign
import com.afternote.core.ui.topbar.DetailTopBar
import com.afternote.feature.home.presentation.R

/** 알림함 화면의 상태 없는 본문 — Figma 「알람창」 (#2321). ViewModel 은 [NotificationInboxScreen] 이 든다. */
@Composable
internal fun NotificationInboxContent(
uiState: NotificationInboxUiState,
onBack: () -> Unit,
onRetry: () -> Unit,
onItemClick: (NotificationInboxItem) -> Unit,
) {
Scaffold(
topBar = { DetailTopBar(title = stringResource(R.string.home_notification_inbox_title), onBackClick = onBack) },
containerColor = Color.Transparent,
) { padding ->
Box(modifier = Modifier.fillMaxSize().padding(padding)) {
when {
uiState.isLoading -> {
CircularProgressIndicator(
color = AfternoteDesign.colors.gray9,
modifier = Modifier.align(Alignment.Center),
)
}

uiState.loadFailed -> {
Column(
modifier = Modifier.align(Alignment.Center),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = stringResource(R.string.home_notification_inbox_load_failed),
style = AfternoteDesign.typography.bodySmallR,
color = AfternoteDesign.colors.gray7,
)
Spacer(Modifier.height(16.dp))
TextButton(onClick = onRetry) {
Text(
text = stringResource(R.string.home_tab_retry),
style = AfternoteDesign.typography.captionLargeB,
color = AfternoteDesign.colors.gray9,
)
}
}
}

uiState.items.isEmpty() -> {
Text(
text = stringResource(R.string.home_notification_inbox_empty),
style = AfternoteDesign.typography.bodyBase,
color = AfternoteDesign.colors.gray5,
modifier = Modifier.align(Alignment.Center),
)
}

else -> {
LazyColumn(modifier = Modifier.fillMaxSize().padding(horizontal = 20.dp)) {
items(uiState.items, key = NotificationInboxItem::id) { item ->
NotificationInboxRow(item = item, onClick = { onItemClick(item) })
}
}
}
}
}
}
}

/**
* 알림함 한 줄 — Figma 「알람창」 의 alarm_1~4·alarm_check (#2321).
*
* 읽은 알림은 아이콘·제목·본문을 모두 gray5 로 낮춘다(alarm_check). 날짜 줄은 서버 알림함 응답에 시각이
* 없어 아직 그리지 않는다.
*/
@Composable
private fun NotificationInboxRow(
item: NotificationInboxItem,
onClick: () -> Unit,
) {
val readColor = AfternoteDesign.colors.gray5
Row(
modifier =
Modifier
.fillMaxWidth()
.clickable(role = Role.Button, onClick = onClick)
.bottomBorder(color = AfternoteDesign.colors.gray3, width = 1.dp)
.padding(horizontal = 20.dp, vertical = 12.dp),
horizontalArrangement = Arrangement.spacedBy(20.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Image(
painter = painterResource(item.iconRes()),
contentDescription = null,
colorFilter = if (item.isRead) ColorFilter.tint(readColor) else null,
modifier = Modifier.size(24.dp),
)
Column(modifier = Modifier.weight(1f)) {
Text(
text = item.title,
style = AfternoteDesign.typography.captionLargeR,
color = if (item.isRead) readColor else AfternoteDesign.colors.gray9,
)
Text(
text = item.body,
style = AfternoteDesign.typography.captionLargeR,
color = if (item.isRead) readColor else AfternoteDesign.colors.gray6,
)
}
}
}

/** 알림이 가리키는 곳으로 아이콘을 고른다. 기록·질문은 책, 편지·수신인은 편지, 설정을 권하면 연필, 확인이 필요하면 느낌표. */
@DrawableRes
private fun NotificationInboxItem.iconRes(): Int =
when (data["destination"]) {
"TIME_LETTER_LIST", "TIME_LETTER_DETAIL", "TIME_LETTER_COMPOSE",
"RECEIVER_LIST", "RECEIVER_DETAIL", "INVITATION_DETAIL", "INVITATION", "RECEIVER_HOME",
-> R.drawable.home_ic_notification_letter

"AGENT_SETTINGS" -> R.drawable.home_ic_notification_setting

"RETENTION_CONFIRMATION", "AGENT_CONFIRMATION" -> R.drawable.home_ic_notification_alert

else -> R.drawable.home_ic_notification_record
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.afternote.feature.home.presentation.notification

import androidx.compose.foundation.background
import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -14,7 +15,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
Expand All @@ -27,9 +27,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.Lifecycle
Expand Down Expand Up @@ -69,108 +70,6 @@ fun NotificationInboxScreen(
)
}

@Composable
internal fun NotificationInboxContent(
uiState: NotificationInboxUiState,
onBack: () -> Unit,
onRetry: () -> Unit,
onItemClick: (NotificationInboxItem) -> Unit,
) {
Scaffold(
topBar = { DetailTopBar(title = stringResource(R.string.home_notification_inbox_title), onBackClick = onBack) },
containerColor = Color.Transparent,
) { padding ->
Box(modifier = Modifier.fillMaxSize().padding(padding)) {
when {
uiState.isLoading -> {
CircularProgressIndicator(
color = AfternoteDesign.colors.gray9,
modifier = Modifier.align(Alignment.Center),
)
}

uiState.loadFailed -> {
Column(
modifier = Modifier.align(Alignment.Center),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = stringResource(R.string.home_notification_inbox_load_failed),
style = AfternoteDesign.typography.bodySmallR,
color = AfternoteDesign.colors.gray7,
)
Spacer(Modifier.height(16.dp))
TextButton(onClick = onRetry) {
Text(
text = stringResource(R.string.home_tab_retry),
style = AfternoteDesign.typography.captionLargeB,
color = AfternoteDesign.colors.gray9,
)
}
}
}

uiState.items.isEmpty() -> {
Text(
text = stringResource(R.string.home_notification_inbox_empty),
style = AfternoteDesign.typography.bodyBase,
color = AfternoteDesign.colors.gray5,
modifier = Modifier.align(Alignment.Center),
)
}

else -> {
LazyColumn(modifier = Modifier.fillMaxSize()) {
items(uiState.items, key = NotificationInboxItem::id) { item ->
NotificationInboxRow(item = item, onClick = { onItemClick(item) })
}
}
}
}
}
}
}

@Composable
private fun NotificationInboxRow(
item: NotificationInboxItem,
onClick: () -> Unit,
) {
Row(
modifier =
Modifier
.fillMaxWidth()
.clickable(role = Role.Button, onClick = onClick)
.bottomBorder(color = AfternoteDesign.colors.gray3, width = 1.dp)
.padding(horizontal = 20.dp, vertical = 16.dp),
horizontalArrangement = Arrangement.spacedBy(10.dp),
) {
// 읽지 않은 알림 표시. 읽은 줄도 자리를 비워 두어 글 줄이 흔들리지 않게 한다.
Box(
modifier =
Modifier
.padding(top = 7.dp)
.size(6.dp)
.background(if (item.isRead) Color.Transparent else AfternoteDesign.colors.error, CircleShape),
)
Column(modifier = Modifier.weight(1f)) {
Text(
text = item.title,
style = if (item.isRead) AfternoteDesign.typography.bodyBase else AfternoteDesign.typography.bodyLargeB,
color = if (item.isRead) AfternoteDesign.colors.gray6 else AfternoteDesign.colors.gray9,
)
Spacer(Modifier.height(4.dp))
Text(
text = item.body,
style = AfternoteDesign.typography.captionLargeR,
color = AfternoteDesign.colors.gray6,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
}
}
}

/**
* 홈 탑바 알림 점. 화면이 보일 때마다(처음 포함) 다시 센다 — 알림함에서 읽고 돌아오거나 푸시를 받은 뒤
* 홈으로 돌아오면 점이 맞춰진다.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 알림함 — 보관 확인 등 주의 알림 (Figma alert-circle). -->
<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="M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z"
android:strokeColor="#99000000"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="#00000000"/>
<path
android:pathData="M12 8V12"
android:strokeColor="#99000000"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="#00000000"/>
<path
android:pathData="M12 16H12.01"
android:strokeColor="#99000000"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="#00000000"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 알림함 — 편지·수신인 알림 (Figma Mail). -->
<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="M4 4H20C21.1046 4 22 4.89543 22 6V18C22 19.1046 21.1046 20 20 20H4C2.89543 20 2 19.1046 2 18V6C2 4.89543 2.89543 4 4 4Z"
android:strokeColor="#99000000"
android:strokeWidth="1.66667"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="#00000000"/>
<path
android:pathData="M22 7L13.03 12.7C12.7213 12.8934 12.3643 12.996 12 12.996C11.6357 12.996 11.2787 12.8934 10.97 12.7L2 7"
android:strokeColor="#99000000"
android:strokeWidth="1.66667"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="#00000000"/>
</vector>
Loading
Loading