Skip to content

Commit d6dc195

Browse files
committed
Merge branch 'refs/heads/main' into SPOT-231-FEAT-신청승인UI수정
2 parents 33e8796 + 05c06a0 commit d6dc195

27 files changed

+433
-323
lines changed

SPOTeam_android/.idea/deploymentTargetSelector.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SPOTeam_android/app/src/main/java/com/example/spoteam_android/Data.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,4 +668,19 @@ data class FinishedStudyItem(
668668
val finishedAt: String?
669669
)
670670

671+
data class WithdrawResponse(
672+
val isSuccess: Boolean,
673+
val code: String,
674+
val message: String,
675+
val result: WithdrawResult?
676+
)
677+
678+
data class WithdrawResult(
679+
val memberId: Int,
680+
val name: String,
681+
val email: String,
682+
val inactive: String
683+
)
684+
685+
671686

SPOTeam_android/app/src/main/java/com/example/spoteam_android/login/LoginApiService.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.example.spoteam_android.StudyReasons
1717
import com.example.spoteam_android.ThemeApiResponse
1818
import com.example.spoteam_android.ThemePreferences
1919
import com.example.spoteam_android.ValidateEmailResponse
20+
import com.example.spoteam_android.WithdrawResponse
2021
import com.example.spoteam_android.YourResponse
2122
import retrofit2.Call
2223
import retrofit2.Response
@@ -26,6 +27,7 @@ import retrofit2.http.FormUrlEncoded
2627
import retrofit2.http.GET
2728
import retrofit2.http.Header
2829
import retrofit2.http.Headers
30+
import retrofit2.http.PATCH
2931
import retrofit2.http.POST
3032
import retrofit2.http.Path
3133
import retrofit2.http.Query
@@ -89,4 +91,10 @@ interface LoginApiService {
8991
@Body request: NickNameRequest
9092
): Call<NickNameResponse>
9193

94+
//회원 탈퇴
95+
@PATCH("spot/withdraw")
96+
fun withdraw(): Call<WithdrawResponse>
97+
98+
99+
92100
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.example.spoteam_android.ui.mypage
2+
3+
import android.app.Dialog
4+
import android.content.Context
5+
import android.graphics.Color
6+
import android.graphics.drawable.ColorDrawable
7+
import android.view.Window
8+
import android.widget.Button
9+
import android.widget.ImageView
10+
import com.example.spoteam_android.R
11+
12+
class LogOutCompleteDialog(
13+
private val context: Context,
14+
private val onConfirm: () -> Unit
15+
) {
16+
private val dlg = Dialog(context)
17+
18+
fun start() {
19+
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE)
20+
dlg.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
21+
dlg.setContentView(R.layout.dialog_logout_complete)
22+
23+
val confirmButton: Button = dlg.findViewById(R.id.dialog_complete_bt)
24+
val closeButton: ImageView = dlg.findViewById(R.id.close_iv)
25+
26+
confirmButton.setOnClickListener {
27+
onConfirm()
28+
dlg.dismiss()
29+
}
30+
31+
closeButton.setOnClickListener {
32+
onConfirm()
33+
dlg.dismiss()
34+
}
35+
36+
dlg.show()
37+
}
38+
}

SPOTeam_android/app/src/main/java/com/example/spoteam_android/ui/mypage/LogOutDialog.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,27 @@ import com.example.spoteam_android.R
1111

1212
class LogOutDialog(
1313
private val context: Context,
14-
private val onConfirm: () -> Unit //로그아웃 실행을 콜백함.
14+
private val onConfirm: () -> Unit
1515
) {
1616
private val dlg = Dialog(context)
1717

1818
fun start() {
19-
//다이얼로그 배경처리 관련 로직
2019
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE)
2120
dlg.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
2221
dlg.setContentView(R.layout.dialog_logout)
2322

24-
//다이얼로그 내 버튼별 UI 설정
2523
val logoutBtn: Button = dlg.findViewById(R.id.logout_bt)
2624
val cancelBtn: Button = dlg.findViewById(R.id.cancel_bt)
2725
val closeIv: ImageView = dlg.findViewById(R.id.close_iv)
2826

29-
// 로그아웃 버튼 클릭 시 로그아웃 실행
3027
logoutBtn.setOnClickListener {
31-
onConfirm() // 마이페이지프래그먼트에있는 플랫폼별 로그아웃실행
32-
dlg.dismiss() //다이얼로그 닫기
28+
onConfirm()
29+
dlg.dismiss()
3330
}
3431

35-
// 취소 버튼 및 닫기 버튼 클릭 시 다이얼로그 닫기
3632
cancelBtn.setOnClickListener { dlg.dismiss() }
3733
closeIv.setOnClickListener { dlg.dismiss() }
3834

39-
dlg.show() //다이얼로그 표시
35+
dlg.show()
4036
}
4137
}

