Skip to content

Commit

Permalink
[FEAT/#423] 프로필 수정 재확인 다이얼로그 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchbreeze committed Mar 3, 2024
1 parent c9d313c commit 9296079
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.el.yello.presentation.main.profile.schoolmod

import android.content.res.Resources
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.fragment.app.activityViewModels
import com.el.yello.R
import com.el.yello.databinding.FragmentProfileModDialogBinding
import com.example.ui.base.BindingDialogFragment
import com.example.ui.extension.setOnSingleClickListener
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class SchoolModDialog :
BindingDialogFragment<FragmentProfileModDialogBinding>(R.layout.fragment_profile_mod_dialog) {

private val viewModel by activityViewModels<SchoolProfileModViewModel>()

override fun onStart() {
super.onStart()
setDialogBackground()
}

private fun setDialogBackground() {
val deviceWidth = Resources.getSystem().displayMetrics.widthPixels
val dialogHorizontalMargin = (Resources.getSystem().displayMetrics.density * 16) * 2

dialog?.window?.apply {
setLayout(
(deviceWidth - dialogHorizontalMargin * 2).toInt(),
WindowManager.LayoutParams.WRAP_CONTENT,
)
setBackgroundDrawableResource(R.color.transparent)
}
dialog?.setCanceledOnTouchOutside(false)
dialog?.setCancelable(true)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

initModBtnListener()
initRejectBtnListener()
}

private fun initRejectBtnListener() {
binding.btnProfileDialogReject.setOnSingleClickListener { dismiss() }
}

private fun initModBtnListener() {
binding.btnProfileDialogMod.setOnSingleClickListener {
viewModel.getSchoolGroupIdFromServer()
dismiss()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import com.el.yello.R
import com.el.yello.databinding.ActivityProfileSchoolModBinding
import com.el.yello.presentation.main.profile.detail.ProfileDetailActivity
import com.el.yello.presentation.main.profile.detail.ProfileDetailActivity.Companion.RESULT_PROFILE_MODIFY_FAILURE
import com.el.yello.presentation.main.profile.univmod.UnivProfileModViewModel.Companion.TEXT_NONE
import com.el.yello.presentation.main.profile.univmod.UnivProfileModActivity
import com.el.yello.presentation.main.profile.univmod.UnivProfileModViewModel.Companion.TEXT_NONE
import com.el.yello.util.extension.yelloSnackbar
import com.example.ui.extension.navigateTo
import com.example.ui.base.BindingActivity
import com.example.ui.extension.drawableOf
import com.example.ui.state.UiState
import com.example.ui.extension.navigateTo
import com.example.ui.extension.setOnSingleClickListener
import com.example.ui.state.UiState
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -33,6 +33,7 @@ class SchoolProfileModActivity :
private var schoolModSearchBottomSheet: SchoolModSearchBottomSheet? = null
private var schoolModGradeBottomSheet: SchoolModGradeBottomSheet? = null
private var schoolModClassroomBottomSheet: SchoolModClassroomBottomSheet? = null
private var schoolModDialog: SchoolModDialog? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -86,7 +87,8 @@ class SchoolProfileModActivity :
}

else -> {
viewModel.getSchoolGroupIdFromServer()
schoolModDialog = SchoolModDialog()
schoolModDialog?.show(supportFragmentManager, DIALOG_MOD)
}
}
}
Expand Down Expand Up @@ -196,11 +198,13 @@ class SchoolProfileModActivity :
if (schoolModSearchBottomSheet != null) schoolModSearchBottomSheet?.dismiss()
if (schoolModGradeBottomSheet != null) schoolModGradeBottomSheet?.dismiss()
if (schoolModClassroomBottomSheet != null) schoolModClassroomBottomSheet?.dismiss()
if (schoolModDialog != null) schoolModDialog?.dismiss()
}

