Skip to content

Commit

Permalink
#72 프로필 수정에서 프로필 이미지 설명 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
eoqkrskfk94 committed Mar 6, 2022
1 parent 2707b4e commit 26094d8
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CreateProfileFragment2 : Fragment() {

private fun setProfileInformation() {
viewModel.selectedSkillItems.observe(viewLifecycleOwner) {
if(it.size in 1..3) {
if(it.size in 0..3) {
viewDataBinding.profileImage.setImageResource(R.drawable.image_tree_1)
viewDataBinding.textviewProfileDescription.text = getString(R.string.skill_level_1)
} else if(it.size in 4..7) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContract
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.nexters.checkareer.R
import com.nexters.checkareer.databinding.EditProfileFragBinding
import com.nexters.checkareer.domain.vo.SkillTree
import com.nexters.checkareer.presentation.ui.editprofile.adapter.MySkillEditAdapter
Expand All @@ -26,6 +28,7 @@ import com.nexters.checkareer.presentation.ui.editprofile.listener.ItemDragListe
import com.nexters.checkareer.presentation.ui.editprofile.skillorder.ChangeSkillOrderActivity
import com.nexters.checkareer.presentation.ui.editprofile.util.ItemTouchHelperCallback
import com.nexters.checkareer.presentation.ui.home.adapter.MySkillAdapter
import com.skydoves.balloon.*
import dagger.hilt.android.AndroidEntryPoint


Expand All @@ -35,6 +38,7 @@ class EditProfileFragment : Fragment(), SkillEditListener {
private val viewModel by activityViewModels<EditProfileViewModel>()
private lateinit var viewDataBinding: EditProfileFragBinding

private lateinit var profileImageDescriptionBalloon: Balloon
private lateinit var startActivityForResult: ActivityResultLauncher<Intent>
private lateinit var editSkillAdapter: MySkillEditAdapter
private lateinit var addSkillBottomSheet: BottomSheetDialogFragment
Expand All @@ -59,6 +63,8 @@ class EditProfileFragment : Fragment(), SkillEditListener {
setupMySkillAdapter()
setupMySkillTopThreeAdapter()
setEvents()
setProfileInformation()
setProfileDescriptionBalloon()

}

Expand All @@ -79,6 +85,42 @@ class EditProfileFragment : Fragment(), SkillEditListener {
}
}

private fun setProfileInformation() {
viewModel.profile.observe(viewLifecycleOwner) {
if(it?.skills?.size in 0..3) {
viewDataBinding.profileImage.setImageResource(R.drawable.image_tree_1)
viewDataBinding.textviewProfileDescription.text = getString(R.string.skill_level_1)
} else if(it?.skills?.size in 4..7) {
viewDataBinding.profileImage.setImageResource(R.drawable.image_tree_2)
viewDataBinding.textviewProfileDescription.text = getString(R.string.skill_level_2)
} else {
viewDataBinding.profileImage.setImageResource(R.drawable.image_tree_3)
viewDataBinding.textviewProfileDescription.text = getString(R.string.skill_level_3)
}
}
}

private fun setProfileDescriptionBalloon() {
profileImageDescriptionBalloon = Balloon.Builder(requireContext())
.setLayout(R.layout.profile_description_item)
.setArrowOrientation(ArrowOrientation.TOP)
.setArrowPositionRules(ArrowPositionRules.ALIGN_ANCHOR)
.setWidthRatio(1f)
.setMarginLeft(20)
.setMarginRight(20)
.setCornerRadius(10f)
.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
.setBalloonAnimation(BalloonAnimation.OVERSHOOT)
.setLifecycleOwner(viewLifecycleOwner)
.build()



viewDataBinding.imageviewProfileDescription.setOnClickListener {
viewDataBinding.imageviewProfileDescription.showAlignBottom(profileImageDescriptionBalloon)
}
}

private fun setupBackButton() {
viewDataBinding.imageviewBack.setOnClickListener {
requireActivity().finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HomeFragment2 : Fragment() {

private fun setProfileImage() {
viewModel.profile.observe(viewLifecycleOwner) {
if(it.skills.size in 1..3) {
if(it.skills.size in 0..3) {
viewDataBinding.profileImage.setImageResource(R.drawable.image_tree_1)
} else if(it.skills.size in 4..7) {
viewDataBinding.profileImage.setImageResource(R.drawable.image_tree_2)
Expand Down
46 changes: 43 additions & 3 deletions app/src/main/res/layout/edit_profile_frag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,62 @@
android:paddingEnd="@dimen/margin_8dp"
android:paddingBottom="@dimen/margin_normal">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:orientation="horizontal">

<TextView
android:id="@+id/textview_profile_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:layout_weight="1"
tools:text="아직 찍먹 중인"
android:textColor="@color/light_gray"
android:textSize="20sp" />

<ImageView
android:id="@+id/imageview_profile_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:padding="5dp"
android:src="@drawable/ic_question_mark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/gray" />


</LinearLayout>

<EditText
android:id="@+id/edittext_name"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="@dimen/margin_normal"
android:layout_marginBottom="10dp"
android:backgroundTint="@color/point_color_1"
android:hint="@string/please_insert_name"
android:inputType="text"
android:text="@{viewmodel.profile.user.name}"
android:textSize="18sp"
android:textSize="20sp"
android:textStyle="bold" />

<ImageView
android:id="@+id/profile_image"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_gravity="center"
android:layout_marginBottom="15dp"
tools:src="@drawable/image_tree_1" />


<TextView
style="@style/BoldText"
Expand Down

0 comments on commit 26094d8

Please sign in to comment.