-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : 게시글 등록 모듈 생성 * feat : 게시글 등록 기능 UI 구현 완료 * feat : UI기능 전까지 완료 * feat : 커스텀 갤러리 기능 구현 * feat : 갤러리에서 선택한 이미지를 게시글에서 받도록 구현 * feat : 게시글 등록 API 연동 구현 * feat : StringResource 리팩토링 * feat : Dependency Graph 모듈 볼수 있는 플러그인 추가 * feat : 화면 회전시 앱이 안보이는 버그 수정 * feat : GetAlbumImagesUseCase로 네이밍 수정 * feat : GetAlbumImagesUseCase에서 ImagePagingInfo를 주도록 변경 * feat : GalleryViewModel Test 작성 * feat : 앱 난독화 적용 * test : RegisterPostViewModel 테스트 작성 * feat : core-ui 모듈 추가 및 PostTopicUiState core-ui로 이동 * refactor : Rebase 충돌 수정 * refactor : 모듈을 post에서 postList로 수정 * refactor : material3 버젼 업 * feat : 게시글 목록 화면 탭 UI 구현 * feat : Tab에 viewModel 상태 적용 * feat : 게시글 목록 UI 구현 완료 * feat : Date 계산 로직 도메인으로 이동 * feat : 사진 변경사항 적용 - 고정 크기로 변경 - 사진이 없을 경우 대처 * feat : 게시글 목록 가져오는 기능 Usecase 및 Repository 로직 구현 * feat : 게시글 목록 조회 Paging 기능 ViewModel 및 View에 적용 * feat : snapshotList를 쓰지 않도록 수정 - snapshotList는 페이징 적용 x * feat : 에러 이벤트 처리 구현 * feat : UiModel 적용 * feat : 리뷰 반영
- Loading branch information
Showing
23 changed files
with
552 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
core/data/src/main/kotlin/com/withpeace/withpeace/core/data/mapper/DateMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.withpeace.withpeace.core.data.mapper | ||
|
||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
fun String.toLocalDateTime(): LocalDateTime = LocalDateTime.parse( | ||
this, | ||
DateTimeFormatter.ofPattern(SERVER_DATE_FORMAT), | ||
) | ||
|
||
private const val SERVER_DATE_FORMAT = "yyyy/MM/dd HH:mm:ss" |
15 changes: 15 additions & 0 deletions
15
core/data/src/main/kotlin/com/withpeace/withpeace/core/data/mapper/PostMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.withpeace.withpeace.core.data.mapper | ||
|
||
import com.withpeace.withpeace.core.domain.model.date.Date | ||
import com.withpeace.withpeace.core.domain.model.post.Post | ||
import com.withpeace.withpeace.core.network.di.response.post.PostResponse | ||
|
||
fun PostResponse.toDomain() = | ||
Post( | ||
postId = postId, | ||
title = title, | ||
content = content, | ||
postTopic = type.toDomain(), | ||
createDate = Date(createDate.toLocalDateTime()), | ||
postImageUrl = postImageUrl, | ||
) |
21 changes: 21 additions & 0 deletions
21
core/data/src/main/kotlin/com/withpeace/withpeace/core/data/mapper/PostTopicMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.withpeace.withpeace.core.data.mapper | ||
|
||
import com.withpeace.withpeace.core.domain.model.post.PostTopic | ||
import com.withpeace.withpeace.core.network.di.response.post.PostTopicResponse | ||
import com.withpeace.withpeace.core.network.di.response.post.PostTopicResponse.ECONOMY | ||
import com.withpeace.withpeace.core.network.di.response.post.PostTopicResponse.FREEDOM | ||
import com.withpeace.withpeace.core.network.di.response.post.PostTopicResponse.HOBBY | ||
import com.withpeace.withpeace.core.network.di.response.post.PostTopicResponse.INFORMATION | ||
import com.withpeace.withpeace.core.network.di.response.post.PostTopicResponse.LIVING | ||
import com.withpeace.withpeace.core.network.di.response.post.PostTopicResponse.QUESTION | ||
|
||
fun PostTopicResponse.toDomain(): PostTopic { | ||
return when (this) { | ||
FREEDOM -> PostTopic.FREEDOM | ||
INFORMATION -> PostTopic.INFORMATION | ||
QUESTION -> PostTopic.QUESTION | ||
LIVING -> PostTopic.LIVING | ||
HOBBY -> PostTopic.HOBBY | ||
ECONOMY -> PostTopic.ECONOMY | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
core/domain/src/main/java/com/withpeace/withpeace/core/domain/model/post/PostPageInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.withpeace.withpeace.core.domain.model.post | ||
|
||
import androidx.paging.PagingConfig | ||
import androidx.paging.PagingSource | ||
|
||
data class PostPageInfo( | ||
val pageSize: Int, | ||
val enablePlaceholders: Boolean = true, | ||
val pagingSource: PagingSource<Int, Post>, | ||
) { | ||
val pagingConfig = | ||
PagingConfig( | ||
pageSize = pageSize, | ||
enablePlaceholders = enablePlaceholders, | ||
) | ||
} |
44 changes: 44 additions & 0 deletions
44
core/domain/src/main/java/com/withpeace/withpeace/core/domain/paging/PostPagingSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.withpeace.withpeace.core.domain.paging | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.paging.PagingState | ||
import com.withpeace.withpeace.core.domain.model.WithPeaceError | ||
import com.withpeace.withpeace.core.domain.model.post.Post | ||
import com.withpeace.withpeace.core.domain.model.post.PostTopic | ||
import com.withpeace.withpeace.core.domain.repository.PostRepository | ||
import kotlinx.coroutines.flow.firstOrNull | ||
|
||
data class PostPagingSource( | ||
private val postRepository: PostRepository, | ||
private val postTopic: PostTopic, | ||
private val pageSize: Int, | ||
private val onError: suspend (WithPeaceError) -> Unit, | ||
) : PagingSource<Int, Post>() { | ||
|
||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Post> { | ||
return try { | ||
val currentPage = params.key ?: STARTING_PAGE_INDEX | ||
val data = postRepository.getPosts( | ||
postTopic = postTopic, | ||
pageIndex = currentPage, | ||
pageSize = params.loadSize, | ||
onError = onError, | ||
).firstOrNull() ?: emptyList() | ||
val endOfPaginationReached = data.isEmpty() | ||
val prevKey = if (currentPage == STARTING_PAGE_INDEX) null else currentPage - 1 | ||
val nextKey = | ||
if (endOfPaginationReached) null else currentPage + (params.loadSize / pageSize) | ||
LoadResult.Page(data, prevKey, nextKey) | ||
} catch (exception: Exception) { | ||
LoadResult.Error(exception) | ||
} | ||
} | ||
|
||
override fun getRefreshKey(state: PagingState<Int, Post>): Int? { | ||
return state.anchorPosition | ||
} | ||
|
||
companion object { | ||
const val STARTING_PAGE_INDEX = 0 | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
core/domain/src/main/java/com/withpeace/withpeace/core/domain/repository/PostRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
core/domain/src/main/java/com/withpeace/withpeace/core/domain/usecase/GetPostsUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.withpeace.withpeace.core.domain.usecase | ||
|
||
import com.withpeace.withpeace.core.domain.model.WithPeaceError | ||
import com.withpeace.withpeace.core.domain.model.post.PostPageInfo | ||
import com.withpeace.withpeace.core.domain.model.post.PostTopic | ||
import com.withpeace.withpeace.core.domain.paging.PostPagingSource | ||
import com.withpeace.withpeace.core.domain.repository.PostRepository | ||
import javax.inject.Inject | ||
|
||
class GetPostsUseCase @Inject constructor( | ||
private val postRepository: PostRepository, | ||
) { | ||
operator fun invoke( | ||
postTopic: PostTopic, | ||
pageSize: Int, | ||
onError: suspend (WithPeaceError) -> Unit, | ||
): PostPageInfo = PostPageInfo( | ||
pageSize = pageSize, | ||
pagingSource = PostPagingSource( | ||
postRepository = postRepository, | ||
postTopic = postTopic, | ||
pageSize = pageSize, | ||
onError = onError, | ||
), | ||
) | ||
} |
2 changes: 1 addition & 1 deletion
2
.../core/network/di/response/PostResponse.kt → ...etwork/di/response/post/PostIdResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...twork/src/main/java/com/withpeace/withpeace/core/network/di/response/post/PostResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.withpeace.withpeace.core.network.di.response.post | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class PostResponse( | ||
val postId: Long, | ||
val title: String, | ||
val content: String, | ||
val type: PostTopicResponse, | ||
val postImageUrl: String? = null, | ||
val createDate: String, | ||
) |
10 changes: 10 additions & 0 deletions
10
.../src/main/java/com/withpeace/withpeace/core/network/di/response/post/PostTopicResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.withpeace.withpeace.core.network.di.response.post; | ||
|
||
enum class PostTopicResponse { | ||
FREEDOM, | ||
INFORMATION, | ||
QUESTION, | ||
LIVING, | ||
HOBBY, | ||
ECONOMY | ||
} |
Oops, something went wrong.