Skip to content

Commit 5e70d1f

Browse files
committed
#212 Add dining status chip
1 parent e930e32 commit 5e70d1f

File tree

6 files changed

+50
-7
lines changed

6 files changed

+50
-7
lines changed

koin/src/main/java/in/koreatech/koin/ui/main/activity/MainActivity.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import android.os.Bundle
2424
import android.view.View
2525
import android.view.WindowManager
2626
import androidx.activity.viewModels
27+
import androidx.core.content.ContextCompat
2728
import androidx.core.view.isVisible
2829
import androidx.recyclerview.widget.LinearLayoutManager
2930
import androidx.recyclerview.widget.RecyclerView
@@ -185,5 +186,25 @@ class MainActivity : KoinNavigationDrawerActivity() {
185186
).zip(diningArranged[position].menu).forEach { (textView, menu) ->
186187
textView.text = menu
187188
}
189+
190+
val isSoldOut = diningArranged[position].soldoutAt.isNotEmpty()
191+
val isChanged = diningArranged[position].changedAt.isNotEmpty()
192+
with (binding.textViewDiningStatus) {
193+
when {
194+
isSoldOut -> {
195+
text = context.getString(R.string.dining_soldout)
196+
setTextColor(ContextCompat.getColor(context, R.color.dining_soldout_text))
197+
background = ContextCompat.getDrawable(context, R.drawable.dining_soldout_fill_radius_4)
198+
}
199+
isChanged -> {
200+
text = context.getString(R.string.dining_changed)
201+
setTextColor(ContextCompat.getColor(context, R.color.dining_changed_text))
202+
background = ContextCompat.getDrawable(context, R.drawable.dining_changed_fill_radius_4)
203+
}
204+
else -> {
205+
visibility = View.INVISIBLE
206+
}
207+
}
208+
}
188209
}
189210
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<solid android:color="@color/dining_changed_background"/>
4+
<corners android:radius="4dp"/>
5+
</shape>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<solid android:color="@color/dining_soldout_background"/>
4+
<corners android:radius="4dp"/>
5+
</shape>

koin/src/main/res/layout/activity_main.xml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,25 @@
182182
android:layout_height="52dp"
183183
android:paddingStart="16dp"
184184
android:paddingEnd="48dp"
185+
app:layout_constraintEnd_toStartOf="@id/text_view_dining_status"
185186
app:layout_constraintStart_toStartOf="parent"
186-
app:layout_constraintEnd_toStartOf="@id/text_view_card_dining_time"
187187
app:layout_constraintTop_toTopOf="parent" />
188188

189189
<TextView
190-
android:id="@+id/text_view_card_dining_time"
190+
android:id="@+id/text_view_dining_status"
191191
android:layout_width="wrap_content"
192192
android:layout_height="wrap_content"
193-
android:layout_marginTop="18dp"
193+
android:layout_marginTop="17dp"
194194
android:layout_marginEnd="16dp"
195-
android:text="아침"
196-
android:textColor="@color/black"
197-
android:textSize="13sp"
195+
android:includeFontPadding="false"
196+
android:paddingHorizontal="8dp"
197+
android:paddingVertical="4dp"
198+
android:textSize="12sp"
198199
app:layout_constraintEnd_toEndOf="parent"
199-
app:layout_constraintTop_toTopOf="parent" />
200+
app:layout_constraintTop_toTopOf="parent"
201+
tools:background="@drawable/dining_soldout_fill_radius_4"
202+
tools:text="@string/dining_soldout"
203+
tools:textColor="@color/dining_soldout_text" />
200204

201205
<TableLayout
202206
android:layout_width="0dp"

koin/src/main/res/values/colors.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<!-- dining sold out -->
4+
<color name="dining_soldout_text">#FFAD0D</color>
5+
<color name="dining_soldout_background">#FFF7E1</color>
6+
<!-- dining changed -->
7+
<color name="dining_changed_text">#4B4B4B</color>
8+
<color name="dining_changed_background">#EEEEEE</color>
39
</resources>

koin/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@
232232
<string name="dining_western">양식</string>
233233
<string name="dining_nungsu">능수관</string>
234234
<string name="dining_non_upload">학교에서 식단이 업로드 되지 않았습니다.</string>
235+
<string name="dining_soldout">품절</string>
236+
<string name="dining_changed">변경됨</string>
235237
<string name="bus_app_bar_title">버스 / 교통</string>
236238
<string name="bus_tab_info">운행정보</string>
237239
<string name="bus_tab_search_info">운행 정보 검색</string>

0 commit comments

Comments
 (0)