Skip to content

Commit

Permalink
[MERGE] KKUMI-108 #90 : 홈 화면에서 핀 정보 열람, 포스트 삭제
Browse files Browse the repository at this point in the history
[FEAT] KKUMI-108 #90 : 홈 화면에서 핀 정보 열람, 포스트 삭제
  • Loading branch information
jung0115 authored Oct 16, 2024
2 parents 6c347dd + a8bd927 commit a54152e
Show file tree
Hide file tree
Showing 41 changed files with 942 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class MainViewModel @Inject constructor(
if (userInfo.nickname == null) {
navController.navigate(route = LoginScreens.LoginSelectHobbyScreen.name)
}
// 로그인 상태
else {
// TODO: uuid로 변경
// 닉네임 저장
authTokenDataStore.saveUserNickname(userInfo.nickname!!)
}
} catch (e: ApiException.UnknownApiException) {
showToast("서비스 오류가 발생했습니다.")
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.marastro.mykkumi.common_ui.base

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -9,6 +10,7 @@ import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.google.android.material.internal.ViewUtils.hideKeyboard

abstract class BaseFragment<T: ViewDataBinding>(
@LayoutRes private val layoutId: Int
Expand Down Expand Up @@ -39,8 +41,11 @@ abstract class BaseFragment<T: ViewDataBinding>(
binding.apply(block)
}

@SuppressLint("RestrictedApi")
override fun onDestroyView() {
view?.let { hideKeyboard(it) }
_binding = null
super.onDestroyView()

}
}
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,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/neutral_100"/>
<corners
android:radius="6dp"/>

</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>
13 changes: 13 additions & 0 deletions core/common-ui/src/main/res/layout/item_post_writer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@
android:background="@drawable/shape_btn_round6_primary"
android:layout_alignParentRight="true"/>

<TextView
android:id="@+id/btn_delete_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="12dp"
android:paddingVertical="4dp"
android:text="@string/btn_delete_post"
android:textColor="@color/neutral_900"
android:textSize="13sp"
android:fontFamily="@font/pretendard_medium"
android:background="@drawable/shape_btn_round6_neutral100"
android:layout_alignParentRight="true"/>

</RelativeLayout>

</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
46 changes: 45 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,21 @@

<!---->
<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_delete_post">삭제</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="post_delete_confirm_dialog_title">게시물을 삭제할까요?</string>
<string name="post_delete_confirm_dialog_notice_content">삭제된 게시물은 복구할 수 없으니\n신중히 선택해주세요</string>

<!-- 포스트 작성 -->
<string name="update_product_info_of_pin">수정</string>
Expand All @@ -46,4 +58,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 @@ -3,9 +3,12 @@ package com.marastro.mykkumi.data.datasource
import com.marastro.mykkumi.data.dto.request.PostEditRequestDTO
import com.marastro.mykkumi.data.dto.response.HomePostListDTO
import com.marastro.mykkumi.data.dto.response.PostEditResponseDTO
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface PostDataSource {
Expand All @@ -19,4 +22,9 @@ interface PostDataSource {
suspend fun uploadPost(
@Body params: PostEditRequestDTO
) : PostEditResponseDTO

@DELETE("/api/v1/posts/{postId}")
suspend fun deletePost(
@Path("postId") postId: Int
) : Response<Void?>?
}
Loading

0 comments on commit a54152e

Please sign in to comment.