Skip to content

Commit

Permalink
KKUMI-108 [FEAT] #90 - 홈 화면에서 핀 정보 보이게 하기
Browse files Browse the repository at this point in the history
  • Loading branch information
jung0115 committed Oct 16, 2024
1 parent 6cfedb9 commit 199eac2
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ package com.marastro.mykkumi.common_ui.post

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.marastro.mykkumi.common_ui.R
import com.marastro.mykkumi.common_ui.databinding.ItemPostImageViewViewpagerBinding
import com.marastro.mykkumi.domain.entity.HomePostImageVO
import com.marastro.mykkumi.domain.entity.HomePostProductVO


class PostImagesAdapter(
private val context: Context,
private var postImageList: MutableList<HomePostImageVO>
private var postImageList: MutableList<HomePostImageVO>,
private val openViewProductInfo: (productInfo: HomePostProductVO) -> Unit,
) : RecyclerView.Adapter<PostImagesAdapter.PostItemImageViewHolder>() {

override fun onCreateViewHolder(
Expand Down Expand Up @@ -97,6 +100,11 @@ class PostImagesAdapter(
pinView.x = pin.positionX * (parentWidth - pinView.width)
pinView.y = pin.positionY * (parentHeight - pinView.height)
}

// 핀 터치 시 내용 열람
pinView.setOnClickListener(View.OnClickListener {
openViewProductInfo(item.pins[idx].productInfo)
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.marastro.mykkumi.common_ui.post

import android.os.Bundle
import android.view.View
import com.marastro.mykkumi.common_ui.base.BaseBottomSheetFragment
import com.marastro.mykkumi.common_ui.databinding.FragmentViewProductInfoBottomSheetBinding
import com.marastro.mykkumi.common_ui.R


class ViewProductInfoBottomSheet : BaseBottomSheetFragment<FragmentViewProductInfoBottomSheetBinding>(R.layout.fragment_view_product_info_bottom_sheet) {

private var productName: String = ""
private var productUrl: String = ""

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// 구매처 없는 경우 숨기기
if(productUrl.isEmpty()) {
binding.textInputProductUrlLabel.visibility = View.GONE
binding.textInputProductUrl.visibility = View.GONE
}
else {
binding.textInputProductUrlLabel.visibility = View.VISIBLE
binding.textInputProductUrl.visibility = View.VISIBLE
}

// 닫기버튼
binding.btnClose.setOnClickListener(View.OnClickListener {
dismiss()
})
}

override suspend fun initView() {
productName = arguments?.getString("productName") ?: ""
productUrl = arguments?.getString("productUrl") ?: ""

binding.textInputProductName.setText(productName)
binding.textInputProductUrl.setText(productUrl)
}
}
10 changes: 10 additions & 0 deletions core/common-ui/src/main/res/drawable/shape_back_light_round12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid
android:color="@color/main_light_color"/>
<corners
android:radius="12dp"/>

</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.marastro.mykkumi.common_ui.post.ViewProductInfoBottomSheet">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingTop="20dp"
android:paddingHorizontal="16dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="@color/neutral_900"
android:fontFamily="@font/pretendard_semibold"
android:text="@string/title_view_product_info"
android:layout_marginBottom="28dp"/>

<LinearLayout
android:id="@+id/linear_input_product_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="84dp"
android:orientation="vertical">

<TextView
android:id="@+id/text_input_product_name_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_product_name_for_input_product_info"
android:textSize="15sp"
android:textColor="@color/neutral_700"
android:fontFamily="@font/pretendard_semibold"
android:layout_marginBottom="8dp"/>

<TextView
android:id="@+id/text_input_product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="@color/neutral_900"
android:fontFamily="@font/pretendard_medium"
android:textColorHint="@color/neutral_300"
android:gravity="top"
android:paddingVertical="14dp"
android:paddingHorizontal="16dp"
android:background="@drawable/shape_back_light_round12" />

<TextView
android:id="@+id/text_input_product_url_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_product_url_for_input_product_info"
android:textSize="15sp"
android:textColor="@color/neutral_700"
android:fontFamily="@font/pretendard_semibold"
android:layout_marginTop="20dp"
android:layout_marginBottom="8dp"/>

<TextView
android:id="@+id/text_input_product_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="@color/neutral_900"
android:fontFamily="@font/pretendard_medium"
android:textColorHint="@color/neutral_300"
android:gravity="top"
android:paddingVertical="14dp"
android:paddingHorizontal="16dp"
android:background="@drawable/shape_back_light_round12"/>

</LinearLayout>

<LinearLayout
android:id="@+id/linear_confirm_btns"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="16dp"
android:layout_marginBottom="10dp">


<TextView
android:id="@+id/btn_close"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/close_view_product_info"
android:textColor="@color/white"
android:textSize="15sp"
android:fontFamily="@font/pretendard_semibold"
android:background="@drawable/shape_btn_round12_primary"
android:gravity="center"
android:paddingVertical="15.5dp"/>

</LinearLayout>

</LinearLayout>

</layout>
1 change: 1 addition & 0 deletions core/common-ui/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<color name="primary_color">#12D6E3</color>
<color name="secondary_color">#FFF493</color>
<color name="main_light_color">#E7FAFC</color>

<color name="neutral_900">#131417</color>
<color name="neutral_800">#2A2C34</color>
Expand Down
42 changes: 41 additions & 1 deletion core/common-ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@

<!---->
<string name="home_banner_all_title">이벤트</string>
<string name="user_complaint">신고하기</string>
<string name="user_report">신고하기</string>
<string name="btn_follow">팔로우</string>
<string name="btn_add_comment">댓글 작성</string>
<string name="btn_more_content">더보기</string>
<string name="btn_close_content">접기</string>

<string name="notice_more_banner">더 많은 이벤트가 있어요!</string>
<string name="btn_open_more_banner">이벤트 모두 보기</string>

<string name="title_view_product_info">제품 정보</string>
<string name="close_view_product_info">닫기</string>

<!-- 포스트 작성 -->
<string name="update_product_info_of_pin">수정</string>
Expand All @@ -46,4 +54,36 @@
<string name="post_report_confirm_dialog_confirm">신고할게요</string>
<string name="post_report_confirm_dialog_cancel">아니요</string>
<string name="post_report_confirm_clear_toast">신고 처리되었습니다.</string>

<!-- post -->
<string name="post_edit_title">새 게시물</string>
<string name="upload_post">등록하기</string>
<string name="done_image_picker">다음</string>
<string name="done_select_hobby_category">완료</string>
<string name="image_picker_title">이미지 선택</string>
<string name="add_new_image">이미지 올리기</string>
<string name="notice_not_select_image">이미지를 하나 이상 첨부해주세요.</string>
<string name="btn_add_pin">핀 추가</string>
<string name="btn_auto_add_pin">핀 자동 생성</string>
<string name="title_input_content">내용 입력</string>
<string name="title_select_category">카테고리 선택</string>
<string name="done_input_product_info">저장하기</string>

<string name="confirm_delete_image_for_post_edit">사진을 삭제할까요?</string>
<string name="confirm_delete_image_for_post_edit_description">사진을 삭제하시면 사진에 포함된\n제품 핀도 함께 삭제됩니다.</string>
<string name="btn_cancel">취소</string>
<string name="btn_agree_delete">삭제</string>
<string name="toast_done_delete">삭제되었습니다.</string>
<string name="notice_input_product_info_for_pin">핀에 보여줄 제품 정보를 입력해주세요.\n(제품명은 필수입니다)</string>
<string name="label_product_name_for_input_product_info">제품명</string>
<string name="label_product_url_for_input_product_info">구매처</string>
<string name="placeholder_product_name_for_input_product_info">최대 20자까지 작성할 수 있어요.</string>
<string name="placeholder_product_url_for_input_product_info">구매한 사이트의 URL을 작성해주세요. (예: https://www.shop.com)</string>
<string name="notice_product_name_not_null">제품명을 입력해주세요.</string>
<string name="notice_product_name_max_length">제품명은 20자 이내로 입력해주세요.</string>
<string name="placeholder_input_post_content">최대 2000자까지 작성할 수 있어요.\n해시태그는 20개까지 추가할 수 있어요.</string>
<string name="notice_post_content_max_length">내용은 2000자 이내로 입력해주세요.</string>
<string name="notice_post_hashtag_max_count">해시태그는 최대 20개까지 추가할 수 있어요.</string>
<string name="notice_select_hobby_category_of_post">취미 카테고리를 선택해주세요.</string>
<string name="toast_delete_pin">해당 핀을 삭제했어요</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.marastro.mykkumi.common_ui.base.BaseFragment
import com.marastro.mykkumi.common_ui.report.PostReportConfirmDialog
import com.marastro.mykkumi.common_ui.report.PostWriterReportConfirmDialog
import com.marastro.mykkumi.domain.entity.BannerItemVO
import com.marastro.mykkumi.domain.entity.HomePostProductVO
import com.marastro.mykkumi.feature.home.banner.HomeBannerViewPagerAdapter
import com.marastro.mykkumi.feature.home.databinding.FragmentHomeBinding
import com.marastro.mykkumi.feature.home.post.PostListAdapter
Expand Down Expand Up @@ -197,7 +198,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home),
reportPost = { writerUuid: String, postId: Int ->
postReportConfirm(writerUuid, postId)
},
viewModel
viewModel,
openViewProductInfo = {
openViewProductInfo(it)
}
)
binding.recyclerviewPostList.layoutManager = LinearLayoutManager(
context,
Expand Down Expand Up @@ -309,6 +313,11 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home),
dialog.show(writerUuid)
}

// 제품 정보 열람
fun openViewProductInfo(productInfo: HomePostProductVO) {
viewModel.viewProductInfoForPin(this@HomeFragment, productInfo)
}

override fun onDestroyView() {
_binding = null
timer.cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import androidx.navigation.NavController
import com.marastro.mykkumi.domain.datastore.AuthTokenDataStore
import com.marastro.mykkumi.domain.entity.BannerItemVO
import com.marastro.mykkumi.domain.entity.HomePostItemVO
import com.marastro.mykkumi.domain.entity.HomePostProductVO
import com.marastro.mykkumi.domain.exception.ApiException
import com.marastro.mykkumi.domain.usecase.banner.GetBannerListUseCase
import com.marastro.mykkumi.domain.usecase.post.GetHomePostListUseCase
import com.marastro.mykkumi.domain.usecase.report.ReportPostUseCase
import com.marastro.mykkumi.domain.usecase.report.ReportUserUseCase
import com.marastro.mykkumi.common_ui.post.ViewProductInfoBottomSheet
import com.marastro.mykkumi.feature.home.report.ChooseReportBottomSheet
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -183,4 +185,15 @@ class HomeViewModel @Inject constructor(
}
}
}

