Skip to content

Commit

Permalink
feat: colored on today was not selected (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
HI-JIN2 authored Sep 17, 2024
1 parent 392bcea commit 4f7253f
Showing 1 changed file with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.eatssu.android.ui.main.calendar

import android.os.Build
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.eatssu.android.R
Expand Down Expand Up @@ -32,18 +34,36 @@ internal class CalendarAdapter(
}


@RequiresApi(Build.VERSION_CODES.O)
override fun onBindViewHolder(holder: CalendarViewHolder, position: Int) {
val date = days[position]
holder.dayOfMonth.text = date.dayOfMonth.toString()
holder.dayText.text =
date.dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.KOREAN).toString()

if (date == CalendarUtils.selectedDate) {
//๋‚ ์งœ
/**
* iOS์˜ FSCalendar๋ฅผ Custom์œผ๋กœ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.
* 1. ์„ ํƒํ•œ ๋‚ ์งœ๋Š” primary color๋กœ selectํ•ฉ๋‹ˆ๋‹ค.
* 2. ์˜ค๋Š˜ ๋‚ ์งœ != ์„ ํƒํ•œ ๋‚ ์งœ ์ผ ๊ฒฝ์šฐ์—๋Š”, ์˜ค๋Š˜ ๋‚ ์งœ์˜ text ์ƒ‰์ƒ์„ primary color ํ‘œ๊ธฐํ•˜์—ฌ, ์˜ค๋Š˜ ๋‚ ์งœ๋ฅผ ๊ฐ•์กฐํ•ฉ๋‹ˆ๋‹ค.
*/

if (date == CalendarUtils.selectedDate) { //์…€๋ ‰ํŠธ ๋œ ๋‚ ์งœ
holder.dayOfMonth.setBackgroundResource(R.drawable.selector_background_blue)
holder.dayOfMonth.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.selector_calendar_colortext))
}
else {
holder.dayOfMonth.setTextColor(
ContextCompat.getColor(
holder.itemView.context,
R.color.selector_calendar_colortext
)
)
} else if (date == LocalDate.now() && date != CalendarUtils.selectedDate) {
//์˜ค๋Š˜ ๋‚ ์งœ๊ฐ€ ์„ ํƒ ๋˜์ง€ ์•Š์•˜์„ ๋•Œ, ์˜ค๋Š˜ ๋‚  text ์ƒ‰ ์ง€์ •
holder.dayOfMonth.setTextColor(
ContextCompat.getColor(
holder.itemView.context,
R.color.primary
)
)
} else { //๋‹ค๋ฅธ ๋‚ ์งœ๋“ค
holder.parentView.setBackgroundResource(R.drawable.ic_selector_background_white)
}
}
Expand Down

0 comments on commit 4f7253f

Please sign in to comment.