-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
core/src/main/java/com/depromeet/threedays/core/util/ThreeDaysImageSnackBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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 | ||
} | ||
|
||
binding.tvTitle.text = title | ||
binding.tvContent.text = content | ||
binding.tvActionButton.text = actionText | ||
binding.tvActionButton.setOnSingleClickListener { | ||
onAction() | ||
snackbar.dismiss() | ||
} | ||
|
||
snackbar.show() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?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:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:background="@android:color/transparent" | ||
tools:ignore="ContentDescription"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="6dp" | ||
android:background="@drawable/bg_rect_gray700_r15" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent"> | ||
|
||
<ImageView | ||
android:id="@+id/iv_illustrator" | ||
android:layout_width="61dp" | ||
android:layout_height="61dp" | ||
android:layout_marginVertical="14dp" | ||
android:layout_marginStart="14dp" | ||
android:src="@drawable/bg_rect_gray100_r10" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="12dp" | ||
android:layout_marginBottom="4dp" | ||
android:textAppearance="@style/Typography.SubTitle" | ||
android:textColor="@color/gray_500" | ||
android:textSize="14dp" | ||
app:layout_constraintBottom_toTopOf="@+id/tv_content" | ||
app:layout_constraintStart_toEndOf="@+id/iv_illustrator" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_chainStyle="packed" | ||
tools:text="레벨 업" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_content" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textAppearance="@style/Typography.Body1" | ||
android:textColor="@color/white" | ||
android:textSize="14dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="@+id/tv_title" | ||
app:layout_constraintTop_toBottomOf="@+id/tv_title" | ||
tools:text="Lv.2 로 레벨업 했어요!" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_action_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="12dp" | ||
android:padding="12dp" | ||
android:textAppearance="@style/Typography.Body4.SemiBold" | ||
android:textColor="@color/blue_50" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="이동" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |