diff --git a/app/src/main/java/com/doyoonkim/knutice/model/DataWrappers.kt b/app/src/main/java/com/doyoonkim/knutice/model/DataWrappers.kt index af3f7c0..a0745f8 100644 --- a/app/src/main/java/com/doyoonkim/knutice/model/DataWrappers.kt +++ b/app/src/main/java/com/doyoonkim/knutice/model/DataWrappers.kt @@ -69,7 +69,8 @@ data class DetailedContentState( val title: String = "", val info: String = "", val fullContent: String = "", - val fullContentUrl: String = "" + val fullContentUrl: String = "", + val imageUrl: String = "" ) data class CustomerServiceReportState( diff --git a/app/src/main/java/com/doyoonkim/knutice/model/Types.kt b/app/src/main/java/com/doyoonkim/knutice/model/Types.kt index c8e221f..14b7e9c 100644 --- a/app/src/main/java/com/doyoonkim/knutice/model/Types.kt +++ b/app/src/main/java/com/doyoonkim/knutice/model/Types.kt @@ -16,5 +16,6 @@ data class NavDestination( data class FullContent( val title: String? = null, val info: String? = null, - val url: String + val url: String, + val imgUrl: String ) \ No newline at end of file diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt index 9e64ee6..136f50d 100644 --- a/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt +++ b/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt @@ -64,8 +64,8 @@ fun CategorizedNotification( titleColor = MaterialTheme.colorScheme.notificationType1, contents = uiState.notificationGeneral, onMoreClicked = { onMoreNoticeRequested(Destination.MORE_GENERAL) } - ) { title, info, url -> - onFullContentRequested(FullContent(title, info, url)) + ) { title, info, url, imgUrl -> + onFullContentRequested(FullContent(title, info, url, imgUrl)) } NotificationPreviewList( @@ -73,8 +73,8 @@ fun CategorizedNotification( titleColor = MaterialTheme.colorScheme.notificationType2, contents = uiState.notificationAcademic, onMoreClicked = { onMoreNoticeRequested(Destination.MORE_ACADEMIC) } - ) { title, info, url -> - onFullContentRequested(FullContent(title, info, url)) + ) { title, info, url, imgUrl -> + onFullContentRequested(FullContent(title, info, url, imgUrl)) } NotificationPreviewList( @@ -82,8 +82,8 @@ fun CategorizedNotification( titleColor = MaterialTheme.colorScheme.notificationType3, contents = uiState.notificationScholarship, onMoreClicked = { onMoreNoticeRequested(Destination.MORE_SCHOLARSHIP) } - ) { title, info, url -> - onFullContentRequested(FullContent(title, info, url)) + ) { title, info, url, imgUrl -> + onFullContentRequested(FullContent(title, info, url, imgUrl)) } NotificationPreviewList( @@ -91,8 +91,8 @@ fun CategorizedNotification( titleColor = MaterialTheme.colorScheme.notificationType4, contents = uiState.notificationEvent, onMoreClicked = { onMoreNoticeRequested(Destination.MORE_EVENT) } - ) { title, info, url -> - onFullContentRequested(FullContent(title, info, url)) + ) { title, info, url, imgUrl -> + onFullContentRequested(FullContent(title, info, url, imgUrl)) } } } @@ -104,7 +104,7 @@ fun NotificationPreviewList( titleColor: Color = Color.Unspecified, contents: List = listOf(), onMoreClicked: () -> Unit = { }, - onNoticeClicked: (String, String, String) -> Unit + onNoticeClicked: (String, String, String, String) -> Unit ) { Column( modifier = Modifier.fillMaxWidth() @@ -140,7 +140,11 @@ fun NotificationPreviewList( notificationTitle = content.title, notificationInfo = "[${content.departName}] ${content.timestamp}" ) { - onNoticeClicked(content.title, content.departName, content.url) + onNoticeClicked( + content.title, + "[${content.departName}] ${content.timestamp}", + content.url, + content.imageUrl) } } } diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt index da43e3f..9f060af 100644 --- a/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt +++ b/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt @@ -25,6 +25,7 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight @@ -35,6 +36,8 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.doyoonkim.knutice.ui.theme.buttonContainer import com.doyoonkim.knutice.ui.theme.containerBackground import com.doyoonkim.knutice.R @@ -93,12 +96,29 @@ fun DetailedNoticeContent( color = MaterialTheme.colorScheme.containerBackground, shape = RoundedCornerShape(10.dp) ) { - Text( - modifier = Modifier.fillMaxWidth().padding(10.dp), - text = state.fullContent, - fontSize = 18.sp, - fontWeight = FontWeight.Medium, - ) + Column( + modifier = Modifier.fillMaxSize(), + verticalArrangement = Arrangement.Top + ) { + if (state.imageUrl != "") { + AsyncImage( + model = ImageRequest.Builder(LocalContext.current) + .data(state.imageUrl) + .crossfade(true) + .build(), + contentDescription = "Loaded Image, which is a part of the notice.", + contentScale = ContentScale.FillWidth, + modifier = Modifier.fillMaxSize().padding(7.dp) + ) + } + Text( + modifier = Modifier.fillMaxWidth().padding(10.dp), + text = state.fullContent, + fontSize = 18.sp, + fontWeight = FontWeight.Medium, + ) + } + } Button( diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/MoreCategorizedNoticiation.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/MoreCategorizedNoticiation.kt index bf56026..c346f3e 100644 --- a/app/src/main/java/com/doyoonkim/knutice/presentation/MoreCategorizedNoticiation.kt +++ b/app/src/main/java/com/doyoonkim/knutice/presentation/MoreCategorizedNoticiation.kt @@ -97,7 +97,8 @@ fun MoreCategorizedNotification( onNoticeSelected(FullContent( notice.title, "[${notice.departName}] ${notice.timestamp}", - notice.url + notice.url, + notice.imageUrl )) } ) { diff --git a/app/src/main/java/com/doyoonkim/knutice/viewModel/DetailedNoticeContentViewModel.kt b/app/src/main/java/com/doyoonkim/knutice/viewModel/DetailedNoticeContentViewModel.kt index 3727931..aa1ee03 100644 --- a/app/src/main/java/com/doyoonkim/knutice/viewModel/DetailedNoticeContentViewModel.kt +++ b/app/src/main/java/com/doyoonkim/knutice/viewModel/DetailedNoticeContentViewModel.kt @@ -45,7 +45,8 @@ class DetailedNoticeContentViewModel @Inject constructor( title = content.title, info = content.info, fullContent = content.fullContent, - fullContentUrl = content.fullContentUrl + fullContentUrl = content.fullContentUrl, + imageUrl = requested.imgUrl ) } },