From 00e8e7a575b313cff4d7e83d39e0fc9fa4dfdd57 Mon Sep 17 00:00:00 2001 From: Sangho Kim Date: Fri, 9 Jun 2023 15:28:02 +0900 Subject: [PATCH] =?UTF-8?q?#11=20/=20[ADD]=20BindingDialogFragment=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/util/base/BindingDialogFragment.kt | 43 +++++++++++++++++++ app/src/main/res/layout/activity_sign_up.xml | 1 - app/src/main/res/values/colors.xml | 2 + 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/org/android/go/sopt/util/base/BindingDialogFragment.kt diff --git a/app/src/main/java/org/android/go/sopt/util/base/BindingDialogFragment.kt b/app/src/main/java/org/android/go/sopt/util/base/BindingDialogFragment.kt new file mode 100644 index 0000000..68641d0 --- /dev/null +++ b/app/src/main/java/org/android/go/sopt/util/base/BindingDialogFragment.kt @@ -0,0 +1,43 @@ +package org.android.go.sopt.util.base + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.view.WindowManager +import androidx.annotation.LayoutRes +import androidx.databinding.DataBindingUtil +import androidx.databinding.ViewDataBinding +import androidx.fragment.app.DialogFragment +import org.android.go.sopt.R + +abstract class BindingDialogFragment(@LayoutRes private val layoutRes: Int) : + DialogFragment() { + private var _binding: B? = null + val binding get() = requireNotNull(_binding!!) { "${this::class.java.simpleName}에서 에러가 발생했습니다." } + + override fun onStart() { + super.onStart() + dialog?.window?.apply { + setLayout( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.WRAP_CONTENT, + ) + setBackgroundDrawableResource(R.color.transparent) + } + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle?, + ): View { + _binding = DataBindingUtil.inflate(inflater, layoutRes, container, false) + return binding.root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_sign_up.xml b/app/src/main/res/layout/activity_sign_up.xml index 8c8707c..9a2985e 100644 --- a/app/src/main/res/layout/activity_sign_up.xml +++ b/app/src/main/res/layout/activity_sign_up.xml @@ -3,7 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> - #64ffda #1de9b6 #00bfa5 + + #00FFFFFF \ No newline at end of file