Skip to content

Commit

Permalink
#212 Add dining status chip
Browse files Browse the repository at this point in the history
  • Loading branch information
wateralsie committed Apr 8, 2024
1 parent b2f6dc9 commit 0c9c1f3
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -185,5 +186,25 @@ class MainActivity : KoinNavigationDrawerActivity() {
).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
}
}
}
}
}
5 changes: 5 additions & 0 deletions koin/src/main/res/drawable/dining_changed_fill_radius_4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/dining_changed_background"/>
<corners android:radius="4dp"/>
</shape>
5 changes: 5 additions & 0 deletions koin/src/main/res/drawable/dining_soldout_fill_radius_4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/dining_soldout_background"/>
<corners android:radius="4dp"/>
</shape>
18 changes: 11 additions & 7 deletions koin/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,25 @@
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_constraintEnd_toStartOf="@id/text_view_card_dining_time"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/text_view_card_dining_time"
android:id="@+id/text_view_dining_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginTop="17dp"
android:layout_marginEnd="16dp"
android:text="아침"
android:textColor="@color/black"
android:textSize="13sp"
android:includeFontPadding="false"
android:paddingHorizontal="8dp"
android:paddingVertical="4dp"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="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"
Expand Down
6 changes: 6 additions & 0 deletions koin/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- dining sold out -->
<color name="dining_soldout_text">#FFAD0D</color>
<color name="dining_soldout_background">#FFF7E1</color>
<!-- dining changed -->
<color name="dining_changed_text">#4B4B4B</color>
<color name="dining_changed_background">#EEEEEE</color>
</resources>
2 changes: 2 additions & 0 deletions koin/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@
<string name="dining_western">양식</string>
<string name="dining_nungsu">능수관</string>
<string name="dining_non_upload">학교에서 식단이 업로드 되지 않았습니다.</string>
<string name="dining_soldout">품절</string>
<string name="dining_changed">변경됨</string>
<string name="bus_app_bar_title">버스 / 교통</string>
<string name="bus_tab_info">운행정보</string>
<string name="bus_tab_search_info">운행 정보 검색</string>
Expand Down

0 comments on commit 0c9c1f3

Please sign in to comment.