From dc13961e46c500303e08eb420da4e421ab771474 Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 03:00:45 +0900 Subject: [PATCH 01/14] =?UTF-8?q?#117=20[FEAT]=20:=20statusBarModeOf=20?= =?UTF-8?q?=ED=99=95=EC=9E=A5=ED=95=A8=EC=88=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/teamwable/ui/extensions/FragmentExt.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/ui/src/main/java/com/teamwable/ui/extensions/FragmentExt.kt b/core/ui/src/main/java/com/teamwable/ui/extensions/FragmentExt.kt index 0c370c52..98be7d0b 100644 --- a/core/ui/src/main/java/com/teamwable/ui/extensions/FragmentExt.kt +++ b/core/ui/src/main/java/com/teamwable/ui/extensions/FragmentExt.kt @@ -2,13 +2,13 @@ package com.teamwable.ui.extensions import android.content.Intent import android.net.Uri -import android.provider.Settings import android.view.View import android.widget.Toast import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.core.content.ContextCompat +import androidx.core.view.WindowInsetsControllerCompat import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import com.google.android.material.snackbar.Snackbar @@ -55,3 +55,9 @@ fun Fragment.statusBarColorOf( fun Fragment.openUri(uri: String) { Intent(Intent.ACTION_VIEW, Uri.parse(uri)).also { startActivity(it) } } + +fun Fragment.statusBarModeOf(isLightStatusBar: Boolean = true) { + requireActivity().window.apply { + WindowInsetsControllerCompat(this, decorView).isAppearanceLightStatusBars = isLightStatusBar + } +} From 832132156a43ade4bfa89970c6c9fa2b2f228db3 Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 03:00:53 +0900 Subject: [PATCH 02/14] =?UTF-8?q?#117=20[MOD]=20:=20statusBarModeOf=20?= =?UTF-8?q?=ED=99=95=EC=9E=A5=ED=95=A8=EC=88=98=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/news/src/main/java/com/teamwable/news/NewsFragment.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/feature/news/src/main/java/com/teamwable/news/NewsFragment.kt b/feature/news/src/main/java/com/teamwable/news/NewsFragment.kt index 9bdef28f..ebf60a41 100644 --- a/feature/news/src/main/java/com/teamwable/news/NewsFragment.kt +++ b/feature/news/src/main/java/com/teamwable/news/NewsFragment.kt @@ -11,6 +11,7 @@ import com.teamwable.news.databinding.FragmentNewsBinding import com.teamwable.ui.base.BindingFragment import com.teamwable.ui.extensions.colorOf import com.teamwable.ui.extensions.statusBarColorOf +import com.teamwable.ui.extensions.statusBarModeOf import com.teamwable.ui.extensions.stringOf import dagger.hilt.android.AndroidEntryPoint @@ -18,6 +19,8 @@ import dagger.hilt.android.AndroidEntryPoint class NewsFragment : BindingFragment(FragmentNewsBinding::inflate) { override fun initView() { statusBarColorOf(com.teamwable.ui.R.color.black) + statusBarModeOf(false) + initNewsViewPagerAdapter() initTabClickListener() @@ -74,5 +77,6 @@ class NewsFragment : BindingFragment(FragmentNewsBinding::i override fun onDestroyView() { super.onDestroyView() statusBarColorOf(com.teamwable.ui.R.color.white) + statusBarModeOf() } } From 457f97eef224af4437450e60d2e6015930683f78 Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:43:10 +0900 Subject: [PATCH 03/14] =?UTF-8?q?#117=20[FEAT]=20:=20repository=20impl=20g?= =?UTF-8?q?etNoticeInfo=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repositoryimpl/DefaultNewsRepository.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/data/src/main/java/com/teamwable/data/repositoryimpl/DefaultNewsRepository.kt b/core/data/src/main/java/com/teamwable/data/repositoryimpl/DefaultNewsRepository.kt index 9dd3c0ea..f1fb5ace 100644 --- a/core/data/src/main/java/com/teamwable/data/repositoryimpl/DefaultNewsRepository.kt +++ b/core/data/src/main/java/com/teamwable/data/repositoryimpl/DefaultNewsRepository.kt @@ -7,6 +7,7 @@ import androidx.paging.map import com.teamwable.data.mapper.toModel.toNewsInfoModel import com.teamwable.data.mapper.toModel.toNewsMatchModel import com.teamwable.data.mapper.toModel.toNewsRankModel +import com.teamwable.data.mapper.toModel.toNoticeInfoModel import com.teamwable.data.repository.NewsRepository import com.teamwable.model.news.NewsInfoModel import com.teamwable.model.news.NewsMatchModel @@ -49,4 +50,15 @@ internal class DefaultNewsRepository @Inject constructor( pagingData.map { it.toNewsInfoModel() } } } + + override fun getNoticeInfo(): Flow> { + return Pager(PagingConfig(pageSize = 15, prefetchDistance = 1)) { + GenericPagingSource( + apiCall = { cursor -> newsService.getNoticeInfo(cursor).data }, + getNextCursor = { feeds -> feeds.lastOrNull()?.noticeId }, + ) + }.flow.map { pagingData -> + pagingData.map { it.toNoticeInfoModel() } + } + } } From b0073b5f745a7d40123897a53b8d1798aa031bf1 Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:43:27 +0900 Subject: [PATCH 04/14] =?UTF-8?q?#117=20[MOD]=20:=20=EB=9E=8C=EB=8B=A4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/teamwable/news/notice/NewsNoticeFragment.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeFragment.kt b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeFragment.kt index 4cb97ac7..bfb0b708 100644 --- a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeFragment.kt +++ b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeFragment.kt @@ -1,7 +1,5 @@ package com.teamwable.news.notice -import android.os.Build -import androidx.annotation.RequiresApi import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.navigation.fragment.findNavController import com.teamwable.designsystem.theme.WableTheme @@ -13,18 +11,16 @@ import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class NewsNoticeFragment : BindingFragment(FragmentNewsNoticeBinding::inflate) { - @RequiresApi(Build.VERSION_CODES.O) override fun initView() { initComposeView() } - @RequiresApi(Build.VERSION_CODES.O) private fun initComposeView() { binding.composeNewsNotice.apply { setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setContent { WableTheme { - NewsNoticeRoute(navigateToDetail = { notice -> navigateToDetail(notice) }) + NewsNoticeRoute(navigateToDetail = ::navigateToDetail) } } } From 96de40049cdd43f00cd9731b4e4977e25cfcd53f Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:43:44 +0900 Subject: [PATCH 05/14] =?UTF-8?q?#117=20[MOD]=20:=20=EC=9D=B8=EC=9E=90=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B0=8F=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/teamwable/news/notice/NewsNoticeItem.kt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeItem.kt b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeItem.kt index cbf5e05a..9ce7802a 100644 --- a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeItem.kt +++ b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeItem.kt @@ -1,8 +1,5 @@ package com.teamwable.news.notice -import android.content.Context -import android.os.Build -import androidx.annotation.RequiresApi import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column @@ -17,26 +14,24 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.teamwable.designsystem.theme.WableTheme import com.teamwable.model.news.NewsInfoModel -import com.teamwable.ui.util.CalculateTime +import com.teamwable.news.news.component.WableNewsTimeText -@RequiresApi(Build.VERSION_CODES.O) @Composable fun NewsNoticeItem( - context: Context, data: NewsInfoModel, - navigateToDetail: (NewsInfoModel) -> Unit + onItemClick: (NewsInfoModel) -> Unit ) { Column( modifier = Modifier .fillMaxWidth() .background(WableTheme.colors.white) - .clickable { navigateToDetail(data) } + .clickable { onItemClick(data) } .padding(vertical = 12.dp, horizontal = 20.dp) ) { Row { Text(text = data.newsTitle, style = WableTheme.typography.body01) Spacer(modifier = Modifier.weight(1f)) - Text(text = CalculateTime().getCalculateTime(context, data.time), color = WableTheme.colors.gray500, style = WableTheme.typography.caption04) + WableNewsTimeText(data.time) } Spacer(modifier = Modifier.height(2.dp)) Text(text = data.newsText, color = WableTheme.colors.gray600, maxLines = 2, style = WableTheme.typography.body04) From 03ff86985d27e02b9eace15ca29da118262c12bf Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:44:07 +0900 Subject: [PATCH 06/14] =?UTF-8?q?#117=20[FEAT]=20:=20news=20notice=20pagin?= =?UTF-8?q?g=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teamwable/news/notice/NewsNoticeRoute.kt | 104 +++++++++++++----- 1 file changed, 79 insertions(+), 25 deletions(-) diff --git a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt index b8fb059b..cc731c51 100644 --- a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt +++ b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt @@ -1,54 +1,108 @@ package com.teamwable.news.notice -import android.content.Context -import android.os.Build -import androidx.annotation.RequiresApi import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.flowWithLifecycle +import androidx.paging.LoadState +import androidx.paging.PagingData +import androidx.paging.compose.LazyPagingItems +import androidx.paging.compose.collectAsLazyPagingItems +import androidx.paging.compose.itemContentType +import androidx.paging.compose.itemKey +import com.teamwable.designsystem.component.paging.WablePagingSpinner +import com.teamwable.designsystem.component.screen.LoadingScreen import com.teamwable.designsystem.component.screen.NewsNoticeEmptyScreen import com.teamwable.designsystem.theme.WableTheme +import com.teamwable.designsystem.type.ContentType import com.teamwable.model.news.NewsInfoModel -import com.teamwable.news.NewsViewModel import com.teamwable.news.R +import com.teamwable.news.news.model.NewsInfoSideEffect +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.flowOf -@RequiresApi(Build.VERSION_CODES.O) @Composable internal fun NewsNoticeRoute( - viewModel: NewsViewModel = hiltViewModel(), + viewModel: NewsNoticeViewModel = hiltViewModel(), navigateToDetail: (NewsInfoModel) -> Unit ) { - val context = LocalContext.current + val lifecycleOwner = LocalLifecycleOwner.current + val newsItems = viewModel.noticePagingFlow.collectAsLazyPagingItems() - viewModel.dummyNotice.apply { - if (this.isNotEmpty()) { - NewsNoticeScreen(context = context, notices = this, navigateToDetail = navigateToDetail) - } else { - NewsNoticeEmptyScreen(R.string.tv_news_notice_empty) - } + LaunchedEffect(lifecycleOwner) { + viewModel.sideEffect.flowWithLifecycle(lifecycleOwner.lifecycle) + .collectLatest { sideEffect -> + when (sideEffect) { + is NewsInfoSideEffect.NavigateToDetail -> navigateToDetail(sideEffect.newsInfoModel) + else -> Unit + } + } } + NewsNoticeScreen( + noticeItems = newsItems, + onItemClick = viewModel::onItemClick + ) } -@RequiresApi(Build.VERSION_CODES.O) @Composable fun NewsNoticeScreen( - context: Context, - notices: List, - navigateToDetail: (NewsInfoModel) -> Unit + noticeItems: LazyPagingItems, + onItemClick: (NewsInfoModel) -> Unit ) { + val isLoading = noticeItems.loadState.refresh is LoadState.Loading + val isEmpty = noticeItems.itemCount == 0 && !isLoading + LazyColumn(modifier = Modifier.fillMaxSize()) { - items(items = notices, key = { item -> item.newsId }) { notice -> - NewsNoticeItem(context, notice, navigateToDetail) - HorizontalDivider( - thickness = 1.dp, - color = WableTheme.colors.gray200, - ) + when { + isLoading -> item { LoadingScreen() } + isEmpty -> item { NewsNoticeEmptyScreen(emptyTxt = R.string.tv_news_notice_empty) } + else -> { + items( + count = noticeItems.itemCount, + key = noticeItems.itemKey { it.newsId }, + contentType = noticeItems.itemContentType { ContentType.Item.name }, + ) { idx -> + noticeItems[idx]?.let { + NewsNoticeItem(it, onItemClick) + HorizontalDivider( + thickness = 1.dp, + color = WableTheme.colors.gray200, + ) + } + } + item( + key = ContentType.Spinner.name, + contentType = noticeItems.itemContentType { ContentType.Spinner.name }, + ) { + if (noticeItems.loadState.append is LoadState.Loading) { + WablePagingSpinner( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 16.dp), + ) + } + } + } } } } + +@Preview(showBackground = true) +@Composable +fun GreetingPreview() { + WableTheme { + NewsNoticeScreen( + onItemClick = {}, + noticeItems = flowOf(PagingData.from(emptyList())).collectAsLazyPagingItems(), + ) + } +} From 2553349a0f7e5528881abe196365d77fd6daf89a Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:44:16 +0900 Subject: [PATCH 07/14] =?UTF-8?q?#117=20[FEAT]=20:=20news=20notice=20viewM?= =?UTF-8?q?odel=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../news/notice/NewsNoticeViewModel.kt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeViewModel.kt diff --git a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeViewModel.kt b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeViewModel.kt new file mode 100644 index 00000000..7c5dc0cd --- /dev/null +++ b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeViewModel.kt @@ -0,0 +1,30 @@ +package com.teamwable.news.notice + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import androidx.paging.cachedIn +import com.teamwable.data.repository.NewsRepository +import com.teamwable.model.news.NewsInfoModel +import com.teamwable.news.news.model.NewsInfoSideEffect +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class NewsNoticeViewModel @Inject constructor( + newsRepository: NewsRepository, +) : ViewModel() { + private val _sideEffect = MutableSharedFlow() + val sideEffect: SharedFlow get() = _sideEffect.asSharedFlow() + + val noticePagingFlow = newsRepository.getNoticeInfo().cachedIn(viewModelScope) + + fun onItemClick(newsInfoModel: NewsInfoModel) { + viewModelScope.launch { + _sideEffect.emit(NewsInfoSideEffect.NavigateToDetail(newsInfoModel)) + } + } +} From 34390100e68784b9ebe8c379c9aae539d52de514 Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:44:44 +0900 Subject: [PATCH 08/14] =?UTF-8?q?#117=20[FEAT]=20:=20repository=20getNotic?= =?UTF-8?q?eInfo=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/teamwable/data/repository/NewsRepository.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/data/src/main/java/com/teamwable/data/repository/NewsRepository.kt b/core/data/src/main/java/com/teamwable/data/repository/NewsRepository.kt index 74db3073..2b37457d 100644 --- a/core/data/src/main/java/com/teamwable/data/repository/NewsRepository.kt +++ b/core/data/src/main/java/com/teamwable/data/repository/NewsRepository.kt @@ -14,4 +14,6 @@ interface NewsRepository { suspend fun getRank(): Result> fun getNewsInfo(): Flow> + + fun getNoticeInfo(): Flow> } From a00b1c390cb382b0de55f66ed1b83dfbb5cf1474 Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:44:57 +0900 Subject: [PATCH 09/14] =?UTF-8?q?#117=20[FEAT]=20:=20service=20getNoticeIn?= =?UTF-8?q?fo=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/teamwable/network/datasource/NewsService.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/network/src/main/java/com/teamwable/network/datasource/NewsService.kt b/core/network/src/main/java/com/teamwable/network/datasource/NewsService.kt index 056c6643..23f0d3d3 100644 --- a/core/network/src/main/java/com/teamwable/network/datasource/NewsService.kt +++ b/core/network/src/main/java/com/teamwable/network/datasource/NewsService.kt @@ -2,6 +2,7 @@ package com.teamwable.network.datasource import com.teamwable.network.dto.response.news.ResponseGameTypeDto import com.teamwable.network.dto.response.news.ResponseNewsInfoDto +import com.teamwable.network.dto.response.news.ResponseNoticeInfoDto import com.teamwable.network.dto.response.news.ResponseRankDto import com.teamwable.network.dto.response.news.ResponseScheduleDto import com.teamwable.network.util.BaseResponse @@ -22,4 +23,9 @@ interface NewsService { suspend fun getNewsInfo( @Query(value = "cursor") contentId: Long = -1, ): BaseResponse> + + @GET("api/v1/information/notice") + suspend fun getNoticeInfo( + @Query(value = "cursor") contentId: Long = -1, + ): BaseResponse> } From c54505ffde9967d938c2162ac77b60e66a62dab1 Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:45:08 +0900 Subject: [PATCH 10/14] =?UTF-8?q?#117=20[MOD]=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/teamwable/news/NewsViewModel.kt | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/feature/news/src/main/java/com/teamwable/news/NewsViewModel.kt b/feature/news/src/main/java/com/teamwable/news/NewsViewModel.kt index b821ad66..f408e9a2 100644 --- a/feature/news/src/main/java/com/teamwable/news/NewsViewModel.kt +++ b/feature/news/src/main/java/com/teamwable/news/NewsViewModel.kt @@ -4,7 +4,6 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.teamwable.common.uistate.UiState import com.teamwable.data.repository.NewsRepository -import com.teamwable.model.news.NewsInfoModel import com.teamwable.model.news.NewsMatchModel import com.teamwable.model.news.NewsRankModel import dagger.hilt.android.lifecycle.HiltViewModel @@ -25,17 +24,6 @@ class NewsViewModel private val _rankUiState = MutableStateFlow>>(UiState.Loading) val rankUiState = _rankUiState.asStateFlow() - val dummyNotice = listOf( - NewsInfoModel(1, "와블 커뮤니티 업데이트 안내", "본문입니다 본문입니다 본문입니다 본문입니다 본문입니다 본문입니다 본문입니다 본문입니다 본문입니다", "www.11", "2024-01-10 11:47:18"), - NewsInfoModel(2, "제목2", "내용2", null, "2024-06-12 20:00:37"), - NewsInfoModel(3, "제목3", "내용3", "www.33", "2024-11-22 04:50:26"), - NewsInfoModel(4, "제목4", "내용4", "www.33", "2024-11-22 04:50:26"), - NewsInfoModel(5, "제목5", "내용5", "www.33", "2024-11-22 04:50:26"), - NewsInfoModel(6, "제목6", "내용6", "www.33", "2024-11-22 04:50:26"), - NewsInfoModel(7, "제목7", "내용7", "www.33", "2024-11-22 04:50:26"), - NewsInfoModel(8, "제목8", "내용8", "www.33", "2024-11-22 04:50:26"), - ) - init { getGameType() } From 3292fc3014799264311ff0e412149065c55fb93c Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:45:21 +0900 Subject: [PATCH 11/14] =?UTF-8?q?#117=20[FEAT]=20:=20mapper=20toNoticeInfo?= =?UTF-8?q?Model=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/mapper/toModel/ResponseNewsDtoMapper.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/data/src/main/java/com/teamwable/data/mapper/toModel/ResponseNewsDtoMapper.kt b/core/data/src/main/java/com/teamwable/data/mapper/toModel/ResponseNewsDtoMapper.kt index e5852be2..6770a8bf 100644 --- a/core/data/src/main/java/com/teamwable/data/mapper/toModel/ResponseNewsDtoMapper.kt +++ b/core/data/src/main/java/com/teamwable/data/mapper/toModel/ResponseNewsDtoMapper.kt @@ -6,6 +6,7 @@ import com.teamwable.model.news.NewsMatchScoreModel import com.teamwable.model.news.NewsRankModel import com.teamwable.network.dto.response.news.ResponseGameDto import com.teamwable.network.dto.response.news.ResponseNewsInfoDto +import com.teamwable.network.dto.response.news.ResponseNoticeInfoDto import com.teamwable.network.dto.response.news.ResponseRankDto import com.teamwable.network.dto.response.news.ResponseScheduleDto @@ -43,3 +44,12 @@ internal fun ResponseNewsInfoDto.toNewsInfoModel(): NewsInfoModel = newsText = newsText, time = time, ) + +internal fun ResponseNoticeInfoDto.toNoticeInfoModel(): NewsInfoModel = + NewsInfoModel( + newsId = noticeId, + newsTitle = noticeTitle, + newsImage = noticeImage, + newsText = noticeText, + time = time + ) From ecb6984ee37659eaa4dfd5eea8795a88686b190e Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 17:45:41 +0900 Subject: [PATCH 12/14] =?UTF-8?q?#117=20[FEAT]=20:=20dto=20ResponseNoticeI?= =?UTF-8?q?nfoDto=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/news/ResponseNoticeInfoDto.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 core/network/src/main/java/com/teamwable/network/dto/response/news/ResponseNoticeInfoDto.kt diff --git a/core/network/src/main/java/com/teamwable/network/dto/response/news/ResponseNoticeInfoDto.kt b/core/network/src/main/java/com/teamwable/network/dto/response/news/ResponseNoticeInfoDto.kt new file mode 100644 index 00000000..cdee7b16 --- /dev/null +++ b/core/network/src/main/java/com/teamwable/network/dto/response/news/ResponseNoticeInfoDto.kt @@ -0,0 +1,18 @@ +package com.teamwable.network.dto.response.news + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ResponseNoticeInfoDto( + @SerialName("noticeId") + val noticeId: Long, + @SerialName("noticeTitle") + val noticeTitle: String, + @SerialName("noticeText") + val noticeText: String, + @SerialName("noticeImage") + val noticeImage: String?, + @SerialName("time") + val time: String, +) From 0b7951fb7fe849b9e994594165ccee261fa22ebb Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 18:46:35 +0900 Subject: [PATCH 13/14] =?UTF-8?q?#117=20[MOD]=20:=20preview=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/teamwable/news/notice/NewsNoticeItem.kt | 12 ++++++++++++ .../com/teamwable/news/notice/NewsNoticeRoute.kt | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeItem.kt b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeItem.kt index 9ce7802a..b895e199 100644 --- a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeItem.kt +++ b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeItem.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.teamwable.designsystem.theme.WableTheme import com.teamwable.model.news.NewsInfoModel @@ -37,3 +38,14 @@ fun NewsNoticeItem( Text(text = data.newsText, color = WableTheme.colors.gray600, maxLines = 2, style = WableTheme.typography.body04) } } + +@Preview(showBackground = true) +@Composable +fun NewsNoticeItemPreview() { + WableTheme { + NewsNoticeItem( + data = NewsInfoModel(1, "제목", "내용", null, "2024-01-10 11:47:18"), + onItemClick = {} + ) + } +} diff --git a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt index cc731c51..c206093b 100644 --- a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt +++ b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt @@ -98,7 +98,7 @@ fun NewsNoticeScreen( @Preview(showBackground = true) @Composable -fun GreetingPreview() { +fun NewsNoticeScreenPreview() { WableTheme { NewsNoticeScreen( onItemClick = {}, From df183a398e265a4791bc14657ee8407a91ec1d79 Mon Sep 17 00:00:00 2001 From: Eonji-sw Date: Mon, 25 Nov 2024 18:52:06 +0900 Subject: [PATCH 14/14] =?UTF-8?q?#117=20[REFACTOR]=20:=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EB=B6=84=EA=B8=B0=EC=B2=98=EB=A6=AC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teamwable/news/notice/NewsNoticeRoute.kt | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt index c206093b..729d7f11 100644 --- a/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt +++ b/feature/news/src/main/java/com/teamwable/news/notice/NewsNoticeRoute.kt @@ -36,7 +36,10 @@ internal fun NewsNoticeRoute( navigateToDetail: (NewsInfoModel) -> Unit ) { val lifecycleOwner = LocalLifecycleOwner.current - val newsItems = viewModel.noticePagingFlow.collectAsLazyPagingItems() + val noticeItems = viewModel.noticePagingFlow.collectAsLazyPagingItems() + + val isLoading = noticeItems.loadState.refresh is LoadState.Loading + val isEmpty = noticeItems.itemCount == 0 && !isLoading LaunchedEffect(lifecycleOwner) { viewModel.sideEffect.flowWithLifecycle(lifecycleOwner.lifecycle) @@ -47,10 +50,15 @@ internal fun NewsNoticeRoute( } } } - NewsNoticeScreen( - noticeItems = newsItems, - onItemClick = viewModel::onItemClick - ) + + when { + isLoading -> LoadingScreen() + isEmpty -> NewsNoticeEmptyScreen(emptyTxt = R.string.tv_news_notice_empty) + else -> NewsNoticeScreen( + noticeItems = noticeItems, + onItemClick = viewModel::onItemClick + ) + } } @Composable @@ -58,39 +66,30 @@ fun NewsNoticeScreen( noticeItems: LazyPagingItems, onItemClick: (NewsInfoModel) -> Unit ) { - val isLoading = noticeItems.loadState.refresh is LoadState.Loading - val isEmpty = noticeItems.itemCount == 0 && !isLoading - LazyColumn(modifier = Modifier.fillMaxSize()) { - when { - isLoading -> item { LoadingScreen() } - isEmpty -> item { NewsNoticeEmptyScreen(emptyTxt = R.string.tv_news_notice_empty) } - else -> { - items( - count = noticeItems.itemCount, - key = noticeItems.itemKey { it.newsId }, - contentType = noticeItems.itemContentType { ContentType.Item.name }, - ) { idx -> - noticeItems[idx]?.let { - NewsNoticeItem(it, onItemClick) - HorizontalDivider( - thickness = 1.dp, - color = WableTheme.colors.gray200, - ) - } - } - item( - key = ContentType.Spinner.name, - contentType = noticeItems.itemContentType { ContentType.Spinner.name }, - ) { - if (noticeItems.loadState.append is LoadState.Loading) { - WablePagingSpinner( - modifier = Modifier - .fillMaxWidth() - .padding(vertical = 16.dp), - ) - } - } + items( + count = noticeItems.itemCount, + key = noticeItems.itemKey { it.newsId }, + contentType = noticeItems.itemContentType { ContentType.Item.name }, + ) { idx -> + noticeItems[idx]?.let { + NewsNoticeItem(it, onItemClick) + HorizontalDivider( + thickness = 1.dp, + color = WableTheme.colors.gray200, + ) + } + } + item( + key = ContentType.Spinner.name, + contentType = noticeItems.itemContentType { ContentType.Spinner.name }, + ) { + if (noticeItems.loadState.append is LoadState.Loading) { + WablePagingSpinner( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 16.dp), + ) } } }