Skip to content

Commit

Permalink
[feat/#51] 쿠폰 아이템 모델 재구현, 쿠폰 아이템 재구현
Browse files Browse the repository at this point in the history
  • Loading branch information
NaZe0320 committed Feb 9, 2024
1 parent 77b36dd commit b471420
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ dependencies {
implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.12")

//ktx
implementation ("androidx.activity:activity-ktx:1.8.2")
implementation ("androidx.fragment:fragment-ktx:1.6.2")
implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
implementation ("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation ("androidx.collection:collection-ktx:1.4.0")
implementation ("androidx.navigation:navigation-runtime-ktx:2.7.6")
implementation ("androidx.navigation:navigation-fragment-ktx:2.7.6")
implementation ("androidx.navigation:navigation-ui-ktx:2.7.6")
implementation ("androidx.activity:activity-ktx:1.8.2")
implementation ("androidx.fragment:fragment-ktx:1.6.2")
implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
implementation ("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation ("androidx.collection:collection-ktx:1.4.0")
implementation ("androidx.navigation:navigation-runtime-ktx:2.7.6")
implementation ("androidx.navigation:navigation-fragment-ktx:2.7.6")
implementation ("androidx.navigation:navigation-ui-ktx:2.7.6")

//Glide
implementation ("com.github.bumptech.glide:glide:4.11.0")
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/umc/coumo/domain/model/CouponModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import android.net.Uri
data class CouponModel(
val name: String,
val stampCount: Int,
val color: String,
val stampMax: Int,
val color: String = "#FFDA26",
val fontColor: String = "#535043",
val stampMax: Int = 10,
val stampImage: Uri?,
) {
}
27 changes: 27 additions & 0 deletions app/src/main/java/com/umc/coumo/utils/BindingAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.umc.coumo.utils

import android.content.res.ColorStateList
import android.graphics.Color
import android.net.Uri
import android.text.Spannable
import android.text.SpannableString
Expand Down Expand Up @@ -91,4 +93,29 @@ fun TextView.setHighlightedText(fullText: String?) {

text = spannableString
}
}

@BindingAdapter("app:dynamicBackgroundColor")
fun setDynamicBackgroundColor(view:View, color: String?) {
view.backgroundTintList = if (color != null && isValidColorCode(color)) {
val parsedColor = Color.parseColor(color)
ColorStateList.valueOf(parsedColor)
} else {
ColorStateList.valueOf(Color.parseColor("#FFDA26"))
}
}

@BindingAdapter("app:dynamicTextColor")
fun TextView.setDynamicTextColor(color: String?) {
if (color != null && isValidColorCode(color)) {
val parseColor = Color.parseColor(color)
setTextColor(parseColor)
} else {
setTextColor(Color.parseColor("#535043"))
}
}

private fun isValidColorCode(color: String): Boolean {
val regex = "^#[0-9A-Fa-f]{6}$"
return color.matches(regex.toRegex())
}
Binary file added app/src/main/res/font/modak_400.ttf
Binary file not shown.
42 changes: 34 additions & 8 deletions app/src/main/res/layout/item_coupon.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>
<variable
Expand Down Expand Up @@ -35,15 +36,40 @@
app:layout_constraintBaseline_toBaselineOf="@id/tv_coupon_title"
app:layout_constraintStart_toEndOf="@id/tv_coupon_title"/>

<androidx.constraintlayout.utils.widget.ImageFilterView
android:id="@+id/iv_coupon"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:src="@drawable/coupon"
app:layout_constraintTop_toBottomOf="@id/tv_coupon_title"
app:layout_constraintStart_toStartOf="parent"/>
android:background="@drawable/shape_rect_round_6"
android:paddingTop="28dp"
app:dynamicBackgroundColor="@{item.color}"
tools:backgroundTint="#FFDA26"
app:layout_constraintDimensionRatio="308:180"
app:layout_constraintTop_toBottomOf="@id/tv_coupon_title">

<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{item.name}"
android:textSize="22sp"
android:fontFamily="@font/modak_400"
app:dynamicTextColor="@{item.fontColor}"
tools:text="COFFEE SHOP"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_stamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>


</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

0 comments on commit b471420

Please sign in to comment.