Skip to content

Commit

Permalink
mod/#5: 마이페이지<->홈 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeeum committed Apr 11, 2024
1 parent 8f52e11 commit 131ba88
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 53 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/sopt/now/Friend.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package com.sopt.now

import androidx.annotation.DrawableRes

data class User(
@DrawableRes val profileImage: Int,
val name: String,
val selfDescription: String
)
data class Friend(
@DrawableRes val profileImage: Int,
val name: String,
Expand Down
38 changes: 32 additions & 6 deletions app/src/main/java/com/sopt/now/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,44 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.sopt.now.databinding.FragmentHomeBinding

class HomeFragment : Fragment() {
private lateinit var binding: FragmentHomeBinding

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

private val mockFriendList = listOf<Friend>(
Friend(
profileImage = R.drawable.ic_home_white_24,
name = "이의경",
selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지? ㅎㅎ 아직 반도 안왔어 ^&^",
),
Friend(
profileImage = R.drawable.ic_home_white_24,
name = "우상욱",
selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐",
),
Friend(
profileImage = R.drawable.ic_home_white_24,
name = "배지현",
selfDescription = "표정 풀자 ^^",
),
)
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home, container, false)
binding=FragmentHomeBinding.inflate(inflater)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val friendAdapter = FriendAdapter()
binding.rvFriends.run {
adapter = friendAdapter
layoutManager = LinearLayoutManager(requireContext())
}
friendAdapter.setFriendList(mockFriendList)
}

}
15 changes: 11 additions & 4 deletions app/src/main/java/com/sopt/now/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class LoginActivity : AppCompatActivity() {
}
}
binding.btnLogin.setOnClickListener {
startMainActivity()
sendData(id,pw,nick)
}
}
Expand All @@ -61,12 +62,18 @@ class LoginActivity : AppCompatActivity() {
Toast.makeText(this,message,Toast.LENGTH_SHORT).show()
return loginBool
}
private fun startMainActivity(){
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
}
private fun sendData(id:String,pw:String,nick:String){
if (isLoginAvailable(id, pw)) {
val intent = Intent(this, MainActivity::class.java)
//메인 액티비티로 데이터를 보냄
intent.putExtra("id", id).putExtra("pw", pw).putExtra("nick", nick)
startActivity(intent)
var mypagefragment = MyPageFragment()
var bundle = Bundle()
bundle.putString("id",id)
bundle.putString("pw",pw)
bundle.putString("nick",nick)
mypagefragment.arguments = bundle
}
}
}
41 changes: 13 additions & 28 deletions app/src/main/java/com/sopt/now/MyPageFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,29 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.sopt.now.databinding.FragmentMyPageBinding

class MyPageFragment : Fragment() {
private lateinit var binding:FragmentMyPageBinding
private lateinit var binding: FragmentMyPageBinding

private var param1: String? = null
private var param2: String? = null

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

private val mockFriendList = listOf<Friend>(
Friend(
profileImage = R.drawable.ic_home_white_24,
name = "이의경",
selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지? ㅎㅎ 아직 반도 안왔어 ^&^",
),
Friend(
profileImage = R.drawable.ic_home_white_24,
name = "우상욱",
selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐",
),
Friend(
profileImage = R.drawable.ic_home_white_24,
name = "배지현",
selfDescription = "표정 풀자 ^^",
),
)
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding=FragmentMyPageBinding.inflate(inflater)
getUserInfo()
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val friendAdapter = FriendAdapter()
binding.rvFriends.run {
adapter = friendAdapter
layoutManager = LinearLayoutManager(requireContext())
}
friendAdapter.setFriendList(mockFriendList)
private fun getUserInfo() {
binding.tvMainNick.text = arguments?.getString("nick")
binding.tvMainId.text = arguments?.getString("id")
binding.tvMainPw.text = arguments?.getString("pw")
}

}
10 changes: 7 additions & 3 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".HomeFragment">

<!-- TODO: Update blank fragment layout -->
<TextView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_friends"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="home" />
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_friend"
android:paddingVertical="5dp"/>

</FrameLayout>
83 changes: 71 additions & 12 deletions app/src/main/res/layout/fragment_my_page.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MyPageFragment">
<ImageView
android:id="@+id/iv_main_user_img"
android:layout_width="200dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:src="@drawable/main"
android:layout_marginTop="30dp"
app:layout_constraintDimensionRatio="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_main_nick"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:textColor="#000000"
android:textSize="25sp"
android:textStyle="bold"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_main_user_img" />
<TextView
android:id="@+id/tv_main_title_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="@string/id"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_main_nick" />
<TextView
android:id="@+id/tv_main_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="15sp"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_main_title_id" />
<TextView
android:id="@+id/tv_main_title_pw"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/pw"
android:textColor="#000000"
android:textSize="25sp"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_main_id" />
<TextView
android:id="@+id/tv_main_pw"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="15sp"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_main_title_pw" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_friends"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_friend"
android:paddingVertical="5dp"/>

</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 131ba88

Please sign in to comment.