Skip to content

Commit

Permalink
[MERGE] #423 -> develop
Browse files Browse the repository at this point in the history
[FIX/#423] 3차 스프린트 건의사항 추합 반영
  • Loading branch information
Marchbreeze authored Mar 3, 2024
2 parents 180c264 + 9296079 commit a0b1fee
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.el.yello.presentation.main.profile.info

import android.content.Intent
import android.content.res.Resources
import android.net.Uri
import android.os.Bundle
import android.view.View
import android.view.animation.AnimationUtils
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
Expand Down Expand Up @@ -101,7 +103,8 @@ class ProfileFragment : BindingFragment<FragmentProfileBinding>(R.layout.fragmen
itemClick = ::initItemClickListener,
shopClick = ::initShopClickListener,
modClick = ::initProfileModClickListener,
bannerClick = ::initProfileBannerClickListener
bannerClick = ::initProfileBannerClickListener,
setHeight = ::setSpinnerHeight
)
binding.rvProfileFriendsList.adapter = adapter
}
Expand Down Expand Up @@ -180,6 +183,7 @@ class ProfileFragment : BindingFragment<FragmentProfileBinding>(R.layout.fragmen
is UiState.Success -> {
binding.ivProfileLoading.isVisible = false
friendsList = state.data.friends
binding.tvProfileNoFriend.isVisible = friendsList.isEmpty()
adapter.addItemList(friendsList)
}

Expand Down Expand Up @@ -231,6 +235,7 @@ class ProfileFragment : BindingFragment<FragmentProfileBinding>(R.layout.fragmen
delay(450)
binding.rvProfileFriendsList.addItemDecoration(itemDivider)
viewModel.myFriendCount -= 1
binding.tvProfileNoFriend.isVisible = viewModel.myFriendCount == 0
adapter.notifyDataSetChanged()
}
AmplitudeManager.trackEventWithProperties("complete_profile_delete_friend")
Expand Down Expand Up @@ -271,6 +276,18 @@ class ProfileFragment : BindingFragment<FragmentProfileBinding>(R.layout.fragmen
}.launchIn(lifecycleScope)
}

private fun setSpinnerHeight(userInfoHeight: Int) {
val screenHeight = Resources.getSystem().displayMetrics.heightPixels
binding.ivProfileLoading.layoutParams =
(binding.ivProfileLoading.layoutParams as ConstraintLayout.LayoutParams).apply {
bottomMargin = (screenHeight - userInfoHeight) / 2
}
binding.tvProfileNoFriend.layoutParams =
(binding.tvProfileNoFriend.layoutParams as ConstraintLayout.LayoutParams).apply {
bottomMargin = (screenHeight - userInfoHeight) / 2
}
}

