Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#20 가족연결 기능 개발 #40

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
android:exported="true"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:theme="@style/Theme.Owori">
android:theme="@style/Theme.Owori"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(R.layou
with(viewModel) {
// TODO : PolicyFragment를 위해 작성한 부분이라 수정 필요.
callKakaoLogin.observe(viewLifecycleOwner) {
navigateTo(R.id.action_loginFragment_to_PolicyFragment)
navigateTo(R.id.action_LoginFragment_to_nickNameFragment)
}

callGoogleLogin.observe(viewLifecycleOwner) {
navigateTo(R.id.action_loginFragment_to_PolicyFragment)
navigateTo(R.id.action_LoginFragment_to_nickNameFragment)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.owori.android.presenter.policy

import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.core.BaseFragment
import com.owori.android.databinding.FragmentAgreeServiceConditionBinding

class AgreeServiceConditionFragment : BaseFragment<FragmentAgreeServiceConditionBinding, AgreeServiceConditionViewModel>(R.layout.fragment_agree_service_condition) {
override val viewModel: AgreeServiceConditionViewModel by viewModels()
override fun setBindingVariables() {
with(binding) {
vm = viewModel
}
}

override fun initView() {

}

override fun initObserver() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.owori.android.presenter.policy

import androidx.lifecycle.LiveData
import com.owori.android.core.BaseViewModel
import com.owori.android.presenter.util.SingleLiveEvent
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class AgreeServiceConditionViewModel @Inject constructor(): BaseViewModel() {
private val _btnNext: SingleLiveEvent<Unit> = SingleLiveEvent()
val btnNext: LiveData<Unit> = _btnNext

fun onClickCheckButton() {
_btnNext.call()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.owori.android.presenter.policy


import android.text.Editable
import android.text.TextWatcher
import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.core.BaseFragment
import com.owori.android.core.navigateTo
import com.owori.android.databinding.FragmentBirthDateBinding


class BirthDateFragment : BaseFragment<FragmentBirthDateBinding, BirthDateViewModel>(R.layout.fragment_birth_date) {
override val viewModel: BirthDateViewModel by viewModels()
override fun setBindingVariables() {
with(binding) {
vm = viewModel
}
}

override fun initView() {
initTextWatcher()
}

override fun initObserver() {
with(viewModel) {
btnNext.observe(viewLifecycleOwner) {
navigateTo(R.id.action_birthDateFragment_to_familyConnectFragment)
}

birthDate.observe(viewLifecycleOwner) {
val verify = it.split("-")
if(verify.size == 3) {
if(verify[0].length == 4 && verify[1].length == 2 && verify[2].length == 2) {
setButtonEnableTrue()
} else {
setButtonEnableFalse()
}
} else {
setButtonEnableFalse()
}
}

btnBack.observe(viewLifecycleOwner) {
requireActivity().onBackPressedDispatcher.onBackPressed()
}
}
}

private fun initTextWatcher() {
binding.birthdateEt.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
var textlength = 0
if(binding.birthdateEt.isFocusable && s.toString() != "") {
try{
textlength = binding.birthdateEt.text.toString().length
}catch (e: NumberFormatException){
e.printStackTrace()
return
}
if (textlength == 4 && before != 1) {
val date = binding.birthdateEt.text.toString()+"-"
binding.birthdateEt.setText(date)
binding.birthdateEt.setSelection(binding.birthdateEt.text.length)

}else if (textlength == 7&& before != 1){
val date = binding.birthdateEt.text.toString()+"-"
binding.birthdateEt.setText(date)
binding.birthdateEt.setSelection(binding.birthdateEt.text.length)

}else if(textlength == 5 && !binding.birthdateEt.text.toString().contains("-") &&
!binding.birthdateEt.text.toString().substring(0,4).contains('-')){
val date = binding.birthdateEt.text.toString().substring(0,4)+"-"+binding.birthdateEt.text.toString().substring(4)
binding.birthdateEt.setText(date)
binding.birthdateEt.setSelection(binding.birthdateEt.text.length)

}else if(textlength == 8 && binding.birthdateEt.text.toString().substring(7,8) != "-" &&
!binding.birthdateEt.text.toString().substring(0,4).contains('-') &&
!binding.birthdateEt.text.toString().substring(5,8).contains('-') &&
!binding.birthdateEt.text.toString().substring(5).contains('-')){
val date = binding.birthdateEt.text.toString().substring(0,7)+"-"+binding.birthdateEt.text.toString().substring(7)
binding.birthdateEt.setText(date)
binding.birthdateEt.setSelection(binding.birthdateEt.text.length)
}
}
}

override fun afterTextChanged(s: Editable?) {
}

})
}

private fun setButtonEnableTrue() {
with(binding.viewpagerButton) {
isEnabled = true
setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
}
}

private fun setButtonEnableFalse() {
with(binding.viewpagerButton) {
isEnabled = false
setTextColor(ContextCompat.getColor(requireContext(), R.color.grey_909090))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.owori.android.presenter.policy

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.owori.android.core.BaseViewModel
import com.owori.android.presenter.util.SingleLiveEvent
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class BirthDateViewModel @Inject constructor(): BaseViewModel() {
private val _btnNext: SingleLiveEvent<Unit> = SingleLiveEvent()
val btnNext: LiveData<Unit> = _btnNext
private val _btnBack: SingleLiveEvent<Unit> = SingleLiveEvent()
val btnBack: LiveData<Unit> = _btnBack

val _birthDate: MutableLiveData<String> = MutableLiveData("")
val birthDate: LiveData<String> = _birthDate

fun onClickCheckButton() {
_btnNext.call()
}

fun onClickBackButton() {
_btnBack.call()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.owori.android.presenter.policy


import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.core.BaseFragment
import com.owori.android.core.navigateTo
import com.owori.android.databinding.FragmentFamilyConnectBinding


class FamilyConnectFragment : Fragment() {
private var _binding: FragmentFamilyConnectBinding? = null
private val binding get() = _binding!!

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentFamilyConnectBinding.inflate(inflater, container, false)
return binding.root
}

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

private fun initView() {
binding.makeCodeButton.setOnClickListener {
navigateTo(R.id.action_familyConnectFragment_to_groupFragment)
}
binding.receivedCodeButton.setOnClickListener {
navigateTo(R.id.action_familyConnectFragment_to_inputFamilyCodeFragment)
}
binding.backButton.setOnClickListener {
requireActivity().onBackPressedDispatcher.onBackPressed()
}
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.owori.android.presenter.policy


import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.core.BaseFragment
import com.owori.android.core.navigateTo
import com.owori.android.databinding.FragmentGroupBinding


class GroupFragment : BaseFragment<FragmentGroupBinding, GroupViewModel>(R.layout.fragment_group) {
override val viewModel: GroupViewModel by viewModels()
override fun setBindingVariables() {
with(binding) {
vm = viewModel
}
}

override fun initView() {

}

override fun initObserver() {
with(viewModel) {
btnNext.observe(viewLifecycleOwner) {
navigateTo(R.id.action_groupFragment_to_shareCodeFragment)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.owori.android.presenter.policy

import androidx.lifecycle.LiveData
import com.owori.android.core.BaseViewModel
import com.owori.android.presenter.util.SingleLiveEvent
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class GroupViewModel @Inject constructor(): BaseViewModel() {
private val _btnNext: SingleLiveEvent<Unit> = SingleLiveEvent()
val btnNext: LiveData<Unit> = _btnNext

fun onClickCheckButton() {
_btnNext.call()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.owori.android.presenter.policy


import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.core.BaseFragment
import com.owori.android.core.navigateTo
import com.owori.android.databinding.FragmentInputFamilyCodeBinding


class InputFamilyCodeFragment : BaseFragment<FragmentInputFamilyCodeBinding, InputFamilyCodeViewModel>(R.layout.fragment_input_family_code) {
override val viewModel: InputFamilyCodeViewModel by viewModels()
override fun setBindingVariables() {
with(binding) {
vm = viewModel
}
}

override fun initView() {

}

override fun initObserver() {
with(viewModel) {
btnNext.observe(viewLifecycleOwner) {
navigateTo(R.id.action_inputFamilyCodeFragment_to_agreeServiceConditionFragment)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.owori.android.presenter.policy

import androidx.lifecycle.LiveData
import com.owori.android.core.BaseViewModel
import com.owori.android.presenter.util.SingleLiveEvent
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class InputFamilyCodeViewModel @Inject constructor(): BaseViewModel() {
private val _btnNext: SingleLiveEvent<Unit> = SingleLiveEvent()
val btnNext: LiveData<Unit> = _btnNext

fun onClickCheckButton() {
_btnNext.call()
}
}
Loading