-
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
[ADD/#32] 공고 정렬 바텀시트 구현 #45
Changes from 9 commits
d28d2d0
fdf7c42
4617f1d
5e89f9e
729de30
92fc971
8d85dc8
69b88a9
2e9898e
750eb57
2d4071e
73e093d
244b8d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.terning.core.designsystem.component.bottomsheet | ||
|
||
import androidx.annotation.StringRes | ||
import com.terning.core.R | ||
|
||
enum class SortBy(@StringRes val type: Int) { | ||
EARLIEST(R.string.sort_by_earliest), | ||
SHORTEST(R.string.sort_by_shortest), | ||
LONGEST(R.string.sort_by_longest), | ||
SCRAP(R.string.sort_by_scrap), | ||
VIEW_COUNT(R.string.sort_by_view_count), | ||
} | ||
Comment on lines
+6
to
+12
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. 파라미터로 들어가는 문자열 리소스 값들이 코드에서 직접적으로 사용되나요?? 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. 넵!! 바텀시트랑 버튼에서 사용합니다! |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,92 @@ | ||||||||||||||||||
package com.terning.core.designsystem.component.bottomsheet | ||||||||||||||||||
|
||||||||||||||||||
import androidx.compose.foundation.layout.Arrangement | ||||||||||||||||||
import androidx.compose.foundation.layout.fillMaxWidth | ||||||||||||||||||
import androidx.compose.foundation.layout.padding | ||||||||||||||||||
import androidx.compose.foundation.lazy.LazyColumn | ||||||||||||||||||
import androidx.compose.material3.ExperimentalMaterial3Api | ||||||||||||||||||
import androidx.compose.material3.HorizontalDivider | ||||||||||||||||||
import androidx.compose.material3.Text | ||||||||||||||||||
import androidx.compose.material3.rememberModalBottomSheetState | ||||||||||||||||||
import androidx.compose.runtime.Composable | ||||||||||||||||||
import androidx.compose.runtime.MutableState | ||||||||||||||||||
import androidx.compose.runtime.getValue | ||||||||||||||||||
import androidx.compose.runtime.mutableStateOf | ||||||||||||||||||
import androidx.compose.runtime.remember | ||||||||||||||||||
import androidx.compose.runtime.rememberCoroutineScope | ||||||||||||||||||
import androidx.compose.runtime.setValue | ||||||||||||||||||
import androidx.compose.ui.Modifier | ||||||||||||||||||
import androidx.compose.ui.res.stringResource | ||||||||||||||||||
import androidx.compose.ui.text.style.TextAlign | ||||||||||||||||||
import androidx.compose.ui.unit.dp | ||||||||||||||||||
import com.terning.core.R | ||||||||||||||||||
import com.terning.core.designsystem.theme.Black | ||||||||||||||||||
import com.terning.core.designsystem.theme.Grey200 | ||||||||||||||||||
import com.terning.core.designsystem.theme.Grey400 | ||||||||||||||||||
import com.terning.core.designsystem.theme.TerningMain | ||||||||||||||||||
import com.terning.core.designsystem.theme.TerningTheme | ||||||||||||||||||
import com.terning.core.extension.noRippleClickable | ||||||||||||||||||
import kotlinx.coroutines.launch | ||||||||||||||||||
|
||||||||||||||||||
@OptIn(ExperimentalMaterial3Api::class) | ||||||||||||||||||
Comment on lines
+30
to
+31
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. 저번에 얘기해봤을 때 요거 라이브러리 추가로 없앨 수 있지 않았나용,,? 괜찮다면 그걸루 해봐도 될 것 같네영 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. 근데 그게 추가를 해도 없애면 오류가 생기더라구요🥹 이것도 다른 방법 찾게 되면 한번 해볼게요!! |
||||||||||||||||||
@Composable | ||||||||||||||||||
fun SortingBottomSheet( | ||||||||||||||||||
modifier: Modifier = Modifier, | ||||||||||||||||||
onDismiss: () -> Unit, | ||||||||||||||||||
currentSortBy: Int, | ||||||||||||||||||
newSortBy: MutableState<Int> = mutableStateOf(currentSortBy), | ||||||||||||||||||
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.
Suggested change
이렇게 순서 맞춰주면 좋을 것 같아요! 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. 와우 인정합니다 감사해요!! |
||||||||||||||||||
) { | ||||||||||||||||||
val scope = rememberCoroutineScope() | ||||||||||||||||||
val sheetState = rememberModalBottomSheetState() | ||||||||||||||||||
var currentSortBy by remember { mutableStateOf(currentSortBy) } | ||||||||||||||||||
|
||||||||||||||||||
TerningBasicBottomSheet( | ||||||||||||||||||
content = { | ||||||||||||||||||
Text( | ||||||||||||||||||
text = stringResource(id = R.string.sort_bottom_sheet_title), | ||||||||||||||||||
style = TerningTheme.typography.title2, | ||||||||||||||||||
color = Black, | ||||||||||||||||||
modifier = modifier | ||||||||||||||||||
.padding(start = 27.dp, bottom = 16.dp) | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
HorizontalDivider( | ||||||||||||||||||
thickness = 1.dp, | ||||||||||||||||||
color = Grey200, | ||||||||||||||||||
modifier = modifier.padding(horizontal = 24.dp) | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
LazyColumn( | ||||||||||||||||||
modifier = modifier | ||||||||||||||||||
.padding(top = 12.dp, bottom = 19.dp) | ||||||||||||||||||
.padding(horizontal = 24.dp), | ||||||||||||||||||
verticalArrangement = Arrangement.spacedBy(8.dp) | ||||||||||||||||||
) { | ||||||||||||||||||
items(5) { sortIndex -> | ||||||||||||||||||
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. 전 이런 부분에 const val, companion object 등을 사용하여 하드코딩을 피하는 편입니다!! 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. 오호 그게 훨씬 더 좋아보이네요!! 감사합니다:) |
||||||||||||||||||
Text( | ||||||||||||||||||
text = stringResource(id = SortBy.entries[sortIndex].type), | ||||||||||||||||||
style = TerningTheme.typography.button3, | ||||||||||||||||||
color = if (currentSortBy == sortIndex) TerningMain else Grey400, | ||||||||||||||||||
textAlign = TextAlign.Start, | ||||||||||||||||||
modifier = modifier | ||||||||||||||||||
.fillMaxWidth() | ||||||||||||||||||
.padding(start = 3.dp) | ||||||||||||||||||
.padding(vertical = 12.dp) | ||||||||||||||||||
.noRippleClickable { | ||||||||||||||||||
newSortBy.value = sortIndex | ||||||||||||||||||
scope | ||||||||||||||||||
.launch { sheetState.hide() } | ||||||||||||||||||
.invokeOnCompletion { | ||||||||||||||||||
if (!sheetState.isVisible) { | ||||||||||||||||||
onDismiss() | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+75
to
+82
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. 바텀시트 내려가는 부분 구현해준 효빈언니 최고!!!!!! 참고하겠습니당 |
||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
) | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
}, | ||||||||||||||||||
onDismissRequest = { onDismiss() }, | ||||||||||||||||||
sheetState = sheetState | ||||||||||||||||||
) | ||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
package com.terning.core.designsystem.component.bottomsheet | ||
|
||
import androidx.compose.foundation.layout.navigationBarsPadding | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.ModalBottomSheet | ||
import androidx.compose.material3.SheetState | ||
import androidx.compose.material3.rememberModalBottomSheetState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import com.terning.core.designsystem.theme.White | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun TerningBasicBottomSheet( | ||
modifier: 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. 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. 이거 사용 안해서 삭제할게욤!! |
||
content: @Composable () -> Unit, | ||
onDismissRequest: () -> Unit | ||
onDismissRequest: () -> Unit, | ||
sheetState: SheetState = rememberModalBottomSheetState() | ||
) { | ||
val sheetState = rememberModalBottomSheetState() | ||
|
||
ModalBottomSheet( | ||
onDismissRequest = { | ||
onDismissRequest() | ||
}, | ||
sheetState = sheetState, | ||
modifier = modifier.navigationBarsPadding() | ||
containerColor = White, | ||
Comment on lines
21
to
+23
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. 요것두 반영해준 거 최고!! |
||
) { | ||
content() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.terning.core.designsystem.component.button | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import com.terning.core.R | ||
import com.terning.core.designsystem.theme.Black | ||
import com.terning.core.designsystem.theme.TerningTheme | ||
import com.terning.core.extension.noRippleClickable | ||
|
||
@Composable | ||
fun SortingButton( | ||
sortBy: Int = 0, | ||
modifier: Modifier = Modifier, | ||
onCLick: () -> Unit, | ||
) { | ||
Row( | ||
modifier = modifier | ||
.noRippleClickable { onCLick() } | ||
) { | ||
Text( | ||
text = stringResource( | ||
id = when (sortBy) { | ||
1 -> R.string.sort_by_shortest | ||
2 -> R.string.sort_by_longest | ||
3 -> R.string.sort_by_scrap | ||
4 -> R.string.sort_by_view_count | ||
else -> R.string.sort_by_earliest | ||
} | ||
), | ||
style = TerningTheme.typography.button3, | ||
color = Black, | ||
modifier = modifier | ||
.padding( | ||
top = 6.dp, | ||
bottom = 5.dp, | ||
start = 12.dp, | ||
) | ||
) | ||
Image( | ||
painter = painterResource(id = R.drawable.ic_down), | ||
contentDescription = stringResource(id = R.string.sort_button_description), | ||
modifier = modifier | ||
.padding(vertical = 5.dp) | ||
.padding(end = 2.dp) | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="18dp" | ||
android:height="18dp" | ||
android:viewportWidth="18" | ||
android:viewportHeight="18"> | ||
<path | ||
android:pathData="M5,7L9,11L13,7" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="1.5" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#000000" | ||
android:strokeLineCap="round"/> | ||
</vector> |
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.
홈에서 쓰이는 부분을 core 모듈에서 관리하는 이유가 있나용?
이 부분은 TerningBasicBottomSheet를 재사용하는 부분이 아니라, 홈의 바텀시트에 들어갈 구성이라면 feature 모듈에서 관리해줘도 될 것 같아서요!
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.
이게 탐색 뷰에서도 동일한 바텀시트가 사용돼서 홈, 탐색 뷰에서 같이 사용하려고 이렇게 구현했는데 저도 이 enum class 위치가 여기가 맞는지 고민이네요...🥹 이건 좀 더 고민해볼게요..!!