From b7ffa3d06285b5e84a008c60dc1430a5c03d8c90 Mon Sep 17 00:00:00 2001 From: jihyunniiii Date: Tue, 4 Jun 2024 01:48:34 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20#19=20=EC=9B=94=EA=B0=84=20=EB=A6=AC?= =?UTF-8?q?=ED=8F=AC=ED=8A=B8=20=EB=B7=B0=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/model/MonthlyReportModel.kt | 6 ++++++ .../calendar/calendar/CalendarFragment.kt | 19 ++++++++++++++----- .../monthlyreport/MonthlyReportFragment.kt | 18 ++++++++++++++---- .../monthlyreport/MonthlyReportViewModel.kt | 10 ++++++++-- 4 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 domain/src/main/java/com/dongguk/telepigeon/domain/model/MonthlyReportModel.kt diff --git a/domain/src/main/java/com/dongguk/telepigeon/domain/model/MonthlyReportModel.kt b/domain/src/main/java/com/dongguk/telepigeon/domain/model/MonthlyReportModel.kt new file mode 100644 index 0000000..56eecef --- /dev/null +++ b/domain/src/main/java/com/dongguk/telepigeon/domain/model/MonthlyReportModel.kt @@ -0,0 +1,6 @@ +package com.dongguk.telepigeon.domain.model + +data class MonthlyReportModel( + val positiveKeywords: List, + val negativeKeywords: List +) \ No newline at end of file diff --git a/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/calendar/CalendarFragment.kt b/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/calendar/CalendarFragment.kt index a1e0c82..0b7a2fd 100644 --- a/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/calendar/CalendarFragment.kt +++ b/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/calendar/CalendarFragment.kt @@ -2,13 +2,16 @@ package com.dongguk.telepigeon.feature.calendar.calendar import android.os.Bundle import android.view.View +import androidx.core.os.bundleOf import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import com.dongguk.telepigeon.core.design.system.R import com.dongguk.telepigeon.feature.databinding.FragmentCalendarBinding import com.dongguk.telpigeon.core.ui.base.BindingFragment import com.dongguk.telpigeon.core.ui.util.fragment.stringOf +import java.time.Instant import java.time.LocalDate +import java.time.ZoneId class CalendarFragment : BindingFragment({ FragmentCalendarBinding.inflate(it) }) { private val calendarViewModel by viewModels() @@ -22,7 +25,7 @@ class CalendarFragment : BindingFragment({ FragmentCale initAdapter() setCvCalendarDateChangeListener() - setBtnCalendarMonthlyReportClickListener() + setBtnCalendarMonthlyReportClickListener(LocalDate.now().year.toString() + "-" + LocalDate.now().monthValue) } private fun initAdapter() { @@ -43,16 +46,22 @@ class CalendarFragment : BindingFragment({ FragmentCale private fun setCvCalendarDateChangeListener() { binding.cvCalendar.setOnDateChangeListener { _, year, month, dayOfMonth -> binding.tvCalendarEmpty.text = if (LocalDate.now() == LocalDate.of(year, month + 1, dayOfMonth)) stringOf(R.string.calendar_today_answer_empty) else stringOf(R.string.calendar_future_answer_empty) + + setBtnCalendarMonthlyReportClickListener(year.toString() + "-" + (month + 1)) } } - private fun setBtnCalendarMonthlyReportClickListener() { + private fun setBtnCalendarMonthlyReportClickListener(date: String) { binding.btnCalendarMonthlyReport.setOnClickListener { - navigateToMonthlyReport() + navigateToMonthlyReport(date) } } - private fun navigateToMonthlyReport() { - findNavController().navigate(com.dongguk.telepigeon.feature.R.id.action_all_navi_calender_to_monthly_report) + private fun navigateToMonthlyReport(date: String) { + findNavController().navigate(com.dongguk.telepigeon.feature.R.id.action_all_navi_calender_to_monthly_report, bundleOf(DATE to date)) + } + + companion object { + const val DATE = "date" } } diff --git a/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportFragment.kt b/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportFragment.kt index 5ccd87e..a0ac69c 100644 --- a/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportFragment.kt +++ b/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportFragment.kt @@ -5,6 +5,7 @@ import android.view.View import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController import com.dongguk.telepigeon.design.system.type.AppBarType +import com.dongguk.telepigeon.feature.calendar.calendar.CalendarFragment.Companion.DATE import com.dongguk.telepigeon.feature.databinding.FragmentMonthlyReportBinding import com.dongguk.telpigeon.core.ui.base.BindingFragment @@ -31,10 +32,19 @@ class MonthlyReportFragment : BindingFragment({ Fr private fun initLayout() { with(binding) { - layoutMonthlyReportNegativeKeyword.visibility = View.INVISIBLE - layoutMonthlyReportPositiveKeyword.visibility = View.INVISIBLE - tvMonthlyReportPositiveKeyword.visibility = View.INVISIBLE - tvMonthlyReportNegativeKeyword.visibility = View.INVISIBLE + tvMonthlyReportTitle.text = getString(com.dongguk.telepigeon.core.design.system.R.string.monthly_report_title, requireArguments().getString(DATE)?.split("-")?.getOrNull(1)?.toIntOrNull()) + + ivMonthlyReportEmpty.visibility = if (monthlyReportViewModel.dummyMonthlyReportModel == null) View.VISIBLE else View.INVISIBLE + tvMonthlyReportEmpty.visibility = if (monthlyReportViewModel.dummyMonthlyReportModel == null) View.VISIBLE else View.INVISIBLE + + monthlyReportViewModel.dummyMonthlyReportModel?.let { monthlyReportModel -> + tvMonthlyReportPositiveKeywordRank1.text = monthlyReportModel.positiveKeywords[0] + tvMonthlyReportPositiveKeywordRank2.text = monthlyReportModel.positiveKeywords[1] + tvMonthlyReportPositiveKeywordRank3.text = monthlyReportModel.positiveKeywords[2] + tvMonthlyReportNegativeKeywordRank1.text = monthlyReportModel.negativeKeywords[0] + tvMonthlyReportNegativeKeywordRank2.text = monthlyReportModel.positiveKeywords[1] + tvMonthlyReportNegativeKeywordRank3.text = monthlyReportModel.positiveKeywords[2] + } } } diff --git a/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportViewModel.kt b/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportViewModel.kt index aa82790..53eba68 100644 --- a/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportViewModel.kt +++ b/feature/src/main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportViewModel.kt @@ -1,10 +1,16 @@ package com.dongguk.telepigeon.feature.calendar.monthlyreport import androidx.lifecycle.ViewModel +import com.dongguk.telepigeon.domain.model.MonthlyReportModel import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel class MonthlyReportViewModel - @Inject - constructor() : ViewModel() +@Inject +constructor() : ViewModel() { + val dummyMonthlyReportModel : MonthlyReportModel? = MonthlyReportModel( + positiveKeywords = listOf("운동", "-", "-"), + negativeKeywords = listOf("건강", "-", "-") + ) +}