Skip to content

Commit

Permalink
[FEAT/#66] 이용약관 view 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
seongh06 committed Sep 29, 2024
1 parent f6b60e3 commit c87ed7e
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding>(R.layout.fragment_login
}

private fun navigateToSignupNicknameScreen() {
navigator.navigate(R.id.action_loginFragment_to_signupNicknameFragment)
navigator.navigate(R.id.action_loginFragment_to_signupTosFragment)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package umc.everyones.lck.presentation.login

import android.view.LayoutInflater
import android.view.View
import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import dagger.hilt.android.AndroidEntryPoint
import umc.everyones.lck.R
import umc.everyones.lck.databinding.ActivitiyTestBinding
import umc.everyones.lck.databinding.DialogNicknameConfirmBinding
import umc.everyones.lck.databinding.FragmentSignupSuccessBinding
import umc.everyones.lck.databinding.FragmentSignupTosBinding
import umc.everyones.lck.presentation.base.BaseActivity
import umc.everyones.lck.presentation.base.BaseFragment
import umc.everyones.lck.presentation.test.TestViewModel
import umc.everyones.lck.util.extension.repeatOnStarted
import umc.everyones.lck.util.extension.setOnSingleClickListener

@AndroidEntryPoint
class SignupTosFragment : BaseFragment<FragmentSignupTosBinding>(R.layout.fragment_signup_tos) {
//
private val viewModel: SignupViewModel by activityViewModels()
private val navigator by lazy { findNavController() }

private var isAgree1Checked = false
private var isAgree2Checked = false

override fun initObserver() {

}

override fun initView() {
binding.tvSignupTosDetailsAgree1.setOnClickListener {
// 세부 정보 보기 클릭 시 다이얼로그 표시
showDetailsDialog1()
}

binding.tvSignupTosDetailsAgree2.setOnClickListener {
// 세부 정보 보기 클릭 시 다이얼로그 표시
showDetailsDialog2()
}

binding.ivSignupTosNext.setOnClickListener {
if (!isAgree1Checked || !isAgree2Checked) {
Toast.makeText(requireContext(), "모든 동의 항목을 체크해주세요.", Toast.LENGTH_SHORT).show()
} else {
navigateToSignupNickname()
}
}

binding.viewSignupTosAgreeCircle.setOnClickListener {
toggleAgreement(1)
}

binding.viewSignupTosAgree1Circle.setOnClickListener {
toggleAgreement(2)
}
}

private fun showDetailsDialog1() {
val dialogView =
LayoutInflater.from(requireContext()).inflate(R.layout.dialog_signup_tos_details_agree_1, null)

val dialogBinding = DialogNicknameConfirmBinding.bind(dialogView)

val dialog = AlertDialog.Builder(requireContext())
.setView(dialogView)
.setCancelable(false)
.create()

dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
dialog.show()

val layoutParams = dialog.window?.attributes
layoutParams?.dimAmount = 0.8f
dialog.window?.attributes = layoutParams

dialogBinding.btnConfirm.setOnSingleClickListener {
dialog.dismiss()
toggleAgreement(1)
}
}

private fun showDetailsDialog2() {
val dialogView =
LayoutInflater.from(requireContext()).inflate(R.layout.dialog_signup_tos_details_agree_2, null)

val dialogBinding = DialogNicknameConfirmBinding.bind(dialogView)

val dialog = AlertDialog.Builder(requireContext())
.setView(dialogView)
.setCancelable(false)
.create()

dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
dialog.show()

val layoutParams = dialog.window?.attributes
layoutParams?.dimAmount = 0.8f
dialog.window?.attributes = layoutParams

dialogBinding.btnConfirm.setOnSingleClickListener {
dialog.dismiss()
toggleAgreement(2)
}
}

private fun navigateToSignupNickname() {
navigator.navigate(R.id.action_signupTosFragment_to_signupNicknameFragment)
}

private fun toggleAgreement(agreementNumber: Int) {
if (agreementNumber == 1) {
isAgree1Checked = !isAgree1Checked
updateCircleView(binding.viewSignupTosAgreeCircle, isAgree1Checked)
} else if (agreementNumber == 2) {
isAgree2Checked = !isAgree2Checked
updateCircleView(binding.viewSignupTosAgree1Circle, isAgree2Checked)
}
}

private fun updateCircleView(view: View, isChecked: Boolean) {
view.background = if (isChecked) {
ContextCompat.getDrawable(requireContext(), R.drawable.shape_selected_oval)
} else {
ContextCompat.getDrawable(requireContext(), R.drawable.shape_oval)
}
}
}
16 changes: 16 additions & 0 deletions app/src/main/res/drawable/shape_selected_oval.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="12dp"
android:viewportWidth="12"
android:viewportHeight="12">
<path
android:strokeColor="#FFFFFFFF"
android:strokeWidth="0.8"
android:pathData="M6 0.4A5.6 5.6 0 1 0 6 11.6 5.6 5.6 0 1 0 6 0.4z"/>
<path
android:fillColor="#FFFFFFFF"
android:strokeColor="#FFFFFFFF"
android:strokeWidth="0.8"
android:pathData="M6 2.4A3.6 3.6 0 1 0 6 9.6 3.6 3.6 0 1 0 6 2.4z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
android:layout_width="321dp"
android:layout_height="wrap_content"
android:text=""
style="@style/TextAppearance.LCK.Bold.List_14sp"
style="@style/TextAppearance.LCK.Light.Body_14sp"
android:textColor="@color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/res/navigation/login_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@
android:label="Login"
tools:layout="@layout/fragment_login">
<action
android:id="@+id/action_loginFragment_to_signupNicknameFragment"
app:destination="@id/signupNicknameFragment" />
android:id="@+id/action_loginFragment_to_signupTosFragment"
app:destination="@id/signupTosFragment" />
</fragment>

<fragment
android:id="@+id/signupTosFragment"
android:name="umc.everyones.lck.presentation.login.SignupTosFragment"
android:label="SignupTosFragment"
tools:layout="@layout/fragment_signup_tos">
<action
android:id="@+id/action_signupTosFragment_to_signupNicknameFragment"
app:destination="@id/signupNicknameFragment"/>
</fragment>

<!-- Signup Nickname Fragment -->
Expand Down

0 comments on commit c87ed7e

Please sign in to comment.