-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from TelePigeon/feat-calender-view
[feat] Main 캘린더 뷰 구현
- Loading branch information
Showing
17 changed files
with
699 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...e/src/main/java/com/dongguk/telepigeon/feature/calendar/calendar/CalendarAnswerAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.dongguk.telepigeon.feature.calendar.calendar | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import com.dongguk.telepigeon.domain.model.QuestionAnswerModel | ||
import com.dongguk.telepigeon.feature.databinding.ItemCalendarAnswerBinding | ||
import com.dongguk.telpigeon.core.ui.util.view.ItemDiffCallback | ||
|
||
class CalendarAnswerAdapter : ListAdapter<QuestionAnswerModel, CalendarAnswerViewHolder>( | ||
ItemDiffCallback<QuestionAnswerModel>( | ||
onItemsTheSame = { old, new -> old.answerImage == new.answerImage }, | ||
onContentsTheSame = { old, new -> old == new }, | ||
), | ||
) { | ||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): CalendarAnswerViewHolder = CalendarAnswerViewHolder(binding = ItemCalendarAnswerBinding.inflate(LayoutInflater.from(parent.context), parent, false)) | ||
|
||
override fun onBindViewHolder( | ||
holder: CalendarAnswerViewHolder, | ||
position: Int, | ||
) { | ||
holder.onBind(questionAnswerModel = currentList[position]) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...rc/main/java/com/dongguk/telepigeon/feature/calendar/calendar/CalendarAnswerViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.dongguk.telepigeon.feature.calendar.calendar | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import coil.load | ||
import com.dongguk.telepigeon.domain.model.QuestionAnswerModel | ||
import com.dongguk.telepigeon.feature.databinding.ItemCalendarAnswerBinding | ||
|
||
class CalendarAnswerViewHolder(private val binding: ItemCalendarAnswerBinding) : RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(questionAnswerModel: QuestionAnswerModel) { | ||
with(binding) { | ||
ivCalendarAnswerImage.load(questionAnswerModel.answerImage) | ||
tvCalendarAnswerQuestionName.text = questionAnswerModel.questionerName | ||
tvCalendarAnswerQuestionContent.text = questionAnswerModel.questionContent | ||
tvCalendarAnswerAnswerName.text = questionAnswerModel.answerName | ||
tvCalendarAnswerAnswerContent.text = questionAnswerModel.answerContent | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
feature/src/main/java/com/dongguk/telepigeon/feature/calendar/calendar/CalendarFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.dongguk.telepigeon.feature.calendar.calendar | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
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.LocalDate | ||
|
||
class CalendarFragment : BindingFragment<FragmentCalendarBinding>({ FragmentCalendarBinding.inflate(it) }) { | ||
private val calendarViewModel by viewModels<CalendarViewModel>() | ||
private lateinit var calendarAnswerAdapter: CalendarAnswerAdapter | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initAdapter() | ||
setCvCalendarDateChangeListener() | ||
setBtnCalendarMonthlyReportClickListener() | ||
} | ||
|
||
private fun initAdapter() { | ||
calendarAnswerAdapter = CalendarAnswerAdapter() | ||
binding.rvCalendarAnswer.adapter = calendarAnswerAdapter | ||
|
||
// TODO 서버통신 구현 후 collectData 함수로 해당 로직 이동 | ||
calendarAnswerAdapter.submitList(calendarViewModel.dummyQuestionAnswerModels) | ||
|
||
(calendarViewModel.dummyQuestionAnswerModels.isEmpty()).let { isEmpty -> | ||
with(binding) { | ||
ivCalendarEmpty.visibility = if (isEmpty) View.VISIBLE else View.INVISIBLE | ||
tvCalendarEmpty.visibility = if (isEmpty) View.VISIBLE else View.INVISIBLE | ||
} | ||
} | ||
} | ||
|
||
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) | ||
} | ||
} | ||
|
||
private fun setBtnCalendarMonthlyReportClickListener() { | ||
binding.btnCalendarMonthlyReport.setOnClickListener { | ||
navigateToMonthlyReport() | ||
} | ||
} | ||
|
||
private fun navigateToMonthlyReport() { | ||
findNavController().navigate(com.dongguk.telepigeon.feature.R.id.action_all_navi_calender_to_monthly_report) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
feature/src/main/java/com/dongguk/telepigeon/feature/calendar/calendar/CalendarViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.dongguk.telepigeon.feature.calendar.calendar | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.dongguk.telepigeon.domain.model.QuestionAnswerModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class CalendarViewModel | ||
@Inject | ||
constructor() : ViewModel() { | ||
val dummyQuestionAnswerModels = | ||
listOf( | ||
QuestionAnswerModel( | ||
questionerName = "김둘기", | ||
answerName = "둘기맘", | ||
questionContent = "오늘 점심은 무슨 음식을 먹었나요?", | ||
answerContent = "분식을 먹었어요! 맛있었어요!", | ||
answerImage = "https://avatars.githubusercontent.com/u/103172971?v=4", | ||
), | ||
QuestionAnswerModel( | ||
questionerName = "둘기맘", | ||
answerName = "김둘기", | ||
questionContent = "영양제는 잘 챙겨먹고 있나요?", | ||
answerContent = "어제는 까먹었어요.. 오늘은 꼭 먹을게요!", | ||
answerImage = "https://avatars.githubusercontent.com/u/103172971?v=4", | ||
), | ||
) | ||
} |
46 changes: 46 additions & 0 deletions
46
.../main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.dongguk.telepigeon.feature.calendar.monthlyreport | ||
|
||
import android.os.Bundle | ||
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.databinding.FragmentMonthlyReportBinding | ||
import com.dongguk.telpigeon.core.ui.base.BindingFragment | ||
|
||
class MonthlyReportFragment : BindingFragment<FragmentMonthlyReportBinding>({ FragmentMonthlyReportBinding.inflate(it) }) { | ||
private val monthlyReportViewModel by viewModels<MonthlyReportViewModel>() | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initAppBar() | ||
initLayout() | ||
setBtnMonthlyReportCheckClickListener() | ||
} | ||
|
||
private fun initAppBar() { | ||
binding.appbarMonthlyReport.initLayout(appBarType = AppBarType.X) | ||
binding.appbarMonthlyReport.binding.ivAppBarTelepigeonX.setOnClickListener { | ||
findNavController().popBackStack() | ||
} | ||
} | ||
|
||
private fun initLayout() { | ||
with(binding) { | ||
layoutMonthlyReportNegativeKeyword.visibility = View.INVISIBLE | ||
layoutMonthlyReportPositiveKeyword.visibility = View.INVISIBLE | ||
tvMonthlyReportPositiveKeyword.visibility = View.INVISIBLE | ||
tvMonthlyReportNegativeKeyword.visibility = View.INVISIBLE | ||
} | ||
} | ||
|
||
private fun setBtnMonthlyReportCheckClickListener() { | ||
binding.btnMonthlyReportCheck.setOnClickListener { | ||
findNavController().popBackStack() | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...main/java/com/dongguk/telepigeon/feature/calendar/monthlyreport/MonthlyReportViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.dongguk.telepigeon.feature.calendar.monthlyreport | ||
|
||
import androidx.lifecycle.ViewModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class MonthlyReportViewModel | ||
@Inject | ||
constructor() : ViewModel() |
15 changes: 0 additions & 15 deletions
15
feature/src/main/java/com/dongguk/telepigeon/feature/calender/CalenderFragment.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?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" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".calendar.calendar.CalendarFragment"> | ||
|
||
<androidx.constraintlayout.widget.Guideline | ||
android:id="@+id/gl_start" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
app:layout_constraintGuide_begin="@dimen/horizontal_margin" /> | ||
|
||
<androidx.constraintlayout.widget.Guideline | ||
android:id="@+id/gl_end" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
app:layout_constraintGuide_end="@dimen/horizontal_margin" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_calendar_title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="40dp" | ||
android:text="@string/all_navi_calender" | ||
android:textAppearance="@style/TextAppearance.TelePigeon.Title.Extra.40" | ||
app:layout_constraintStart_toStartOf="@id/gl_start" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_calendar_content" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:text="@string/calendar_content" | ||
android:textAppearance="@style/TextAppearance.TelePigeon.Sub.Semi.16" | ||
android:textColor="@color/g_06" | ||
app:layout_constraintEnd_toStartOf="@+id/gl_end" | ||
app:layout_constraintStart_toStartOf="@+id/gl_start" | ||
app:layout_constraintTop_toBottomOf="@+id/tv_calendar_title" /> | ||
|
||
<CalendarView | ||
android:id="@+id/cv_calendar" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="30dp" | ||
app:layout_constraintEnd_toEndOf="@id/gl_end" | ||
app:layout_constraintStart_toStartOf="@id/gl_start" | ||
app:layout_constraintTop_toBottomOf="@id/tv_calendar_content" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/btn_calendar_monthly_report" | ||
style="@style/Theme.TelePigeon.Button.Small" | ||
android:layout_width="wrap_content" | ||
android:text="@string/calendar_monthly_report" | ||
app:layout_constraintEnd_toStartOf="@+id/gl_end" | ||
app:layout_constraintTop_toBottomOf="@+id/cv_calendar" /> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/rv_calendar_answer" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:layout_marginTop="22dp" | ||
android:layout_marginBottom="8dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="@id/gl_end" | ||
app:layout_constraintStart_toStartOf="@id/gl_start" | ||
app:layout_constraintTop_toBottomOf="@id/btn_calendar_monthly_report" | ||
tools:itemCount="2" | ||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
tools:listitem="@layout/item_calendar_answer" /> | ||
|
||
<ImageView | ||
android:id="@+id/iv_calendar_empty" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:src="@drawable/ic_character_sad" | ||
app:layout_constraintBottom_toTopOf="@id/tv_calendar_empty" | ||
app:layout_constraintEnd_toStartOf="@id/gl_end" | ||
app:layout_constraintVertical_chainStyle="packed" | ||
app:layout_constraintStart_toStartOf="@id/gl_start" | ||
app:layout_constraintTop_toBottomOf="@id/btn_calendar_monthly_report" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_calendar_empty" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:textAppearance="@style/TextAppearance.TelePigeon.Sub.Semi.16" | ||
android:textColor="@color/g_07" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@+id/gl_end" | ||
app:layout_constraintStart_toStartOf="@+id/gl_start" | ||
app:layout_constraintTop_toBottomOf="@+id/iv_calendar_empty" | ||
android:text="@string/calendar_today_answer_empty" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.