Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 건물상세창 운영시간 클릭가능영역 확장/Ui 개선 + 닉네임 수정 후 마이페이지로 이동 #38

Merged
merged 1 commit into from
Sep 21, 2024
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
5 changes: 4 additions & 1 deletion app/src/main/java/com/devkor/kodaero/ApiService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import android.os.Parcelable
import kotlinx.parcelize.Parcelize

data class ApiResponse<T>(
val statusCode: Int,
Expand Down Expand Up @@ -148,6 +150,7 @@ data class UserTokens(
val refreshToken: String
)

@Parcelize
data class UserInfo(
val username: String,
val email: String,
Expand All @@ -156,7 +159,7 @@ data class UserInfo(
val role: String,
val level: String,
val categoryCount: Int
)
) : Parcelable

data class BuildingListResponse(
val list: List<BuildingItem>
Expand Down
38 changes: 32 additions & 6 deletions app/src/main/java/com/devkor/kodaero/EditNameFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package com.devkor.kodaero
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.activity.addCallback
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.devkor.kodaero.databinding.FragmentEditNameBinding

Expand Down Expand Up @@ -67,12 +69,7 @@ class EditNameFragment : Fragment() {

viewModel.editUserName(newUsername)

TokenManager.clearTokensAndUserInfo()

val splashIntent = Intent(requireActivity(), SplashActivity::class.java)
startActivity(splashIntent)

requireActivity().finish()
checkTokensAndFetchUserInfo()
}

binding.editNameNoButton.setOnClickListener {
Expand All @@ -95,6 +92,35 @@ class EditNameFragment : Fragment() {
inputMethodManager.hideSoftInputFromWindow(binding.editNameText.windowToken, 0)
}

private fun checkTokensAndFetchUserInfo() {
val accessToken = TokenManager.getAccessToken()
val refreshToken = TokenManager.getRefreshToken()

if (accessToken != null && refreshToken != null) {
viewModel.fetchUserInfo()

viewModel.userInfo.observe(viewLifecycleOwner, Observer { userInfo ->
if (userInfo != null) {
TokenManager.saveUserInfo(userInfo)

val bundle = Bundle().apply {
putParcelable("userInfo", userInfo)
}

val mypageFragment = MypageFragment().apply {
arguments = bundle
}

val transaction = requireActivity().supportFragmentManager.beginTransaction()
requireActivity().supportFragmentManager.popBackStack()
transaction.add(R.id.main_container, mypageFragment)
transaction.addToBackStack("MypageFragment")
transaction.commit()
}
})
}
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/devkor/kodaero/MypageFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MypageFragment : Fragment() {
_binding = FragmentMypageBinding.inflate(inflater, container, false)
val view = binding.root

val userInfo = TokenManager.getUserInfo()
val userInfo = arguments?.getParcelable<UserInfo>("userInfo") ?: TokenManager.getUserInfo()

userInfo?.let {
binding.username.text = it.username
Expand Down Expand Up @@ -149,4 +149,5 @@ class MypageFragment : Fragment() {
val mainActivity = activity as? MainActivity
mainActivity?.binding?.bottomNavigationView?.selectedItemId = R.id.fragment_home
}

}
10 changes: 4 additions & 6 deletions app/src/main/res/layout/fragment_building_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
android:id="@+id/show_operating_time_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingVertical="5dp"
android:paddingEnd="10dp"
app:layout_constraintTop_toBottomOf="@id/building_detail_address"
app:layout_constraintStart_toEndOf="@id/building_detail_guideline1">

Expand Down Expand Up @@ -140,7 +141,6 @@
android:id="@+id/building_detail_operating_time_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/show_operating_time_layout"
Expand Down Expand Up @@ -224,7 +224,7 @@
android:id="@+id/building_detail_facility_types"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_building_detail_types"
Expand Down Expand Up @@ -316,9 +316,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/building_detail_boundary"
app:layout_constraintVertical_bias="0.5">
app:layout_constraintTop_toBottomOf="@+id/building_detail_boundary">

<androidx.constraintlayout.widget.Guideline
android:id="@+id/building_detail_guideline5"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_edit_name.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
android:hint="어흥"
android:textSize="14dp"
android:textColor="@color/map_main"
android:textColorHint="@color/map_main"
android:textColorHint="@color/map_sub"
android:fontFamily="@font/pretendard_semibold"
android:background="@drawable/rounded_rec_bright_gray"
android:elevation="8dp"
Expand Down