Skip to content

Commit

Permalink
#212 Add dining tab
Browse files Browse the repository at this point in the history
  • Loading branch information
wateralsie committed Apr 16, 2024
1 parent 8571f2e commit 380f69a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import `in`.koreatech.koin.domain.util.ext.typeFilter

object DiningUtil {
private val diningEndTime = listOf("09:00", "13:30", "18:30", "23:59")
val diningPlace = listOf("A코너", "B코너", "C코너", "능수관" )

fun typeFiltering(diningList: List<Dining>, type: DiningType): List<Dining> =
diningList.typeFilter(type).arrange()
Expand Down
100 changes: 52 additions & 48 deletions koin/src/main/java/in/koreatech/koin/ui/main/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,22 @@ class MainActivity : KoinNavigationDrawerActivity() {
adapter = storeCategoryRecyclerAdapter
}

recyclerViewDiningType.apply {
layoutManager =
LinearLayoutManager(this@MainActivity, RecyclerView.HORIZONTAL, false)
adapter = diningTypeAdapter
}
// recyclerViewDiningType.apply {
// layoutManager =
// LinearLayoutManager(this@MainActivity, RecyclerView.HORIZONTAL, false)
// adapter = diningTypeAdapter
// }

mainSwipeRefreshLayout.setOnRefreshListener {
mainActivityViewModel.updateDining()
}

diningContainer.setOnClickListener {
callDrawerItem(R.id.navi_item_dining)
// diningContainer.setOnClickListener {
// callDrawerItem(R.id.navi_item_dining)
// }

DiningUtil.diningPlace.forEach { place ->
tabDining.addTab(tabDining.newTab().setText(place))
}
}

Expand Down Expand Up @@ -165,46 +169,46 @@ class MainActivity : KoinNavigationDrawerActivity() {
}
)

if (list.isEmpty() || position >= diningArranged.size) {
binding.viewEmptyDining.emptyDiningListFrameLayout.isVisible = true
return
}

binding.viewEmptyDining.emptyDiningListFrameLayout.isVisible = false

listOf(
binding.textViewCardDiningMenu0,
binding.textViewCardDiningMenu2,
binding.textViewCardDiningMenu4,
binding.textViewCardDiningMenu6,
binding.textViewCardDiningMenu8,
binding.textViewCardDiningMenu1,
binding.textViewCardDiningMenu3,
binding.textViewCardDiningMenu5,
binding.textViewCardDiningMenu7,
binding.textViewCardDiningMenu9
).zip(diningArranged[position].menu).forEach { (textView, menu) ->
textView.text = menu
}

val isSoldOut = diningArranged[position].soldoutAt.isNotEmpty()
val isChanged = diningArranged[position].changedAt.isNotEmpty()
with (binding.textViewDiningStatus) {
when {
isSoldOut -> {
text = context.getString(R.string.dining_soldout)
setTextColor(ContextCompat.getColor(context, R.color.dining_soldout_text))
background = ContextCompat.getDrawable(context, R.drawable.dining_soldout_fill_radius_4)
}
isChanged -> {
text = context.getString(R.string.dining_changed)
setTextColor(ContextCompat.getColor(context, R.color.dining_changed_text))
background = ContextCompat.getDrawable(context, R.drawable.dining_changed_fill_radius_4)
}
else -> {
visibility = View.INVISIBLE
}
}
}
// if (list.isEmpty() || position >= diningArranged.size) {
// binding.viewEmptyDining.emptyDiningListFrameLayout.isVisible = true
// return
// }

// binding.viewEmptyDining.emptyDiningListFrameLayout.isVisible = false
//
// listOf(
// binding.textViewCardDiningMenu0,
// binding.textViewCardDiningMenu2,
// binding.textViewCardDiningMenu4,
// binding.textViewCardDiningMenu6,
// binding.textViewCardDiningMenu8,
// binding.textViewCardDiningMenu1,
// binding.textViewCardDiningMenu3,
// binding.textViewCardDiningMenu5,
// binding.textViewCardDiningMenu7,
// binding.textViewCardDiningMenu9
// ).zip(diningArranged[position].menu).forEach { (textView, menu) ->
// textView.text = menu
// }

// val isSoldOut = diningArranged[position].soldoutAt.isNotEmpty()
// val isChanged = diningArranged[position].changedAt.isNotEmpty()
// with (binding.textViewDiningStatus) {
// when {
// isSoldOut -> {
// text = context.getString(R.string.dining_soldout)
// setTextColor(ContextCompat.getColor(context, R.color.dining_soldout_text))
// background = ContextCompat.getDrawable(context, R.drawable.dining_soldout_fill_radius_4)
// }
// isChanged -> {
// text = context.getString(R.string.dining_changed)
// setTextColor(ContextCompat.getColor(context, R.color.dining_changed_text))
// background = ContextCompat.getDrawable(context, R.drawable.dining_changed_fill_radius_4)
// }
// else -> {
// visibility = View.INVISIBLE
// }
// }
// }
}
}
214 changes: 9 additions & 205 deletions koin/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,215 +151,19 @@

</androidx.constraintlayout.widget.ConstraintLayout>

<com.google.android.material.card.MaterialCardView
android:id="@+id/dining_container"
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_dining"
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:elevation="@dimen/normal_card_elevation"
app:cardCornerRadius="0dp">
android:layout_marginHorizontal="24dp"
app:tabMode="scrollable" />

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_dining_type"
android:layout_width="0dp"
android:layout_height="52dp"
android:paddingStart="16dp"
android:paddingEnd="48dp"
app:layout_constraintEnd_toStartOf="@id/text_view_dining_status"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/text_view_dining_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="17dp"
android:layout_marginEnd="16dp"
android:includeFontPadding="false"
android:paddingHorizontal="8dp"
android:paddingVertical="4dp"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:background="@drawable/dining_soldout_fill_radius_4"
tools:text="@string/dining_soldout"
tools:textColor="@color/dining_soldout_text" />

<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="33dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="33dp"
android:layout_marginBottom="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<TableRow android:paddingBottom="4dp">

<TextView
android:id="@+id/text_view_card_dining_menu_0"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴1" />

<TextView
android:id="@+id/text_view_card_dining_menu_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴2" />

</TableRow>

<TableRow android:paddingBottom="4dp">

<TextView
android:id="@+id/text_view_card_dining_menu_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴3" />

<TextView
android:id="@+id/text_view_card_dining_menu_3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴4" />

</TableRow>

<TableRow android:paddingBottom="4dp">

<TextView
android:id="@+id/text_view_card_dining_menu_4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴5" />

<TextView
android:id="@+id/text_view_card_dining_menu_5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴6" />

</TableRow>

<TableRow android:paddingBottom="4dp">

<TextView
android:id="@+id/text_view_card_dining_menu_6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴7" />

<TextView
android:id="@+id/text_view_card_dining_menu_7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴8" />

</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="4dp">

<TextView
android:id="@+id/text_view_card_dining_menu_8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="메뉴9" />

<TextView
android:id="@+id/text_view_card_dining_menu_9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black"
android:textSize="12sp"
tools:text="까르보나라민트초코파맛첵스파게티" />

</TableRow>

</TableLayout>

<include
android:id="@+id/view_empty_dining"
layout="@layout/dining_view_empty"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recycler_view_dining_type"
tools:visibility="invisible" />

</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E1E1E1" />

</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
Expand Down

0 comments on commit 380f69a

Please sign in to comment.