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

Feature/#111 news notice UI #116

Merged
merged 18 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5b6aff1
#111 [UI] : news ์ƒ๋‹จ๋ฐ” lottie background color ๋ณ€๊ฒฝ
Eonji-sw Nov 24, 2024
868bab3
#111 [UI] : news_detail fragment UI ์ƒ์„ฑ
Eonji-sw Nov 24, 2024
950f8aa
#111 [UI] : news_notice fragment UI composeView ๊ตฌํ˜„
Eonji-sw Nov 24, 2024
fc03e98
#111 [UI] : news graph notice -> detail ์ด๋™ ์ถ”๊ฐ€
Eonji-sw Nov 24, 2024
b19fa3d
#111 [FEAT] : NewsDetailFragment ๊ตฌํ˜„
Eonji-sw Nov 24, 2024
450ef39
#111 [MOD] : NewsInfoModel parcelize ์ ์šฉ
Eonji-sw Nov 24, 2024
ec4ece9
#111 [FEAT] : NewsNoticeFragment compose ์ ์šฉ ๋ฐ navi ํ•จ์ˆ˜ ๊ตฌํ˜„
Eonji-sw Nov 24, 2024
3cd6473
#111 [UI] : NewsNoticeItem UI ๊ตฌํ˜„
Eonji-sw Nov 24, 2024
2d44674
#111 [FEAT] : NewsNotice Route ๋ฐ Screen ๊ตฌํ˜„
Eonji-sw Nov 24, 2024
fe301f9
#111 [MOD] : notice dummy ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€
Eonji-sw Nov 24, 2024
1bd1218
#111 [UI] : string export
Eonji-sw Nov 24, 2024
feb72eb
#111 [MOD] : RequiresApi ์ถ”๊ฐ€
Eonji-sw Nov 24, 2024
83d3762
#111 [MOD] : ๋ถˆํ•„์š”ํ•œ ์ฝ”๋“œ ์ œ๊ฑฐ
Eonji-sw Nov 24, 2024
ffe67cb
#111 [MOD] : ๋ฐ์ดํ„ฐ ํŒŒ๋ผ๋ฏธํ„ฐํ™” ๋ฐ ๋ถˆํ•„์š”ํ•œ ์ฝ”๋“œ ์ œ๊ฑฐ
Eonji-sw Nov 24, 2024
5d0b78d
#111 [REFACTOR] : ๋ถˆํ•„์š”ํ•œ ๋ฆฌ์ปดํฌ์ง€์…˜ ๋ฐฉ์ง€
Eonji-sw Nov 24, 2024
9e3d9da
#111 [MOD] : dummy data id ๋ณ€๊ฒฝ
Eonji-sw Nov 24, 2024
5f66b8d
#111 [MOD] : clickable ์šฐ์„ ์ˆœ์œ„ ์ˆ˜์ •
Eonji-sw Nov 24, 2024
3a9a158
#111 [MOD] : StringRes ์ถ”๊ฐ€
Eonji-sw Nov 24, 2024
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
@@ -0,0 +1,19 @@
package com.teamwable.news

import androidx.navigation.fragment.navArgs
import com.teamwable.news.databinding.FragmentNewsDetailBinding
import com.teamwable.news.model.NewsInfoModel
import com.teamwable.ui.base.BindingFragment

