Skip to content

Commit

Permalink
[CHORE] #21 ktlint 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
l5x5l committed Jul 26, 2024
1 parent 99ad97f commit fa6d1da
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package pokitmons.pokit.core.ui.utils

import androidx.compose.ui.Modifier

internal fun Modifier.conditional(condition : Boolean, modifier : Modifier.() -> Modifier) : Modifier {
internal fun Modifier.conditional(condition: Boolean, modifier: Modifier.() -> Modifier): Modifier {
return if (condition) {
then(modifier(Modifier))
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package pokitmons.pokit.search

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.assertEquals

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
110 changes: 55 additions & 55 deletions feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import androidx.compose.ui.unit.dp
import pokitmons.pokit.core.ui.theme.PokitTheme
import pokitmons.pokit.search.components.filter.FilterArea
import pokitmons.pokit.search.components.filterbottomsheet.FilterBottomSheet
import pokitmons.pokit.search.components.searchitemlist.SearchItemList
import pokitmons.pokit.search.components.recentsearchword.RecentSearchWord
import pokitmons.pokit.search.components.searchitemlist.SearchItemList
import pokitmons.pokit.search.components.toolbar.Toolbar
import pokitmons.pokit.search.model.Filter
import pokitmons.pokit.search.model.FilterType
Expand All @@ -25,7 +25,7 @@ import pokitmons.pokit.search.model.SearchScreenStep
@Composable
fun SearchScreenContainer(
viewModel: SearchViewModel,
onBackPressed: () -> Unit
onBackPressed: () -> Unit,
) {
val state by viewModel.state.collectAsState()
val searchWord by viewModel.searchWord.collectAsState()
Expand Down Expand Up @@ -54,7 +54,7 @@ fun SearchScreenContainer(
fun SearchScreen(
state: SearchScreenState = SearchScreenState(),
currentSearchWord: String = "",
linkList : List<Link> = emptyList(),
linkList: List<Link> = emptyList(),
onClickBack: () -> Unit = {},
inputSearchWord: (String) -> Unit = {},
onClickSearch: () -> Unit = {},
Expand All @@ -65,63 +65,63 @@ fun SearchScreen(
onClickFilterSelect: () -> Unit = {},
onClickFilterItem: (FilterType) -> Unit = {},
hideBottomSheet: () -> Unit = {},
onClickFilterSave : (Filter) -> Unit = {},
onClickFilterSave: (Filter) -> Unit = {},
toggleSortOrder: () -> Unit = {},
) {
Column(
modifier = Modifier.fillMaxSize()
) {
Toolbar(
onClickBack = onClickBack,
inputSearchWord = inputSearchWord,
currentSearchWord = currentSearchWord,
onClickSearch = onClickSearch,
onClickRemove = remember {{ inputSearchWord("") }}
)
Column(
modifier = Modifier.fillMaxSize()
) {
Toolbar(
onClickBack = onClickBack,
inputSearchWord = inputSearchWord,
currentSearchWord = currentSearchWord,
onClickSearch = onClickSearch,
onClickRemove = remember { { inputSearchWord("") } }
)

if (state.step == SearchScreenStep.INPUT) {
RecentSearchWord(
onClickRemoveAll = onClickRemoveAllRecentSearchWord,
onToggleAutoSave = onClickUseRecentSearchWord,
useAutoSave = state.useRecentSearchWord,
recentSearchWords = state.recentSearchWords,
onClickRemoveSearchWord = onClickRemoveRecentSearchWord,
onClickSearchWord = onClickRecentSearchWord
)
}
if (state.step == SearchScreenStep.INPUT) {
RecentSearchWord(
onClickRemoveAll = onClickRemoveAllRecentSearchWord,
onToggleAutoSave = onClickUseRecentSearchWord,
useAutoSave = state.useRecentSearchWord,
recentSearchWords = state.recentSearchWords,
onClickRemoveSearchWord = onClickRemoveRecentSearchWord,
onClickSearchWord = onClickRecentSearchWord
)
}

if (state.step == SearchScreenStep.RESULT){
FilterArea(
filter = state.filter,
onClickFilter = onClickFilterSelect,
onClickBookmark = remember{{ onClickFilterItem(FilterType.Collect) }},
onClickPokitName = remember {{ onClickFilterItem(FilterType.Pokit) }},
onClickPeriod = remember {{ onClickFilterItem(FilterType.Period) }}
)
}
if (state.step == SearchScreenStep.RESULT) {
FilterArea(
filter = state.filter,
onClickFilter = onClickFilterSelect,
onClickBookmark = remember { { onClickFilterItem(FilterType.Collect) } },
onClickPokitName = remember { { onClickFilterItem(FilterType.Pokit) } },
onClickPeriod = remember { { onClickFilterItem(FilterType.Period) } }
)
}

HorizontalDivider(
thickness = 6.dp,
color = PokitTheme.colors.backgroundPrimary
)
HorizontalDivider(
thickness = 6.dp,
color = PokitTheme.colors.backgroundPrimary
)

if (state.step == SearchScreenStep.RESULT) {
SearchItemList(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
onToggleSort = toggleSortOrder,
useRecentOrder = state.sortRecent,
links = linkList
)
}
if (state.step == SearchScreenStep.RESULT) {
SearchItemList(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
onToggleSort = toggleSortOrder,
useRecentOrder = state.sortRecent,
links = linkList
)
}

FilterBottomSheet(
filter = state.filter ?: Filter(),
firstShowType = state.firstBottomSheetFilterType,
show = state.showFilterBottomSheet,
onDismissRequest = hideBottomSheet,
onSaveClilck = onClickFilterSave
)
}
FilterBottomSheet(
filter = state.filter ?: Filter(),
firstShowType = state.firstBottomSheetFilterType,
show = state.showFilterBottomSheet,
onDismissRequest = hideBottomSheet,
onSaveClilck = onClickFilterSave
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class SearchViewModel : ViewModel() {
}
}

fun showFilterBottomSheetWithType(type : FilterType) {
fun showFilterBottomSheetWithType(type: FilterType) {
_state.update { state ->
state.copy(
showFilterBottomSheet = true,
Expand All @@ -112,7 +112,7 @@ class SearchViewModel : ViewModel() {
null
} else {
filter
},
}
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import pokitmons.pokit.search.model.Date
internal fun CalendarCellView(
date: Date,
onClick: ((Date) -> Unit)? = null,
state: CalendarCellState = CalendarCellState.ACTIVE
state: CalendarCellState = CalendarCellState.ACTIVE,
) {
val backgroundColor = getBackgroundColor(state = state)
val textColor = getTextColor(state = state)
Expand All @@ -48,7 +48,7 @@ internal fun CalendarCellView(
modifier = Modifier.align(Alignment.Center),
textAlign = TextAlign.Center,
text = date.day.toString(),
style = PokitTheme.typography.body1Medium.copy(color = textColor),
style = PokitTheme.typography.body1Medium.copy(color = textColor)
)
}
}
Expand All @@ -58,7 +58,7 @@ enum class CalendarCellState {
}

@Composable
private fun getTextColor(state: CalendarCellState) : Color {
private fun getTextColor(state: CalendarCellState): Color {
return when (state) {
CalendarCellState.INACTIVE -> {
PokitTheme.colors.textTertiary
Expand All @@ -76,7 +76,7 @@ private fun getTextColor(state: CalendarCellState) : Color {
}

@Composable
private fun getBackgroundColor(state: CalendarCellState) : Color {
private fun getBackgroundColor(state: CalendarCellState): Color {
return when (state) {
CalendarCellState.IN_RANGE -> {
Orange100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ internal fun CalendarView(
endDate: Date? = null,
onClickCell: (Date) -> Unit = {},
) {
var currentPage by remember { mutableStateOf(calendarPage)}
var currentPage by remember { mutableStateOf(calendarPage) }
val calendarCells = remember(
currentPage, startDate, endDate
currentPage,
startDate,
endDate
) {
getCells(year = currentPage.year, month = currentPage.month, startDate = startDate, endDate = endDate)
}
Expand Down Expand Up @@ -134,8 +136,7 @@ internal fun CalendarView(
onClick = onClickCell,
state = CalendarCellState.IN_RANGE
)
}
else {
} else {
CalendarCellView(
date = cell.date,
onClick = onClickCell,
Expand All @@ -145,5 +146,4 @@ internal fun CalendarView(
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,21 @@ private fun Preview() {
calendarPage = CalendarPage(endDate),
startDate = startDate,
endDate = endDate,
onClickCell = remember{{ date ->
val currentStartDate = startDate
if (currentStartDate != null && endDate == null) {
if (date <= currentStartDate) {
startDate = date
onClickCell = remember {
{ date ->
val currentStartDate = startDate
if (currentStartDate != null && endDate == null) {
if (date <= currentStartDate) {
startDate = date
} else {
endDate = date
}
} else {
endDate = date
startDate = date
endDate = null
}
} else {
startDate = date
endDate = null
}
}}
}
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonSize
import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonStyle
import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonType
import pokitmons.pokit.search.R
import pokitmons.pokit.core.ui.R.drawable as coreDrawable
import pokitmons.pokit.search.model.Filter
import pokitmons.pokit.core.ui.R.drawable as coreDrawable

@Composable
fun FilterArea(
filter: Filter? = null,
onClickFilter: () -> Unit = {},
onClickPeriod: () -> Unit = {},
onClickPokitName: () -> Unit = {},
onClickBookmark: () -> Unit = {}
onClickBookmark: () -> Unit = {},
) {
val scrollState = rememberScrollState()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private fun Preview() {
FilterArea(
filter = Filter(
startDate = Date(year = 2024, month = 7, day = 20),
endDate = Date(year = 2024, month = 7, day = 20),
endDate = Date(year = 2024, month = 7, day = 20)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fun FilterBottomSheet(
onSaveClilck: (Filter) -> Unit = {},
pokits: List<Pokit> = samplePokits,
show: Boolean = false,
onDismissRequest: () -> Unit = {}
onDismissRequest: () -> Unit = {},
) {
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
var visibility by remember { mutableStateOf(show) }
Expand All @@ -61,10 +61,12 @@ fun FilterBottomSheet(

if (visibility) {
ModalBottomSheet(
onDismissRequest = remember{{
onDismissRequest()
visibility = false
}},
onDismissRequest = remember {
{
onDismissRequest()
visibility = false
}
},
sheetState = bottomSheetState,
scrimColor = Color.Transparent,
shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp),
Expand Down Expand Up @@ -99,5 +101,4 @@ fun FilterBottomSheet(
)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ fun FilterBottomSheetContent(
.padding(12.dp)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() },
interactionSource = remember { MutableInteractionSource() }
) {
currentFilter = currentFilter.copy(bookmark = !currentFilter.bookmark)
}
.padding(12.dp)
) {
PokitCheckbox(
checked = currentFilter.bookmark,
onClick = {currentFilter = currentFilter.copy(bookmark = !currentFilter.bookmark)}
onClick = { currentFilter = currentFilter.copy(bookmark = !currentFilter.bookmark) }
)
Spacer(modifier = Modifier.width(16.dp))
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import pokitmons.pokit.core.ui.theme.PokitTheme


@Preview(showBackground = true)
@Composable
private fun Preview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ internal fun RecentSearchWord(
.padding(start = 20.dp, end = 20.dp, top = 16.dp, bottom = 28.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {

Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
Expand Down Expand Up @@ -115,6 +114,5 @@ internal fun RecentSearchWord(
}
}
}

}
}
Loading

0 comments on commit fa6d1da

Please sign in to comment.