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

refactor : 게시글 내용을 수정할 때만 스크롤 되도록 수정 #99

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
Expand Down Expand Up @@ -470,9 +471,12 @@ fun RegisterPostContent(
) {
val coroutineScope = rememberCoroutineScope()
val keyboardHeight = WindowInsets.ime.getBottom(LocalDensity.current)
var isContentFocus by remember {
mutableStateOf(false)
}

LaunchedEffect(key1 = keyboardHeight, key2 = content.lines().size) {
if (content.lines().size >= SCROLL_THRESHOLD_LINE) {
if (content.lines().size >= SCROLL_THRESHOLD_LINE && isContentFocus) {
coroutineScope.launch { scrollByKeyboardHeight(keyboardHeight.toFloat()) }
}
} // 키보드기 올라가거나, Content의 라인이 변할때마다 내용이 키보드 영역에 가려지지 않도록 키보드 영역만큼 스크롤해줌.
Expand All @@ -484,6 +488,7 @@ fun RegisterPostContent(
vertical = 16.dp,
horizontal = WithpeaceTheme.padding.BasicHorizontalPadding,
)
.onFocusChanged { isContentFocus = it.isFocused }
.fillMaxSize(),
value = content,
onValueChange = onContentChanged,
Expand Down
Loading