class NewsDetailFragment : BindingFragment<FragmentNewsDetailBinding>(FragmentNewsDetailBinding::inflate) {
private val args: NewsDetailFragmentArgs by navArgs()
private val notice: NewsInfoModel by lazy { args.newsInfoModel }

override fun initView() {
receiveResultFromNotice()
}

private fun receiveResultFromNotice() {
binding.tvNewsDetail.text = notice.newsText
}
}
12 changes: 12 additions & 0 deletions feature/news/src/main/java/com/teamwable/news/NewsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.teamwable.common.uistate.UiState
import com.teamwable.data.repository.NewsRepository
import com.teamwable.model.news.NewsMatchModel
import com.teamwable.model.news.NewsRankModel
import com.teamwable.news.model.NewsInfoModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
Expand All @@ -24,6 +25,17 @@ class NewsViewModel
private val _rankUiState = MutableStateFlow<UiState<List<NewsRankModel>>>(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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.teamwable.news.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class NewsInfoModel(
val newsId: Int,
val newsTitle: String,
val newsText: String,
val newsImage: String,
val newsImage: String?,
val time: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
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
import com.teamwable.news.NewsFragmentDirections
import com.teamwable.news.databinding.FragmentNewsNoticeBinding
import com.teamwable.news.model.NewsInfoModel
import com.teamwable.ui.base.BindingFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class NewsNoticeFragment : BindingFragment<FragmentNewsNoticeBinding>(FragmentNewsNoticeBinding::inflate) {
@RequiresApi(Build.VERSION_CODES.O)
override fun initView() {
initComposeView()
}

@RequiresApi(Build.VERSION_CODES.O)
Eonji-sw marked this conversation as resolved.
Show resolved Hide resolved
private fun initComposeView() {
binding.composeNewsNotice.apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
WableTheme {
NewsNoticeRoute(navigateToDetail = { notice -> navigateToDetail(notice) })
}
}
}
}

private fun navigateToDetail(notice: NewsInfoModel) {
val parentNavController = requireParentFragment().findNavController()
val action = NewsFragmentDirections.actionNavigationNewsToNavigationNewsDetail(notice)
parentNavController.navigate(action)
Comment on lines +34 to +36
Copy link
Collaborator

Choose a reason for hiding this comment

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

์™€ parent๊ฑฐ ๊ฐ€์ ธ์˜ค๋Š” ๋ฒ•์€ ์ฒ˜์Œ์•Œ์•˜๋„ค์š” ์งฑ!

Copy link
Member Author

Choose a reason for hiding this comment

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

ํ—ˆ๋•์ด๋‹ค๊ฐ€.. ์‚ฌ์šฉํ•ด๋ณด์•˜์Šด๋‹ค

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
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.unit.dp
import com.teamwable.designsystem.theme.WableTheme
import com.teamwable.news.model.NewsInfoModel
import com.teamwable.ui.util.CalculateTime

@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun NewsNoticeItem(
context: Context,
data: NewsInfoModel,
navigateToDetail: (NewsInfoModel) -> Unit
) {
Column(
modifier = Modifier
.fillMaxWidth()
.background(WableTheme.colors.white)
.clickable { navigateToDetail(data) }
Eonji-sw marked this conversation as resolved.
Show resolved Hide resolved
.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)
}
Spacer(modifier = Modifier.height(2.dp))
Text(text = data.newsText, color = WableTheme.colors.gray600, maxLines = 2, style = WableTheme.typography.body04)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.teamwable.news.notice

import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.teamwable.designsystem.theme.WableTheme
import com.teamwable.news.NewsViewModel
import com.teamwable.news.R
import com.teamwable.news.model.NewsInfoModel

@RequiresApi(Build.VERSION_CODES.O)
@Composable
internal fun NewsNoticeRoute(
viewModel: NewsViewModel = hiltViewModel(),
navigateToDetail: (NewsInfoModel) -> Unit
) {
val context = LocalContext.current

viewModel.dummyNotice.apply {
Copy link
Collaborator

Choose a reason for hiding this comment

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

p1 :์ด๊ฑด ์ถ”ํ›„์— ์„œ๋ฒ„ํ†ต์‹ ํ•˜๋ฉด์„œ state๋ฅผ collectํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ฐ”๊พธ์–ด์ฃผ์„ธ์š”!

    val showEmptyText by viewModel.showDialog.collectAsStateWithLifecycle()

์ด๋Ÿฐ์‹์œผ๋กœ์š”! ๋„ค์ด๋ฐ์€ ์•Œ์ž˜๋”ฑ๊ฐˆ์„ผ์œผ๋กœ~

Copy link
Collaborator

Choose a reason for hiding this comment

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

์ง€๊ธˆ ๊ตฌ์กฐ์—์„œ๋Š” List์˜ ๊ฐ’์„ ์ง์ ‘๊ฐ€์ ธ์˜ค๋Š” ์‹์ธ๋ฐ
์ปดํฌ์ €๋ธ”์—์„œ๋Š” List์˜ ๊ฒฝ์šฐ unstatble๋กœ ๊ฐ„์ฃผ( ์™œ๋ƒ๋ฉด list๋Š” ๊ฐ’์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์œผ๋‹ˆ๊นŒ MutableList๋ฅผ ๋„ฃ์„์ˆ˜ ์žˆ๊ธฐ๋•Œ๋ฌธ) ๋˜๊ธฐ์— ๋ฆฌ์ปดํฌ์ง€์…˜์˜ ์›์ธ์ด ๋ฉ๋‹ˆ๋‹ค!
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

ImmutableList์™€ PersistentList๋ฅผ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•˜๋„๋ก ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ ํ•ด๋†“์•˜์Šต๋‹ˆ๋‹ค~

Copy link
Member Author

Choose a reason for hiding this comment

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

๋„น ์„œ๋ฒ„ํ†ต์‹  ํ•  ๋•Œ ์ ์šฉํ•ด๋ณผ๊ฒŒ์šฉ ^.<

if (this.isNotEmpty()) {
NewsNoticeScreen(context = context, notices = this, navigateToDetail = navigateToDetail)
Eonji-sw marked this conversation as resolved.
Show resolved Hide resolved
} else {
NewsNoticeEmptyScreen(R.string.tv_news_notice_empty)
}
}
}

@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun NewsNoticeScreen(
context: Context,
notices: List<NewsInfoModel>,
navigateToDetail: (NewsInfoModel) -> Unit
) {
LazyColumn(modifier = Modifier.fillMaxSize()) {
items(items = notices, key = { item -> item.newsId }) { notice ->
NewsNoticeItem(context, notice, navigateToDetail)
HorizontalDivider(
thickness = 1.dp,
color = WableTheme.colors.gray200,
)
}
}
}

@Composable
fun NewsNoticeEmptyScreen(@StringRes emptyTxt: Int) {
Box(modifier = Modifier.fillMaxSize()) {
Text(
modifier = Modifier.align(Alignment.Center),
text = stringResource(emptyTxt),
color = WableTheme.colors.gray500,
style = WableTheme.typography.body02
)
}
}
1 change: 1 addition & 0 deletions feature/news/src/main/res/layout/fragment_news.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
android:id="@+id/lottie_news_tab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/black"
android:scaleType="fitXY"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
17 changes: 17 additions & 0 deletions feature/news/src/main/res/layout/fragment_news_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/tv_news_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="detail"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 4 additions & 4 deletions feature/news/src/main/res/layout/fragment_news_notice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="notice"
<androidx.compose.ui.platform.ComposeView
android:id="@+id/compose_news_notice"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
16 changes: 15 additions & 1 deletion feature/news/src/main/res/navigation/graph_news.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,19 @@
android:id="@+id/navigation_news"
android:name="com.teamwable.news.NewsFragment"
android:label="NewsFragment"
tools:layout="@layout/fragment_news" />
tools:layout="@layout/fragment_news">
<action
android:id="@+id/action_navigation_news_to_navigation_news_detail"
app:destination="@id/navigation_news_detail" />
</fragment>

<fragment
android:id="@+id/navigation_news_detail"
android:name="com.teamwable.news.NewsDetailFragment"
android:label="NewsDetailFragment"
tools:layout="@layout/fragment_news_detail">
<argument
android:name="newsInfoModel"
app:argType="com.teamwable.news.model.NewsInfoModel" />
</fragment>
</navigation>
3 changes: 3 additions & 0 deletions feature/news/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@
<!-- fragment_news & fragment_news_notice -->
<string name="tv_news_tab_notice">๊ณต์ง€์‚ฌํ•ญ</string>

<!-- fragment_news_notice -->
<string name="tv_news_notice_empty">์•„์ง ์ž‘์„ฑ๋œ ๊ณต์ง€์‚ฌํ•ญ์ด ์—†์–ด์š”.</string>

</resources>