Skip to content
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 @@ -3,6 +3,7 @@ package com.eatssu.android.presentation.cafeteria.menu
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -45,11 +46,19 @@ class MenuAdapter(
binding.tvCafeteriaLocation.text =
binding.root.context.getString(sectionModel.cafeteria.locationResId)

val menuList = sectionModel.menuList.orEmpty()
val hasMenu = menuList.isNotEmpty()

binding.rvMenu.isVisible = hasMenu
binding.tvClosedMessage.isVisible = !hasMenu

binding.rvMenu.apply {
setHasFixedSize(true)
layoutManager = LinearLayoutManager(binding.root.context)
adapter = sectionModel.menuList?.let {
MenuSubAdapter(it, sectionModel.cafeteria, analyticsTracker)
adapter = if (hasMenu) {
MenuSubAdapter(menuList, sectionModel.cafeteria, analyticsTracker)
} else {
null
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,9 @@ class MenuFragment : Fragment() {
val menuMap = state.data.menuMap
Timber.d("Menu map received: $menuMap")

val sectionList = buildList {
menuMap
.filter { (_, menuList) -> menuList.isNotEmpty() }
.forEach { (restaurant, menuList) ->
val location =
infoViewModel.getRestaurantInfo(restaurant)?.location ?: ""
add(
Section(
restaurant.menuType,
restaurant,
menuList,
location
)
)
}
}.sortedBy { it.cafeteria.ordinal }
val sectionList = buildMenuSections(menuMap) { restaurant ->
infoViewModel.getRestaurantInfo(restaurant)?.location.orEmpty()
}

setupRecyclerView(sectionList)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.eatssu.android.presentation.cafeteria.menu

import com.eatssu.android.domain.model.Menu
import com.eatssu.android.domain.model.Section
import com.eatssu.common.enums.Restaurant

internal suspend fun buildMenuSections(
menuMap: Map<Restaurant, List<Menu>>,
locationProvider: suspend (Restaurant) -> String,
): List<Section> = buildList {
for ((restaurant, menuList) in menuMap) {
add(
Section(
menuType = restaurant.menuType,
cafeteria = restaurant,
menuList = menuList,
cafeteriaLocation = locationProvider(restaurant),
)
)
}
}.sortedBy { it.cafeteria.ordinal }
14 changes: 13 additions & 1 deletion app/src/main/res/layout/item_cafeteria_section.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,20 @@
android:layout_marginTop="11dp"
android:layout_marginBottom="18dp"
tools:listitem="@layout/item_menu" />

<TextView
android:id="@+id/tv_closed_message"
style="@style/Body3"
android:layout_width="match_parent"
android:layout_height="64dp"
android:gravity="center"
android:includeFontPadding="false"
android:text="@string/cafeteria_outside_business_hours"
android:textColor="@color/black"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<!-- Menu/Restaurant Related -->
<!-- ========================== -->
<string name="today_menu">Today\'s Menu</string>
<string name="cafeteria_outside_business_hours">It\'s outside business hours.</string>
<string name="price">Price</string>
<string name="rate">★</string>
<string name="student_cafeteria">Student Cafeteria</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<!-- Menu/Restaurant Related -->
<!-- ========================== -->
<string name="today_menu">今日のメニュー</string>
<string name="cafeteria_outside_business_hours">営業時間外です。</string>
<string name="price">価格</string>
<string name="rate">★</string>
<string name="student_cafeteria">学生食堂</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<!-- Menu/Restaurant Related -->
<!-- ========================== -->
<string name="today_menu">Thực đơn hôm nay</string>
<string name="cafeteria_outside_business_hours">Hiện đang ngoài giờ phục vụ.</string>
<string name="price">Giá</string>
<string name="rate">★</string>
<string name="student_cafeteria">Nhà ăn sinh viên</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<!-- Menu/Restaurant Related -->
<!-- ========================== -->
<string name="today_menu">오늘의 메뉴</string>
<string name="cafeteria_outside_business_hours">영업 시간이 아니에요.</string>
<string name="price">가격</string>
<string name="rate">평점</string>
<string name="student_cafeteria">학생식당</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.eatssu.android.presentation.cafeteria.menu

import com.eatssu.android.domain.model.Menu
import com.eatssu.android.test.AppBehaviorSpec
import com.eatssu.common.enums.Restaurant
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.test.runTest

class MenuSectionBuilderBehaviorSpec : AppBehaviorSpec({

given("식당별 메뉴 섹션 구성") {
`when`("메뉴가 비어 있는 식당이 포함되면") {
val menu = Menu(id = 1, name = "오늘의 메뉴", price = 5_000, rate = 4.0)
val menuMap = linkedMapOf(
Restaurant.DODAM to emptyList(),
Restaurant.HAKSIK to listOf(menu),
)

then("빈 식당을 제거하지 않고 식당 순서대로 구성한다") {
runTest {
val sections = buildMenuSections(menuMap) { restaurant ->
"${restaurant.name} 위치"
}

sections.map { it.cafeteria } shouldBe listOf(
Restaurant.HAKSIK,
Restaurant.DODAM,
)
sections.first { it.cafeteria == Restaurant.HAKSIK }.menuList shouldBe listOf(menu)
sections.first { it.cafeteria == Restaurant.DODAM }.menuList shouldBe emptyList()
sections.first { it.cafeteria == Restaurant.DODAM }.cafeteriaLocation shouldBe
"DODAM 위치"
}
}
}
}
})
4 changes: 4 additions & 0 deletions language.csv
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ none_review_my,첫 리뷰를 남겨 주세요!,Be the first to leave a review!,
none_review_list_detail,메뉴에 가장 먼저 리뷰를 남겨주세요!,Be the first to review this menu item!,このメニューに最初のレビューを残しましょう!,Hãy là người đầu tiên đánh giá món này!
rate_n,%1$d점,%1$d pts,%1$d点,%1$d điểm
today_menu,오늘의 메뉴,Today's Menu,今日のメニュー,Thực đơn hôm nay
cafeteria_outside_business_hours,영업 시간이 아니에요.,It's outside business hours.,営業時間外です。,Hiện đang ngoài giờ phục vụ.
price,가격,Price,価格,Giá
rate,평점,★,★,★
student_cafeteria,학생식당,Student Cafeteria,学生食堂,Nhà ăn sinh viên
Expand Down Expand Up @@ -163,6 +164,9 @@ time,영업 시간,Hours,営業時間,Giờ mở cửa
favorite_partnership,찜한 제휴,Favorite Partners,お気に入りの提携,Ưu đãi yêu thích
partnership_filter_mine,내 제휴,My Partners,自分の提携,Ưu đãi của tôi
partnership_filter_all,전체,All,すべて,Tất cả
partnership_filter_restaurant,음식점,Restaurant,レストラン,Nhà hàng
partnership_filter_cafe,카페,Cafe,カフェ,Quán cà phê
partnership_filter_pub,주점,Pub,居酒屋,Quán rượu
partnership_filter_department_placeholder,학과,Department,学科,Ngành/Khoa
policy_url,https://github.com/EAT-SSU/Docs/wiki/EAT%E2%80%90SSU-%EA%B0%9C%EC%9D%B8%EC%A0%95%EB%B3%B4%EC%B2%98%EB%A6%AC%EB%B0%A9%EC%B9%A8,,,
terms_url,https://github.com/EAT-SSU/Docs/wiki/EAT%E2%80%90SSU-%EC%84%9C%EB%B9%84%EC%8A%A4-%EC%9D%B4%EC%9A%A9%EC%95%BD%EA%B4%80,,,
Expand Down
Loading