Skip to content

Commit

Permalink
[feat/#110] SpotSnackBar bottom padding 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Jokwanhee committed Aug 24, 2024
1 parent d51594b commit 8ecb2db
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@ package com.dpm.designsystem

import android.graphics.Paint
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import androidx.core.content.ContextCompat
import com.depromeet.designsystem.R
import com.depromeet.designsystem.databinding.SpotSnackbarBinding
import com.dpm.designsystem.extension.dpToPx
import com.google.android.material.snackbar.Snackbar


class SpotSnackBar(
view: View,
private val snackBarBackground: Int,
private val message: String,
private val marginBottom: Int,
private val endMessage: String,
private val onClick: () -> Unit
) {
companion object {
fun make(view: View, background: Int = R.drawable.rect_transfer_black_03_fill_60, message: String = "", endMessage: String = "", onClick: () -> Unit) =
SpotSnackBar(view = view, snackBarBackground = background, message= message, endMessage = endMessage, onClick = onClick)
fun make(view: View, background: Int = R.drawable.rect_transfer_black_03_fill_60, marginBottom: Int = 0, message: String = "", endMessage: String = "", onClick: () -> Unit) =
SpotSnackBar(view = view, snackBarBackground = background, marginBottom = marginBottom, message= message, endMessage = endMessage, onClick = onClick)
}

private val context = view.context
Expand All @@ -34,14 +38,24 @@ class SpotSnackBar(
private fun initView() {
with(snackbarLayout) {
removeAllViews()
setPadding(0, 0, 0, 0)
setBackgroundResource(snackBarBackground)
setPadding(0, 0, 0, marginBottom.dpToPx(context))
setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent))
addView(snackbarBinding.root, 0)

setOnTouchListener { v, event ->
if (event.action == MotionEvent.ACTION_UP) {
v.performClick()
true
} else {
false
}
}
}
with(snackbarBinding) {
tvDescription.text = message
tvTrigger.paintFlags = Paint.UNDERLINE_TEXT_FLAG
tvTrigger.text = endMessage
clContainer.setBackgroundResource(snackBarBackground)
}
}

Expand Down
58 changes: 34 additions & 24 deletions core/designsystem/src/main/res/layout/spot_snackbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,44 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:background="@drawable/rect_transfer_black_03_fill_60">
android:background="@android:color/transparent">

<TextView
android:id="@+id/tv_description"
android:layout_width="wrap_content"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingVertical="19dp"
android:paddingStart="16dp"
android:textAppearance="@style/TextAppearance.Spot.Label08"
android:textColor="@color/color_foreground_white"
app:layout_constraintEnd_toStartOf="@id/tv_trigger"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="아직 잠실야구장만 이용할 수 있어요!" />
tools:background="@drawable/rect_transfer_black_03_fill_60">

<TextView
android:id="@+id/tv_trigger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="19dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextAppearance.Spot.Label08"
android:textColor="@color/color_foreground_white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@id/tv_description"
app:layout_constraintTop_toTopOf="parent"
tools:text="잠실야구장 시야보기" />
<TextView
android:id="@+id/tv_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="19dp"
android:paddingStart="16dp"
android:textAppearance="@style/TextAppearance.Spot.Label08"
android:textColor="@color/color_foreground_white"
app:layout_constraintEnd_toStartOf="@id/tv_trigger"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="아직 잠실야구장만 이용할 수 있어요!" />

<TextView
android:id="@+id/tv_trigger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="19dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextAppearance.Spot.Label08"
android:textColor="@color/color_foreground_white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@id/tv_description"
app:layout_constraintTop_toTopOf="parent"
tools:text="잠실야구장 시야보기" />
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class StadiumDetailPictureFragment : BindingFragment<FragmentStadiumDetailPictur
}

private fun initEvent() {
binding.root.setOnClickListener {
return@setOnClickListener
}
onBackPressed()
setOnClickSpotAppbar()
}
Expand Down Expand Up @@ -120,10 +123,10 @@ class StadiumDetailPictureFragment : BindingFragment<FragmentStadiumDetailPictur

private fun initSnackBar() {
snackBar = SpotSnackBar.make(
binding.root.rootView,
com.depromeet.designsystem.R.drawable.rect_body_subtitle_fill_60,
getString(R.string.viewfinder_snackbar_scrap),
getString(R.string.viewfinder_underscore_snackbar_scrap),
view = binding.root.rootView,
background = com.depromeet.designsystem.R.drawable.rect_body_subtitle_fill_60,
message = getString(R.string.viewfinder_snackbar_scrap),
endMessage = getString(R.string.viewfinder_underscore_snackbar_scrap),
onClick = {
// TODO : 스크랩 화면으로 이동
})
Expand Down

0 comments on commit 8ecb2db

Please sign in to comment.