-
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.
- Content 로 텍스트만을 보여주는 TextConfirmDialogFragment 추가 - Fragment 를 띄우기 위한 확장함수 추가
- Loading branch information
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/moyerun/moyeorun_android/common/dialog/TextConfirmDialogFragment.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,60 @@ | ||
package com.moyerun.moyeorun_android.common.dialog | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.moyerun.moyeorun_android.common.extension.getStringFromArgument | ||
import com.moyerun.moyeorun_android.common.extension.putStringToArgument | ||
import com.moyerun.moyeorun_android.databinding.DialogContentTextBinding | ||
|
||
class TextConfirmDialogFragment : CustomContentDialogFragment() { | ||
|
||
private var onPositiveClick: () -> Unit = {} | ||
private var onNegativeClick: () -> Unit = {} | ||
|
||
override fun onCreateContentView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
return DialogContentTextBinding.inflate(inflater, container, false).root | ||
} | ||
|
||
override fun onContentViewCreated(view: View, savedInstanceState: Bundle?) { | ||
val binding = DialogContentTextBinding.bind(view) | ||
binding.textDialogContent.text = getStringFromArgument(ARG_CONTENT) | ||
} | ||
|
||
override fun onPositiveClick() { | ||
onPositiveClick.invoke() | ||
} | ||
|
||
override fun onNegativeClick() { | ||
onNegativeClick.invoke() | ||
} | ||
|
||
companion object { | ||
private const val ARG_CONTENT = "content" | ||
|
||
fun newInstance( | ||
title: String, | ||
content: String, | ||
positiveLabel: String? = null, | ||
negativeLabel: String? = null, | ||
dismissOnPause: Boolean = false, | ||
isCancelable: Boolean = false, | ||
onPositiveClick: () -> Unit = {}, | ||
onNegativeClick: () -> Unit = {} | ||
): TextConfirmDialogFragment = TextConfirmDialogFragment().apply { | ||
putStringToArgument(ARG_CONTENT, content) | ||
setTitle(title) | ||
setPositiveLabel(positiveLabel) | ||
setNegativeLabel(negativeLabel) | ||
setDismissOnPause(dismissOnPause) | ||
this.isCancelable = isCancelable | ||
this.onPositiveClick = onPositiveClick | ||
this.onNegativeClick = onNegativeClick | ||
} | ||
} | ||
} |
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
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
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingHorizontal="@dimen/padding_dialog_common" | ||
android:paddingVertical="23dp"> | ||
|
||
<TextView | ||
android:id="@+id/text_dialog_content" | ||
style="@style/Dialog.Content" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
tools:text="텍스트" /> | ||
|
||
</FrameLayout> |