Skip to content

Commit

Permalink
[MERGE] #33 -> develop
Browse files Browse the repository at this point in the history
[UI/#33] 로그인뷰 / UI 구현
  • Loading branch information
Marchbreeze authored Jul 7, 2024
2 parents dd82450 + 3b2c895 commit af3c22e
Show file tree
Hide file tree
Showing 49 changed files with 1,415 additions and 206 deletions.
16 changes: 16 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="co.orange.presentation.auth.login.LoginActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="co.orange.presentation.auth.signup.SignUpActivity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />

<activity
android:name="co.orange.presentation.auth.submit.SubmitActivity"
android:exported="false"
android:screenOrientation="portrait" />

</application>

</manifest>
10 changes: 10 additions & 0 deletions core/src/main/java/co/orange/core/extension/ActivityExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.util.DisplayMetrics
import android.view.View
import android.view.WindowInsets
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedCallback
import androidx.core.content.ContextCompat
Expand Down Expand Up @@ -55,3 +57,11 @@ fun ComponentActivity.initOnBackPressedListener(

this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

fun Activity.initFocusWithKeyboard(editText: EditText) {
editText.requestFocus()
(getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager).showSoftInput(
editText,
InputMethodManager.SHOW_IMPLICIT,
)
}
10 changes: 10 additions & 0 deletions domain/src/main/kotlin/co/orange/domain/enums/MobileType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package co.orange.domain.enums

enum class MobileType(val description: String) {
SKT("SKT"),
KT("KT"),
LG("LG U+"),
SKT_A("SKT 알뜰폰"),
KT_A("KT 알뜰폰"),
LG_A("LG U+ 알뜰폰"),
}
Binary file added presentation/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package co.orange.presentation.auth.login

import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import co.orange.presentation.auth.signup.SignUpActivity
import dagger.hilt.android.AndroidEntryPoint
import kr.genti.core.base.BaseActivity
import kr.genti.core.extension.setOnSingleClickListener
import kr.genti.presentation.R
import kr.genti.presentation.databinding.ActivityLoginBinding

@AndroidEntryPoint
class LoginActivity : BaseActivity<ActivityLoginBinding>(R.layout.activity_login) {
private val viewModel by viewModels<LoginViewModel>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initLoginBtnListener()
}

private fun initLoginBtnListener() {
binding.btnLoginKakao.setOnSingleClickListener {
Intent(this, SignUpActivity::class.java).apply {
startActivity(this)
}
finish()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package co.orange.presentation.auth.login

import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class LoginViewModel
@Inject
constructor(
// private val authRepository: AuthRepository,
) : ViewModel()
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package co.orange.presentation.auth.signup

import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import co.orange.domain.enums.MobileType
import kr.genti.core.base.BaseBottomSheet
import kr.genti.core.extension.setOnSingleClickListener
import kr.genti.presentation.R
import kr.genti.presentation.databinding.BottomSheetMobileBinding

class MobileBottomSheet :
BaseBottomSheet<BottomSheetMobileBinding>(R.layout.bottom_sheet_mobile) {
private val viewModel by activityViewModels<SignUpViewModel>()

override fun onStart() {
super.onStart()
dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
}

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

initBtnsListener()
}

private fun initBtnsListener() {
with(binding) {
btnMobileSkt.setOnSingleClickListener { setMobile(MobileType.SKT) }
btnMobileKt.setOnSingleClickListener { setMobile(MobileType.KT) }
btnMobileLg.setOnSingleClickListener { setMobile(MobileType.LG) }
btnMobileSktA.setOnSingleClickListener { setMobile(MobileType.SKT_A) }
btnMobileKtA.setOnSingleClickListener { setMobile(MobileType.KT_A) }
btnMobileLgA.setOnSingleClickListener { setMobile(MobileType.LG_A) }
}
}

private fun setMobile(mobileType: MobileType) {
with(viewModel) {
mobile.value = mobileType.description
isMobileFinished.value = true
}
dismiss()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package co.orange.presentation.auth.signup

import android.os.Bundle
import androidx.activity.viewModels
import dagger.hilt.android.AndroidEntryPoint
import kr.genti.core.base.BaseActivity
import kr.genti.core.extension.hideKeyboard
import kr.genti.core.extension.initFocusWithKeyboard
import kr.genti.core.extension.setOnSingleClickListener
import kr.genti.presentation.R
import kr.genti.presentation.databinding.ActivitySignUpBinding

@AndroidEntryPoint
class SignUpActivity : BaseActivity<ActivitySignUpBinding>(R.layout.activity_sign_up) {
private val viewModel by viewModels<SignUpViewModel>()

private var mobileBottomSheet: MobileBottomSheet? = null
private var termBottomSheet: TermBottomSheet? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding.vm = viewModel
initConfirmBtnListener()
initMobileBtnListener()
initVerifyBtnListener()
observeBirthFrontFinished()
observeBirthBackFinished()
observeMobileFinished()
observePhoneFinished()
observeCodeFinished()
}

private fun initConfirmBtnListener() {
binding.btnConfirm.setOnSingleClickListener {
termBottomSheet = TermBottomSheet()
termBottomSheet?.show(supportFragmentManager, BOTTOM_SHEET_TERM)
}
}

private fun initMobileBtnListener() {
binding.btnSelectMobile.setOnSingleClickListener { showMobileBottomSheet() }
}

private fun showMobileBottomSheet() {
mobileBottomSheet = MobileBottomSheet()
mobileBottomSheet?.show(supportFragmentManager, BOTTOM_SHEET_MOBILE)
}

private fun initVerifyBtnListener() {
binding.btnPhoneCertify.setOnSingleClickListener {
// TODO 서버통신
}
}

private fun observeBirthFrontFinished() {
viewModel.isBirthFrontFinished.observe(this) { isFinished ->
if (isFinished) {
binding.etSignUpBirthBack.requestFocus()
}
}
}

private fun observeBirthBackFinished() {
viewModel.isBirthBackFinished.observe(this) { isFinished ->
if (isFinished) {
currentFocus?.let { hideKeyboard(it) }
currentFocus?.clearFocus()
showMobileBottomSheet()
}
}
}

private fun observeMobileFinished() {
viewModel.isMobileFinished.observe(this) { isFinished ->
if (isFinished) {
initFocusWithKeyboard(binding.etSignUpPhone)
}
}
}

private fun observePhoneFinished() {
viewModel.isPhoneFinished.observe(this) { isFinished ->
if (isFinished) {
currentFocus?.let { hideKeyboard(it) }
currentFocus?.clearFocus()
}
}
}

private fun observeCodeFinished() {
viewModel.isCodeFinished.observe(this) { isFinished ->
if (isFinished) {
currentFocus?.let { hideKeyboard(it) }
currentFocus?.clearFocus()
}
}
}

override fun onDestroy() {
super.onDestroy()

mobileBottomSheet = null
termBottomSheet = null
}

companion object {
private const val BOTTOM_SHEET_MOBILE = "BOTTOM_SHEET_MOBILE"
private const val BOTTOM_SHEET_TERM = "BOTTOM_SHEET_TERM"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package co.orange.presentation.auth.signup

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class SignUpViewModel
@Inject
constructor(
// private val authRepository: AuthRepository,
) : ViewModel() {
val name = MutableLiveData<String>()
val isNameFinished = MutableLiveData(false)

val birthFront = MutableLiveData<String>()
val isBirthFrontFinished = MutableLiveData(false)

val birthBack = MutableLiveData<String>()
val isBirthBackFinished = MutableLiveData(false)

val mobile = MutableLiveData<String>("선택해주세요")
val isMobileFinished = MutableLiveData(false)

val phone = MutableLiveData<String>()
val isPhoneFinished = MutableLiveData(false)

val code = MutableLiveData<String>()
val isCodeFinished = MutableLiveData(false)

val isCompleted = MutableLiveData(false)

fun checkNameFinished() {
isNameFinished.value = name.value?.isNotEmpty()
checkIsCompleted()
}

fun checkBirthFrontFinished() {
isBirthFrontFinished.value = birthFront.value?.length == 6
checkIsCompleted()
}

fun checkBirthBackFinished() {
isBirthBackFinished.value = birthBack.value?.length == 1
checkIsCompleted()
}

fun checkPhoneFinished() {
isPhoneFinished.value = phone.value?.length == 11
}

fun checkCodeFinished() {
isCodeFinished.value = code.value?.length == 6
checkIsCompleted()
}

fun checkIsCompleted() {
isCompleted.value =
(isNameFinished.value == true && isBirthFrontFinished.value == true && isBirthBackFinished.value == true && isMobileFinished.value == true && isPhoneFinished.value == true && isCodeFinished.value == true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package co.orange.presentation.auth.signup

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import co.orange.presentation.auth.submit.SubmitActivity
import kr.genti.core.base.BaseBottomSheet
import kr.genti.core.extension.setOnSingleClickListener
import kr.genti.presentation.R
import kr.genti.presentation.databinding.BottomSheetTermBinding

class TermBottomSheet :
BaseBottomSheet<BottomSheetTermBinding>(R.layout.bottom_sheet_term) {
private val viewModel by activityViewModels<SignUpViewModel>()

override fun onStart() {
super.onStart()
dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
}

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

initTermBtnsListener()
initSubmitBtnListener()
}

private fun initTermBtnsListener() {
with(binding) {
// TODO
}
}

private fun initSubmitBtnListener() {
binding.btnSubmit.setOnSingleClickListener {
Intent(requireActivity(), SubmitActivity::class.java).apply {
startActivity(this)
}
requireActivity().finish()
dismiss()
}
}
}
Loading

0 comments on commit af3c22e

Please sign in to comment.