Skip to content

Commit

Permalink
feat/#9: 홈 화면에 회원 정보 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
youjin09222 committed May 3, 2024
1 parent 1e0e58d commit 242824b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions app/src/main/java/com/sopt/now/test/presentation/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.sopt.now.R
import com.sopt.now.databinding.FragmentHomeBinding
import com.sopt.now.test.data.Friend
import com.sopt.now.test.data.UserPreference
import com.sopt.now.test.friend.FriendAdapter

class HomeFragment: Fragment() {
Expand All @@ -19,7 +18,7 @@ class HomeFragment: Fragment() {
get() = requireNotNull(_binding) { "바인딩 객체 좀 생성해주세요 제발!!" }

private val viewModel by viewModels<HomeViewModel>()
private lateinit var userPreference: UserPreference
private val userInfoViewModel by viewModels<UserInfoViewModel>()

override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -33,23 +32,24 @@ class HomeFragment: Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

userPreference = UserPreference(requireContext())

setFriendList()
setRecyclerView()
}

// 리스트에 사용자 정보 추가
private fun setFriendList(){
val userData = userPreference.getUserData()
private fun setFriendList() {
userInfoViewModel.userInfo()

userData?.let {
val newFriend = Friend(
profileImage = R.drawable.iv_user_profile,
name = it.userName,
phone = it.userPhone
)
viewModel.mockFriendList.add(0, newFriend)
userInfoViewModel.userInfoLiveData.observe(requireActivity()) { userData ->
userData?.let {
val newFriend = Friend(
profileImage = R.drawable.iv_user_profile,
name = it.data.nickname,
phone = it.data.phone
)
viewModel.mockFriendList.add(0, newFriend)
setRecyclerView()
}
}
}

Expand Down

0 comments on commit 242824b

Please sign in to comment.