-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 10 commits
bdff90f
e95c491
cf10836
0785726
2d70b89
4b66946
58596a1
c4aa77c
e65341e
809743a
0de159f
21a6a33
308e067
830538f
b7e491a
1a1ed20
641f6de
6020dd8
3bd4b0d
91e5fa5
003c38d
a7f951d
39ab182
ea25198
514b612
1b8822a
04c1ab7
6345800
9a39999
7afa071
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .idea 폴더의 파일이 포함되지 않도록 gitignore를 수정해주세요. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package kr.co.database | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import kr.co.database.dao.RecentFileDao | ||
import kr.co.database.model.RecentFile | ||
|
||
@Database( | ||
entities = [ | ||
RecentFile::class | ||
], | ||
version = 1, | ||
exportSchema = true | ||
) | ||
|
||
abstract class SeeDocsDatabase : RoomDatabase() { | ||
|
||
abstract fun recentFileDao(): RecentFileDao | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재의 PR에서 SeeDocsDatabase가 사용되는 곳은 없는데, 이 PR에 포함된 이유가 있을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 잘못 포함된 커밋입니다,, revert해서 도려낼까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 가급적 PR에 포함되지 않아야할 내용은 포함되지 않도록 하는것이 좋습니다. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package kr.co.database.converter | ||
|
||
import androidx.room.ProvidedTypeConverter | ||
import androidx.room.TypeConverter | ||
|
||
@ProvidedTypeConverter | ||
internal class EnumConverter { | ||
|
||
@TypeConverter | ||
fun <T: Enum<T>> fromEnum(value: T): String = | ||
value.name | ||
|
||
@TypeConverter | ||
fun <T: Enum<T>> toEnum(value: String, enumClass: Class<T>): T? = | ||
enumClass.enumConstants?.firstOrNull { it.name == value } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package kr.co.database.converter | ||
|
||
import androidx.room.ProvidedTypeConverter | ||
import androidx.room.TypeConverter | ||
import java.time.LocalDateTime | ||
|
||
@ProvidedTypeConverter | ||
internal class LocalDateTimeConverter { | ||
|
||
@TypeConverter | ||
fun fromString(value: String): LocalDateTime = | ||
LocalDateTime.parse(value) | ||
|
||
@TypeConverter | ||
fun toString(value: LocalDateTime): String = | ||
value.toString() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package kr.co.database.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import kotlinx.coroutines.flow.Flow | ||
import kr.co.database.model.RecentFile | ||
|
||
@Dao | ||
interface RecentFileDao { | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun insert(recentFile: RecentFile) | ||
|
||
@Query("SELECT * FROM recent_file ORDER BY updatedAt DESC LIMIT 10") | ||
fun get(): Flow<List<RecentFile>> | ||
|
||
@Delete | ||
suspend fun delete(recentFile: RecentFile) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package kr.co.database.model | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import kr.co.model.FileInfo.Type | ||
import java.time.LocalDateTime | ||
|
||
@Entity(tableName = "recent_file") | ||
data class RecentFile( | ||
val name: String, | ||
@PrimaryKey val path: String, | ||
val type: Type, | ||
val size: Long, | ||
val updatedAt: LocalDateTime = LocalDateTime.now(), | ||
) |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이외의 확장자를 IMAGE로 했을 때 문제가 되는 부분은 없을까요? |
||
} | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package kr.co.ui.widget | ||
|
||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextFieldDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.text.input.VisualTransformation | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import kr.co.ui.theme.SeeDocsTheme | ||
import kr.co.ui.theme.Theme | ||
|
||
enum class TextFieldInputType { | ||
NUMBER, | ||
TEXT | ||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun SimpleTextField( | ||
value: String, | ||
onValueChange: (String) -> Unit, | ||
modifier: Modifier = Modifier, | ||
hint: String? = null, | ||
inputType: TextFieldInputType = TextFieldInputType.TEXT, | ||
) { | ||
val interactionSource = remember { MutableInteractionSource() } | ||
|
||
val keyboardOptions = when(inputType) { | ||
TextFieldInputType.NUMBER -> KeyboardOptions.Default.copy( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TextFieldInputType를 추가로 사용하신 이유가 궁금합니다. |
||
keyboardType = KeyboardType.Number | ||
) | ||
TextFieldInputType.TEXT -> KeyboardOptions.Default | ||
} | ||
|
||
BasicTextField( | ||
modifier = modifier, | ||
value = value, | ||
onValueChange = onValueChange, | ||
textStyle = Theme.typography.body1r.copy(color = Theme.colors.text), | ||
singleLine = true, | ||
keyboardOptions = keyboardOptions, | ||
) { | ||
Box( | ||
modifier = Modifier | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OutlinedTextField를 사용하지 않은 이유는 contentPadding 때문일까요? |
||
.border( | ||
width = 1.dp, | ||
color = Theme.colors.stroke, | ||
shape = RoundedCornerShape(8.dp) | ||
), | ||
contentAlignment = Alignment.CenterStart | ||
) { | ||
TextFieldDefaults.DecorationBox( | ||
value = value, | ||
innerTextField = { it() }, | ||
enabled = true, | ||
singleLine = true, | ||
visualTransformation = VisualTransformation.None, | ||
interactionSource = interactionSource, | ||
placeholder = { | ||
hint?.let { | ||
Text( | ||
text = it, | ||
color = Theme.colors.grayText, | ||
style = Theme.typography.body1r | ||
) | ||
} | ||
}, | ||
colors = TextFieldDefaults.colors( | ||
focusedIndicatorColor = Color.Transparent, | ||
unfocusedIndicatorColor = Color.Transparent, | ||
focusedContainerColor = Color.Transparent, | ||
unfocusedContainerColor = Color.Transparent, | ||
disabledContainerColor = Color.Transparent, | ||
), | ||
contentPadding = PaddingValues( | ||
horizontal = 12.dp, | ||
vertical = 4.dp | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun Preview() { | ||
SeeDocsTheme { | ||
SimpleTextField( | ||
value = "34", | ||
onValueChange = {}, | ||
hint = "hint" | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
필요하지 않은 파일 확인해주세요.