generated from NOW-SOPT-ANDROID/now-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a74bb8
commit d6bfa77
Showing
8 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
core/designsystem/src/main/java/org/sopt/designsystem/dialog/AlertDialogFragment.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,78 @@ | ||
package org.sopt.designsystem.dialog | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import org.sopt.designsystem.databinding.FragmentAlertDialogBinding | ||
import org.sopt.ui.base.BindingDialogFragment | ||
|
||
class AlertDialogFragment : BindingDialogFragment<FragmentAlertDialogBinding>({ FragmentAlertDialogBinding.inflate(it)}) { | ||
private var handleNegativeButton: (() -> Unit)? = null | ||
private var handlePositiveButton: (() -> Unit)? = null | ||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
dialog?.setCanceledOnTouchOutside(false) | ||
|
||
val title = arguments?.getString(ARG_TITLE) | ||
val negativeButtonLabel = arguments?.getString(ARG_NEGATIVE_BUTTON_LABEL) | ||
val positiveButtonLabel = arguments?.getString(ARG_POSITIVE_BUTTON_LABEL) | ||
|
||
if (title != null && negativeButtonLabel != null && positiveButtonLabel != null) { | ||
initDialogText(title, positiveButtonLabel, negativeButtonLabel) | ||
} | ||
|
||
initNegativeButtonClickListener(handleNegativeButton) | ||
initPositiveButtonClickListener(handlePositiveButton) | ||
} | ||
|
||
private fun initDialogText( | ||
title: String, | ||
positiveButtonLabel: String, | ||
negativeButtonLabel: String | ||
) { | ||
binding.tvAlertFragmentTitle.text = title | ||
binding.tvAlertFragmentPositive.text = positiveButtonLabel | ||
binding.tvAlertFragmentNegative.text = negativeButtonLabel | ||
} | ||
|
||
private fun initNegativeButtonClickListener(handleNegativeButton: (() -> Unit)?) { | ||
binding.tvAlertFragmentNegative.setOnClickListener { | ||
handleNegativeButton?.invoke() | ||
dismiss() | ||
} | ||
} | ||
|
||
private fun initPositiveButtonClickListener(handlePositiveButton: (() -> Unit)?) { | ||
binding.tvAlertFragmentPositive.setOnClickListener { | ||
handlePositiveButton?.invoke() | ||
dismiss() | ||
} | ||
} | ||
|
||
companion object { | ||
private const val ARG_TITLE = "title" | ||
private const val ARG_NEGATIVE_BUTTON_LABEL = "negativeButtonLabel" | ||
private const val ARG_POSITIVE_BUTTON_LABEL = "positiveButtonLabel" | ||
|
||
fun newInstance( | ||
title: String, | ||
negativeButtonLabel: String, | ||
positiveButtonLabel: String, | ||
handleNegativeButton: () -> Unit, | ||
handlePositiveButton: () -> Unit | ||
): AlertDialogFragment { | ||
val args = Bundle() | ||
args.putString(ARG_TITLE, title) | ||
args.putString(ARG_NEGATIVE_BUTTON_LABEL, negativeButtonLabel) | ||
args.putString(ARG_POSITIVE_BUTTON_LABEL, positiveButtonLabel) | ||
|
||
val fragment = AlertDialogFragment() | ||
fragment.arguments = args | ||
|
||
fragment.handleNegativeButton = handleNegativeButton | ||
fragment.handlePositiveButton = handlePositiveButton | ||
|
||
return fragment | ||
} | ||
} | ||
} |
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,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/> | ||
|
||
</vector> |
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,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@android:color/white" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> | ||
|
||
</vector> |
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,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@android:color/white" android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/> | ||
|
||
</vector> |
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,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@android:color/white" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/> | ||
|
||
</vector> |
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,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/> | ||
|
||
</vector> |
11 changes: 11 additions & 0 deletions
11
core/designsystem/src/main/res/drawable/shape_gray_line_50_rect.xml
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<stroke | ||
android:width="5dp" | ||
android:color="?colorSurfaceVariant" /> | ||
|
||
<corners android:radius="50dp" /> | ||
|
||
</shape> |
53 changes: 53 additions & 0 deletions
53
core/designsystem/src/main/res/layout/fragment_alert_dialog.xml
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,53 @@ | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
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" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:id="@+id/tv_alert_fragment_title" | ||
android:layout_width="250dp" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:layout_margin="20dp" | ||
android:textSize="20dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="정말로 삭제하시겠습니까?" /> | ||
|
||
<Button | ||
android:id="@+id/tv_alert_fragment_positive" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="30dp" | ||
android:layout_marginEnd="20dp" | ||
android:backgroundTint="?colorPrimary" | ||
android:textSize="14dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_alert_fragment_title" | ||
app:layout_constraintBottom_toTopOf="@id/v_alert_fragment" | ||
tools:text="삭제" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_alert_fragment_negative" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="20dp" | ||
android:textSize="14dp" | ||
app:layout_constraintBottom_toBottomOf="@id/tv_alert_fragment_positive" | ||
app:layout_constraintEnd_toStartOf="@id/tv_alert_fragment_positive" | ||
app:layout_constraintTop_toTopOf="@id/tv_alert_fragment_positive" | ||
tools:text="아니요" /> | ||
|
||
<View | ||
android:id="@+id/v_alert_fragment" | ||
android:layout_width="0dp" | ||
android:layout_height="10dp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" /> | ||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |