Skip to content

Commit

Permalink
Merge pull request #73 from Nexters/enhancement/72/profile-image
Browse files Browse the repository at this point in the history
close #72 Enhancement/72/profile image
  • Loading branch information
eoqkrskfk94 authored Mar 6, 2022
2 parents 00af0ba + 26094d8 commit a32fe39
Show file tree
Hide file tree
Showing 13 changed files with 528 additions and 24 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,7 @@ dependencies {
implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
kapt "com.github.bumptech.glide:compiler:$rootProject.glideVersion"

// Ballon layout
implementation "com.github.skydoves:balloon:1.4.2"

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.core.widget.addTextChangedListener
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import com.nexters.checkareer.R
import com.nexters.checkareer.data.adapter.db.data.UserProfile
import com.nexters.checkareer.databinding.CreateProfileFrag2Binding
import com.nexters.checkareer.domain.skill.Skill
Expand All @@ -24,6 +26,7 @@ import com.nexters.checkareer.presentation.ui.createprofile.listener.SkillCatego
import com.nexters.checkareer.presentation.ui.createprofile.model.CategorySelect
import com.nexters.checkareer.presentation.ui.home.HomeActivity
import com.nexters.checkareer.presentation.ui.home.adapter.MySkillAdapter
import com.skydoves.balloon.*
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber

Expand All @@ -32,6 +35,7 @@ class CreateProfileFragment2 : Fragment() {

private val viewModel by viewModels<CreateProfile2ViewModel>()
private val args: CreateProfileFragment2Args by navArgs()
private lateinit var profileImageDescriptionBalloon: Balloon

private lateinit var viewDataBinding: CreateProfileFrag2Binding

Expand All @@ -50,6 +54,8 @@ class CreateProfileFragment2 : Fragment() {
setupMySkillAdapter()
setupEditTextEvent()
setEvents()
setProfileInformation()
setProfileDescriptionBalloon()

viewDataBinding.imageviewBack.setOnClickListener {
findNavController().popBackStack()
Expand All @@ -66,6 +72,42 @@ class CreateProfileFragment2 : Fragment() {
}
}

private fun setProfileInformation() {
viewModel.selectedSkillItems.observe(viewLifecycleOwner) {
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) {
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 setEvents() {
viewModel.goHome.observe(this.viewLifecycleOwner) {
val intent = Intent(requireContext(), HomeActivity::class.java)
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 @@ -5,14 +5,18 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import com.nexters.checkareer.R
import com.nexters.checkareer.databinding.HomeFrag2Binding
import com.nexters.checkareer.presentation.ui.createprofile.CreateProfileActivity
import com.nexters.checkareer.presentation.ui.editprofile.EditProfileActivity
import com.nexters.checkareer.presentation.ui.home.adapter.MySkillAdapter
import com.nexters.checkareer.presentation.ui.home.adapter.skill.SkillTreeAdapter
import com.nexters.checkareer.presentation.ui.home.adapter.skill.SkillTreeViewType
import com.skydoves.balloon.*
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand All @@ -22,6 +26,8 @@ class HomeFragment2 : Fragment() {

private lateinit var viewDataBinding: HomeFrag2Binding

private lateinit var profileImageDescriptionBalloon: Balloon

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
viewDataBinding = HomeFrag2Binding.inflate(inflater, container, false).apply {
viewmodel = viewModel
Expand All @@ -38,6 +44,8 @@ class HomeFragment2 : Fragment() {
setupLifecycleOwner()
setupMySkillAdapter()
setupMySkillTopThreeAdapter()
setProfileImage()
setProfileDescriptionBalloon()
}

private fun setupProfileEditButton() {
Expand All @@ -46,6 +54,39 @@ class HomeFragment2 : Fragment() {
}
}

private fun setProfileImage() {
viewModel.profile.observe(viewLifecycleOwner) {
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)
} else {
viewDataBinding.profileImage.setImageResource(R.drawable.image_tree_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 setupProfileDeleteButton() {
viewDataBinding.imageviewDelete.setOnClickListener {
val mDialogView = LayoutInflater.from(requireContext()).inflate(R.layout.confirm_dialog, null)
Expand Down
Binary file added app/src/main/res/drawable-v24/image_tree_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-v24/image_tree_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-v24/image_tree_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_question_mark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z"/>
</vector>
48 changes: 44 additions & 4 deletions app/src/main/res/layout/create_profile_frag_2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,61 @@
android:orientation="vertical"
android:padding="10dp">

<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="5dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="20dp"
android:layout_marginBottom="10dp"
android:backgroundTint="@color/point_color_1"
android:hint="@string/please_insert_name"
android:inputType="text"
android:textSize="16sp"
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
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -129,7 +169,7 @@
mySkillTopThreeItems="@{viewmodel.selectedSkillItems}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:requiresFadingEdge="horizontal"/>
android:requiresFadingEdge="horizontal" />


</LinearLayout>
Expand Down
Loading

0 comments on commit a32fe39

Please sign in to comment.