Skip to content

Commit a68d9c6

Browse files
committed
✨ 편집 모양 아이콘 클릭 시 닉네임 수정하는 다이얼로그 띄우기
1 parent dce9dde commit a68d9c6

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

presentation/src/main/java/com/whyranoid/presentation/myrun/MyRunFragment.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.whyranoid.presentation.myrun
22

33
import android.os.Bundle
44
import android.view.View
5+
import androidx.appcompat.app.AlertDialog
56
import androidx.fragment.app.viewModels
67
import com.whyranoid.presentation.R
78
import com.whyranoid.presentation.base.BaseFragment
@@ -24,6 +25,9 @@ internal class MyRunFragment : BaseFragment<FragmentMyRunBinding>(R.layout.fragm
2425
private fun initViews() {
2526
viewModel.getNickName()
2627
viewModel.getProfileImgUri()
28+
binding.ivEditNickName.setOnClickListener {
29+
popUpEditNickNameDialog()
30+
}
2731
}
2832

2933
private fun observeInfo() {
@@ -35,4 +39,20 @@ internal class MyRunFragment : BaseFragment<FragmentMyRunBinding>(R.layout.fragm
3539
binding.ivProfileImage.loadImage(it)
3640
}
3741
}
42+
43+
private fun popUpEditNickNameDialog() {
44+
val builder = AlertDialog.Builder(requireActivity())
45+
.setView(R.layout.dialog_edit_nick_name)
46+
.setPositiveButton(
47+
getString(R.string.my_run_edit_nick_name_dialog_positive)
48+
) { dialog, id ->
49+
// 닉네임 변경 로직
50+
}
51+
.setNegativeButton(
52+
getString(R.string.my_run_edit_nick_name_dialog_negative)
53+
) { dialog, _ ->
54+
dialog.dismiss()
55+
}
56+
builder.show()
57+
}
3858
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content">
6+
7+
<TextView
8+
android:id="@+id/tv_dialog_description"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:layout_marginTop="20dp"
12+
android:text="@string/my_run_edit_nick_name_dialog_description"
13+
app:layout_constraintEnd_toEndOf="parent"
14+
app:layout_constraintStart_toStartOf="parent"
15+
app:layout_constraintTop_toTopOf="parent" />
16+
17+
<EditText
18+
android:id="@+id/et_change_nick_name"
19+
android:layout_width="0dp"
20+
android:layout_height="wrap_content"
21+
android:layout_marginHorizontal="20dp"
22+
android:layout_marginTop="20dp"
23+
android:autofillHints="name"
24+
android:hint="@string/my_run_edit_nick_name_dialog_hint"
25+
android:inputType="textPersonName"
26+
android:maxLength="20"
27+
android:maxLines="1"
28+
app:layout_constraintEnd_toEndOf="parent"
29+
app:layout_constraintStart_toStartOf="parent"
30+
app:layout_constraintTop_toBottomOf="@id/tv_dialog_description" />
31+
32+
</androidx.constraintlayout.widget.ConstraintLayout>

presentation/src/main/res/layout/fragment_my_run.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
tools:text="병희희" />
7272

7373
<ImageView
74+
android:id="@+id/iv_edit_nick_name"
7475
android:layout_width="wrap_content"
7576
android:layout_height="wrap_content"
7677
android:layout_marginStart="20dp"

presentation/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<string name="my_run_tool_bar_menu_setting">설정</string>
2626
<string name="my_run_profile_image_description">사용자의 프로필 사진입니다</string>
2727
<string name="my_run_edit_nick_name_button_description">닉네임 수정 버튼입니다</string>
28+
<string name="my_run_edit_nick_name_dialog_description">변경할 닉네임을 입력해주세요</string>
29+
<string name="my_run_edit_nick_name_dialog_positive">수정</string>
30+
<string name="my_run_edit_nick_name_dialog_negative">취소</string>
31+
<string name="my_run_edit_nick_name_dialog_hint">20글자 이하로 입력해주세요</string>
2832

2933
<!-- 설정 화면 -->
3034
<string name="setting_connected_account">연결된 계정</string>

signin/src/main/java/com/whyranoid/SignInDataSourceImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SignInDataSourceImpl @Inject constructor(
2828
preferences[PreferenceKeys.profileImgUri] = userInfo.profileImgUri ?: EMPTY_STRING
2929
}
3030

31-
fireBaseDb.collection("Users")
31+
fireBaseDb.collection(USER_COLLECTION_PATH)
3232
.document(userInfo.uid).set(
3333
UserResponse(
3434
userInfo.uid,
@@ -47,5 +47,6 @@ class SignInDataSourceImpl @Inject constructor(
4747
private const val NICK_NAME_KEY = "nick_name"
4848
private const val PROFILE_IMG_URI = "profile_img_uri"
4949
private const val EMPTY_STRING = ""
50+
private const val USER_COLLECTION_PATH = "Users"
5051
}
5152
}

0 commit comments

Comments
 (0)