Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ dependencies {
// calendar
implementation(libs.kizitonwose.calendar)

// Paging
implementation(libs.androidx.room.paging)
implementation(libs.androidx.paging.runtime.android)
implementation(libs.androidx.paging.runtime)

// Google
implementation(libs.androidx.credentials)
implementation(libs.androidx.credentials.play.services.auth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ fun RegisterTestInfoBottomSheet(
}
.padding(horizontal = screenWidthDp(12.dp))
.noRippleClickable {
showPlaceP1List = true
if (!showPlaceP2List) {
showPlaceP1List = true
}
},
verticalAlignment = Alignment.CenterVertically
) {
Expand Down Expand Up @@ -328,7 +330,7 @@ fun RegisterTestInfoBottomSheet(
.clip(RoundedCornerShape(4.dp))
.padding(horizontal = screenWidthDp(12.dp))
.noRippleClickable {
if (cityText.isNotEmpty()) {
if (cityText.isNotEmpty() && !showPlaceP1List) {
showPlaceP2List = true
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package org.sopt.certi.core.component.dialog

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import org.sopt.certi.R
import org.sopt.certi.core.util.heightForScreenPercentage
import org.sopt.certi.core.util.screenHeightDp
import org.sopt.certi.core.util.screenWidthDp
import org.sopt.certi.ui.theme.CertiTheme

@Composable
fun CertiContentDialog(
titleText: String,
contentText: String,
onConfirmClick: () -> Unit,
onDismissClick: () -> Unit
) {
Dialog(onDismissRequest = onDismissClick) {
Column(
modifier = Modifier
.clip(RoundedCornerShape(12.dp))
.background(CertiTheme.colors.white)
.padding(top = screenHeightDp(30.dp)),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = titleText,
style = CertiTheme.typography.body.semibold_16,
color = CertiTheme.colors.gray600,
modifier = Modifier.padding(horizontal = screenWidthDp(16.dp)),
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.heightForScreenPercentage(16.dp))

Text(
text = contentText,
style = CertiTheme.typography.caption.regular_14,
color = CertiTheme.colors.gray600,
modifier = Modifier.padding(horizontal = screenWidthDp(16.dp)),
textAlign = TextAlign.Center
)

Spacer(modifier = Modifier.heightForScreenPercentage(26.dp))

HorizontalDivider(
thickness = 1.dp,
color = CertiTheme.colors.gray100
)

Row(modifier = Modifier.height(IntrinsicSize.Max)) {
DialogButton(
text = stringResource(R.string.delete_dialog_cancel),
textColor = CertiTheme.colors.black,
onClick = onDismissClick,
modifier = Modifier.weight(1f)
)
VerticalDivider(
thickness = 1.dp,
color = CertiTheme.colors.gray100
)
DialogButton(
text = stringResource(R.string.delete_dialog_confirm),
textColor = CertiTheme.colors.purpleBlue,
onClick = onConfirmClick,
modifier = Modifier.weight(1f)
)
}
}
}
}

@Preview
@Composable
private fun PreviewCertiContentDialog() {
CertiContentDialog(
titleText = "프리뷰 프리뷰",
contentText = "콘텐트 콘텐트",
onConfirmClick = {},
onDismissClick = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import org.sopt.certi.R
Expand Down Expand Up @@ -74,3 +75,13 @@ fun CertiDialog(
}
}
}

@Preview
@Composable
private fun PreviewCertiDialog() {
CertiDialog(
text = "프리뷰 프리뷰",
onConfirmClick = {},
onDismissClick = {}
)
}
8 changes: 8 additions & 0 deletions app/src/main/java/org/sopt/certi/core/network/TokenManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ class TokenManager @Inject constructor(
return sharedPreferences.getString("NICKNAME", "").orEmpty()
}

fun saveUserId(userId: Long) {
sharedPreferences.edit().putLong("USERID", userId).apply()
}

fun getUserId(): Long {
return sharedPreferences.getLong("USERID", 0L)
}

fun nicknameFlow(): Flow<String> = callbackFlow {
trySend(getNickName())

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.sopt.certi.data.mapper.todomain.comment

import org.sopt.certi.data.remote.dto.response.comment.CommentItemResponseDto
import org.sopt.certi.data.remote.dto.response.comment.GetCommentListResponseDto
import org.sopt.certi.domain.model.comment.CommentData
import org.sopt.certi.domain.model.comment.CommentItemData
import org.sopt.certi.domain.type.CertStateType

fun GetCommentListResponseDto.toDomain(): CommentData {
return CommentData(
content = content.map { it.toDomain() },
totalPages = totalPages,
totalElements = totalElements,
isLast = isLast
)
}

fun CommentItemResponseDto.toDomain(): CommentItemData {
return CommentItemData(
commentId = commentId,
userId = userId,
nickName = nickName,
content = content,
userMajor = userMajor,
userJob = userJob,
state = CertStateType.fromStateName(state),
createdTime = createdTime,
lastModifiedTime = lastModifiedTime,
isLike = isLike,
likeCount = likeCount
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import org.sopt.certi.data.remote.dto.response.UserInfoResponseDto
import org.sopt.certi.domain.model.user.UserInfoData

fun UserInfoResponseDto.toDomain() = UserInfoData(
userId = userId,
nickname = nickname,
name = name,
university = university,
major = major,
job = job,
profileImageUrl = profileImage,
birthday = birthDate
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.sopt.certi.data.mapper.todto.comment

import org.sopt.certi.data.remote.dto.request.comment.CommentListPageableRequestDto
import org.sopt.certi.data.remote.dto.request.comment.RegisterCommentRequestDto
import org.sopt.certi.domain.model.comment.CommentListPageableRequest
import org.sopt.certi.domain.model.comment.RegisterCommentRequest

fun RegisterCommentRequest.toDto(): RegisterCommentRequestDto {
return RegisterCommentRequestDto(
content = content,
certificationId = certificationId
)
}

fun CommentListPageableRequest.toDto(): CommentListPageableRequestDto {
return CommentListPageableRequestDto(
page = page,
size = size,
sort = sort
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.sopt.certi.data.mapper.todto.report

import org.sopt.certi.data.remote.dto.request.report.ReportCommentRequestDto
import org.sopt.certi.domain.model.report.ReportCommentRequest

fun ReportCommentRequest.toDto(): ReportCommentRequestDto {
return ReportCommentRequestDto(
content = this.content,
shouldBlockUser = this.shouldBlockUser
)
}
54 changes: 54 additions & 0 deletions app/src/main/java/org/sopt/certi/data/pagingsource/CertiPaging.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.sopt.certi.data.pagingsource

import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingSource
import androidx.paging.PagingState

class CertiPagingSource<T : Any>(
private val pageSize: Int,
private val getList: suspend (Int) -> List<T>
) : PagingSource<Int, T>() {
override fun getRefreshKey(state: PagingState<Int, T>): Int? {
val anchor = state.anchorPosition ?: return null
val page = state.closestPageToPosition(anchor) ?: return null
return page.prevKey?.plus(1) ?: page.nextKey?.minus(1)
}

override suspend fun load(params: LoadParams<Int>): LoadResult<Int, T> {
val currentPage = params.key ?: 0
return try {
val list = getList(currentPage)
LoadResult.Page(
data = list,
prevKey = if (currentPage == 0) null else currentPage - 1,
nextKey = if (list.size < pageSize) null else currentPage + 1
)
} catch (e: Exception) {
LoadResult.Error(e)
}
}
}

fun <T : Any> createPager(
limit: Int = 10,
initialLoadSize: Int = 20,
q: List<String>? = null,
startPage: Int? = null,
pagingSourceFactory: suspend (page: Int, limit: Int, sort: List<String>?) -> List<T>
): Pager<Int, T> {
return Pager(
config = PagingConfig(
pageSize = limit,
initialLoadSize = initialLoadSize,
prefetchDistance = 1,
enablePlaceholders = false
),
initialKey = startPage ?: 0,
pagingSourceFactory = {
CertiPagingSource<T>(pageSize = limit) { page ->
pagingSourceFactory(page, limit, q)
}
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.certi.data.remote.datasource

import org.sopt.certi.data.remote.dto.base.ApiResponse
import org.sopt.certi.data.remote.dto.base.NullableApiResponse
import org.sopt.certi.data.remote.dto.request.comment.CommentListPageableRequestDto
import org.sopt.certi.data.remote.dto.request.comment.RegisterCommentRequestDto
import org.sopt.certi.data.remote.dto.response.comment.GetCommentListResponseDto

interface CommentRemoteDataSource {
suspend fun getCommentList(certificationId: Long, pageable: CommentListPageableRequestDto): ApiResponse<GetCommentListResponseDto>
suspend fun registerComment(registerCommentRequest: RegisterCommentRequestDto): NullableApiResponse<Unit>
suspend fun likeComment(commentId: Long): NullableApiResponse<Unit>
suspend fun deleteComment(commentId: Long): NullableApiResponse<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.sopt.certi.data.remote.datasource

import org.sopt.certi.data.remote.dto.base.NullableApiResponse
import org.sopt.certi.data.remote.dto.request.report.ReportCommentRequestDto

interface ReportRemoteDataSource {
suspend fun reportComment(
certificationCommentId: Long,
reportCommentRequestDto: ReportCommentRequestDto
): NullableApiResponse<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.sopt.certi.data.remote.datasourceimpl

import org.sopt.certi.data.remote.datasource.CommentRemoteDataSource
import org.sopt.certi.data.remote.dto.base.ApiResponse
import org.sopt.certi.data.remote.dto.base.NullableApiResponse
import org.sopt.certi.data.remote.dto.request.comment.CommentListPageableRequestDto
import org.sopt.certi.data.remote.dto.request.comment.RegisterCommentRequestDto
import org.sopt.certi.data.remote.dto.response.comment.GetCommentListResponseDto
import org.sopt.certi.data.remote.service.CommentService
import javax.inject.Inject

class CommentRemoteDataSourceImpl @Inject constructor(
private val commentService: CommentService
) : CommentRemoteDataSource {
override suspend fun getCommentList(certificationId: Long, pageable: CommentListPageableRequestDto): ApiResponse<GetCommentListResponseDto> =
commentService.getCommentList(certificationId, page = pageable.page, size = pageable.size, sort = if (pageable.sort.isNotEmpty()) pageable.sort.toString() else null)

override suspend fun registerComment(registerCommentRequest: RegisterCommentRequestDto): NullableApiResponse<Unit> =
commentService.registerComment(registerCommentRequest)

override suspend fun likeComment(commentId: Long): NullableApiResponse<Unit> =
commentService.likeComment(commentId)

override suspend fun deleteComment(commentId: Long): NullableApiResponse<Unit> =
commentService.deleteComment(commentId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.sopt.certi.data.remote.datasourceimpl

import org.sopt.certi.data.remote.datasource.ReportRemoteDataSource
import org.sopt.certi.data.remote.dto.base.NullableApiResponse
import org.sopt.certi.data.remote.dto.request.report.ReportCommentRequestDto
import org.sopt.certi.data.remote.service.ReportService
import javax.inject.Inject

class ReportRemoteDataSourceImpl @Inject constructor(
private val reportService: ReportService
) : ReportRemoteDataSource {
override suspend fun reportComment(certificationCommentId: Long, reportCommentRequestDto: ReportCommentRequestDto): NullableApiResponse<Unit> {
return reportService.reportComment(certificationCommentId, reportCommentRequestDto)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.certi.data.remote.dto.request.comment

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class CommentListPageableRequestDto(
@SerialName("page")
val page: Int,
@SerialName("size")
val size: Int,
@SerialName("sort")
val sort: List<String>
)
Loading