Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF 화면 구성 및 PDF 렌더링 #27

Merged
merged 30 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bdff90f
Feat: PDF 렌더링
Guri999 Dec 5, 2024
e95c491
Feat: PDF Zoom & drag
Guri999 Dec 6, 2024
cf10836
Feat: PDF 해상도 증가
Guri999 Dec 6, 2024
0785726
Feat: PDF Topbar
Guri999 Dec 7, 2024
2d70b89
Feat: PDF TopBar Page calculation
Guri999 Dec 7, 2024
4b66946
Feat: Domain 모듈 제거
Guri999 Dec 7, 2024
58596a1
Feat: Domain 모듈 제거
Guri999 Dec 7, 2024
c4aa77c
Feat: File Model 생성, 파일 찾기 로직 분리
Guri999 Dec 7, 2024
e65341e
Feat: Room 생성
Guri999 Dec 8, 2024
809743a
Refactor: 파일 탐색 백그라운드 스레드로 변경
Guri999 Dec 31, 2024
0de159f
Refactor: Uri remember로 처리
Guri999 Jan 3, 2025
21a6a33
Refactor: 매직넘버 상수로 관리
Guri999 Jan 3, 2025
308e067
Refactor: page,onPageChange -> page, onPageChange
Guri999 Jan 3, 2025
830538f
Refactor: 빈 프리뷰 제거
Guri999 Jan 3, 2025
b7e491a
Refactor: TopBar 관리 캡슐화
Guri999 Jan 6, 2025
1a1ed20
Refactor: Permission 관리 변경
Guri999 Jan 6, 2025
641f6de
Chore: onTopBarVisibleChange -> onPdfBodyPressed 이름 변경
Guri999 Jan 6, 2025
6020dd8
Refactor: PdfToBitmap class 생성하여 pdf 렌더링 관리
Guri999 Jan 6, 2025
3bd4b0d
Chore: if문 괄호
Guri999 Jan 6, 2025
91e5fa5
Feat: Koin 설정
Guri999 Jan 7, 2025
003c38d
Refactor: PDF화면 MVI refactor
Guri999 Jan 7, 2025
a7f951d
Revert "Refactor: PDF화면 MVI refactor"
Guri999 Jan 7, 2025
39ab182
Revert "Feat: Koin 설정"
Guri999 Jan 7, 2025
ea25198
Refactor: TopBarState currentScope -> currentJob
Guri999 Jan 7, 2025
514b612
Refactor: TopBarState onBodyPress -> show
Guri999 Jan 7, 2025
1b8822a
Refactor: TopBarState 생성자 제한
Guri999 Jan 7, 2025
04c1ab7
Chore: bitmap 줄내림 수정
Guri999 Jan 7, 2025
6345800
Chore: if문 중괄호 표시
Guri999 Jan 7, 2025
9a39999
Chore: line 제거
Guri999 Jan 7, 2025
7afa071
Chore: ignore .idea 추가
Guri999 Jan 7, 2025
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
26 changes: 26 additions & 0 deletions core/model/src/main/java/kr/co/model/FileInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package kr.co.model

data class FileInfo(
val name: String,
val path: String,
val type: Type,
val isDirectory: Boolean,
val isHidden: Boolean,
val size: Long,
) {
enum class Type {
PDF,
IMAGE,
FOLDER
;

companion object {
fun from(extension: String): Type =
when(extension) {
"pdf" -> PDF
"jpg", "jpeg", "png", "gif" -> IMAGE
else -> IMAGE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이외의 확장자를 IMAGE로 했을 때 문제가 되는 부분은 없을까요?

}
}
}
}
24 changes: 3 additions & 21 deletions feature/explore/src/main/java/kr/co/explore/ExploreScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kr.co.model.FileInfo
import kr.co.ui.theme.SeeDocsTheme
import kr.co.ui.theme.Theme
import kr.co.ui.widget.FileBox
import kr.co.util.readPDFOrDirectory
import kr.co.widget.FolderBox
import java.io.File

@Composable
internal fun ExploreRoute(
Expand All @@ -45,7 +46,7 @@ internal fun ExploreRoute(
@Composable
private fun ExploreScreen(
path: String,
files: List<Item> = emptyList(),
files: List<FileInfo> = emptyList(),
padding: PaddingValues,
onFolderClick: (String) -> Unit = {},
onFileClick: (String) -> Unit = {}
Expand Down Expand Up @@ -114,25 +115,6 @@ private fun ExploreScreen(
}
}

private fun readPDFOrDirectory(
path: String,
): List<Item> =
File(path).listFiles()?.filter { !it.isHidden && (it.isDirectory || it.extension == "pdf") }?.map {
Item(
name = it.name,
path = it.path,
type = it.extension,
isDirectory = it.isDirectory
)
}?: emptyList()

private data class Item(
val name: String,
val path: String,
val type: String,
val isDirectory: Boolean,
)

@Preview
@Composable
private fun Preview() {
Expand Down
18 changes: 18 additions & 0 deletions feature/explore/src/main/java/kr/co/util/FileUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package kr.co.util

import kr.co.model.FileInfo
import java.io.File

internal fun readPDFOrDirectory(
path: String,
): List<FileInfo> =
File(path).listFiles()?.filter { !it.isHidden && (it.isDirectory || it.extension == "pdf") }?.map {
FileInfo(
name = it.name,
path = it.path,
type = FileInfo.Type.from(it.extension),
isDirectory = it.isDirectory,
size = it.length(),
isHidden = it.isHidden
)
}?: emptyList()