SPOTeam_android/app/src/main/java/com/example/spoteam_android/ui/mypage/MyPageFragment.kt

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.example.spoteam_android.RetrofitInstance
2626
import com.example.spoteam_android.StudyItem
2727
import com.example.spoteam_android.StudyResponse
2828
import com.example.spoteam_android.ThemeApiResponse
29+
import com.example.spoteam_android.WithdrawResponse
2930
import com.example.spoteam_android.databinding.FragmentMypageBinding
3031
import com.example.spoteam_android.login.LoginApiService
3132
import com.example.spoteam_android.login.StartLoginActivity
@@ -34,7 +35,7 @@ import com.example.spoteam_android.ui.community.MyPageStudyNumInfo
3435
import com.example.spoteam_android.ui.community.MyPageStudyNumResponse
3536
import com.example.spoteam_android.ui.community.ScrapFragment
3637
import com.example.spoteam_android.ui.interestarea.FinishedStudyApiService
37-
import com.example.spoteam_android.ui.mypage.cancel.CancelSPOTFragment
38+
import com.example.spoteam_android.ui.mypage.cancel.CancelDialog
3839
import com.example.spoteam_android.ui.mypage.rule.CommunityPrivacyPolicyFragment
3940
import com.example.spoteam_android.ui.mypage.rule.CommunityRestrictionsFragment
4041
import com.example.spoteam_android.ui.mypage.rule.CommunityRuleFragment
@@ -76,7 +77,6 @@ class MyPageFragment : Fragment() {
7677
frameLayoutInProgress.setOnClickListener { navigateToFragment(ParticipatingStudyFragment()) }
7778
frameLayoutRecruiting.setOnClickListener { navigateToFragment(ConsiderAttendanceFragment()) }
7879
framelayoutApplied.setOnClickListener { navigateToFragment(PermissionWaitFragment()) }
79-
framelayoutDeleteAccount.setOnClickListener { showConfirmationDialog("회원 탈퇴", "정말로 회원 탈퇴를 진행하시겠습니까? 탈퇴 시 모든 데이터가 삭제됩니다.") { performAccountDeletion() } }
8080
framelayoutLogout.setOnClickListener {
8181
val dialog = LogOutDialog(requireContext()){
8282
performLogout()
@@ -94,7 +94,10 @@ class MyPageFragment : Fragment() {
9494
framelayout9.setOnClickListener{navigateToFragment(CommunityPrivacyPolicyFragment())}
9595
framelayout10.setOnClickListener{navigateToFragment(CommunityTermsOfUseFragment())}
9696

97-
tvDeleteAccount.setOnClickListener{navigateToFragment(CancelSPOTFragment())}
97+
framelayoutDeleteAccount.setOnClickListener{ val dialog = CancelDialog(requireContext()) {
98+
performWithdrawal()
99+
}
100+
dialog.start()}
98101
}
99102
}
100103

@@ -206,7 +209,7 @@ class MyPageFragment : Fragment() {
206209
val sharedPreferences = requireActivity().getSharedPreferences("MyPrefs", Context.MODE_PRIVATE)
207210
val loginPlatform = sharedPreferences.getString("loginPlatform", null)
208211

209-
when (loginPlatform) { //플랫폼별 로그인 구현. 일반로그인은 아직 구현중
212+
when (loginPlatform) {
210213
"kakao" -> logoutFromKakao()
211214
"naver" -> logoutFromNaver()
212215
else -> {
@@ -218,7 +221,6 @@ class MyPageFragment : Fragment() {
218221
private fun logoutFromKakao() {
219222
UserApiClient.instance.logout { error ->
220223
if (error != null) {
221-
// 🔸 이미 로그아웃된 상태라면 에러가 나올 수 있음
222224
Log.w("MyPageFragment", "카카오 로그아웃 실패 또는 이미 로그아웃됨: ${error.message}")
223225
} else {
224226
Log.i("MyPageFragment", "카카오 로그아웃 성공")
@@ -228,20 +230,19 @@ class MyPageFragment : Fragment() {
228230
clearSharedPreferences()
229231
RetrofitInstance.setAuthToken(null)
230232

231-
Toast.makeText(requireContext(), "로그아웃되었습니다", Toast.LENGTH_SHORT).show()
232-
navigateToLoginScreen()
233+
showLogoutCompleteDialog()
233234
}
234235
}
235236

237+
236238
private fun logoutFromNaver() {
237239
NaverIdLoginSDK.logout()
238240

239241
clearSharedPreferences()
240242

241243
RetrofitInstance.setAuthToken(null)
242244

243-
Toast.makeText(requireContext(), "네이버 로그아웃 성공", Toast.LENGTH_SHORT).show()
244-
navigateToLoginScreen()
245+
showLogoutCompleteDialog()
245246
}
246247

247248
private fun fetchFinishedStudyData() {
@@ -409,12 +410,39 @@ class MyPageFragment : Fragment() {
409410
startActivity(intent)
410411
}
411412

412-
private fun showConfirmationDialog(title: String, message: String, onConfirm: () -> Unit) {
413-
AlertDialog.Builder(requireContext())
414-
.setTitle(title)
415-
.setMessage(message)
416-
.setPositiveButton("확인") { _, _ -> onConfirm() }
417-
.setNegativeButton("취소", null)
418-
.show()
413+
//스터디 탈퇴 로직은 도입전.
414+
private fun performWithdrawal() {
415+
val service = RetrofitInstance.retrofit.create(LoginApiService::class.java)
416+
417+
service.withdraw().enqueue(object : Callback<WithdrawResponse> {
418+
override fun onResponse(call: Call<WithdrawResponse>, response: Response<WithdrawResponse>) {
419+
if (response.isSuccessful && response.body()?.isSuccess == true) {
420+
RetrofitInstance.setAuthToken(null)
421+
clearSharedPreferences()
422+
showWithdrawCompleteDialog()
423+
} else {
424+
Log.e("탈퇴 실패", response.errorBody()?.string() ?: "알 수 없는 오류")
425+
}
426+
}
427+
428+
override fun onFailure(call: Call<WithdrawResponse>, t: Throwable) {
429+
Log.e("탈퇴 실패", t.message ?: "네트워크 오류")
430+
}
431+
})
432+
}
433+
434+
private fun showLogoutCompleteDialog() {
435+
val dialog = LogOutCompleteDialog(requireContext()) {
436+
navigateToLoginScreen()
437+
}
438+
dialog.start()
419439
}
440+
private fun showWithdrawCompleteDialog() {
441+
val dialog = CancelFinishDialog(requireContext()) {
442+
navigateToLoginScreen()
443+
}
444+
dialog.start()
445+
}
446+
447+
420448
}

SPOTeam_android/app/src/main/java/com/example/spoteam_android/ui/mypage/RegionPreferenceFragment.kt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.spoteam_android.ui.mypage
22

3+
import LocationStudyFragment
34
import android.content.Context
45
import android.os.Bundle
56
import android.util.Log
@@ -48,7 +49,6 @@ class RegionPreferenceFragment : Fragment() {
4849
Toast.makeText(requireContext(), "Email not provided", Toast.LENGTH_SHORT).show()
4950
}
5051

51-
// 이유 수정 버튼 클릭 시
5252
binding.checklistspotLocationEditBt.setOnClickListener {
5353
val fragment = TemporaryRegionFragment()
5454
val bundle = Bundle().apply {
@@ -116,9 +116,9 @@ class RegionPreferenceFragment : Fragment() {
116116

117117
private fun displayRegions(regions: List<Region>) {
118118
val linearLayout = binding.fragmentRegionPreferenceLinearLayout
119-
linearLayout.removeAllViews() // 기존 TextView를 모두 제거
120-
selectedRegions.clear() // 새로운 데이터로 채우기 전에 리스트를 초기화
121-
selectedCodes.clear() // 코드 리스트도 초기화
119+
linearLayout.removeAllViews()
120+
selectedRegions.clear()
121+
selectedCodes.clear()
122122

123123
for (region in regions) {
124124
val regionText = "${region.province} ${region.district} ${region.neighborhood}"
@@ -150,6 +150,27 @@ class RegionPreferenceFragment : Fragment() {
150150
linearLayout.addView(textView)
151151
}
152152
}
153+
private fun createStyledRegionView(regionText: String): TextView {
154+
return TextView(requireContext()).apply {
155+
text = regionText
156+
textSize = 14.4f
157+
setPadding(30, 35, 50, 35)
158+
setTextColor(resources.getColor(R.color.b500, null))
159+
setBackgroundResource(R.drawable.button_background)
160+
typeface = ResourcesCompat.getFont(requireContext(), R.font.suit_semi_bold)
161+
162+
val params = LinearLayout.LayoutParams(
163+
LinearLayout.LayoutParams.MATCH_PARENT,
164+
LinearLayout.LayoutParams.WRAP_CONTENT
165+
).apply {
166+
marginStart = 20
167+
marginEnd = 20
168+
topMargin = 25
169+
}
170+
layoutParams = params
171+
}
172+
}
173+
153174

154175

155176
private fun goToLocationFragment() {

0 commit comments

Comments
 (0)