Skip to content

Commit

Permalink
Merge pull request #115 from depromeet/feat/#110-viewfinder-ui-v2
Browse files Browse the repository at this point in the history
[FEAT] 시야 찾기 2차 MVP 구현 V2
  • Loading branch information
Jokwanhee authored Aug 24, 2024
2 parents e7fc0fd + 8ecb2db commit 05d02dd
Show file tree
Hide file tree
Showing 34 changed files with 1,228 additions and 325 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ package com.dpm.designsystem

import android.graphics.Paint
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import androidx.core.content.ContextCompat
import com.depromeet.designsystem.R
import com.depromeet.designsystem.databinding.SpotSnackbarBinding
import com.dpm.designsystem.extension.dpToPx
import com.google.android.material.snackbar.Snackbar


class SpotSnackBar(
view: View,
private val snackBarBackground: Int,
private val message: String,
private val marginBottom: Int,
private val endMessage: String,
private val onClick: () -> Unit
) {
companion object {
fun make(view: View, message: String = "", endMessage: String = "", onClick: () -> Unit) =
SpotSnackBar(view, message, endMessage, onClick)
fun make(view: View, background: Int = R.drawable.rect_transfer_black_03_fill_60, marginBottom: Int = 0, message: String = "", endMessage: String = "", onClick: () -> Unit) =
SpotSnackBar(view = view, snackBarBackground = background, marginBottom = marginBottom, message= message, endMessage = endMessage, onClick = onClick)
}

private val context = view.context
Expand All @@ -32,14 +38,24 @@ class SpotSnackBar(
private fun initView() {
with(snackbarLayout) {
removeAllViews()
setPadding(0, 0, 0, 0)
setPadding(0, 0, 0, marginBottom.dpToPx(context))
setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent))
addView(snackbarBinding.root, 0)

setOnTouchListener { v, event ->
if (event.action == MotionEvent.ACTION_UP) {
v.performClick()
true
} else {
false
}
}
}
with(snackbarBinding) {
tvDescription.text = message
tvTrigger.paintFlags = Paint.UNDERLINE_TEXT_FLAG
tvTrigger.text = endMessage
clContainer.setBackgroundResource(snackBarBackground)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/color_foreground_body_subtitle" />
<corners android:radius="60dp" />
</shape>
58 changes: 34 additions & 24 deletions core/designsystem/src/main/res/layout/spot_snackbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,44 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rect_transfer_black_03_fill_60">
android:background="@android:color/transparent">

<TextView
android:id="@+id/tv_description"
android:layout_width="wrap_content"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingVertical="19dp"
android:paddingStart="16dp"
android:textAppearance="@style/TextAppearance.Spot.Label08"
android:textColor="@color/color_foreground_white"
app:layout_constraintEnd_toStartOf="@id/tv_trigger"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="아직 잠실야구장만 이용할 수 있어요!" />
tools:background="@drawable/rect_transfer_black_03_fill_60">

<TextView
android:id="@+id/tv_trigger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="19dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextAppearance.Spot.Label08"
android:textColor="@color/color_foreground_white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@id/tv_description"
app:layout_constraintTop_toTopOf="parent"
tools:text="잠실야구장 시야보기" />
<TextView
android:id="@+id/tv_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="19dp"
android:paddingStart="16dp"
android:textAppearance="@style/TextAppearance.Spot.Label08"
android:textColor="@color/color_foreground_white"
app:layout_constraintEnd_toStartOf="@id/tv_trigger"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="아직 잠실야구장만 이용할 수 있어요!" />

<TextView
android:id="@+id/tv_trigger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="19dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextAppearance.Spot.Label08"
android:textColor="@color/color_foreground_white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@id/tv_description"
app:layout_constraintTop_toTopOf="parent"
tools:text="잠실야구장 시야보기" />
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ interface ViewfinderDataSource {
queryParam: RequestBlockReviewQueryDto
): ResponseBlockReviewDto
suspend fun getBlockRow(stadiumId: Int, blockCode: String): ResponseBlockRowDto
suspend fun updateScrap(reviewId: Int)
suspend fun updateLike(reviewId: Int)
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,12 @@ class ViewfinderDataSourceImpl @Inject constructor(
override suspend fun getBlockRow(stadiumId: Int, blockCode: String): ResponseBlockRowDto {
return viewfinderService.getBlockRow(stadiumId, blockCode)
}

override suspend fun updateScrap(reviewId: Int) {
viewfinderService.postScrap(reviewId)
}

override suspend fun updateLike(reviewId: Int) {
viewfinderService.postLike(reviewId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class ResponseBlockReviewDto(
@SerialName("reviews")
val reviews: List<ResponseReviewDto>,
@SerialName("topReviewImages")
val topReviewImages: List<ResponseTopReviewImagesDto>,
val topReviewImages: List<ResponseReviewDto>,
@SerialName("totalElements")
val totalElements: Long,
@SerialName("nextCursor")
Expand Down Expand Up @@ -56,7 +56,7 @@ data class ResponseBlockReviewDto(
@SerialName("block")
val block: ResponseReviewBlockDto,
@SerialName("row")
val row: ResponseReviewRowDto,
val row: ResponseReviewRowDto?,
@SerialName("seat")
val seat: ResponseReviewSeatDto?,
@SerialName("dateTime")
Expand All @@ -67,8 +67,13 @@ data class ResponseBlockReviewDto(
val images: List<ResponseReviewImageDto>,
@SerialName("keywords")
val keywords: List<ResponseReviewKeywordDto>,

) {
@SerialName("likesCount")
val likesCount: Long,
@SerialName("scrapsCount")
val scrapsCount: Long,
@SerialName("reviewType")
val reviewType: String?,
) {
@Serializable
data class ResponseReviewImageDto(
@SerialName("id")
Expand Down Expand Up @@ -126,9 +131,9 @@ data class ResponseBlockReviewDto(
@Serializable
data class ResponseReviewRowDto(
@SerialName("id")
val id: Int,
val id: Int?,
@SerialName("number")
val number: Int,
val number: Int?,
)

@Serializable
Expand All @@ -140,20 +145,6 @@ data class ResponseBlockReviewDto(
)
}

@Serializable
data class ResponseTopReviewImagesDto(
@SerialName("url")
val url: String,
@SerialName("reviewId")
val reviewId: Int,
@SerialName("blockCode")
val blockCode: String,
@SerialName("rowNumber")
val rowNumber: Int,
@SerialName("seatNumber")
val seatNumber: Int?,
)

@Serializable
data class ResponseReviewFilterDto(
@SerialName("rowNumber")
Expand All @@ -171,7 +162,7 @@ fun ResponseBlockReviewDto.toBlockReviewResponse() = ResponseBlockReview(
location = location?.toLocationResponse() ?: ResponseBlockReview.ResponseLocation(),
keywords = keywords.map { it.toKeywordResponse() },
reviews = reviews.map { it.toReviewResponse() },
topReviewImages = topReviewImages.map { it.toTopReviewImagesResponse() },
topReviewImages = topReviewImages.map { it.toReviewResponse() },
totalElements = totalElements,
nextCursor = nextCursor ?: "",
hasNext = hasNext,
Expand All @@ -185,15 +176,6 @@ fun ResponseBlockReviewDto.ResponseKeywordDto.toKeywordResponse() =
isPositive = isPositive
)

fun ResponseBlockReviewDto.ResponseTopReviewImagesDto.toTopReviewImagesResponse() =
ResponseBlockReview.ResponseTopReviewImages(
url = url,
reviewId = reviewId,
blockCode = blockCode,
rowNumber = rowNumber,
seatNumber = seatNumber ?: 0
)

fun ResponseBlockReviewDto.ResponseReviewFilterDto.toReviewFilterResponse() =
ResponseBlockReview.ResponseReviewFilter(
rowNumber = rowNumber ?: 0,
Expand All @@ -209,12 +191,18 @@ fun ResponseBlockReviewDto.ResponseReviewDto.toReviewResponse() =
stadium = stadium.toReviewStadiumResponse(),
section = section.toReviewSectionResponse(),
block = block.toReviewBlockResponse(),
row = row.toReviewRowResponse(),
seat = seat?.toReviewSeatResponse() ?: ResponseBlockReview.ResponseReview.ResponseReviewSeat(),
row = row?.toReviewRowResponse() ?: ResponseBlockReview.ResponseReview.ResponseReviewRow(),
seat = seat?.toReviewSeatResponse()
?: ResponseBlockReview.ResponseReview.ResponseReviewSeat(),
dateTime = dateTime,
content = content ?: "",
images = images.map { it.toReviewImageResponse() },
keywords = keywords.map { it.toReviewKeywordResponse() }
keywords = keywords.map { it.toReviewKeywordResponse() },
isLike = false,
isScrap = false,
likesCount = likesCount,
scrapsCount = scrapsCount,
reviewType = reviewType ?: ""
)

fun ResponseBlockReviewDto.ResponseLocationDto.toLocationResponse() =
Expand Down Expand Up @@ -263,8 +251,8 @@ fun ResponseBlockReviewDto.ResponseReviewDto.ResponseReviewBlockDto.toReviewBloc

fun ResponseBlockReviewDto.ResponseReviewDto.ResponseReviewRowDto.toReviewRowResponse() =
ResponseBlockReview.ResponseReview.ResponseReviewRow(
id = id,
number = number
id = id ?: 0,
number = number ?: 0
)

fun ResponseBlockReviewDto.ResponseReviewDto.ResponseReviewSeatDto.toReviewSeatResponse() =
Expand Down
22 changes: 19 additions & 3 deletions data/src/main/java/com/dpm/data/preference/SharedPreference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DefaultSharedPreference @Inject constructor(
}

override var teamName: String
get() = preferences.getString("teamName","").orEmpty()
get() = preferences.getString("teamName", "").orEmpty()
set(value) {
preferences.edit(commit = true) {
putString("teamName", value)
Expand All @@ -64,12 +64,12 @@ class DefaultSharedPreference @Inject constructor(
get() = preferences.getString("levelTitle", "").orEmpty()
set(value) {
preferences.edit(commit = true) {
putString("levelTitle",value)
putString("levelTitle", value)
}
}

override var profileImage: String
get() = preferences.getString("profileImage","").orEmpty()
get() = preferences.getString("profileImage", "").orEmpty()
set(value) {
preferences.edit(commit = true) {
putString("profileImage", value)
Expand All @@ -83,4 +83,20 @@ class DefaultSharedPreference @Inject constructor(
putBoolean("isFirstTime", value)
}
}

override var isFirstShare: Boolean
get() = preferences.getBoolean("isFirstShare", true)
set(value) {
preferences.edit(commit = true) {
putBoolean("isFirstShare", value)
}
}

override var isFirstLike: Boolean
get() = preferences.getBoolean("isFirstLike", true)
set(value) {
preferences.edit(commit = true) {
putBoolean("isFirstLike", value)
}
}
}
12 changes: 12 additions & 0 deletions data/src/main/java/com/dpm/data/remote/ViewfinderService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.dpm.data.model.response.viewfinder.ResponseBlockRowDto
import com.dpm.data.model.response.viewfinder.ResponseStadiumDto
import com.dpm.data.model.response.viewfinder.ResponseStadiumsDto
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

Expand Down Expand Up @@ -35,4 +36,15 @@ interface ViewfinderService {
@Path("stadiumId") stadiumId: Int,
@Path("blockCode") blockCode: String
): ResponseBlockRowDto

@POST("/api/v1/reviews/{reviewId}/scrap")
suspend fun postScrap(
@Path("reviewId") reviewId: Int
)


@POST("/api/v1/reviews/{reviewId}/like")
suspend fun postLike(
@Path("reviewId") reviewId: Int
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,16 @@ class ViewfinderRepositoryImpl @Inject constructor(
viewfinderDataSource.getBlockRow(stadiumId, blockCode).toBlockRowResponse()
}
}

override suspend fun updateScrap(reviewId: Int): Result<Unit> {
return runCatching {
viewfinderDataSource.updateScrap(reviewId)
}
}

override suspend fun updateLike(reviewId: Int): Result<Unit> {
return runCatching {
viewfinderDataSource.updateLike(reviewId)
}
}
}
Loading

0 comments on commit 05d02dd

Please sign in to comment.