Skip to content

Commit

Permalink
[feat] #19 월간 리포트 뷰 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jihyunniiii committed Jun 3, 2024
1 parent 57da377 commit b7ffa3d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.dongguk.telepigeon.domain.model

data class MonthlyReportModel(
val positiveKeywords: List<String>,
val negativeKeywords: List<String>
)
Original file line number Diff line number Diff line change
Expand Up @@ -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>({ FragmentCalendarBinding.inflate(it) }) {
private val calendarViewModel by viewModels<CalendarViewModel>()
Expand All @@ -22,7 +25,7 @@ class CalendarFragment : BindingFragment<FragmentCalendarBinding>({ FragmentCale

initAdapter()
setCvCalendarDateChangeListener()
setBtnCalendarMonthlyReportClickListener()
setBtnCalendarMonthlyReportClickListener(LocalDate.now().year.toString() + "-" + LocalDate.now().monthValue)
}

private fun initAdapter() {
Expand All @@ -43,16 +46,22 @@ class CalendarFragment : BindingFragment<FragmentCalendarBinding>({ 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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -31,10 +32,19 @@ class MonthlyReportFragment : BindingFragment<FragmentMonthlyReportBinding>({ 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]
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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("건강", "-", "-")
)
}

0 comments on commit b7ffa3d

Please sign in to comment.