Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

메인화면 식단 영역 리뉴얼 #218

Merged
merged 8 commits into from
Apr 10, 2024
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 @@ -15,10 +15,8 @@ fun DiningResponse.toDining() = Dining(
this.imageUrl ?: "",
this.createdAt,
this.updatedAt,
this.isSoldOut,
// TODO: sold_out 품절 시각으로 변경시 대응
// this.soldOutAt ?: ""
this.isChanged,
this.soldoutAt ?: "",
this.changedAt ?: "",
this.error ?: ""
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ data class DiningResponse(
@SerializedName("image_url") val imageUrl: String?,
@SerializedName("created_at") val createdAt: String,
@SerializedName("updated_at") val updatedAt: String,
@SerializedName("sold_out") val isSoldOut: Boolean,
// TODO: sold_out 품절 시각으로 변경시 대응
// @SerializedName("sold_out") val soldOutAt: String?,
@SerializedName("is_changed") val isChanged: Boolean,
@SerializedName("soldout_at") val soldoutAt: String?,
@SerializedName("changed_at") val changedAt: String?,
@SerializedName("error") val error: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ fun DiningType.localized(context: Context) = when(this) {
DiningType.Breakfast -> context.getString(R.string.dining_breakfast)
DiningType.Lunch -> context.getString(R.string.dining_lunch)
DiningType.Dinner -> context.getString(R.string.dining_dinner)
DiningType.NextBreakfast -> context.getString(R.string.dining_next_breakfast)
}
1 change: 1 addition & 0 deletions data/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@
<string name="dining_breakfast">아침</string>
<string name="dining_lunch">점심</string>
<string name="dining_dinner">저녁</string>
<string name="dining_next_breakfast">내일 아침</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ data class Dining(
val imageUrl: String,
val createdAt: String,
val updatedAt: String,
val isSoldOut: Boolean,
// TODO: sold_out 품절 시각으로 변경시 대응
// val soldOutAt: String,
val isChanged: Boolean,
val soldoutAt: String,
val changedAt: String,
val error: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ enum class DiningType(
) {
Breakfast (BREAKFAST, "아침"),
Lunch (LUNCH, "점심"),
Dinner (DINNER, "저녁");
Dinner (DINNER, "저녁"),
NextBreakfast (BREAKFAST, "내일 아침");
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@ import `in`.koreatech.koin.domain.util.ext.arrange
import `in`.koreatech.koin.domain.util.ext.typeFilter

object DiningUtil {
private val diningEndTime = listOf("09:00", "13:30", "18:30")
private val diningEndTime = listOf("09:00", "13:30", "18:30", "23:59")

fun typeFiltering(diningList: List<Dining>, type: DiningType): List<Dining> =
diningList.typeFilter(type).arrange()

fun getCurrentType() = if (TimeUtil.compareWithCurrentTime(diningEndTime[0]) >= 0) {
DiningType.Breakfast
} else if (TimeUtil.compareWithCurrentTime(diningEndTime[1]) >= 0) {
DiningType.Lunch
} else if (TimeUtil.compareWithCurrentTime(diningEndTime[2]) >= 0) {
DiningType.Dinner
} else {
DiningType.Breakfast
fun getCurrentType(): DiningType {
var currentType = DiningType.Breakfast
diningEndTime.forEachIndexed { index, time ->
if (TimeUtil.compareWithCurrentTime(time) >= 0) {
currentType = when (index) {
0 -> DiningType.Breakfast
1 -> DiningType.Lunch
2 -> DiningType.Dinner
3 -> DiningType.NextBreakfast
else -> DiningType.Breakfast
}
return currentType
}
}
return currentType
}

fun isNextDay() = TimeUtil.compareWithCurrentTime(diningEndTime[2]) < 0
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
org.gradle.jvmargs=-Xmx1536m \
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

#Enable daemon
org.gradle.daemon=true
Expand All @@ -22,7 +25,6 @@ org.gradle.parallel=true
org.gradle.configureondemand=true



# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class DiningActivity : KoinNavigationDrawerActivity() {
DiningType.Breakfast -> tabsDiningTime.selectTab(tabsDiningTime.getTabAt(0))
DiningType.Lunch -> tabsDiningTime.selectTab(tabsDiningTime.getTabAt(1))
DiningType.Dinner -> tabsDiningTime.selectTab(tabsDiningTime.getTabAt(2))
DiningType.NextBreakfast -> tabsDiningTime.selectTab(tabsDiningTime.getTabAt(0))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ class DiningAdapter : ListAdapter<Dining, RecyclerView.ViewHolder>(diffCallback)
}
}

if(dining.isSoldOut) {
if(dining.soldoutAt.isNotEmpty()) {
groupSoldOut.visibility = View.VISIBLE
textViewDiningSoldOut.visibility = View.VISIBLE
} else {
groupSoldOut.visibility = View.INVISIBLE
textViewDiningSoldOut.visibility = View.INVISIBLE
}

if(dining.isChanged) {
if(dining.changedAt.isNotEmpty()) {
textViewDiningChanged.visibility = View.VISIBLE
} else {
textViewDiningChanged.visibility = View.INVISIBLE
Expand Down
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 @@ -134,7 +135,7 @@ class MainActivity : KoinNavigationDrawerActivity() {
}

observeLiveData(selectedType) {
binding.textViewCardDiningTime.text = it.localized(this@MainActivity)
binding.textViewDiningTime.text = it.localized(this@MainActivity)
}

observeLiveData(busTimer) {
Expand Down Expand Up @@ -173,17 +174,37 @@ class MainActivity : KoinNavigationDrawerActivity() {

listOf(
binding.textViewCardDiningMenu0,
binding.textViewCardDiningMenu1,
binding.textViewCardDiningMenu2,
binding.textViewCardDiningMenu3,
binding.textViewCardDiningMenu4,
binding.textViewCardDiningMenu5,
binding.textViewCardDiningMenu6,
binding.textViewCardDiningMenu7,
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
}
}
}
}
}
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>
Loading