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

Feature/UI #18

Merged
merged 15 commits into from
Dec 16, 2024
115 changes: 115 additions & 0 deletions feature/explore/src/main/java/kr/co/explore/ExploreScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package kr.co.explore

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.GridItemSpan
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
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 androidx.hilt.navigation.compose.hiltViewModel
import kr.co.ui.theme.SeeDocsTheme
import kr.co.ui.theme.Theme
import kr.co.widget.FileBox
import kr.co.widget.FolderBox

@Composable
internal fun ExploreRoute(
viewModel: ExploreViewModel = hiltViewModel(),
padding: PaddingValues,
) {

ExploreScreen(
padding = padding,
)
}

@Composable
private fun ExploreScreen(
padding: PaddingValues,
) {
Box(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.background(color = Theme.colors.bg)
) {
LazyVerticalGrid(
modifier = Modifier
.padding(

Choose a reason for hiding this comment

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

contentPadding을 사용하지 않고 Modifier의 padding을 사용한 이유는 무엇인가요?

top = 32.dp
)
.padding(
horizontal = 16.dp
),
columns = GridCells.Fixed(2),
horizontalArrangement = Arrangement.spacedBy(12.dp),
verticalArrangement = Arrangement.spacedBy(24.dp)
) {
item(
span = { GridItemSpan(maxLineSpan) }
) {
Column(
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = "파일 탐색",
style = Theme.typography.body1sb,
color = Theme.colors.text
)
Text(
text = buildAnnotatedString {
append("규상의 S24 >")
withStyle(
Theme.typography.caption1r.copy(color = Theme.colors.highlight)
.toSpanStyle()
) {
append("Download")
}
},
style = Theme.typography.caption1r,
color = Theme.colors.grayText,
)
}
}

items(listOf("Download", "Documents", "DCIM")) { folder ->
FolderBox(
name = folder
)
}

items(
items = listOf("Effective Kotlin", "Android Developer"),
span = { GridItemSpan(maxLineSpan) }
) { file ->
FileBox(
name = file
)
}
}
}
}

@Preview
@Composable
private fun Preview() {
SeeDocsTheme {
ExploreScreen(
padding = PaddingValues(),
)
}
}
12 changes: 12 additions & 0 deletions feature/explore/src/main/java/kr/co/explore/ExploreViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package kr.co.explore

import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

Choose a reason for hiding this comment

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

의미없는 코드는 커밋에 포함되지 않도록 하시는게 좋을 것 같아요.
이를 방지하기 위해선 개발 계획을 잘 세우시는게 중요합니다.


@HiltViewModel
internal class ExploreViewModel @Inject constructor(

) : ViewModel() {

}
4 changes: 0 additions & 4 deletions feature/explore/src/main/java/kr/co/explore/MyClass.kt

This file was deleted.

72 changes: 72 additions & 0 deletions feature/explore/src/main/java/kr/co/widget/FileBox.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package kr.co.widget

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable;
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kr.co.ui.icon.SeeDocsIcon
import kr.co.ui.icon.seedocsicon.PDF
import kr.co.ui.theme.SeeDocsTheme
import kr.co.ui.theme.Theme

@Composable
internal fun FileBox(
name: String,
onFileClick: () -> Unit = {},
) {
Row(
modifier = Modifier
.fillMaxWidth()
.clickable(onClick = onFileClick)
.padding(
vertical = 12.dp,
horizontal = 8.dp
),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(24.dp)
) {
Icon(
modifier = Modifier.size(32.dp)
.clearAndSetSemantics { },
imageVector = SeeDocsIcon.PDF,
contentDescription = null,
tint = Color.Unspecified
)

Column(
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
Text(
text = name,
style = Theme.typography.body2sb,
color = Theme.colors.text
)
Text(
text = "2023.01.01",
style = Theme.typography.caption1r,
color = Theme.colors.grayText
)
}
}
}

@Preview
@Composable
private fun Preview() {
SeeDocsTheme {
FileBox("Effective Kotlin")
}
}
72 changes: 72 additions & 0 deletions feature/explore/src/main/java/kr/co/widget/FolderBox.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package kr.co.widget

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kr.co.ui.icon.SeeDocsIcon
import kr.co.ui.icon.seedocsicon.Folder
import kr.co.ui.theme.SeeDocsTheme
import kr.co.ui.theme.Theme

@Composable
internal fun FolderBox(
name: String,
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier
.border(
width = 1.dp,
color = Theme.colors.grayText,
shape = RoundedCornerShape(8.dp)
)
.padding(8.dp),
contentAlignment = Alignment.CenterStart
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
Icon(
imageVector = SeeDocsIcon.Folder,
contentDescription = "폴더",
tint = Theme.colors.grayText,
)

Text(
text = name,
style = Theme.typography.body2r,
color = Theme.colors.text
)
}
}
}

@Preview
@Composable
private fun Preview() {
SeeDocsTheme {
Box(
modifier = Modifier.background(Color.White)
) {
FolderBox(
name = "Download",
modifier = Modifier
)
}
}
}
2 changes: 2 additions & 0 deletions feature/main/src/main/java/kr/co/main/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,14 @@ private fun MainTopBar(
modifier = Modifier.size(24.dp),
imageVector = SeeDocsIcon.Search,
contentDescription = "파일 검색",
tint = Theme.colors.icon
)

Icon(
modifier = Modifier.size(24.dp),
imageVector = SeeDocsIcon.Settings,
contentDescription = "설정",
tint = Theme.colors.icon
)
}
}
Expand Down