private companion object {
const val DIALOG_SCHOOL = "school"
const val DIALOG_GRADE = "grade"
const val DIALOG_CLASSROOM = "classroom"
const val DIALOG_MOD = "mod"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.el.yello.presentation.main.profile.univmod

import android.content.res.Resources
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.fragment.app.activityViewModels
import com.el.yello.R
import com.el.yello.databinding.FragmentProfileModDialogBinding
import com.example.ui.base.BindingDialogFragment
import com.example.ui.extension.setOnSingleClickListener
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class UnivModDialog :
BindingDialogFragment<FragmentProfileModDialogBinding>(R.layout.fragment_profile_mod_dialog) {

private val viewModel by activityViewModels<UnivProfileModViewModel>()

override fun onStart() {
super.onStart()
setDialogBackground()
}

private fun setDialogBackground() {
val deviceWidth = Resources.getSystem().displayMetrics.widthPixels
val dialogHorizontalMargin = (Resources.getSystem().displayMetrics.density * 16) * 2

dialog?.window?.apply {
setLayout(
(deviceWidth - dialogHorizontalMargin * 2).toInt(),
WindowManager.LayoutParams.WRAP_CONTENT,
)
setBackgroundDrawableResource(R.color.transparent)
}
dialog?.setCanceledOnTouchOutside(false)
dialog?.setCancelable(true)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

initModBtnListener()
initRejectBtnListener()
}

private fun initRejectBtnListener() {
binding.btnProfileDialogReject.setOnSingleClickListener { dismiss() }
}

private fun initModBtnListener() {
binding.btnProfileDialogMod.setOnSingleClickListener {
viewModel.postNewProfileToServer()
dismiss()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import com.el.yello.presentation.main.profile.detail.ProfileDetailActivity.Compa
import com.el.yello.presentation.main.profile.schoolmod.SchoolProfileModActivity
import com.el.yello.presentation.main.profile.univmod.UnivProfileModViewModel.Companion.TEXT_NONE
import com.el.yello.util.extension.yelloSnackbar
import com.example.ui.extension.navigateTo
import com.example.ui.base.BindingActivity
import com.example.ui.extension.drawableOf
import com.example.ui.state.UiState
import com.example.ui.extension.navigateTo
import com.example.ui.extension.setOnSingleClickListener
import com.example.ui.state.UiState
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -32,6 +32,7 @@ class UnivProfileModActivity :

private var univModSearchBottomSheet: UnivModSearchBottomSheet? = null
private var univModSelectBottomSheet: UnivModSelectBottomSheet? = null
private var univModDialog: UnivModDialog? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -77,7 +78,8 @@ class UnivProfileModActivity :
}

else -> {
viewModel.postNewProfileToServer()
univModDialog = UnivModDialog()
univModDialog?.show(supportFragmentManager, DIALOG_MOD)
}
}
}
Expand Down Expand Up @@ -161,11 +163,13 @@ class UnivProfileModActivity :
super.onDestroy()
if (univModSearchBottomSheet != null) univModSearchBottomSheet?.dismiss()
if (univModSelectBottomSheet != null) univModSelectBottomSheet?.dismiss()
if (univModDialog != null) univModDialog?.dismiss()
}

private companion object {
const val DIALOG_SCHOOL = "school"
const val DIALOG_SUBGROUP = "subgroup"
const val DIALOG_YEAR = "year"
const val DIALOG_MOD = "mod"
}
}
68 changes: 68 additions & 0 deletions app/src/main/res/layout/fragment_profile_mod_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?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"
android:layout_gravity="center">

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="40dp"
android:background="@drawable/shape_grayscales900_fill_8_rect"
android:paddingBottom="26dp">

<TextView
android:id="@+id/tv_profile_dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:gravity="center"
android:lineSpacingMultiplier="1.5"
android:text="@string/profile_mod_dialog_tv_title"
android:textAppearance="?textAppearanceSubtitle2"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/btn_profile_dialog_reject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="27dp"
android:layout_marginTop="24dp"
android:gravity="center"
android:paddingVertical="8dp"
android:paddingEnd="14dp"
android:text="@string/profile_dialog_btn_no"
android:textAppearance="?textAppearanceButton"
android:textColor="@color/grayscales_600"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btn_profile_dialog_mod"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_profile_dialog_title" />

<TextView
android:id="@+id/btn_profile_dialog_mod"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:layout_marginEnd="27dp"
android:gravity="center"
android:paddingVertical="8dp"
android:text="@string/profile_mod_dialog_tv_yes"
android:textAppearance="?textAppearanceButton"
android:textColor="@color/yello_main_500"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/btn_profile_dialog_reject"
app:layout_constraintTop_toTopOf="@id/btn_profile_dialog_reject" />

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
103 changes: 52 additions & 51 deletions app/src/main/res/layout/fragment_profile_quit_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,61 @@

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="40dp"
android:background="@drawable/shape_grayscales900_fill_8_rect"
android:paddingBottom="26dp">

<TextView
android:id="@+id/tv_profile_dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="@string/profile_dialog_tv_title"
android:textAppearance="?textAppearanceSubtitle2"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_profile_dialog_title"
android:layout_marginTop="24dp"
android:layout_marginHorizontal="34dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="40dp"
android:background="@drawable/shape_grayscales900_fill_8_rect"
android:paddingBottom="26dp">

<TextView
android:id="@+id/btn_profile_dialog_reject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="3dp"
android:text="@string/profile_dialog_btn_no"
android:textAppearance="?textAppearanceButton"
android:textColor="@color/grayscales_600"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_profile_dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="@string/profile_dialog_tv_title"
android:textAppearance="?textAppearanceSubtitle2"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/btn_profile_dialog_quit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="3dp"
android:text="@string/profile_dialog_btn_yes"
android:textAppearance="?textAppearanceButton"
android:textColor="@color/semantic_red_500"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/btn_profile_dialog_reject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="27dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="7dp"
android:paddingEnd="14dp"
android:gravity="center"
android:paddingVertical="8dp"
android:text="@string/profile_dialog_btn_no"
android:textAppearance="?textAppearanceButton"
android:textColor="@color/grayscales_600"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btn_profile_dialog_quit"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_profile_dialog_title" />

</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/btn_profile_dialog_quit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:layout_marginEnd="27dp"
android:gravity="center"
android:paddingVertical="8dp"
android:text="@string/profile_dialog_btn_yes"
android:textAppearance="?textAppearanceButton"
android:textColor="@color/semantic_red_500"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/btn_profile_dialog_reject"
app:layout_constraintTop_toTopOf="@id/btn_profile_dialog_reject" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
Loading

0 comments on commit 9296079

Please sign in to comment.