Skip to content

Commit

Permalink
mod/#9: selfDescription에서 phone으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
youjin09222 committed May 3, 2024
1 parent c254cc9 commit af3798c
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 55 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/sopt/now/test/data/Friend.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.annotation.DrawableRes
data class Friend(
@DrawableRes val profileImage: Int,
val name: String,
val selfDescription: String,
val phone: String,
) {
companion object {
const val TYPE_USER = 0
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/sopt/now/test/data/UserData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import kotlinx.android.parcel.Parcelize
@Parcelize
data class UserData(
val userId: String,
val userPw: String,
val userName: String,
val selfDescription: String
val userPhone: String
): Parcelable
10 changes: 4 additions & 6 deletions app/src/main/java/com/sopt/now/test/data/UserPreference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ class UserPreference(context: Context) {
fun saveUserData(userData: UserData) {
with(sharedPreferences.edit()){
putString("userId", userData.userId)
putString("userPw", userData.userPw)
putString("userName", userData.userName)
putString("selfDescription", userData.selfDescription)
putString("userPhone", userData.userPhone)
apply()
}
}
Expand All @@ -20,12 +19,11 @@ class UserPreference(context: Context) {
fun getUserData(): UserData? {
with(sharedPreferences){
val userId = getString("userId", null)
val userPw = getString("userPw", null)
val userName = getString("userName", null)
val selfDescription = getString("selfDescription", null)
val userPhone = getString("userPhone", null)

return if (userId != null && userPw != null && userName != null && selfDescription != null) {
UserData(userId, userPw, userName, selfDescription)
return if (userId != null && userName != null && userPhone != null) {
UserData(userId, userName, userPhone)
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FriendViewHolder(private val binding: ItemFriendBinding) : BaseViewHolder(
binding.run {
ivFriendProfile.setImageResource(friendData.profileImage)
tvFriendName.text = friendData.name
tvFriendDescription.text = friendData.selfDescription
tvFriendPhone.text = friendData.phone
}
}
}
Expand All @@ -23,7 +23,7 @@ class UserViewHolder(private val binding: ItemUserBinding) : BaseViewHolder(bind
binding.run {
ivMyProfile.setImageResource(userData.profileImage)
tvMyName.text = userData.name
tvMyDescription.text = userData.selfDescription
tvMyPhone.text = userData.phone
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HomeFragment: Fragment() {
val newFriend = Friend(
profileImage = R.drawable.iv_user_profile,
name = it.userName,
selfDescription = it.selfDescription
phone = it.userPhone
)
viewModel.mockFriendList.add(0, newFriend)
}
Expand Down
21 changes: 11 additions & 10 deletions app/src/main/java/com/sopt/now/test/presentation/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,59 @@ package com.sopt.now.test.presentation

import androidx.lifecycle.ViewModel
import com.sopt.now.R
import com.sopt.now.test.data.Friend

class HomeViewModel() : ViewModel() {
val mockFriendList = mutableListOf<Friend>(
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "AAA",
selfDescription = "AAA님의 한 줄 소개",
phone = "AAA님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "BBB",
selfDescription = "BBB님의 한 줄 소개",
phone = "BBB님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "CCC",
selfDescription = "CCC님의 한 줄 소개",
phone = "CCC님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "DDD",
selfDescription = "DDD님의 한 줄 소개",
phone = "DDD님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "EEE",
selfDescription = "EEE님의 한 줄 소개",
phone = "EEE님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "FFF",
selfDescription = "FFF님의 한 줄 소개",
phone = "FFF님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "GGG",
selfDescription = "GGG님의 한 줄 소개",
phone = "GGG님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "HHH",
selfDescription = "HHH님의 한 줄 소개",
phone = "HHH님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "III",
selfDescription = "III님의 한 줄 소개",
phone = "III님의 한 줄 소개",
),
Friend(
profileImage = R.drawable.iv_friend_profile,
name = "JJJ",
selfDescription = "JJJ님의 한 줄 소개",
phone = "JJJ님의 한 줄 소개",
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ class MyPageFragment : Fragment() {
val userData = userPreference.getUserData()
if (userData != null) {
with(binding) {
tvMyName.text = userData.userName
tvMyDescription.text = userData.selfDescription
tvMyId.text = userData.userId
tvMyPw.text = userData.userPw
tvMyName.text = userData.userName
tvMyPhone.text = userData.userPhone
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="@string/tv_user_description"
android:text="@string/tv_user_phone"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et_sign_up_name"/>

<EditText
android:id="@+id/et_sign_up_description"
android:id="@+id/et_sign_up_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/hint_user_description"
android:hint="@string/hint_user_phone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_sign_up_description"/>
Expand Down
23 changes: 2 additions & 21 deletions app/src/main/res/layout/fragment_mypage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
app:layout_constraintTop_toTopOf="@+id/iv_my_profile" />

<TextView
android:id="@+id/tv_my_description"
android:id="@+id/tv_my_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tv_user_description"
android:text="@string/tv_user_phone"
app:layout_constraintStart_toStartOf="@+id/tv_my_name"
app:layout_constraintTop_toBottomOf="@+id/tv_my_name"/>

Expand All @@ -55,23 +55,4 @@
android:text="@string/tv_id"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_id"/>

<TextView
android:id="@+id/tv_pw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="@string/tv_pw"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_my_id"/>

<TextView
android:id="@+id/tv_my_pw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/tv_pw"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_pw"/>
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/item_friend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
app:layout_constraintTop_toTopOf="@id/iv_friend_profile" />

<TextView
android:id="@+id/tv_friend_description"
android:id="@+id/tv_friend_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/tv_user_description"
android:text="@string/tv_user_phone"
android:textAlignment="textEnd"
android:maxLines="1"
android:ellipsize="end"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/item_user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
app:layout_constraintTop_toTopOf="@id/cv_my_profile" />

<TextView
android:id="@+id/tv_my_description"
android:id="@+id/tv_my_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@string/tv_user_description"
android:text="@string/tv_user_phone"
android:textAlignment="textEnd"
android:maxLines="1"
android:ellipsize="end"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<string name="title_sign_up">SIGN UP</string>
<string name="tv_user_name">닉네임</string>
<string name="hint_user_name">닉네임을 입력해주세요.</string>
<string name="tv_user_description">한 줄 소개</string>
<string name="hint_user_description">한 줄 소개를 입력해주세요.</string>
<string name="tv_user_phone">핸드폰 번호</string>
<string name="hint_user_phone">핸드폰 번호를 입력해주세요.</string>
</resources>

0 comments on commit af3798c

Please sign in to comment.