Skip to content

Commit

Permalink
[Redesign] change home design (#198)
Browse files Browse the repository at this point in the history
* redesign: calendar

* redesign: item_cafeteria_section.xml

* fix: top 여백을 fragment에서 item으로 변경

* feat: 장소 바인딩
  • Loading branch information
HI-JIN2 authored Aug 21, 2024
1 parent 2af86dc commit d2188b7
Show file tree
Hide file tree
Showing 20 changed files with 268 additions and 254 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/eatssu/android/data/model/Section.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ data class Section(
val menuType: MenuType,
val cafeteria: Restaurant,
val menuList: List<Menu>?,
val cafeteriaLocation: String
// val sortOrder: Int
)
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
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
import com.eatssu.android.databinding.ItemCalendarListBinding
import com.eatssu.android.util.CalendarUtils
import java.time.LocalDate
import java.time.format.TextStyle
import java.util.*
import java.util.Locale


internal class CalendarAdapter(
Expand All @@ -34,17 +32,16 @@ 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) {
holder.parentView.setBackgroundResource(R.drawable.selector_background_blue)
//날짜
holder.dayOfMonth.setBackgroundResource(R.drawable.selector_background_blue)
holder.dayOfMonth.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.selector_calendar_colortext))
holder.dayText.setTextColor(ContextCompat.getColor(holder.itemView.context, R.color.selector_calendar_colortext))
}
else {
holder.parentView.setBackgroundResource(R.drawable.ic_selector_background_white)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.eatssu.android.data.model.Section
import com.eatssu.android.databinding.ItemSectionBinding
import com.eatssu.android.databinding.ItemCafeteriaSectionBinding
import com.eatssu.android.ui.info.InfoActivity

class MenuAdapter(
Expand All @@ -16,7 +16,7 @@ class MenuAdapter(
) : RecyclerView.Adapter<MenuAdapter.MyViewHolder>() {

class MyViewHolder(
private val binding: ItemSectionBinding
private val binding: ItemCafeteriaSectionBinding
) : RecyclerView.ViewHolder(binding.root) {

fun bind(sectionModel: Section) {
Expand All @@ -28,6 +28,8 @@ class MenuAdapter(
}

binding.tvCafeteria.text = sectionModel.cafeteria.displayName
binding.tvCafeteriaLocation.text = sectionModel.cafeteriaLocation

binding.rvMenu.apply {
setHasFixedSize(true)
layoutManager = LinearLayoutManager(binding.root.context)
Expand All @@ -39,7 +41,8 @@ class MenuAdapter(
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
return MyViewHolder(ItemSectionBinding.inflate(
return MyViewHolder(
ItemCafeteriaSectionBinding.inflate(
LayoutInflater.from(parent.context),
parent, false))
}
Expand Down
30 changes: 25 additions & 5 deletions app/src/main/java/com/eatssu/android/ui/main/menu/MenuFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ import com.eatssu.android.data.enums.MenuType
import com.eatssu.android.data.enums.Restaurant
import com.eatssu.android.data.enums.Time
import com.eatssu.android.data.model.Section
import com.eatssu.android.data.repository.FirebaseRemoteConfigRepository
import com.eatssu.android.data.service.MealService
import com.eatssu.android.data.service.MenuService
import com.eatssu.android.databinding.FragmentMenuBinding
import com.eatssu.android.ui.info.InfoViewModel
import com.eatssu.android.ui.info.InfoViewModelFactory
import com.eatssu.android.ui.main.calendar.CalendarViewModel
import com.eatssu.android.util.RetrofitImpl
import java.time.DayOfWeek
Expand All @@ -38,6 +41,7 @@ class MenuFragment : Fragment() {
private lateinit var mealService: MealService

private lateinit var menuDate: String
private lateinit var cafeteriaLocation: String

val foodCourtDataLoaded = MutableLiveData<Boolean>()
val snackCornerDataLoaded = MutableLiveData<Boolean>()
Expand All @@ -47,6 +51,10 @@ class MenuFragment : Fragment() {

private val totalMenuList = ArrayList<Section>()

private lateinit var infoViewModel: InfoViewModel
private lateinit var restaurantType: Restaurant
private lateinit var firebaseRemoteConfigRepository: FirebaseRemoteConfigRepository


companion object {
fun newInstance(time: Time): MenuFragment {
Expand All @@ -67,6 +75,13 @@ class MenuFragment : Fragment() {
savedInstanceState: Bundle?,
): View {
_binding = FragmentMenuBinding.inflate(inflater, container, false)

firebaseRemoteConfigRepository = FirebaseRemoteConfigRepository()
infoViewModel = ViewModelProvider(
this,
InfoViewModelFactory(firebaseRemoteConfigRepository)
)[InfoViewModel::class.java]

return binding.root
}

Expand Down Expand Up @@ -129,7 +144,8 @@ class MenuFragment : Fragment() {
Section(
MenuType.FIXED,
Restaurant.FOOD_COURT,
result.mapFixedMenuResponseToMenu()
result.mapFixedMenuResponseToMenu(),
infoViewModel.foodLocation.value.toString()
)
)
}
Expand All @@ -146,7 +162,8 @@ class MenuFragment : Fragment() {
Section(
MenuType.FIXED,
Restaurant.SNACK_CORNER,
result.mapFixedMenuResponseToMenu()
result.mapFixedMenuResponseToMenu(),
infoViewModel.snackLocation.value.toString()
)
)
}
Expand Down Expand Up @@ -180,7 +197,8 @@ class MenuFragment : Fragment() {
Section(
MenuType.VARIABLE,
Restaurant.HAKSIK,
result.mapTodayMenuResponseToMenu()
result.mapTodayMenuResponseToMenu(),
infoViewModel.haksikLocation.value.toString()
)
)

Expand All @@ -198,7 +216,8 @@ class MenuFragment : Fragment() {
Section(
MenuType.VARIABLE,
Restaurant.DODAM,
result.mapTodayMenuResponseToMenu()
result.mapTodayMenuResponseToMenu(),
infoViewModel.dodamLocation.value.toString()
)
)
}
Expand All @@ -214,7 +233,8 @@ class MenuFragment : Fragment() {
Section(
MenuType.VARIABLE,
Restaurant.DORMITORY,
result.mapTodayMenuResponseToMenu()
result.mapTodayMenuResponseToMenu(),
infoViewModel.dormitoryLocation.value.toString()
)
)
}
Expand Down
Binary file removed app/src/main/res/drawable-v24/ic_arrow_left.png
Binary file not shown.
Binary file added app/src/main/res/drawable/ic_arrow_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/ic_arrow_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_info_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_menu_24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/layer_bottom_shadow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<!-- 하단에 그림자 표시 -->
<item>
<shape android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="@android:color/transparent"
android:startColor="#55000000" />
</shape>
</item>

</layer-list>
6 changes: 2 additions & 4 deletions app/src/main/res/drawable/selector_calendar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
<selector android:exitFadeDuration="@android:integer/config_shortAnimTime"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="true"
android:drawable="@drawable/transparent_calendar_element" />
android:drawable="@drawable/shape_transparent_calendar_element" android:state_checked="true" />
<item
android:state_pressed="true"
android:drawable="@drawable/transparent_calendar_element" />
android:drawable="@drawable/shape_transparent_calendar_element" android:state_pressed="true" />
<item android:drawable="@android:color/transparent" />
</selector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/shape_cafeteria_corner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />

<corners
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp" />
</shape>
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/shape_cafeteria_section.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />

<stroke
android:width="1dp"
android:color="@color/gray200" />

<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
</shape>
Loading

0 comments on commit d2188b7

Please sign in to comment.