From e5b45919541bc5b40e09e42212e35eb1c51467f0 Mon Sep 17 00:00:00 2001 From: juhwankim-dev Date: Tue, 13 Dec 2022 02:11:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?ui:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EA=B0=80?= =?UTF-8?q?=20=EC=9E=88=EB=8A=94=20=EC=8A=A4=EB=82=B5=EB=B0=94=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/util/ThreeDaysImageSnackBar.kt | 45 +++++++++++ .../res/layout/image_snackbar_three_days.xml | 77 +++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt create mode 100644 core/src/main/res/layout/image_snackbar_three_days.xml diff --git a/core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt b/core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt new file mode 100644 index 00000000..252655f2 --- /dev/null +++ b/core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt @@ -0,0 +1,45 @@ +package com.depromeet.threedays.core.util + +import android.view.Gravity +import android.view.LayoutInflater +import android.view.View +import android.widget.FrameLayout +import androidx.core.content.ContextCompat +import com.depromeet.threedays.core.databinding.ImageSnackbarThreeDaysBinding +import com.depromeet.threedays.core.setOnSingleClickListener +import com.google.android.material.snackbar.Snackbar + +class ThreeDaysImageSnackBar { + fun show( + view: View, + title: String, + content: String, + actionText: String, + onAction: () -> Unit + ) { + val binding = ImageSnackbarThreeDaysBinding.inflate(LayoutInflater.from(view.context), null, false) + val snackbar = Snackbar.make(view, title, 5000) + val snackbarLayout = snackbar.view as Snackbar.SnackbarLayout + + with(snackbarLayout) { + removeAllViews() + setPadding(0, 0, 0, 0) + setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)) + addView(binding.root, 0) + + val params = layoutParams as FrameLayout.LayoutParams + params.gravity = Gravity.TOP + layoutParams = params + } + + binding.tvTitle.text = title + binding.tvContent.text = content + binding.tvActionButton.text = actionText + binding.tvActionButton.setOnSingleClickListener { + onAction() + snackbar.dismiss() + } + + snackbar.show() + } +} diff --git a/core/src/main/res/layout/image_snackbar_three_days.xml b/core/src/main/res/layout/image_snackbar_three_days.xml new file mode 100644 index 00000000..18a92ba1 --- /dev/null +++ b/core/src/main/res/layout/image_snackbar_three_days.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + From f2cf04da34c15142af2b3a76d48a74929773ccd9 Mon Sep 17 00:00:00 2001 From: juhwankim-dev Date: Fri, 16 Dec 2022 00:50:59 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20lint=20=EC=9D=B4=EC=8A=88=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt b/core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt index 252655f2..0ce84f4e 100644 --- a/core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt +++ b/core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt @@ -29,7 +29,6 @@ class ThreeDaysImageSnackBar { val params = layoutParams as FrameLayout.LayoutParams params.gravity = Gravity.TOP - layoutParams = params } binding.tvTitle.text = title