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] UX 에러 조치 #106

Open
wants to merge 5 commits into
base: develop2
Choose a base branch
from
Open
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
45 changes: 25 additions & 20 deletions app/src/main/java/com/example/favoriteplace/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ class HomeFragment : Fragment() {
// clearAccessToken()

// 신상품 페이지 이동
binding.homeNewItemMoreBtn.setOnClickListener {

val shopBannerNewFragment = ShopBannerNewFragment() // newItemFragment 인스턴스 생성
val transaction = parentFragmentManager.beginTransaction()
transaction.replace(R.id.main_frameLayout, shopBannerNewFragment)
transaction.addToBackStack(null)
transaction.commit()

binding.newitemlayout.setOnClickListener {
// 바텀 네비게이션 바에서 상점 아이템을 선택된 상태로 설정
(requireActivity() as MainActivity).setSelectedNavItem(R.id.shopFragment)
}


// 추천 랠리 이동
binding.homeRecommendMoreBtn.setOnClickListener {
binding.nonMembersLayout.setOnClickListener {
(requireActivity() as MainActivity).setRecommendRally(R.id.rallyhomeFragment)

}

//회원 랠리 이동
binding.membersRallyLayout.setOnClickListener {
(requireActivity() as MainActivity).setRecommendRally(R.id.rallyhomeFragment)
}

//하단 배너 랠리 이동
binding.homeBannerIv.setOnClickListener {
(requireActivity() as MainActivity).setRecommendRally(R.id.rallyhomeFragment)
}

return binding.root
}
Expand All @@ -94,12 +94,12 @@ class HomeFragment : Fragment() {

homeService = retrofit.create(HomeService::class.java)


val bannerAdapter = BannerVPAdapter(this)
binding.homeBannerVp.adapter = bannerAdapter
binding.homeBannerVp.orientation = ViewPager2.ORIENTATION_HORIZONTAL
bannerAdapter.addFragment(BannerFragment(R.drawable.img_home_banner1))
bannerAdapter.addFragment(BannerFragment(R.drawable.demo))
// val bannerAdapter = BannerVPAdapter(this)
//
// binding.homeBannerVp.adapter = bannerAdapter
// binding.homeBannerVp.orientation = ViewPager2.ORIENTATION_HORIZONTAL
// bannerAdapter.addFragment(BannerFragment(R.drawable.img_home_banner1))
// bannerAdapter.addFragment(BannerFragment(R.drawable.demo))


//로그인 버튼
Expand All @@ -120,7 +120,8 @@ class HomeFragment : Fragment() {

private fun checkLoginStatus() {
// SharedPreferences에서 액세스 토큰 가져오기
val sharedPreferences = requireActivity().getSharedPreferences("MyPrefs", Context.MODE_PRIVATE)
val sharedPreferences =
requireActivity().getSharedPreferences("MyPrefs", Context.MODE_PRIVATE)

accessToken = sharedPreferences.getString(ACCESS_TOKEN_KEY, null)
// TODO : 로그인 상태 다시 돌려놓기
Expand Down Expand Up @@ -151,9 +152,11 @@ class HomeFragment : Fragment() {
"자유게시판" -> Intent(context, PostDetailActivity::class.java).apply {
putExtra("POST_ID", post.id) // "자유게시판"의 경우 "POST_ID" 사용
}

"성지순례 인증" -> Intent(context, MyGuestBookActivity::class.java).apply {
putExtra("GUESTBOOK_ID", post.id) // "성지순례 인증"의 경우 "GUESTBOOK_ID" 사용
putExtra("GUESTBOOK_ID", post.id.toLong()) // "성지순례 인증"의 경우 "GUESTBOOK_ID" 사용
}

else -> return
}
startActivity(intent)
Expand Down Expand Up @@ -184,7 +187,8 @@ class HomeFragment : Fragment() {
private fun getUserInfo(userToken: String) {
lifecycleScope.launch {
try {
val response: Response<HomeService.LoginResponse> = homeService.getUserInfo("Bearer $userToken")
val response: Response<HomeService.LoginResponse> =
homeService.getUserInfo("Bearer $userToken")
if (response.isSuccessful) {
// 로그인 상태인 경우
// 서버로부터 사용자 정보를 성공적으로 받아왔을 때 UI 업데이트
Expand Down Expand Up @@ -336,7 +340,8 @@ class HomeFragment : Fragment() {
}

private fun clearAccessToken() {
val sharedPreferences = requireActivity().getSharedPreferences("MyPrefs", Context.MODE_PRIVATE)
val sharedPreferences =
requireActivity().getSharedPreferences("MyPrefs", Context.MODE_PRIVATE)
val editor = sharedPreferences.edit()
editor.remove(ACCESS_TOKEN_KEY) // 토큰 삭제
editor.apply() // 변경 사항을 적용
Expand Down
117 changes: 63 additions & 54 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@
android:id="@+id/user_layout"
android:layout_width="match_parent"
android:layout_height="160dp"
android:orientation="horizontal"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginStart="3dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="3dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone"

>
Expand All @@ -109,10 +109,10 @@
android:id="@+id/home_member_profile_civ"
android:layout_width="130dp"
android:layout_height="120dp"
app:civ_border_width="1dp"
app:civ_border_overlay="true"
android:src="@drawable/memberimg"
app:civ_border_color="@color/gray"/>
app:civ_border_color="@color/gray"
app:civ_border_overlay="true"
app:civ_border_width="1dp" />


<!--아이콘 크기 통일 시 변경하기-->
Expand All @@ -121,23 +121,23 @@
android:layout_width="130dp"
android:layout_height="120dp"

app:srcCompat="@drawable/ic_shop1"/>
app:srcCompat="@drawable/ic_shop1" />

</FrameLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_marginStart="35dp">
android:layout_marginStart="35dp"
android:orientation="vertical">


<ImageView
android:id="@+id/home_member_badge_iv"
android:layout_width="120dp"
android:layout_height="40dp"
android:src="@drawable/user_title"/>
android:src="@drawable/user_title" />

<LinearLayout
android:layout_width="wrap_content"
Expand All @@ -150,24 +150,26 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="아이"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20dp"/>
android:textSize="20dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text=" 님,"
android:textColor="@color/black"
android:textSize="20dp"/>
android:textSize="20dp" />
</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="여정을 떠나볼까요?"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20dp"/>
android:textSize="20dp"
android:textStyle="bold" />

</LinearLayout>

Expand All @@ -189,16 +191,16 @@
android:id="@+id/non_members_layout"
android:layout_width="180dp"
android:layout_height="170dp"
android:gravity="center"

android:layout_marginStart="10dp">
android:layout_marginStart="10dp"
android:clickable="true"
android:gravity="center">

<ImageView
android:id="@+id/home_recommend_iv"
android:layout_width="180dp"
android:layout_height="170dp"
android:scaleType="fitXY"
android:background="@drawable/round"
android:scaleType="fitXY"
android:src="@drawable/img1" />

<ImageView
Expand Down Expand Up @@ -235,10 +237,9 @@
android:id="@+id/members_rally_layout"
android:layout_width="180dp"
android:layout_height="170dp"
android:gravity="center"
android:layout_marginStart="10dp"
android:visibility="gone"
>
android:gravity="center"
android:visibility="gone">

<androidx.cardview.widget.CardView
android:id="@+id/cv"
Expand All @@ -252,36 +253,36 @@
android:layout_height="170dp"
android:background="@drawable/round"
android:scaleType="fitXY"
android:src="@drawable/img3"/>
android:src="@drawable/img3" />


<ImageView
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:scaleType="fitXY"
android:src="@drawable/ic_black_b"
android:layout_gravity="bottom"/>
android:src="@drawable/ic_black_b" />

<TextView
android:id="@+id/home_rallying_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom"
android:text="최애의 아이"
android:textStyle="bold"
android:textColor="@color/white" />
android:textColor="@color/white"
android:textStyle="bold" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignBottom="@+id/home_rally_iv"
android:layout_alignRight="@+id/home_rally_iv"
android:layout_alignBottom="@+id/home_rally_iv"
android:layout_gravity="bottom|right"
android:layout_marginStart="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom|right">
android:orientation="horizontal">

<TextView
android:id="@+id/rally_locationdetail_check_tv"
Expand Down Expand Up @@ -320,23 +321,24 @@
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
android:layout_weight="1" />


<!-- 신규 아이템 -->
<RelativeLayout
android:id="@+id/newitemlayout"
android:layout_width="180dp"
android:layout_height="170dp"
android:gravity="center"
android:layout_marginEnd="6dp">
android:layout_marginEnd="6dp"
android:clickable="true"
android:gravity="center">

<ImageView
android:id="@+id/home_new_item_iv"
android:layout_width="180dp"
android:layout_height="170dp"
android:scaleType="fitXY"
android:background="@drawable/round"
android:scaleType="fitXY"
android:src="@drawable/img2" />

<ImageView
Expand All @@ -349,19 +351,19 @@
android:id="@+id/home_new_item_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/home_new_item_iv"
android:layout_alignTop="@+id/home_new_item_iv"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:text="신규 아이템"
android:layout_alignStart="@+id/home_new_item_iv"
android:layout_alignTop="@+id/home_new_item_iv"
android:textColor="@color/white" />

<ImageButton
android:id="@+id/home_new_item_more_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignEnd="@+id/home_new_item_iv"
android:layout_alignTop="@+id/home_new_item_iv"
android:layout_alignEnd="@+id/home_new_item_iv"
android:layout_marginTop="3dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_more" />
Expand All @@ -372,16 +374,16 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="15dp"
android:background="@drawable/edge">
android:background="@drawable/edge"
android:orientation="vertical">

<TextView
android:id="@+id/home_real_time_post_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginStart="10dp"
android:layout_marginTop="15dp"
android:text="실시간 인기글"
android:textColor="@color/black"
android:textSize="18sp"
Expand All @@ -391,8 +393,8 @@
android:id="@+id/home_real_time_post2_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:text="소식을 알려드려요.🔥"
android:textColor="@color/black"
android:textSize="15sp" />
Expand All @@ -404,27 +406,34 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"

tools:listitem="@layout/item_trending_post"
app:layout_constraintTop_toBottomOf="@+id/home_real_time_post_tv">
</androidx.recyclerview.widget.RecyclerView>
app:layout_constraintTop_toBottomOf="@+id/home_real_time_post_tv"
tools:listitem="@layout/item_trending_post" />
</LinearLayout>

<!-- 배너 -->
<LinearLayout
android:id="@+id/home_banner_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">


<androidx.viewpager2.widget.ViewPager2
android:id="@+id/home_banner_vp"
<ImageView
android:id="@+id/home_banner_iv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:orientation="vertical"
android:background="@drawable/round" />

android:layout_marginTop="20dp"
android:src="@drawable/img_home_banner1"
android:clickable="true"
android:background="@drawable/round"
/>
<!-- <androidx.viewpager2.widget.ViewPager2-->
<!-- android:id="@+id/home_banner_vp"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginBottom="20dp"-->
<!-- android:orientation="vertical"-->

<!-- android:background="@drawable/round" />-->
</LinearLayout>
</LinearLayout>

Expand Down