diff --git a/core/common-ui/src/main/java/com/marastro/mykkumi/common_ui/post/PostImagesAdapter.kt b/core/common-ui/src/main/java/com/marastro/mykkumi/common_ui/post/PostImagesAdapter.kt index 61dd20f..c0ba039 100644 --- a/core/common-ui/src/main/java/com/marastro/mykkumi/common_ui/post/PostImagesAdapter.kt +++ b/core/common-ui/src/main/java/com/marastro/mykkumi/common_ui/post/PostImagesAdapter.kt @@ -2,6 +2,7 @@ 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 @@ -9,11 +10,13 @@ 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 + private var postImageList: MutableList, + private val openViewProductInfo: (productInfo: HomePostProductVO) -> Unit, ) : RecyclerView.Adapter() { override fun onCreateViewHolder( @@ -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) + }) } } } diff --git a/core/common-ui/src/main/java/com/marastro/mykkumi/common_ui/post/ViewProductInfoBottomSheet.kt b/core/common-ui/src/main/java/com/marastro/mykkumi/common_ui/post/ViewProductInfoBottomSheet.kt new file mode 100644 index 0000000..23ace06 --- /dev/null +++ b/core/common-ui/src/main/java/com/marastro/mykkumi/common_ui/post/ViewProductInfoBottomSheet.kt @@ -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(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) + } +} \ No newline at end of file diff --git a/core/common-ui/src/main/res/drawable/shape_back_light_round12.xml b/core/common-ui/src/main/res/drawable/shape_back_light_round12.xml new file mode 100644 index 0000000..66d7e23 --- /dev/null +++ b/core/common-ui/src/main/res/drawable/shape_back_light_round12.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/core/common-ui/src/main/res/layout/fragment_view_product_info_bottom_sheet.xml b/core/common-ui/src/main/res/layout/fragment_view_product_info_bottom_sheet.xml new file mode 100644 index 0000000..ab91f89 --- /dev/null +++ b/core/common-ui/src/main/res/layout/fragment_view_product_info_bottom_sheet.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/common-ui/src/main/res/values/colors.xml b/core/common-ui/src/main/res/values/colors.xml index c64b69f..910b31b 100644 --- a/core/common-ui/src/main/res/values/colors.xml +++ b/core/common-ui/src/main/res/values/colors.xml @@ -10,6 +10,7 @@ #12D6E3 #FFF493 + #E7FAFC #131417 #2A2C34 diff --git a/core/common-ui/src/main/res/values/strings.xml b/core/common-ui/src/main/res/values/strings.xml index cbe7c62..bdb24a1 100644 --- a/core/common-ui/src/main/res/values/strings.xml +++ b/core/common-ui/src/main/res/values/strings.xml @@ -28,9 +28,17 @@ 이벤트 - 신고하기 + 신고하기 팔로우 댓글 작성 + 더보기 + 접기 + + 더 많은 이벤트가 있어요! + 이벤트 모두 보기 + + 제품 정보 + 닫기 수정 @@ -46,4 +54,36 @@ 신고할게요 아니요 신고 처리되었습니다. + + + 새 게시물 + 등록하기 + 다음 + 완료 + 이미지 선택 + 이미지 올리기 + 이미지를 하나 이상 첨부해주세요. + 핀 추가 + 핀 자동 생성 + 내용 입력 + 카테고리 선택 + 저장하기 + + 사진을 삭제할까요? + 사진을 삭제하시면 사진에 포함된\n제품 핀도 함께 삭제됩니다. + 취소 + 삭제 + 삭제되었습니다. + 핀에 보여줄 제품 정보를 입력해주세요.\n(제품명은 필수입니다) + 제품명 + 구매처 + 최대 20자까지 작성할 수 있어요. + 구매한 사이트의 URL을 작성해주세요. (예: https://www.shop.com) + 제품명을 입력해주세요. + 제품명은 20자 이내로 입력해주세요. + 최대 2000자까지 작성할 수 있어요.\n해시태그는 20개까지 추가할 수 있어요. + 내용은 2000자 이내로 입력해주세요. + 해시태그는 최대 20개까지 추가할 수 있어요. + 취미 카테고리를 선택해주세요. + 해당 핀을 삭제했어요 \ No newline at end of file diff --git a/feature/home/src/main/java/com/marastro/mykkumi/feature/home/HomeFragment.kt b/feature/home/src/main/java/com/marastro/mykkumi/feature/home/HomeFragment.kt index 6dbf4fc..ba3aefb 100644 --- a/feature/home/src/main/java/com/marastro/mykkumi/feature/home/HomeFragment.kt +++ b/feature/home/src/main/java/com/marastro/mykkumi/feature/home/HomeFragment.kt @@ -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 @@ -197,7 +198,10 @@ class HomeFragment : BaseFragment(R.layout.fragment_home), reportPost = { writerUuid: String, postId: Int -> postReportConfirm(writerUuid, postId) }, - viewModel + viewModel, + openViewProductInfo = { + openViewProductInfo(it) + } ) binding.recyclerviewPostList.layoutManager = LinearLayoutManager( context, @@ -309,6 +313,11 @@ class HomeFragment : BaseFragment(R.layout.fragment_home), dialog.show(writerUuid) } + // 제품 정보 열람 + fun openViewProductInfo(productInfo: HomePostProductVO) { + viewModel.viewProductInfoForPin(this@HomeFragment, productInfo) + } + override fun onDestroyView() { _binding = null timer.cancel() diff --git a/feature/home/src/main/java/com/marastro/mykkumi/feature/home/HomeViewModel.kt b/feature/home/src/main/java/com/marastro/mykkumi/feature/home/HomeViewModel.kt index 4725adc..8e91446 100644 --- a/feature/home/src/main/java/com/marastro/mykkumi/feature/home/HomeViewModel.kt +++ b/feature/home/src/main/java/com/marastro/mykkumi/feature/home/HomeViewModel.kt @@ -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 @@ -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) + } } \ No newline at end of file diff --git a/feature/home/src/main/java/com/marastro/mykkumi/feature/home/post/PostListAdapter.kt b/feature/home/src/main/java/com/marastro/mykkumi/feature/home/post/PostListAdapter.kt index 066a06a..1738350 100644 --- a/feature/home/src/main/java/com/marastro/mykkumi/feature/home/post/PostListAdapter.kt +++ b/feature/home/src/main/java/com/marastro/mykkumi/feature/home/post/PostListAdapter.kt @@ -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 @@ -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(){ private final val MAX_CONTENT_LENGTH = 50 @@ -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 diff --git a/feature/home/src/main/res/values/strings.xml b/feature/home/src/main/res/values/strings.xml index 4d0c9ef..0d2c4cc 100644 --- a/feature/home/src/main/res/values/strings.xml +++ b/feature/home/src/main/res/values/strings.xml @@ -1,10 +1,4 @@ - 이벤트 - 신고하기 - 더보기 - 접기 - 더 많은 이벤트가 있어요! - 이벤트 모두 보기 \ No newline at end of file diff --git a/feature/post/src/main/java/com/marastro/mykkumi/feature/post/PostEditFragment.kt b/feature/post/src/main/java/com/marastro/mykkumi/feature/post/PostEditFragment.kt index ad3089e..8cabec2 100644 --- a/feature/post/src/main/java/com/marastro/mykkumi/feature/post/PostEditFragment.kt +++ b/feature/post/src/main/java/com/marastro/mykkumi/feature/post/PostEditFragment.kt @@ -29,6 +29,7 @@ import com.marastro.mykkumi.feature.post.imageWithPin.EditImageWithPinAdapter import com.marastro.mykkumi.feature.post.imageWithPin.InputProductInfoBottomSheet import com.marastro.mykkumi.feature.post.touchEvent.PostEditImageTouchCallback import dagger.hilt.android.AndroidEntryPoint +import com.marastro.mykkumi.common_ui.R as StringR @AndroidEntryPoint class PostEditFragment : BaseFragment(R.layout.fragment_post_edit), @@ -134,7 +135,7 @@ class PostEditFragment : BaseFragment(R.layout.fragment binding.edittextInputContent.setText(concat(s.subSequence(0, start + subLength), s.subSequence(start + count, s.length))) binding.edittextInputContent.setSelection(start + subLength) // 커서를 입력하고 있던 곳에 - showToast(getString(R.string.notice_post_content_max_length)) + showToast(getString(StringR.string.notice_post_content_max_length)) } // 해시태그 개수 @@ -144,7 +145,7 @@ class PostEditFragment : BaseFragment(R.layout.fragment binding.edittextInputContent.setText(concat(s.subSequence(0, hashTagIndex), s.subSequence(start + count, s.length))) binding.edittextInputContent.setSelection(hashTagIndex) // 커서를 입력하고 있던 곳에 - showToast(getString(R.string.notice_post_hashtag_max_count)) + showToast(getString(StringR.string.notice_post_hashtag_max_count)) } // 본문 입력 중 @@ -169,8 +170,8 @@ class PostEditFragment : BaseFragment(R.layout.fragment val content = binding.edittextInputContent.text.toString() viewModel.doneEditPost( content = content, - noticeEmptyImage = getString(R.string.notice_not_select_image), - noticeEmptyCategory = getString(R.string.notice_select_hobby_category_of_post), + noticeEmptyImage = getString(StringR.string.notice_not_select_image), + noticeEmptyCategory = getString(StringR.string.notice_select_hobby_category_of_post), showToast = { showToast(it) }, @@ -389,7 +390,7 @@ class PostEditFragment : BaseFragment(R.layout.fragment fun confirmAgree(position: Int) { viewModel.deleteImage(position) viewModel.doneDeleteImage() - showToast(getString(R.string.toast_done_delete)) + showToast(getString(StringR.string.toast_done_delete)) // 이미지 전체 삭제된 경우 if(viewModel.postEditUiState.value.isNullOrEmpty()) { diff --git a/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imagePicker/ImagePickerFragment.kt b/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imagePicker/ImagePickerFragment.kt index be5080a..489f297 100644 --- a/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imagePicker/ImagePickerFragment.kt +++ b/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imagePicker/ImagePickerFragment.kt @@ -15,6 +15,7 @@ import com.marastro.mykkumi.common_ui.base.BaseFragment import com.marastro.mykkumi.common_ui.permission.ImagePermissionUtils import com.marastro.mykkumi.feature.post.R import com.marastro.mykkumi.feature.post.databinding.FragmentImagePickerBinding +import com.marastro.mykkumi.common_ui.R as StringR class ImagePickerFragment : BaseFragment(R.layout.fragment_image_picker) { @@ -46,7 +47,7 @@ class ImagePickerFragment : BaseFragment(R.layout.fr binding.btnDonePicker.setOnClickListener(View.OnClickListener { // 선택한 이미지가 있는지 확인 if(viewModel.selectImage.value.isNullOrEmpty()) { - Toast.makeText(requireContext(), R.string.notice_not_select_image, Toast.LENGTH_SHORT).show() + Toast.makeText(requireContext(), StringR.string.notice_not_select_image, Toast.LENGTH_SHORT).show() } else { viewModel.doneSelectImages(navController) diff --git a/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imageWithPin/EditImageWithPinAdapter.kt b/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imageWithPin/EditImageWithPinAdapter.kt index c238fa7..6f23fdd 100644 --- a/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imageWithPin/EditImageWithPinAdapter.kt +++ b/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imageWithPin/EditImageWithPinAdapter.kt @@ -194,7 +194,7 @@ class EditImageWithPinAdapter( buttonDeletePin.setOnClickListener(View.OnClickListener { viewModel.deletePinOfImage( position = pinIndex, - message = getString(context, com.marastro.mykkumi.feature.post.R.string.toast_delete_pin), + message = getString(context, R.string.toast_delete_pin), showToast = { showToast(it) }) diff --git a/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imageWithPin/InputProductInfoBottomSheet.kt b/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imageWithPin/InputProductInfoBottomSheet.kt index a1e2a47..9f353c1 100644 --- a/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imageWithPin/InputProductInfoBottomSheet.kt +++ b/feature/post/src/main/java/com/marastro/mykkumi/feature/post/imageWithPin/InputProductInfoBottomSheet.kt @@ -9,6 +9,7 @@ import android.widget.Toast import androidx.core.content.ContextCompat import com.marastro.mykkumi.common_ui.base.BaseBottomSheetFragment import com.marastro.mykkumi.feature.post.R +import com.marastro.mykkumi.common_ui.R as StringR import com.marastro.mykkumi.feature.post.databinding.FragmentInputProductInfoBottomSheetBinding import kotlin.math.max @@ -49,7 +50,7 @@ class InputProductInfoBottomSheet : BaseBottomSheetFragment - 새 게시물 - 등록하기 - 다음 - 완료 - 이미지 선택 - 이미지 올리기 - 이미지를 하나 이상 첨부해주세요. - 핀 추가 - 핀 자동 생성 - 내용 입력 - 카테고리 선택 - 저장하기 - 사진을 삭제할까요? - 사진을 삭제하시면 사진에 포함된\n제품 핀도 함께 삭제됩니다. - 취소 - 삭제 - 삭제되었습니다. - 핀에 보여줄 제품 정보를 입력해주세요.\n(제품명은 필수입니다) - 제품명 - 구매처 URL - 최대 20자까지 작성할 수 있어요. - 구매한 사이트의 URL을 작성해주세요. (예: https://www.shop.com) - 제품명을 입력해주세요. - 제품명은 20자 이내로 입력해주세요. - 최대 2000자까지 작성할 수 있어요.\n해시태그는 20개까지 추가할 수 있어요. - 내용은 2000자 이내로 입력해주세요. - 해시태그는 최대 20개까지 추가할 수 있어요. - 취미 카테고리를 선택해주세요. - 해당 핀을 삭제했어요 \ No newline at end of file