diff --git a/app/src/main/java/com/example/favoriteplace/HomeFragment.kt b/app/src/main/java/com/example/favoriteplace/HomeFragment.kt index 8ad67e8..617eab2 100644 --- a/app/src/main/java/com/example/favoriteplace/HomeFragment.kt +++ b/app/src/main/java/com/example/favoriteplace/HomeFragment.kt @@ -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 } @@ -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)) //로그인 버튼 @@ -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 : 로그인 상태 다시 돌려놓기 @@ -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) @@ -184,7 +187,8 @@ class HomeFragment : Fragment() { private fun getUserInfo(userToken: String) { lifecycleScope.launch { try { - val response: Response = homeService.getUserInfo("Bearer $userToken") + val response: Response = + homeService.getUserInfo("Bearer $userToken") if (response.isSuccessful) { // 로그인 상태인 경우 // 서버로부터 사용자 정보를 성공적으로 받아왔을 때 UI 업데이트 @@ -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() // 변경 사항을 적용 diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index b673fc5..c4edfca 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -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" > @@ -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" /> @@ -121,23 +121,23 @@ android:layout_width="130dp" android:layout_height="120dp" - app:srcCompat="@drawable/ic_shop1"/> + app:srcCompat="@drawable/ic_shop1" /> + android:layout_marginStart="35dp" + android:orientation="vertical"> + android:src="@drawable/user_title" /> + android:textSize="20dp" + android:textStyle="bold" /> + + android:textSize="20dp" /> + + android:textSize="20dp" + android:textStyle="bold" /> @@ -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"> + android:gravity="center" + android:visibility="gone"> + android:src="@drawable/img3" /> + android:src="@drawable/ic_black_b" /> + android:textColor="@color/white" + android:textStyle="bold" /> + android:orientation="horizontal"> + android:layout_weight="1" /> @@ -328,15 +329,16 @@ 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"> @@ -372,16 +374,16 @@ + android:background="@drawable/edge" + android:orientation="vertical"> @@ -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"> - + app:layout_constraintTop_toBottomOf="@+id/home_real_time_post_tv" + tools:listitem="@layout/item_trending_post" /> - - - + android:layout_marginTop="20dp" + android:src="@drawable/img_home_banner1" + android:clickable="true" + android:background="@drawable/round" + /> + + + + + + + +