-
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
[UI/#204] 홈 뷰 / UI 수정사항 반영 및 리팩토링 #232
Changes from 36 commits
3c3cdd5
2ae81c5
879e51f
11b4442
50ab00e
85ccbe4
b5b99f0
61496e0
e885a11
6318b9a
edc307f
f67afb8
356d985
b329364
384fe8e
28f8b72
735354d
ca9f314
f0ae573
5327a86
8a58059
91f8762
33d3dd3
76521ad
f8718ff
b3f3efb
a58d6b0
8a72727
0907e8a
aaadc13
6a02360
58b7425
631ec67
1cfe864
e849735
a4b1cab
f3ba7bc
27adb74
2c207d9
34f73a8
f103667
ec25157
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,208 @@ | ||
package com.terning.core.designsystem.component.bottomsheet | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.wrapContentHeight | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.foundation.lazy.grid.itemsIndexed | ||
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.getValue | ||
import androidx.compose.runtime.mutableIntStateOf | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import com.terning.core.R | ||
import com.terning.core.designsystem.component.button.ChangeFilterButton | ||
import com.terning.core.designsystem.component.button.RoundButton | ||
import com.terning.core.designsystem.component.datepicker.DatePickerUI | ||
import com.terning.core.designsystem.theme.Black | ||
import com.terning.core.designsystem.theme.Grey200 | ||
import com.terning.core.designsystem.theme.TerningTheme | ||
import com.terning.core.extension.currentMonth | ||
import com.terning.core.extension.currentYear | ||
import com.terning.core.type.Grade | ||
import com.terning.core.type.WorkingPeriod | ||
import java.util.Calendar | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun HomeFilteringBottomSheet( | ||
modifier: Modifier = Modifier, | ||
defaultGrade: Grade?, | ||
defaultWorkingPeriod: WorkingPeriod?, | ||
defaultStartYear: Int?, | ||
defaultStartMonth: Int?, | ||
onDismiss: () -> Unit, | ||
onChangeButtonClick: (Int, Int, Int, Int) -> Unit, | ||
) { | ||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) | ||
|
||
var currentGrade by remember { mutableStateOf(defaultGrade) } | ||
var currentPeriod by remember { mutableStateOf(defaultWorkingPeriod) } | ||
var currentStartYear by remember { | ||
mutableIntStateOf( | ||
defaultStartYear ?: Calendar.getInstance().currentYear | ||
) | ||
} | ||
var currentStartMonth by remember { | ||
mutableIntStateOf( | ||
defaultStartMonth ?: Calendar.getInstance().currentMonth | ||
) | ||
} | ||
|
||
TerningBasicBottomSheet( | ||
content = { | ||
Column( | ||
modifier = modifier | ||
.padding(horizontal = 24.dp) | ||
.fillMaxWidth(), | ||
) { | ||
Text( | ||
text = stringResource(id = R.string.change_filter_top_bar_title), | ||
style = TerningTheme.typography.title2, | ||
color = Black, | ||
modifier = Modifier | ||
.padding(bottom = 16.dp), | ||
) | ||
|
||
HorizontalDivider( | ||
thickness = 1.dp, | ||
color = Grey200, | ||
) | ||
|
||
ChangeFilteringTitleText( | ||
text = stringResource(id = R.string.change_filter_grade_title), | ||
modifier = Modifier | ||
.padding(top = 18.dp, bottom = 12.dp) | ||
) | ||
|
||
ChangeFilteringRadioGroup( | ||
initOption = defaultGrade?.ordinal ?: -1, | ||
optionList = listOf( | ||
R.string.change_filter_grade_1, | ||
R.string.change_filter_grade_2, | ||
R.string.change_filter_grade_3, | ||
R.string.change_filter_grade_4, | ||
), | ||
onButtonClick = { index -> | ||
currentGrade = Grade.entries[index] | ||
} | ||
) | ||
|
||
ChangeFilteringTitleText( | ||
text = stringResource(id = R.string.change_filter_period_title), | ||
modifier = Modifier | ||
.padding(top = 32.dp, bottom = 12.dp) | ||
) | ||
|
||
ChangeFilteringRadioGroup( | ||
initOption = defaultWorkingPeriod?.ordinal ?: -1, | ||
optionList = listOf( | ||
R.string.change_filter_period_1, | ||
R.string.change_filter_period_2, | ||
R.string.change_filter_period_3, | ||
), | ||
onButtonClick = { index -> | ||
currentPeriod = WorkingPeriod.entries[index] | ||
} | ||
) | ||
|
||
ChangeFilteringTitleText( | ||
text = stringResource(id = R.string.change_filter_start_work_title), | ||
modifier = Modifier | ||
.padding(top = 32.dp, bottom = 49.dp) | ||
) | ||
|
||
DatePickerUI( | ||
chosenYear = defaultStartYear ?: Calendar.getInstance().currentYear, | ||
chosenMonth = defaultStartMonth?.minus(1) | ||
?: Calendar.getInstance().currentMonth.minus(1), | ||
onYearChosen = { currentStartYear = it }, | ||
onMonthChosen = { currentStartMonth = it }, | ||
) | ||
|
||
RoundButton( | ||
style = TerningTheme.typography.button0, | ||
paddingVertical = 19.dp, | ||
text = R.string.change_filter_save, | ||
cornerRadius = 10.dp, | ||
modifier = Modifier | ||
.padding(top = 51.dp), | ||
onButtonClick = { | ||
currentGrade?.let { grade -> | ||
currentPeriod?.let { workingPeriod -> | ||
onChangeButtonClick( | ||
grade.ordinal, | ||
workingPeriod.ordinal, | ||
currentStartYear, | ||
currentStartMonth, | ||
) | ||
} | ||
} | ||
}, | ||
isEnabled = currentGrade != null && currentPeriod != null | ||
) | ||
} | ||
|
||
}, | ||
onDismissRequest = onDismiss, | ||
sheetState = sheetState, | ||
) | ||
} | ||
|
||
@Composable | ||
fun ChangeFilteringTitleText( | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Text( | ||
text = text, | ||
style = TerningTheme.typography.title4, | ||
color = Black, | ||
modifier = modifier, | ||
) | ||
} | ||
|
||
@Composable | ||
fun ChangeFilteringRadioGroup( | ||
optionList: List<Int>, | ||
initOption: Int, | ||
onButtonClick: (Int) -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
var selectedIndex by remember { mutableIntStateOf(initOption) } | ||
|
||
LazyVerticalGrid( | ||
columns = GridCells.Fixed(optionList.size), | ||
horizontalArrangement = Arrangement.spacedBy(12.dp), | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.wrapContentHeight() | ||
|
||
) { | ||
itemsIndexed(optionList) { index, option -> | ||
ChangeFilterButton( | ||
isSelected = selectedIndex == index, | ||
modifier = Modifier | ||
.wrapContentHeight(), | ||
text = option, | ||
cornerRadius = 10.dp, | ||
paddingVertical = 10.dp, | ||
onButtonClick = { | ||
selectedIndex = index | ||
onButtonClick(index) | ||
} | ||
) | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,40 +10,43 @@ 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.component.bottomsheet.SortBy | ||
import com.terning.core.type.SortBy | ||
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, | ||
sortBy: Int = 0, | ||
onCLick: () -> Unit, | ||
) { | ||
Row( | ||
modifier = modifier | ||
.noRippleClickable { onCLick() } | ||
.noRippleClickable { onCLick() }, | ||
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[sortBy].type | ||
id = SortBy.entries[sortBy].sortBy | ||
), | ||
style = TerningTheme.typography.button3, | ||
color = Black, | ||
modifier = modifier | ||
modifier = Modifier | ||
.padding( | ||
top = 6.dp, | ||
bottom = 5.dp, | ||
start = 12.dp, | ||
bottom = 6.dp, | ||
) | ||
) | ||
Image( | ||
painter = painterResource(id = R.drawable.ic_down_18), | ||
contentDescription = stringResource(id = R.string.sort_button_description), | ||
modifier = modifier | ||
.padding(vertical = 5.dp) | ||
.padding(end = 2.dp) | ||
modifier = Modifier | ||
.padding( | ||
start = 2.dp, | ||
end = 2.dp, | ||
top = 6.dp, | ||
bottom = 4.dp, | ||
) | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.terning.core.type | ||
|
||
import androidx.annotation.StringRes | ||
import com.terning.core.R | ||
|
||
enum class Grade( | ||
val stringValue: String, | ||
@StringRes val stringResId: Int, | ||
) { | ||
FRESHMAN("freshman", R.string.change_filter_grade_1), | ||
SOPHOMORE("sophomore", R.string.change_filter_grade_2), | ||
JUNIOR("junior", R.string.change_filter_grade_3), | ||
SENIOR("senior", R.string.change_filter_grade_4); | ||
|
||
companion object { | ||
fun fromString(value: String?): Grade = when (value) { | ||
"freshman" -> FRESHMAN | ||
"sophomore" -> SOPHOMORE | ||
"junior" -> JUNIOR | ||
"senior" -> SENIOR | ||
else -> FRESHMAN | ||
} | ||
Comment on lines
+15
to
+22
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. 단순 궁금증인데 value 값이 nullable인 이유가 궁금해요..! 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. 사용자 필터링 정보가 없을 때 null로 저장이 돼서 nullable하게 만들었습니다!! null 처리를 screen에서 하니까 코드가 너무 복잡해지더라구요😅 |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.terning.core.type | ||
|
||
import androidx.annotation.StringRes | ||
import com.terning.core.R | ||
|
||
enum class SortBy( | ||
@StringRes val sortBy: Int, | ||
val type: String, | ||
) { | ||
EARLIEST(R.string.sort_by_earliest, "deadlineSoon"), | ||
SHORTEST(R.string.sort_by_shortest, "shortestDuration"), | ||
LONGEST(R.string.sort_by_longest, "longestDuration"), | ||
SCRAP(R.string.sort_by_scrap, "mostScrapped"), | ||
VIEW_COUNT(R.string.sort_by_view_count, "mostViewed"), | ||
} |
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.
요거 제가 최근에 만든
YearMonthPicker
써주면 될 것 같아요!! (피그마에 나온 패딩값 적용하구, 앱 터지지 않게 만들었어요!)feature.filtering.filteringthree.component
파일에 써줬는데 확인해주시면 감사하겠습니당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.
웁씨 깜빡했네요 감사합니다 근데 진짜 데이트피커 수정된거 정말 짱이네요👍🏻