fun scrollToTop() {
binding.rvProfileFriendsList.smoothScrollToPosition(0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ProfileFriendAdapter(
private val shopClick: (Unit) -> (Unit),
private val modClick: (Unit) -> (Unit),
private val bannerClick: (String) -> (Unit),
private val setHeight: (Int) -> (Unit)
) : ListAdapter<ProfileUserModel, RecyclerView.ViewHolder>(diffUtil) {

private var itemList = mutableListOf<ProfileUserModel>()
Expand Down Expand Up @@ -87,6 +88,15 @@ class ProfileFriendAdapter(
}
}

override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder) {
super.onViewAttachedToWindow(holder)
if (holder is ProfileUserInfoViewHolder) {
holder.itemView.post {
setHeight(holder.itemView.height)
}
}
}

companion object {
private val diffUtil = ItemDiffCallback<ProfileUserModel>(
onItemsTheSame = { old, new -> old.userId == new.userId },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.el.yello.presentation.main.profile.schoolmod

import android.content.res.Resources
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.fragment.app.activityViewModels
import com.el.yello.R
import com.el.yello.databinding.FragmentProfileModDialogBinding
import com.example.ui.base.BindingDialogFragment
import com.example.ui.extension.setOnSingleClickListener
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class SchoolModDialog :
BindingDialogFragment<FragmentProfileModDialogBinding>(R.layout.fragment_profile_mod_dialog) {

private val viewModel by activityViewModels<SchoolProfileModViewModel>()

override fun onStart() {
super.onStart()
setDialogBackground()
}

private fun setDialogBackground() {
val deviceWidth = Resources.getSystem().displayMetrics.widthPixels
val dialogHorizontalMargin = (Resources.getSystem().displayMetrics.density * 16) * 2

dialog?.window?.apply {
setLayout(
(deviceWidth - dialogHorizontalMargin * 2).toInt(),
WindowManager.LayoutParams.WRAP_CONTENT,
)
setBackgroundDrawableResource(R.color.transparent)
}
dialog?.setCanceledOnTouchOutside(false)
dialog?.setCancelable(true)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

initModBtnListener()
initRejectBtnListener()
}

private fun initRejectBtnListener() {
binding.btnProfileDialogReject.setOnSingleClickListener { dismiss() }
}

private fun initModBtnListener() {
binding.btnProfileDialogMod.setOnSingleClickListener {
viewModel.getSchoolGroupIdFromServer()
dismiss()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import com.el.yello.R
import com.el.yello.databinding.ActivityProfileSchoolModBinding
import com.el.yello.presentation.main.profile.detail.ProfileDetailActivity
import com.el.yello.presentation.main.profile.detail.ProfileDetailActivity.Companion.RESULT_PROFILE_MODIFY_FAILURE
import com.el.yello.presentation.main.profile.univmod.UnivProfileModViewModel.Companion.TEXT_NONE
import com.el.yello.presentation.main.profile.univmod.UnivProfileModActivity
import com.el.yello.presentation.main.profile.univmod.UnivProfileModViewModel.Companion.TEXT_NONE
import com.el.yello.util.extension.yelloSnackbar
import com.example.ui.extension.navigateTo
import com.example.ui.base.BindingActivity
import com.example.ui.extension.drawableOf
import com.example.ui.state.UiState
import com.example.ui.extension.navigateTo
import com.example.ui.extension.setOnSingleClickListener
import com.example.ui.state.UiState
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -33,6 +33,7 @@ class SchoolProfileModActivity :
private var schoolModSearchBottomSheet: SchoolModSearchBottomSheet? = null
private var schoolModGradeBottomSheet: SchoolModGradeBottomSheet? = null
private var schoolModClassroomBottomSheet: SchoolModClassroomBottomSheet? = null
private var schoolModDialog: SchoolModDialog? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -86,7 +87,8 @@ class SchoolProfileModActivity :
}

else -> {
viewModel.getSchoolGroupIdFromServer()
schoolModDialog = SchoolModDialog()
schoolModDialog?.show(supportFragmentManager, DIALOG_MOD)
}
}
}
Expand Down Expand Up @@ -196,11 +198,13 @@ class SchoolProfileModActivity :
if (schoolModSearchBottomSheet != null) schoolModSearchBottomSheet?.dismiss()
if (schoolModGradeBottomSheet != null) schoolModGradeBottomSheet?.dismiss()
if (schoolModClassroomBottomSheet != null) schoolModClassroomBottomSheet?.dismiss()
if (schoolModDialog != null) schoolModDialog?.dismiss()
}

private companion object {
const val DIALOG_SCHOOL = "school"
const val DIALOG_GRADE = "grade"
const val DIALOG_CLASSROOM = "classroom"
const val DIALOG_MOD = "mod"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.el.yello.presentation.main.profile.univmod

import android.content.res.Resources
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.fragment.app.activityViewModels
import com.el.yello.R
import com.el.yello.databinding.FragmentProfileModDialogBinding
import com.example.ui.base.BindingDialogFragment
import com.example.ui.extension.setOnSingleClickListener
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class UnivModDialog :
BindingDialogFragment<FragmentProfileModDialogBinding>(R.layout.fragment_profile_mod_dialog) {

private val viewModel by activityViewModels<UnivProfileModViewModel>()

override fun onStart() {
super.onStart()
setDialogBackground()
}

private fun setDialogBackground() {
val deviceWidth = Resources.getSystem().displayMetrics.widthPixels
val dialogHorizontalMargin = (Resources.getSystem().displayMetrics.density * 16) * 2

dialog?.window?.apply {
setLayout(
(deviceWidth - dialogHorizontalMargin * 2).toInt(),
WindowManager.LayoutParams.WRAP_CONTENT,
)
setBackgroundDrawableResource(R.color.transparent)
}
dialog?.setCanceledOnTouchOutside(false)
dialog?.setCancelable(true)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

initModBtnListener()
initRejectBtnListener()
}

private fun initRejectBtnListener() {
binding.btnProfileDialogReject.setOnSingleClickListener { dismiss() }
}

private fun initModBtnListener() {
binding.btnProfileDialogMod.setOnSingleClickListener {
viewModel.postNewProfileToServer()
dismiss()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import com.el.yello.presentation.main.profile.detail.ProfileDetailActivity.Compa
import com.el.yello.presentation.main.profile.schoolmod.SchoolProfileModActivity
import com.el.yello.presentation.main.profile.univmod.UnivProfileModViewModel.Companion.TEXT_NONE
import com.el.yello.util.extension.yelloSnackbar
import com.example.ui.extension.navigateTo
import com.example.ui.base.BindingActivity
import com.example.ui.extension.drawableOf
import com.example.ui.state.UiState
import com.example.ui.extension.navigateTo
import com.example.ui.extension.setOnSingleClickListener
import com.example.ui.state.UiState
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -32,6 +32,7 @@ class UnivProfileModActivity :

private var univModSearchBottomSheet: UnivModSearchBottomSheet? = null
private var univModSelectBottomSheet: UnivModSelectBottomSheet? = null
private var univModDialog: UnivModDialog? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -77,7 +78,8 @@ class UnivProfileModActivity :
}

else -> {
viewModel.postNewProfileToServer()
univModDialog = UnivModDialog()
univModDialog?.show(supportFragmentManager, DIALOG_MOD)
}
}
}
Expand Down Expand Up @@ -161,11 +163,13 @@ class UnivProfileModActivity :
super.onDestroy()
if (univModSearchBottomSheet != null) univModSearchBottomSheet?.dismiss()
if (univModSelectBottomSheet != null) univModSelectBottomSheet?.dismiss()
if (univModDialog != null) univModDialog?.dismiss()
}

private companion object {
const val DIALOG_SCHOOL = "school"
const val DIALOG_SUBGROUP = "subgroup"
const val DIALOG_YEAR = "year"
const val DIALOG_MOD = "mod"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/grayscales_800" />
android:color="@color/grayscales_600" />
<corners android:radius="40dp" />
</shape>
18 changes: 16 additions & 2 deletions app/src/main/res/layout/fragment_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,28 @@
android:id="@+id/iv_profile_loading"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="180dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/lottie_spinner_loading_profile" />
app:lottie_rawRes="@raw/lottie_spinner_loading_profile"
tools:visibility="visible" />

<TextView
android:id="@+id/tv_profile_no_friend"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/profile_no_friend"
android:textAppearance="@style/TextAppearance.Yello.LabelLarge"
android:textColor="@color/grayscales_600"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
Loading

0 comments on commit a0b1fee

Please sign in to comment.