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/#14 닉네임 입력 화면 개발 #30

Open
wants to merge 7 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
@@ -0,0 +1,24 @@
package com.owori.android.auth.ui.view

import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.auth.ui.viewmodel.NickNameViewModel
import com.owori.android.common.ui.view.BaseFragment
import com.owori.android.databinding.FragmentAgreeServiceConditionBinding

class AgreeServiceConditionFragment : BaseFragment<FragmentAgreeServiceConditionBinding, NickNameViewModel>(R.layout.fragment_agree_service_condition) {
override val viewModel: NickNameViewModel 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,32 @@
package com.owori.android.auth.ui.view


import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.auth.ui.viewmodel.NickNameViewModel
import com.owori.android.common.navigateTo
import com.owori.android.common.ui.view.BaseFragment
import com.owori.android.databinding.FragmentBirthDateBinding


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

override fun initView() {

}

override fun initObserver() {
with(viewModel) {
btnNext.observe(viewLifecycleOwner) {
navigateTo(R.id.action_birthDateFragment_to_familyConnectFragment)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.owori.android.auth.ui.view


import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.auth.ui.viewmodel.NickNameViewModel
import com.owori.android.common.navigateTo
import com.owori.android.common.ui.view.BaseFragment
import com.owori.android.databinding.FragmentFamilyConnectBinding


class FamilyConnectFragment : BaseFragment<FragmentFamilyConnectBinding, NickNameViewModel>(R.layout.fragment_family_connect) {
override val viewModel: NickNameViewModel by viewModels()
override fun setBindingVariables() {
with(binding) {
vm = viewModel
}
}

override fun initView() {

}

override fun initObserver() {
with(viewModel) {
returnLogin.observe(viewLifecycleOwner) {
navigateTo(R.id.action_familyConnectFragment_to_inputFamilyCodeFragment)
}
btnNext.observe(viewLifecycleOwner) {
navigateTo(R.id.action_familyConnectFragment_to_groupFragment)
}
}
}
}
31 changes: 31 additions & 0 deletions app/src/main/java/com/owori/android/auth/ui/view/GroupFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.owori.android.auth.ui.view


import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.auth.ui.viewmodel.NickNameViewModel
import com.owori.android.common.navigateTo
import com.owori.android.common.ui.view.BaseFragment
import com.owori.android.databinding.FragmentGroupBinding


class GroupFragment : BaseFragment<FragmentGroupBinding, NickNameViewModel>(R.layout.fragment_group) {
override val viewModel: NickNameViewModel 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,31 @@
package com.owori.android.auth.ui.view


import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.auth.ui.viewmodel.NickNameViewModel
import com.owori.android.common.navigateTo
import com.owori.android.common.ui.view.BaseFragment
import com.owori.android.databinding.FragmentInputFamilyCodeBinding


class InputFamilyCodeFragment : BaseFragment<FragmentInputFamilyCodeBinding, NickNameViewModel>(R.layout.fragment_input_family_code) {
override val viewModel: NickNameViewModel 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
Expand Up @@ -27,11 +27,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,46 @@
package com.owori.android.auth.ui.view


import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.auth.ui.viewmodel.NickNameViewModel
import com.owori.android.common.navigateTo
import com.owori.android.common.ui.view.BaseFragment
import com.owori.android.databinding.FragmentNickNameBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class NickNameFragment: BaseFragment<FragmentNickNameBinding, NickNameViewModel>(R.layout.fragment_nick_name) {
override val viewModel: NickNameViewModel by viewModels()
override fun setBindingVariables() {
with(binding) {
vm = viewModel
}
}

override fun initView() {

}

override fun initObserver() {
with(viewModel) {
nickname.observe(viewLifecycleOwner) {
binding.viewpagerButton.isEnabled = it.isNotEmpty()
binding.nicknameLength.text = it.length.toString()
if(it.isNotEmpty()) {
binding.viewpagerButton.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
} else {
binding.viewpagerButton.setTextColor(ContextCompat.getColor(requireContext(), R.color.grey_909090))
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

biding이 공통적으로 사용되는 거 같아 보이는데, with(binding)을 사용해 중복되는 단어를 줄여보는 건 어떤가요?? 각 View들의 속성을 설정하는 부분을 따로 메서드로 생성해 가독성을 높이는 것도 좋아 보이네요.

fun setViewPagerButton(nickname: string) {
    with (binding.viewpagerButton) {
        isEnabled = nickname.isNotEmpty()
        if (isEnabled) {
            setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
        } else {
            setTextColor(ContextCompat.getColor(requireContext(), R.color.grey_909090))
        }
    }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with(binding)을 적용해보겠습니다!

}

returnLogin.observe(viewLifecycleOwner) {
requireActivity().onBackPressedDispatcher.onBackPressed()
}
btnNext.observe(viewLifecycleOwner) {
navigateTo(R.id.action_nickNameFragment_to_birthDateFragment)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.owori.android.auth.ui.view


import androidx.fragment.app.viewModels
import com.owori.android.R
import com.owori.android.auth.ui.viewmodel.NickNameViewModel
import com.owori.android.common.navigateTo
import com.owori.android.common.ui.view.BaseFragment
import com.owori.android.databinding.FragmentShareCodeBinding


class ShareCodeFragment : BaseFragment<FragmentShareCodeBinding, NickNameViewModel>(R.layout.fragment_share_code) {
override val viewModel: NickNameViewModel by viewModels()
override fun setBindingVariables() {
with(binding) {
vm = viewModel
}
}

override fun initView() {

}

override fun initObserver() {
with(viewModel) {
btnNext.observe(viewLifecycleOwner) {
navigateTo(R.id.action_shareCodeFragment_to_agreeServiceConditionFragment)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.owori.android.auth.ui.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.owori.android.common.SingleLiveEvent
import com.owori.android.common.ui.viewmodel.BaseViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class NickNameViewModel @Inject constructor() : BaseViewModel() {

val _nickname: MutableLiveData<String> = MutableLiveData("")
val nickname: LiveData<String> = _nickname

private val _returnLogin: SingleLiveEvent<Unit> = SingleLiveEvent()
val returnLogin: LiveData<Unit> = _returnLogin
private val _btnNext: SingleLiveEvent<Unit> = SingleLiveEvent()
val btnNext: LiveData<Unit> = _btnNext

fun onClickCheckButton() {
_btnNext.call()
}

fun onClickBackButton() {
_returnLogin.call()
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/arrow_back.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#000000" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M11.67,3.87L9.9,2.1 0,12l9.9,9.9 1.77,-1.77L3.54,12z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/check_btn_ripple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/white">
<item android:drawable="@drawable/check_btn_selector"/>
</ripple>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/check_btn_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:drawable="@color/owori_red"/>
<item
android:state_enabled="false"
android:drawable="@color/grey_e9e9e9"/>
</selector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/check_text_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:drawable="@color/white"/>
<item
android:state_enabled="false"
android:drawable="@color/grey_909090"/>
</selector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/focused_agree.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
<path
android:pathData="M11,11m-11,0a11,11 0,1 1,22 0a11,11 0,1 1,-22 0"
android:fillColor="#FA7B53"/>
<path
android:pathData="M10.994,15.117C9.389,15.117 8.182,14.133 8.123,12.785H9.377C9.447,13.512 10.139,14.039 10.994,14.039C12.025,14.039 12.764,13.289 12.764,12.281C12.764,11.25 12.002,10.5 10.936,10.488C10.256,10.488 9.74,10.711 9.447,11.238H8.229L8.779,6.516H13.584V7.617H9.846L9.564,9.996H9.646C9.998,9.656 10.596,9.422 11.24,9.422C12.834,9.422 14.018,10.606 14.018,12.246C14.018,13.922 12.764,15.117 10.994,15.117Z"
android:fillColor="#ffffff"/>
</vector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/focused_birthdate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
<path
android:pathData="M11,11m-11,0a11,11 0,1 1,22 0a11,11 0,1 1,-22 0"
android:fillColor="#FA7B53"/>
<path
android:pathData="M8.182,15V14.063L11.123,11.098C12.049,10.125 12.518,9.586 12.518,8.848C12.518,8.016 11.838,7.477 10.947,7.477C10.01,7.477 9.4,8.074 9.4,8.977H8.182C8.17,7.43 9.354,6.398 10.971,6.398C12.611,6.398 13.736,7.43 13.748,8.813C13.736,9.762 13.291,10.512 11.697,12.082L9.975,13.828V13.898H13.889V15H8.182Z"
android:fillColor="#ffffff"/>
</vector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/focused_connect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="23dp"
android:height="22dp"
android:viewportWidth="23"
android:viewportHeight="22">
<path
android:pathData="M11.5,11m-11,0a11,11 0,1 1,22 0a11,11 0,1 1,-22 0"
android:fillColor="#FA7B53"/>
<path
android:pathData="M11.518,15.117C9.76,15.117 8.506,14.168 8.459,12.785H9.771C9.818,13.535 10.557,14.004 11.506,14.004C12.525,14.004 13.275,13.441 13.275,12.621C13.275,11.789 12.572,11.18 11.365,11.18H10.639V10.125H11.365C12.326,10.125 13.006,9.586 13.006,8.777C13.006,8.004 12.432,7.477 11.529,7.477C10.674,7.477 9.924,7.945 9.889,8.719H8.646C8.682,7.336 9.959,6.398 11.541,6.398C13.205,6.398 14.26,7.453 14.248,8.707C14.26,9.668 13.662,10.371 12.748,10.594V10.652C13.908,10.816 14.576,11.59 14.576,12.668C14.576,14.086 13.275,15.117 11.518,15.117Z"
android:fillColor="#ffffff"/>
</vector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/focused_group.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
<path
android:pathData="M11,11m-11,0a11,11 0,1 1,22 0a11,11 0,1 1,-22 0"
android:fillColor="#FA7B53"/>
<path
android:pathData="M7.754,13.348V12.305L11.504,6.516H13.098V12.258H14.258V13.348H13.098V15H11.879V13.348H7.754ZM9.113,12.258H11.879V8.051H11.785L9.113,12.188V12.258Z"
android:fillColor="#ffffff"/>
</vector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/focused_nickname.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
<path
android:pathData="M11,11m-11,0a11,11 0,1 1,22 0a11,11 0,1 1,-22 0"
android:fillColor="#FA7B53"/>
<path
android:pathData="M12.283,6.516V15H10.982V7.805H10.936L8.908,9.129V7.898L11.018,6.516H12.283Z"
android:fillColor="#ffffff"/>
</vector>
Loading