-
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.
- 타이틀과 하단 버튼만을 구성하고 있는 CustomContentDialogFragment 추가 - 각종 레이아웃 및 drawable 추가 - 테마로 중복코드 해소
- Loading branch information
Showing
11 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -59,6 +59,9 @@ android { | |
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
buildFeatures { | ||
viewBinding true | ||
} | ||
} | ||
|
||
dependencies { | ||
|
82 changes: 82 additions & 0 deletions
82
app/src/main/java/com/moyerun/moyeorun_android/common/dialog/CustomContentDialogFragment.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,82 @@ | ||
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.R | ||
import com.moyerun.moyeorun_android.common.extension.getStringFromArgument | ||
import com.moyerun.moyeorun_android.common.extension.putStringToArgument | ||
import com.moyerun.moyeorun_android.databinding.DialogCustomContentBinding | ||
|
||
abstract class CustomContentDialogFragment : BaseDialogFragment() { | ||
|
||
final override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
return DialogCustomContentBinding.inflate(inflater, container, false).apply { | ||
contentCustomDialog.addView( | ||
onCreateContentView( | ||
inflater, | ||
contentCustomDialog, | ||
savedInstanceState | ||
) | ||
) | ||
}.root | ||
} | ||
|
||
final override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
val binding = DialogCustomContentBinding.bind(view) | ||
binding.headerTextDialog.textDialogHeader.text = getStringFromArgument(ARG_TITLE) | ||
with(binding.footerTextDialog) { | ||
buttonNegativeDialogFooter.text = | ||
getStringFromArgument(ARG_LABEL_NEGATIVE, getString(R.string.cancel)) | ||
buttonPositiveDialogFooter.text = | ||
getStringFromArgument(ARG_LABEL_POSITIVE, getString(R.string.ok)) | ||
|
||
buttonNegativeDialogFooter.setOnClickListener { | ||
onNegativeClick() | ||
dismissAllowingStateLoss() | ||
} | ||
|
||
buttonPositiveDialogFooter.setOnClickListener { | ||
onPositiveClick() | ||
dismissAllowingStateLoss() | ||
} | ||
} | ||
onContentViewCreated(view, savedInstanceState) | ||
} | ||
|
||
abstract fun onCreateContentView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View | ||
|
||
abstract fun onContentViewCreated(view: View, savedInstanceState: Bundle?) | ||
|
||
protected open fun onPositiveClick() { } | ||
|
||
protected open fun onNegativeClick() { } | ||
|
||
protected fun setTitle(title: String?) { | ||
putStringToArgument(ARG_TITLE, title) | ||
} | ||
|
||
protected fun setPositiveLabel(label: String?) { | ||
putStringToArgument(ARG_LABEL_POSITIVE, label) | ||
} | ||
|
||
protected fun setNegativeLabel(label: String?) { | ||
putStringToArgument(ARG_LABEL_NEGATIVE, label) | ||
} | ||
|
||
companion object { | ||
private const val ARG_TITLE = "title" | ||
private const val ARG_LABEL_NEGATIVE = "negativeLabel" | ||
private const val ARG_LABEL_POSITIVE = "positiveLabel" | ||
} | ||
} |
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!--Todo: 스타일 처리--> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item> | ||
<shape android:shape="rectangle"> | ||
<corners android:radius="12dp" /> | ||
<solid android:color="#ffffff" /> | ||
</shape> | ||
</item> | ||
</layer-list> |
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!--Todo: 컬러 스타일 처리--> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item> | ||
<shape android:shape="rectangle"> | ||
<corners android:radius="4dp" /> | ||
<solid android:color="#ffffff" /> | ||
</shape> | ||
</item> | ||
</layer-list> |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item> | ||
<shape android:shape="rectangle"> | ||
<stroke | ||
android:width="1dp" | ||
android:color="#BDBEC1" /> | ||
<corners android:radius="4dp" /> | ||
<solid android:color="#ffffff" /> | ||
</shape> | ||
</item> | ||
</layer-list> |
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,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
style="@style/Dialog.Background" | ||
android:orientation="vertical"> | ||
|
||
<include | ||
android:id="@+id/header_text_dialog" | ||
layout="@layout/dialog_header_text" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
<View style="@style/Dialog.Divider" /> | ||
|
||
<!-- 커스텀 컨텐츠가 들어올 레이아웃 --> | ||
<FrameLayout | ||
android:id="@+id/content_custom_dialog" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
<include | ||
android:id="@+id/footer_text_dialog" | ||
layout="@layout/dialog_footer_two_button" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
</LinearLayout> | ||
|
||
</FrameLayout> |
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="horizontal" | ||
android:paddingHorizontal="@dimen/padding_dialog_common" | ||
android:paddingBottom="@dimen/padding_dialog_common"> | ||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/button_negative_dialog_footer" | ||
style="@style/Dialog.Button.Negative" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="4.5dp" | ||
android:layout_weight="1" | ||
tools:text="Negative" /> | ||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/button_positive_dialog_footer" | ||
style="@style/Dialog.Button.Positive" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="4.5dp" | ||
android:layout_weight="1" | ||
tools:text="Positive" /> | ||
|
||
</LinearLayout> |
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="21dp"> | ||
|
||
<TextView | ||
android:id="@+id/text_dialog_header" | ||
style="@style/Dialog.Title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
tools:text="다이얼로그 제목" /> | ||
|
||
</FrameLayout> |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<dimen name="padding_dialog_common">17dp</dimen> | ||
</resources> |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
<resources> | ||
<string name="app_name">MoyeoRun-android</string> | ||
|
||
<!-- common string --> | ||
<string name="cancel">취소</string> | ||
<string name="ok">확인</string> | ||
|
||
</resources> |
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