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

Design : 식단 화면 리디자인 #156

Merged
merged 15 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -36,15 +36,22 @@ class CafeteriaContainer(
bind.itemCalendarDay.text = dayFormatter.format(day.date)
bind.itemCalendarMonth.text = monthFormatter.format(day.date)

bind.itemCalendarDate.setTextColor(
ContextCompat.getColor(
view.context,
if (day.date == viewModel.selectedDate.value) {
R.color.main
} else {
R.color.black
}
if (day.date == viewModel.selectedDate.value) {
bind.mvItemCalendarDate.setCardBackgroundColor(
ContextCompat.getColor(
view.context,
R.color.blue300
)
)
)
bind.itemCalendarDate.setTextColor(ContextCompat.getColor(view.context, R.color.white))
} else {
bind.mvItemCalendarDate.setCardBackgroundColor(
ContextCompat.getColor(
view.context,
R.color.white
)
)
bind.itemCalendarDate.setTextColor(ContextCompat.getColor(view.context, R.color.black))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.dongyang.android.youdongknowme.ui.view.cafeteria

import android.view.MenuItem
import android.view.View
import androidx.appcompat.view.menu.MenuAdapter
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.window.layout.WindowMetricsCalculator
import com.dongyang.android.youdongknowme.R
import com.dongyang.android.youdongknowme.databinding.FragmentCafeteriaBinding
Expand All @@ -26,62 +29,42 @@ class CafeteriaFragment : BaseFragment<FragmentCafeteriaBinding, CafeteriaViewMo

private lateinit var stuKoreanMenuAdapter: CafeteriaAdapter
private lateinit var stuAnotherMenuAdapter: CafeteriaAdapter
private lateinit var eduKoreanMenuAdapter: CafeteriaAdapter
private lateinit var eduAnotherMenuAdapter: CafeteriaAdapter

override fun initStartView() {
binding.vm = viewModel

stuKoreanMenuAdapter = CafeteriaAdapter()
stuAnotherMenuAdapter = CafeteriaAdapter()
eduKoreanMenuAdapter = CafeteriaAdapter()
eduAnotherMenuAdapter = CafeteriaAdapter()

binding.cafeteriaStuKoreanMenuList.apply {
binding.rvCafeteriaMenuList.apply {
val layoutManager = FlexboxLayoutManager(context)
layoutManager.flexDirection = FlexDirection.ROW
this.adapter = [email protected]
this.layoutManager = layoutManager
this.setHasFixedSize(true)
}

binding.cafeteriaStuAnotherMenuList.apply {
binding.rvCafeteriaAnotherMenuList.apply {
val layoutManager = FlexboxLayoutManager(context)
layoutManager.flexDirection = FlexDirection.ROW
this.adapter = [email protected]
this.layoutManager = layoutManager
this.setHasFixedSize(true)
}

binding.cafeteriaEduKoreanMenuList.apply {
val layoutManager = FlexboxLayoutManager(context)
layoutManager.flexDirection = FlexDirection.ROW
this.adapter = [email protected]
this.layoutManager = layoutManager
this.setHasFixedSize(true)
}

binding.cafeteriaEduAnotherMenuList.apply {
val layoutManager = FlexboxLayoutManager(context)
layoutManager.flexDirection = FlexDirection.ROW
this.adapter = [email protected]
this.layoutManager = layoutManager
this.setHasFixedSize(true)
}

val wmc =
WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(requireActivity())

binding.cafeteriaCalendar.apply {
binding.cvCafeteriaCalendar.apply {
val dayWidth = wmc.bounds.width() / 5
val dayHeight: Int = (dayWidth * 1.25).toInt()

daySize = Size(dayWidth, dayHeight)
}

binding.cafeteriaCalendar.dayBinder = object : DayBinder<CafeteriaContainer> {
binding.cvCafeteriaCalendar.dayBinder = object : DayBinder<CafeteriaContainer> {
override fun create(view: View): CafeteriaContainer =
CafeteriaContainer(view, binding.cafeteriaCalendar, viewModel)
CafeteriaContainer(view, binding.cvCafeteriaCalendar, viewModel)

override fun bind(container: CafeteriaContainer, day: CalendarDay) = container.bind(day)
}
Expand All @@ -103,20 +86,16 @@ class CafeteriaFragment : BaseFragment<FragmentCafeteriaBinding, CafeteriaViewMo
stuAnotherMenuAdapter.submitList(it.second)
}

viewModel.eduMenus.observe(viewLifecycleOwner) {
eduKoreanMenuAdapter.submitList(it.first)
eduAnotherMenuAdapter.submitList(it.second)
}
}

override fun initAfterBinding() {
binding.cafeteriaCalendar.setup(
binding.cvCafeteriaCalendar.setup(
YearMonth.now().minusMonths(2),
YearMonth.now().plusMonths(1),
DayOfWeek.values().random()
)

binding.cafeteriaCalendar.scrollToDate(LocalDate.now().minusDays(2))
binding.cvCafeteriaCalendar.scrollToDate(LocalDate.now().minusDays(2))

binding.cafeteriaErrorContainer.refresh.setOnClickListener {
viewModel.fetchCafeteria()
Expand All @@ -127,7 +106,7 @@ class CafeteriaFragment : BaseFragment<FragmentCafeteriaBinding, CafeteriaViewMo
super.onPause()
notifyDateChanged(
viewModel,
binding.cafeteriaCalendar,
binding.cvCafeteriaCalendar,
viewModel.selectedDate.value,
LocalDate.now()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class CafeteriaViewModel(
private val _stuMenus: MutableLiveData<Pair<List<String>, List<String>>> = MutableLiveData()
val stuMenus: LiveData<Pair<List<String>, List<String>>> = _stuMenus

private val _eduMenus: MutableLiveData<Pair<List<String>, List<String>>> = MutableLiveData()
val eduMenus: LiveData<Pair<List<String>, List<String>>> = _eduMenus

init {
fetchCafeteria()
}
Expand Down Expand Up @@ -77,12 +74,7 @@ class CafeteriaViewModel(
it.date == selectedDate && it.restaurant == resourceProvider.getString(R.string.cafeteria_student) && it.menuContent != "-"
}?.menuContent ?: ""

val eduMenu = cafeteriaList.find {
it.date == selectedDate && it.restaurant == resourceProvider.getString(R.string.cafeteria_employee) && it.menuContent != "-"
}?.menuContent ?: ""

_stuMenus.value = parsingMenu(stuMenu)
_eduMenus.value = parsingMenu(eduMenu)
}

private fun parsingMenu(menu: String): Pair<List<String>, List<String>> {
Expand Down
95 changes: 20 additions & 75 deletions app/src/main/res/layout/fragment_cafeteria.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
layout="@layout/standard_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:title="@{@string/cafeteria_main}" />
app:title="@{@string/cafeteria_title}" />

<androidx.core.widget.NestedScrollView
android:id="@+id/cafeteria_content_container"
android:id="@+id/nsv_cafeteria_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
Expand All @@ -31,7 +31,7 @@
android:orientation="vertical">

<com.kizitonwose.calendarview.CalendarView
android:id="@+id/cafeteria_calendar"
android:id="@+id/cv_cafeteria_calendar"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:cv_dayViewResource="@layout/item_calendar_day"
Expand All @@ -49,20 +49,21 @@
android:id="@+id/cafeteria_info_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingHorizontal="16dp"
android:paddingVertical="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cafeteria_calendar">
app:layout_constraintTop_toBottomOf="@id/cv_cafeteria_calendar">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_location" />

<TextView
android:id="@+id/cafeteria_info_place"
style="@style/PretendardRegular12"
android:id="@+id/tv_cafeteria_info_place"
style="@style/PretendardRegular14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand All @@ -77,8 +78,8 @@
android:src="@drawable/ic_timer" />

<TextView
android:id="@+id/cafeteria_info_time"
style="@style/PretendardRegular12"
android:id="@+id/tv_cafeteria_info_time"
style="@style/PretendardRegular14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand Down Expand Up @@ -107,14 +108,14 @@
</LinearLayout>

<com.google.android.material.card.MaterialCardView
android:id="@+id/cafeteria_stu_menu_container"
android:id="@+id/mv_cafeteria_menu"
bind_is_error="@{vm.cafeteriaList == null}"
bind_is_loading="@{vm.isLoading()}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="12dp"
android:background="@color/main"
android:outlineSpotShadowColor="@color/blue300"
app:cardCornerRadius="16dp"
app:cardElevation="8dp"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -126,15 +127,6 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
style="@style/PretendardBold16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="@string/cafeteria_student"
android:textColor="@color/black" />

<TextView
style="@style/PretendardBold14"
android:layout_width="wrap_content"
Expand All @@ -145,81 +137,35 @@
android:textColor="@color/black" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/cafeteria_stu_korean_menu_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
tools:listitem="@layout/item_cafeteria_menu" />

<TextView
style="@style/PretendardBold14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="@string/cafeteria_another"
android:textColor="@color/black" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/cafeteria_stu_another_menu_list"
android:id="@+id/rv_cafeteria_menu_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginVertical="8dp"
tools:listitem="@layout/item_cafeteria_menu" />

</LinearLayout>
</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:id="@+id/cafeteria_emp_menu_container"
android:id="@+id/mv_cafeteria_another"
bind_is_error="@{vm.cafeteriaList == null}"
bind_is_loading="@{vm.isLoading()}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:background="@color/main"
android:layout_marginTop="20dp"
android:outlineSpotShadowColor="@color/blue300"
app:cardCornerRadius="16dp"
app:cardElevation="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cafeteria_stu_menu_container"
app:layout_constraintBottom_toBottomOf="parent">
app:layout_constraintTop_toBottomOf="@id/mv_cafeteria_menu">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
style="@style/PretendardBold16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="@string/cafeteria_employee"
android:textColor="@color/black" />

<TextView
style="@style/PretendardBold14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:text="@string/cafeteria_korean"
android:textColor="@color/black" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/cafeteria_edu_korean_menu_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
tools:listitem="@layout/item_cafeteria_menu" />

<TextView
style="@style/PretendardBold14"
android:layout_width="wrap_content"
Expand All @@ -230,15 +176,14 @@
android:textColor="@color/black" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/cafeteria_edu_another_menu_list"
android:id="@+id/rv_cafeteria_another_menu_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginVertical="8dp"
tools:listitem="@layout/item_cafeteria_menu" />

</LinearLayout>

</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_cafeteria_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
style="@style/Colors_Widget.MaterialComponents.Chip"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:backgroundTint="@color/blue100"
android:clickable="false"
android:text="@{menu, default = 해바라기멸치볶음}"
android:textAlignment="center" />
Expand Down
Loading
Loading