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

[UI/#13] onboarding profile setting #14

Merged
merged 26 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
89fb554
[ADD/#7] TextInputLayout custom style 추가
chattymin Dec 30, 2023
c78c6a3
[ADD/#7] Onboarding Profile 페이지 string 리소스 추가
chattymin Dec 30, 2023
eabbdf9
[UI/#7] Onboarding Profile 페이지 UI 와이어프레임 구현
chattymin Dec 30, 2023
076a94e
[FEAT/#7] 글자 수 검증 with 이모지, 공백
chattymin Dec 31, 2023
6a8b598
[FIX/#7] 버튼 검증과 입력값 유효성 검증이 다르던 코드 수정
chattymin Dec 31, 2023
6e4cccc
[ADD/#7] 텍스트박스 커서 색 변경
chattymin Dec 31, 2023
86bf4d9
[ADD/#13] hideKeyboard에 focus Clear 기능 추가
chattymin Dec 31, 2023
7c87fc7
[FEAT/#13] 버튼 연동 및 페이지 이동 함수 구현
chattymin Dec 31, 2023
0544c36
[FEAT/#13] 글자수 세기 커스텀 함수 구현
chattymin Dec 31, 2023
aad46aa
[UI/#13] 글자수 세기 string 리소스 생성 및 ui 구현
chattymin Dec 31, 2023
97de0bb
[MOD/#13] 글자수 검사 함수 리펙토링 및 변수명 수정
chattymin Dec 31, 2023
4f0844d
[CHORE/#13] xml 배경색 제거
chattymin Dec 31, 2023
774af30
Merge branch 'develop' into ui/#13-onboarding-profile-setting
chattymin Dec 31, 2023
8d82e62
[CHORE/#13] 정책 변경으로 인한 이름 최대 길이 수 변경
chattymin Jan 1, 2024
b6a6603
[UI/#13] Button radius 처리 및 색상 처리
chattymin Jan 1, 2024
7679e1f
[REFACTOR/#13] 입력창 UI 및 로직 전체 리펙토링 및 커스텀
chattymin Jan 1, 2024
03fe1eb
[UI/#13] 에러 외곽 테두리 색 변경
chattymin Jan 1, 2024
93f0536
[CHORE/#13] enum class 분리
chattymin Jan 1, 2024
a35d5fa
[CHORE/#13] 함수 로직 간략화
chattymin Jan 1, 2024
2e99854
[CHORE/#13] 변수명 변경
chattymin Jan 1, 2024
4f30c20
[CHORE/#13] 변수명 변경 및 불필요 내용 삭제
chattymin Jan 1, 2024
fd8150a
Merge remote-tracking branch 'origin/ui/#13-onboarding-profile-settin…
chattymin Jan 1, 2024
3297edb
[CHORE/#13] 실수로 삭제한 내용 복구
chattymin Jan 1, 2024
afcb5af
[CHORE/#13] 색상코드 변경 반영
chattymin Jan 1, 2024
f6d6187
[CHORE/#13] 변수명 변경
chattymin Jan 1, 2024
32fc59f
[CHORE/#13] 중복 내용 함수화 진행
chattymin Jan 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
</intent-filter>
</activity>

<activity
android:name="com.going.presentation.onboarding.OnboardingProfileSettingActivity"
android:exported="true" />

</application>

</manifest>
3 changes: 2 additions & 1 deletion core-ui/src/main/java/com/going/ui/extension/ContextExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ fun Context.drawableOf(@DrawableRes resId: Int) = ContextCompat.getDrawable(this
fun Context.hideKeyboard(view: View) {
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
}
view.clearFocus()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.going.presentation.onboarding

import android.os.Bundle
import android.view.inputmethod.EditorInfo
import androidx.activity.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.going.presentation.R
import com.going.presentation.databinding.ActivityOnboardingProfileSettingBinding
import com.going.ui.base.BaseActivity
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach

class OnboardingProfileSettingActivity :
BaseActivity<ActivityOnboardingProfileSettingBinding>(R.layout.activity_onboarding_profile_setting) {
private val viewModel by viewModels<OnboardingProfileSettingViewModel>()

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

initBindingViewModel()
initOnLineInfoEditorActionListener()
observeIsProfileAvailable()
observeTextLength()
}

private fun initBindingViewModel() {
binding.viewModel = viewModel
}

private fun initOnLineInfoEditorActionListener() {
binding.etvOnboardingProfileSettingOnLineInfo.setOnEditorActionListener { view, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) view.clearFocus()
false
}
Copy link
Member

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 어우 컴포넌트 id 한번 살벌하네요 ㅋㅋㅋㅋㅋ
우리 에딧텍스트 컨벤션 et로 설정해주셔야할 듯 하구, 지금도 괜찮지만 조오금은 길이 줄여볼 방법도 생각해보면 좋을듯 ㅎㅎ

Copy link
Member Author

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋ 넵 이건 생각해보겠습니당

}

private fun observeIsProfileAvailable() {
viewModel.isMoveScreenAvailable.flowWithLifecycle(lifecycle).onEach { isEnd ->
if (isEnd) moveSplash()
}.launchIn(lifecycleScope)
}

// 커스텀 글자수 제한 함수
private fun observeTextLength() {
viewModel.nowNameLength.observe(this) { length ->
val maxNameLength = viewModel.getMaxNameLen()

if (length > maxNameLength) {
binding.etvOnboardingProfileSettingName.apply {
setText(text?.subSequence(0, maxNameLength))
setSelection(maxNameLength)
}
}
}

viewModel.nowInfoLength.observe(this) { length ->
val maxInfoLength = viewModel.getMaxInfoLen()

if (length > maxInfoLength) {
binding.etvOnboardingProfileSettingOnLineInfo.apply {
setText(text?.subSequence(0, maxInfoLength))
setSelection(maxInfoLength)
}
}
}
}

private fun moveSplash() {
// 스플래시로 이동
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.going.presentation.onboarding

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import java.text.BreakIterator

class OnboardingProfileSettingViewModel : ViewModel() {
val name = MutableLiveData(String())
val nowNameLength = MutableLiveData(0)
val info = MutableLiveData(String())
val nowInfoLength = MutableLiveData(0)

// 추후 해당 값을 활용하여 텍스트박스에 변화를 줄 것 예측샷 ㅋㅋ
val isNameAvailable = MutableLiveData(false)
val isInfoAvailable = MutableLiveData(false)
val isProfileAvailable = MutableLiveData(false)

private val _isMoveScreenAvailable = MutableStateFlow(false)
val isMoveScreenAvailable: StateFlow<Boolean> = _isMoveScreenAvailable

fun getMaxNameLen() = MAX_NAME_LEN
fun getMaxInfoLen() = MAX_INFO_LEN

fun checkProfileAvailable() {
nowNameLength.value = getGraphemeLength(name.value)
nowInfoLength.value = getGraphemeLength(info.value)

isNameAvailable.value =
(getGraphemeLength(name.value) <= MAX_NAME_LEN) && !name.value.isNullOrBlank()
isInfoAvailable.value = getGraphemeLength(info.value) in 1..MAX_INFO_LEN

isProfileAvailable.value = isNameAvailable.value ?: false && isInfoAvailable.value ?: false
}

// 이모지 포함 글자 수 세는 함수
private fun getGraphemeLength(value: String?): Int {
BREAK_ITERATOR.setText(value)

var count = 0
while (BREAK_ITERATOR.next() != BreakIterator.DONE) {
count++
}

return count
}

fun setIsMoveScreenAvailable() {
_isMoveScreenAvailable.value = true
}

companion object {
val BREAK_ITERATOR: BreakIterator = BreakIterator.getCharacterInstance()

const val MAX_NAME_LEN = 5
const val MAX_INFO_LEN = 20
Copy link
Member

Choose a reason for hiding this comment

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

이야 굿굿 !!

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?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"
xmlns:tools="http://schemas.android.com/tools">

<data>

<variable
name="viewModel"
type="com.going.presentation.onboarding.OnboardingProfileSettingViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/tb_onboarding_profile_setting"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/white_000"
android:elevation="2dp"
android:paddingVertical="12dp"
android:paddingStart="18dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/onboarding_title"
Copy link
Member

Choose a reason for hiding this comment

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

이거 저는 액티비티에서의 추출과 xml에서의 추출을 구분하기 위해 onboarding_tb_title 처럼 컴포넌트 유형도 넣어주는 편입니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

좋은 아이디어 같습니다! 반영 완료~

app:titleTextColor="@color/black_000" />

<TextView
android:id="@+id/tv_onboarding_profile_setting_name_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/onboarding_name_title"
android:textColor="@color/black_000"
app:layout_constraintStart_toStartOf="@id/layout_onboarding_profile_setting_name"
app:layout_constraintTop_toBottomOf="@id/tb_onboarding_profile_setting" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/layout_onboarding_profile_setting_name"
style="@style/textInputLayout_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="6dp"
app:boxStrokeWidth="2dp"
app:endIconMode="custom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_onboarding_profile_setting_name_title">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etv_onboarding_profile_setting_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:afterTextChanged="@{(text) -> viewModel.checkProfileAvailable()}"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:text="@={viewModel.name}"
android:textColor="@color/black_000"
android:textSize="15sp"
tools:text="@string/onboarding_name" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/text_count(viewModel.nowNameLength, viewModel.MAX_NAME_LEN)}"
app:layout_constraintEnd_toEndOf="@id/layout_onboarding_profile_setting_name"
app:layout_constraintTop_toBottomOf="@id/layout_onboarding_profile_setting_name" />

<TextView
android:id="@+id/tv_onboarding_profile_setting_on_line_info_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/onboarding_one_line_info_title"
android:textColor="@color/black_000"
app:layout_constraintStart_toStartOf="@id/layout_onboarding_profile_setting_name"
app:layout_constraintTop_toBottomOf="@id/layout_onboarding_profile_setting_name" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/layout_onboarding_profile_setting_on_line_info"
style="@style/textInputLayout_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="6dp"
app:boxStrokeWidth="2dp"
app:endIconMode="custom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_onboarding_profile_setting_on_line_info_title">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etv_onboarding_profile_setting_on_line_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:afterTextChanged="@{(text) -> viewModel.checkProfileAvailable()}"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:text="@={viewModel.info}"
android:textColor="@color/black_000"
android:textSize="15sp"
tools:text="@string/onboarding_one_line_info" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/text_count(viewModel.nowInfoLength, viewModel.MAX_INFO_LEN)}"
app:layout_constraintEnd_toEndOf="@id/layout_onboarding_profile_setting_on_line_info"
app:layout_constraintTop_toBottomOf="@id/layout_onboarding_profile_setting_on_line_info" />

<Button
android:id="@+id/btn_onboarding_profile_setting_finish"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="60dp"
android:enabled="@{viewModel.isProfileAvailable()}"
android:onClick="@{() -> viewModel.setIsMoveScreenAvailable()}"
android:paddingVertical="10dp"
android:text="@string/onboarding_finish_button"
android:textColor="@color/black_000"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
11 changes: 10 additions & 1 deletion presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@
<string name="dummy">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</string>

<string name="server_error">서버 통신에 실패했습니다.</string>

<string name="sign_in_tv_title">여행을 시작해보세요</string>
<string name="sign_in_tv_terms"><u>개인정보처리방침</u></string>

<string name="text_count">%1$d / %2$d</string>

<!--onboarding-->
<string name="onboarding_title">프로필 생성</string>
<string name="onboarding_name_title">이름</string>
<string name="onboarding_name">이름을 입력해주세요.</string>
<string name="onboarding_one_line_info_title">한줄 소개</string>
<string name="onboarding_one_line_info">당신을 한줄로 표현해보세요.</string>
<string name="onboarding_finish_button">유형 검사하러 가기</string>]
Copy link
Member

Choose a reason for hiding this comment

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

요기 뒤에 오타 있는듯 !

Copy link
Member Author

Choose a reason for hiding this comment

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

수정 완!

</resources>
17 changes: 16 additions & 1 deletion presentation/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,19 @@

<style name="Theme.Doorip" parent="Base.Theme.Doorip" />

</resources>
<!-- TextInputLayout Style -->
<style name="ThemeOverlay.Eggeum.TextInputLayout.CursorColor" parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox">
<item name="colorControlActivated">@color/red_600</item>
</style>
Copy link
Member

Choose a reason for hiding this comment

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

Eggeum은 라이브러리명인가요??

Copy link
Member Author

Choose a reason for hiding this comment

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

복붙의...폐헤입니다... 왜 안바꿨지...
죄송함다 ㅠㅠ


<style name="textInputLayout_style" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxBackgroundMode">outline</item>
<item name="boxStrokeColor">@color/red_600</item>
<item name="boxBackgroundColor">@color/white_000</item>
<item name="boxCornerRadiusBottomEnd">6dp</item>
<item name="boxCornerRadiusBottomStart">6dp</item>
<item name="boxCornerRadiusTopEnd">6dp</item>
<item name="boxCornerRadiusTopStart">6dp</item>
<item name="android:theme">@style/ThemeOverlay.Eggeum.TextInputLayout.CursorColor</item>
</style>
</resources>