Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SPOTeam_android/.idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SPOTeam_android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion SPOTeam_android/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ data class StudyDetailsResult( //StudyFragment에서 detail하게 들어갔을
val themes: List<String>,
val regions: List<String>,
val goal: String,
val introduction: String
val introduction: String,
)

data class Owner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,41 @@ class ActivityFeeStudyFragment : Fragment() {
})

viewModel.studyRequest.observe(viewLifecycleOwner) { request ->
if (viewModel.mode.value == StudyFormMode.EDIT && request != null) {
binding.fragmentActivityFeeStudyTv.text = "스터디 정보 수정"
binding.fragmentActivityFeeStudyPreviewBt.text = "수정완료"
setChipState(request.hasFee)

if (request.hasFee) {
binding.fragmentActivityFeeStudyNumFl.visibility = View.VISIBLE
binding.fragmentActivityFeeStudyEt.setText(request.fee.toString())
binding.fragmentActivityFeeStudyPreviewBt.isEnabled = true
} else {
binding.fragmentActivityFeeStudyNumFl.visibility = View.GONE
if (request == null) return@observe

val hasFee = request.hasFee

when (viewModel.mode.value) {
StudyFormMode.EDIT -> {
binding.fragmentActivityFeeStudyTv.text = "스터디 정보 수정"
binding.fragmentActivityFeeStudyPreviewBt.text = "수정완료"

setChipState(hasFee)

if (hasFee == true) {
binding.fragmentActivityFeeStudyNumFl.visibility = View.VISIBLE
binding.fragmentActivityFeeStudyEt.setText(request.fee.toString())
} else {
binding.fragmentActivityFeeStudyNumFl.visibility = View.GONE
}

binding.fragmentActivityFeeStudyPreviewBt.isEnabled = true
}

StudyFormMode.CREATE -> {
setChipState(hasFee)

}
if (viewModel.mode.value == StudyFormMode.CREATE && request != null) {
setChipState(request.hasFee)

if (request.hasFee == true) {
binding.fragmentActivityFeeStudyChipTrue.isChecked = true
binding.fragmentActivityFeeStudyNumFl.visibility = View.VISIBLE
} else if (request.hasFee == false) {
binding.fragmentActivityFeeStudyChipFalse.isChecked = true
binding.fragmentActivityFeeStudyNumFl.visibility = View.GONE
} else {
// 아무 것도 선택하지 않은 상태
binding.fragmentActivityFeeStudyChipTrue.isChecked = false
binding.fragmentActivityFeeStudyChipFalse.isChecked = false
binding.fragmentActivityFeeStudyNumFl.visibility = View.GONE
if (hasFee == true) {
binding.fragmentActivityFeeStudyNumFl.visibility = View.VISIBLE
} else {
binding.fragmentActivityFeeStudyNumFl.visibility = View.GONE
}
}

else -> Unit
}

}

viewModel.patchSuccess.observe(viewLifecycleOwner) { success ->
if (success) {
showCompletionDialog()
Expand Down Expand Up @@ -123,9 +123,9 @@ class ActivityFeeStudyFragment : Fragment() {
}
}

private fun setChipState(hasFee: Boolean) {
binding.fragmentActivityFeeStudyChipTrue.isChecked = hasFee
binding.fragmentActivityFeeStudyChipFalse.isChecked = !hasFee
private fun setChipState(hasFee: Boolean?) {
binding.fragmentActivityFeeStudyChipTrue.isChecked = hasFee == true
binding.fragmentActivityFeeStudyChipFalse.isChecked = hasFee == false
}


Expand All @@ -151,8 +151,13 @@ class ActivityFeeStudyFragment : Fragment() {
val feeText = binding.fragmentActivityFeeStudyEt.text.toString()
val fee = feeText.toIntOrNull() ?: 0

if (fee > 10000) {
binding.fragmentActivityFeeStudyEt.error = "최대 10,000원까지 입력 가능합니다."
if (fee > 100000) {
binding.fragmentActivityFeeStudyEt.error = "최대 100,000원까지 입력 가능합니다."
binding.fragmentActivityFeeStudyPreviewBt.isEnabled = false
return
}
if (fee < 1000) {
binding.fragmentActivityFeeStudyEt.error = "최소 1,000원부터 입력 가능합니다."
binding.fragmentActivityFeeStudyPreviewBt.isEnabled = false
return
}
Expand All @@ -179,7 +184,12 @@ class ActivityFeeStudyFragment : Fragment() {


private fun saveStudyData(fee: Int) {
// ViewModel에 필요한 데이터를 저장합니다
val hasFee = when {
binding.fragmentActivityFeeStudyChipTrue.isChecked -> true
binding.fragmentActivityFeeStudyChipFalse.isChecked -> false
else -> null // 사용자가 아무 칩도 선택하지 않은 경우
}

viewModel.setStudyData(
title = viewModel.studyRequest.value?.title.orEmpty(),
goal = viewModel.studyRequest.value?.goal.orEmpty(),
Expand All @@ -191,10 +201,12 @@ class ActivityFeeStudyFragment : Fragment() {
gender = viewModel.studyRequest.value?.gender ?: Gender.UNKNOWN,
minAge = viewModel.studyRequest.value?.minAge ?: 0,
maxAge = viewModel.studyRequest.value?.maxAge ?: 0,
fee = fee
fee = fee,
hasFee = hasFee
)
}


private fun goToNextFragment() {
val transaction = parentFragmentManager.beginTransaction()
transaction.replace(R.id.main_frm, MyStudyRegisterPreviewFragment())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class DetailStudyFragment : Fragment() {
fragmentDetailStudyViewTv.text = getString(R.string.hit_num_format, details.hitNum)
fragmentDetailStudyMemberMaxTv.text = getString(R.string.max_people_format, details.maxPeople)
fragmentDetailStudyOnlineTv.text = if (details.isOnline) "온라인" else "오프라인"
fragmentDetailStudyFeeTv.text = if (details.fee >0) "${details.fee}원" else "무료"
fragmentDetailStudyAgeTv.text = "${details.maxAge}세 이하"
fragmentDetailStudyChipTv.text = details.themes.take(3).joinToString("/")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class IntroduceStudyFragment : Fragment() {
val minAge = viewModel.studyRequest.value?.minAge ?: 0
val maxAge = viewModel.studyRequest.value?.maxAge ?: 0
val fee = viewModel.studyRequest.value?.fee ?: 0
val hasFee = viewModel.studyRequest.value?.hasFee

viewModel.setStudyData(
title = title,
Expand All @@ -223,7 +224,9 @@ class IntroduceStudyFragment : Fragment() {
gender = gender,
minAge = minAge,
maxAge = maxAge,
fee = fee
fee = fee,
hasFee = hasFee

)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.example.spoteam_android.ui.study

import StudyViewModel
import android.content.Context
import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import com.bumptech.glide.Glide
import com.example.spoteam_android.R
import com.example.spoteam_android.databinding.FragmentIntroduceStudyShortBinding

class IntroduceStudyShortFragment : Fragment() {
Expand All @@ -27,12 +30,29 @@ class IntroduceStudyShortFragment : Fragment() {
}



private fun updateUIWithData() {
val sharedPreferences = requireContext().getSharedPreferences("MyPrefs", Context.MODE_PRIVATE)
val email = sharedPreferences.getString("currentEmail", null)
val loginPlatform = sharedPreferences.getString("loginPlatform", null)

val profileImageUrl = when (loginPlatform) {
"kakao" -> sharedPreferences.getString("${email}_kakaoProfileImageUrl", null)
"naver" -> sharedPreferences.getString("${email}_naverProfileImageUrl", null)
else -> null
}

viewModel.studyRequest.value?.let { studyData ->
binding.fragmentIntroduceStudyShortTv.text = studyData.introduction
binding.fragmentIntroduceStudyShortTv.setTextColor(Color.parseColor("#2D2D2D"))

}

Glide.with(this)
.load(profileImageUrl)
.error(R.drawable.ic_preview_profile) // 실패 시 기본 이미지
.fallback(R.drawable.ic_preview_profile) // null일 때 기본 이미지
.into(binding.ivProfile)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MemberNumberRVAdapter(
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_member_number, parent, false)

val itemWidth = parent.context.resources.displayMetrics.widthPixels / 8
val itemWidth = parent.context.resources.displayMetrics.widthPixels / 7
view.layoutParams = RecyclerView.LayoutParams(itemWidth, ViewGroup.LayoutParams.WRAP_CONTENT)

return ViewHolder(view as ViewGroup)
Expand All @@ -47,7 +47,6 @@ class MemberNumberRVAdapter(

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val number = items[position]
val context = holder.itemView.context

holder.textView.text = number.toString()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,24 @@ class MemberStudyFragment : Fragment() {
val snapHelper = LinearSnapHelper()
snapHelper.attachToRecyclerView(binding.rvMemberStudyNum)

binding.rvMemberStudyNum.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
updateChildAlpha()
}

override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
updateChildAlpha()
}
}
})




binding.rvMemberStudyNum.adapter = memberAdapter


binding.rvMemberStudyNum.adapter = memberAdapter
binding.rvMemberStudyNum.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)


Expand Down Expand Up @@ -112,7 +126,7 @@ class MemberStudyFragment : Fragment() {
}

private fun saveData() {
val maxPeople = memberAdapter.getSelectedNumber() // 👈 새로 만든 함수로 가져오기
val maxPeople = memberAdapter.getSelectedNumber()

val selectedGender = binding.fragmentMemberStudyGenderSpinner.selectedItem.toString()
val gender = when (selectedGender) {
Expand All @@ -126,6 +140,7 @@ class MemberStudyFragment : Fragment() {
val maxAge = ageRangeSlider.values[1].toInt()

val profileImage = viewModel.studyRequest.value?.profileImage
val hasFee = viewModel.studyRequest.value?.hasFee

viewModel.setStudyData(
title = viewModel.studyRequest.value?.title.orEmpty(),
Expand All @@ -138,31 +153,12 @@ class MemberStudyFragment : Fragment() {
minAge = minAge,
maxAge = maxAge,
fee = viewModel.studyRequest.value?.fee ?: 0,
profileImage = profileImage // profileImage 파라미터 추가
profileImage = profileImage,
hasFee = hasFee
)

}

// private fun updateNextButtonState() {
// val isChecked = binding.
//
// if (isOnline) {
// binding.fragmentOnlineStudyBt.isEnabled = true
// binding.fragmentOnlineStudyBt.visibility = View.VISIBLE
// binding.fragmentOnlineStudyLocationPlusBt.visibility = View.GONE
// } else {
// if (hasChip) {
// binding.fragmentOnlineStudyBt.isEnabled = true
// binding.fragmentOnlineStudyBt.visibility = View.VISIBLE
// binding.fragmentOnlineStudyLocationPlusBt.visibility = View.GONE
// } else {
// binding.fragmentOnlineStudyBt.isEnabled = false
// binding.fragmentOnlineStudyBt.visibility = View.GONE
// binding.fragmentOnlineStudyLocationPlusBt.visibility = View.VISIBLE
// }
// }
// }

private fun goToNextFragment() {
val nextFragment = ActivityFeeStudyFragment().apply {
arguments = Bundle().apply {
Expand All @@ -188,16 +184,34 @@ class MemberStudyFragment : Fragment() {
binding.rvMemberStudyNum.smoothScrollBy(scrollBy, 0)
} else {
binding.rvMemberStudyNum.scrollToPosition(position)
binding.rvMemberStudyNum.post {
val v = layoutManager.findViewByPosition(position)
v?.let {
val rvCenterX = binding.rvMemberStudyNum.width / 2
val viewCenterX = it.left + it.width / 2
val scrollBy = viewCenterX - rvCenterX
binding.rvMemberStudyNum.smoothScrollBy(scrollBy, 0)
}
}
}

binding.rvMemberStudyNum.postDelayed({
updateChildAlpha()
}, 200)
}

private fun updateChildAlpha() {

for (i in 0 until binding.rvMemberStudyNum.childCount) {
val child = binding.rvMemberStudyNum.getChildAt(i) ?: continue

val location = IntArray(2)
child.getLocationInWindow(location)
val childCenterX = location[0] + child.width / 2

val rvLocation = IntArray(2)
binding.rvMemberStudyNum.getLocationInWindow(rvLocation)
val rvCenterX = rvLocation[0] + binding.rvMemberStudyNum.width / 2

val distanceFromCenter = kotlin.math.abs(rvCenterX - childCenterX)
val maxDistance = binding.rvMemberStudyNum.width / 2
val ratio = distanceFromCenter.toFloat() / maxDistance
val alpha = 1f - ratio.coerceIn(0f, 0.7f)

child.alpha = alpha
}
}


}
Loading