// 제품 정보 BottomSheet 열람
fun viewProductInfoForPin(fragment: HomeFragment, productInfo: HomePostProductVO) {
val bundle = Bundle()
bundle.putString("productName", productInfo.name)
bundle.putString("productUrl", productInfo.url)

val bottomSheet = ViewProductInfoBottomSheet()
bottomSheet.arguments = bundle
bottomSheet.show(fragment.parentFragmentManager, bottomSheet.tag)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.marastro.mykkumi.common_ui.post.PostImagesAdapter
import com.marastro.mykkumi.domain.entity.HomePostItemVO
import com.marastro.mykkumi.common_ui.R
import com.marastro.mykkumi.common_ui.server_driven.SpannableStringBuilderProvider
import com.marastro.mykkumi.domain.entity.HomePostProductVO
import com.marastro.mykkumi.feature.home.HomeViewModel
import com.marastro.mykkumi.feature.home.databinding.ItemPostRecyclerviewBinding

Expand All @@ -23,7 +24,8 @@ class PostListAdapter (
private val waitNotice: () -> Unit,
private val blockNestedSwipeRefreshAndViewPager: (state: Int) -> Unit,
private val reportPost: (writerUuid: String, postId: Int) -> Unit,
private val viewModel: HomeViewModel
private val viewModel: HomeViewModel,
private val openViewProductInfo: (productInfo: HomePostProductVO) -> Unit,
) : RecyclerView.Adapter<PostListAdapter.PostListViewHolder>(){
private final val MAX_CONTENT_LENGTH = 50

Expand Down Expand Up @@ -68,7 +70,10 @@ class PostListAdapter (
// 포스트 이미지 viewpager
var postItemImageAdapter: PostImagesAdapter = PostImagesAdapter(
context,
item.images.toMutableList()
item.images.toMutableList(),
openViewProductInfo = {
openViewProductInfo(it)
}
)
binding.viewpagerPostImages.adapter = postItemImageAdapter
binding.viewpagerPostImages.orientation = ViewPager2.ORIENTATION_HORIZONTAL
Expand Down
6 changes: 0 additions & 6 deletions feature/home/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="home_banner_all_title">이벤트</string>
<string name="user_report">신고하기</string>
<string name="btn_more_content">더보기</string>
<string name="btn_close_content">접기</string>

<string name="notice_more_banner">더 많은 이벤트가 있어요!</string>
<string name="btn_open_more_banner">이벤트 모두 보기</string>
</resources>
Loading

0 comments on commit 199eac2

Please sign in to comment.