Skip to content

Commit

Permalink
style: 코드 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Jan 30, 2024
1 parent eaaa5b6 commit c6a92d8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ import io.github.boguszpawlowski.composecalendar.selection.DynamicSelectionState
import io.github.boguszpawlowski.composecalendar.selection.SelectionMode
import io.github.boguszpawlowski.composecalendar.week.Week
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch
import timber.log.Timber
Expand Down Expand Up @@ -142,7 +141,7 @@ fun CalendarDetailPage(
)
}

val overScrollPagerState = rememberPagerState(pageCount = {3}, initialPage = 1)
val overScrollPagerState = rememberPagerState(pageCount = { 3 }, initialPage = 1)
var overScrollEnabled by remember {
mutableStateOf(true)
}
Expand Down Expand Up @@ -192,7 +191,7 @@ fun CalendarDetailPage(

LaunchedEffect(currentPostState, pagerState.currentPage) {
if (currentPostState.isReady()) {
if(overScrollPagerState.currentPage != 1)
if (overScrollPagerState.currentPage != 1)
overScrollPagerState.scrollToPage(1)
if (currentPostState.data.size <= pagerState.currentPage) {
return@LaunchedEffect
Expand All @@ -209,28 +208,31 @@ fun CalendarDetailPage(
}

LaunchedEffect(overScrollPagerState) {
snapshotFlow { overScrollPagerState.currentPage }.distinctUntilChanged().collect { nextPage ->
if(nextPage == 1) {
overScrollEnabled = true
return@collect
}
val currSelection = currentCalendarState.selectionState.selection[0]
val currentWeeks = uiState.value.keys
val nextDay = if(nextPage == 0) currentWeeks.filter { it.isBefore(currSelection) }.maxWithOrNull(LocalDate::compareTo)
else currentWeeks.filter { it.isAfter(currSelection) }.minWithOrNull(LocalDate::compareTo)
if(nextDay != null) {
currentCalendarState.selectionState.selection = listOf(nextDay)
currentCalendarState.weekState.currentWeek = Week(nextDay.weekDates())
} else {
snackBarState.showSnackBarWithDismiss(
resources.getString(R.string.no_more_calendar_items),
snackBarWarning
)
overScrollEnabled = false
delay(250L)
overScrollPagerState.scrollToPage(1)
snapshotFlow { overScrollPagerState.currentPage }.distinctUntilChanged()
.collect { nextPage ->
if (nextPage == 1) {
overScrollEnabled = true
return@collect
}
val currSelection = currentCalendarState.selectionState.selection[0]
val currentWeeks = uiState.value.keys
val nextDay = if (nextPage == 0) currentWeeks.filter { it.isBefore(currSelection) }
.maxWithOrNull(LocalDate::compareTo)
else currentWeeks.filter { it.isAfter(currSelection) }
.minWithOrNull(LocalDate::compareTo)
if (nextDay != null) {
currentCalendarState.selectionState.selection = listOf(nextDay)
currentCalendarState.weekState.currentWeek = Week(nextDay.weekDates())
} else {
snackBarState.showSnackBarWithDismiss(
resources.getString(R.string.no_more_calendar_items),
snackBarWarning
)
overScrollEnabled = false
delay(250L)
overScrollPagerState.scrollToPage(1)
}
}
}
}

val yearStr = stringResource(id = R.string.year)
Expand Down Expand Up @@ -292,7 +294,7 @@ fun CalendarDetailPage(
state = overScrollPagerState,
userScrollEnabled = overScrollEnabled,
) {
if(it == 1) {
if (it == 1) {
CompositionLocalProvider(
LocalOverscrollConfiguration provides null
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun CreateRealEmojiBar(
selectedEmoji: String,
emojiMap: Map<String, MemberRealEmoji>,
onTapEmoji: (String) -> Unit = {},
){
) {
Row(
horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.CenterHorizontally),
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.no5ing.bbibbi.presentation.feature.view.main.create_real_emoji

import androidx.camera.core.CameraSelector
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -13,18 +12,15 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.no5ing.bbibbi.R
import com.no5ing.bbibbi.data.repository.Arguments
import com.no5ing.bbibbi.presentation.component.button.CameraCaptureButton
import com.no5ing.bbibbi.util.takePhotoWithImage
import kotlinx.coroutines.launch

@Composable
fun CreateRealEmojiCameraBar(
isCapturing: Boolean,
onClickTorch: () -> Unit = {},
onClickCapture: () -> Unit = {},
onClickRotate: () -> Unit = {},
){
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceAround,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
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.Alignment
Expand Down Expand Up @@ -45,7 +44,7 @@ fun SettingHomePageContent(
mutableIntStateOf(0)
}
LaunchedEffect(versionState) {
if(versionState != 0 && versionState % 6 == 0) {
if (versionState != 0 && versionState % 6 == 0) {
onVersionLongTap()
}
}
Expand Down

0 comments on commit c6a92d8

Please sign in to comment.