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

BottomSheet 구현 #30

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0ea6102
feat : 바텀시트 폴더 추가
leeeyubin Nov 21, 2024
87fda6a
feat : git pull from main
leeeyubin Dec 18, 2024
d943277
feat : bottom sheet UI
leeeyubin Jan 13, 2025
67dc425
feat : handle bar optional인 상태 삭제
leeeyubin Jan 17, 2025
9460ec3
feat : bottomSheetType Sealed class로 구현
leeeyubin Jan 17, 2025
167ed2a
feat : TwoButton 타입 UI 구현
leeeyubin Jan 19, 2025
97b0a9b
feat : preview 수정
leeeyubin Jan 19, 2025
e328e10
feat : BottomSheetDefaults 생성
leeeyubin Jan 19, 2025
ac17d98
feat : 불필요한 코드 삭제
leeeyubin Jan 19, 2025
cf6e412
feat : 바텀시트 data 추가
leeeyubin Jan 19, 2025
0d6f84e
feat : 드래그로 사라지는 애니메이션 구현
leeeyubin Jan 20, 2025
40a9c28
feat : sheet.show 상태 추가
leeeyubin Jan 20, 2025
8e679e0
feat : git pull from main
leeeyubin Jan 20, 2025
b625eb0
feat : conflict 해결
leeeyubin Jan 20, 2025
3212d94
feat : currentValue 업데이트 문제 해결
leeeyubin Jan 20, 2025
364668f
feat : show, hide 애니메이션 구현
leeeyubin Jan 21, 2025
f802d48
feat : 불필요한 코드 수정
leeeyubin Jan 21, 2025
4c2cef6
feat : currentValue 값 업데이트 되도록 수정
leeeyubin Jan 21, 2025
d1f3470
feat : targetValue 추가 및 배경 동기화 수정
leeeyubin Jan 21, 2025
f082ef8
feat : 드래그 후 onDismissRequest 요청할 수 있도록 수정
leeeyubin Jan 21, 2025
b2f71ed
feat : 불필요한 코드 삭제
leeeyubin Jan 21, 2025
6545c06
feat : surface에 shape 적용
leeeyubin Jan 21, 2025
19748ac
feat : 주석 작성 및 Color 추가
leeeyubin Jan 21, 2025
f408080
feat : 주석 수정 및 Color 토큰 추가
leeeyubin Jan 21, 2025
09cb87b
feat : 패딩값 상수화
leeeyubin Jan 21, 2025
d71a8c6
feat : 최소 사이즈 구현
leeeyubin Jan 21, 2025
b0f753f
feat : 프리뷰 바텀시트 보이도록 수정
leeeyubin Jan 21, 2025
3516c97
feat : 프리뷰 경우의 수 추가
leeeyubin Jan 21, 2025
6d55a6e
feat : NoButton 타입 삭제
leeeyubin Jan 21, 2025
781e039
feat : 주석 수정
leeeyubin Jan 21, 2025
3a2542b
feat : 프리뷰 업데이트
leeeyubin Jan 21, 2025
ca7ac13
feat : content 기본값 삭제
leeeyubin Jan 29, 2025
4b1ec41
feat : 줄바꿈 삭제
leeeyubin Feb 1, 2025
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
Prev Previous commit
Next Next commit
feat : 불필요한 코드 삭제
leeeyubin committed Jan 19, 2025
commit ac17d9846f4d46a3d5e6e7e08bdedcebe540cd4b
91 changes: 37 additions & 54 deletions compose/src/main/kotlin/com/yourssu/handy/compose/BottomSheet.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package com.yourssu.handy.compose

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.TweenSpec
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -24,7 +18,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@@ -64,67 +58,56 @@ fun BottomSheet(
bottomSheetType: BottomSheetType = BottomSheetType.NoButton,
content: @Composable () -> Unit = {}
) {
val transitionState = remember { MutableTransitionState(false) }
transitionState.targetState = true

val scope = rememberCoroutineScope()
// Scrim()

Box(
// todo: Scrim 삭제
modifier = modifier
.fillMaxSize()
.background(color = Color(0xFF25262C).copy(alpha = 0.65f))
// .clickable { onDismissRequest() },
.clickable {
transitionState.targetState = false // 애니메이션 종료
onDismissRequest()
}
.clickable { onDismissRequest() },
) {
AnimatedVisibility(
visibleState = transitionState,
enter = slideInVertically(initialOffsetY = { it }) + fadeIn(),
exit = slideOutVertically(targetOffsetY = { it }) + fadeOut(),
modifier = Modifier.align(Alignment.BottomCenter)
Column(
modifier = Modifier
.padding(horizontal = 16.dp)
.padding(bottom = 34.dp)
.fillMaxWidth()
.clip(RoundedCornerShape(24.dp))
.background(HandyTheme.colors.bgBasicDefault)
// .align(Alignment.BottomCenter)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Column(
modifier = Modifier
.padding(horizontal = 16.dp)
.padding(bottom = 34.dp)
.fillMaxWidth()
.clip(RoundedCornerShape(24.dp))
.background(HandyTheme.colors.bgBasicDefault)
// .align(Alignment.BottomCenter)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
if (dragHandle != null) {
DragHandle()
}
Spacer(modifier = Modifier.height(32.dp))
content()
Spacer(modifier = Modifier.height(16.dp))

when (bottomSheetType) {
is BottomSheetType.NoButton -> {}

is BottomSheetType.OneButton -> {
OneButtonBottomSheet(
buttonText = bottomSheetType.buttonText,
onClick = onOneButtonClick
)
}
if (dragHandle != null) {
DragHandle()
}

is BottomSheetType.TwoButton -> {
TwoButtonBottomSheet(
firstButtonText = bottomSheetType.firstButtonText,
secondaryButtonText = bottomSheetType.secondaryButtonText,
onFirstButtonClick = onFirstButtonClick,
onSecondButtonClick = onSecondButtonClick
)
}
Spacer(modifier = Modifier.height(32.dp))
content()
Spacer(modifier = Modifier.height(16.dp))

when (bottomSheetType) {
is BottomSheetType.NoButton -> {}

is BottomSheetType.OneButton -> {
OneButtonBottomSheet(
buttonText = bottomSheetType.buttonText,
onClick = onOneButtonClick
)
}

is BottomSheetType.TwoButton -> {
TwoButtonBottomSheet(
firstButtonText = bottomSheetType.firstButtonText,
secondaryButtonText = bottomSheetType.secondaryButtonText,
onFirstButtonClick = onFirstButtonClick,
onSecondButtonClick = onSecondButtonClick
)
}
}

}
}
}