-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from BCSDLab/feature/timetable_api_v3
[Feature] 시간표 3차 구현
- Loading branch information
Showing
58 changed files
with
3,124 additions
and
581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
...rc/main/java/in/koreatech/koin/core/designsystem/component/snackbar/CustomSnackBarHost.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package `in`.koreatech.koin.core.designsystem.component.snackbar | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.layout.wrapContentHeight | ||
import androidx.compose.foundation.layout.wrapContentWidth | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.SnackbarDuration | ||
import androidx.compose.material3.SnackbarHost | ||
import androidx.compose.material3.SnackbarHostState | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import `in`.koreatech.koin.core.designsystem.noRippleClickable | ||
import `in`.koreatech.koin.core.designsystem.theme.KoinTheme | ||
|
||
// Surface 사용하지 않을 경우, SnackBar 커스텀 | ||
@Composable | ||
fun CustomSnackBarHost( | ||
hotState: SnackbarHostState, | ||
radius: Dp = 0.dp, | ||
messageTextStyle: TextStyle = KoinTheme.typography.regular12.copy( | ||
color = Color.White | ||
), | ||
actionLabelTextStyle: TextStyle = KoinTheme.typography.regular12.copy( | ||
color = Color.White | ||
), | ||
background: Color = Color.Black, | ||
alignment: Alignment = Alignment.BottomCenter, | ||
paddingValues: PaddingValues = PaddingValues(bottom = 20.dp, start = 10.dp, end = 10.dp), | ||
innerPaddingValues: PaddingValues = PaddingValues(horizontal = 10.dp, vertical = 16.dp) | ||
) { | ||
SnackbarHost( | ||
hostState = hotState, | ||
) { snackbarData -> | ||
SnackBarContent( | ||
messageText = snackbarData.visuals.message, | ||
actionLabelText = snackbarData.visuals.actionLabel ?: "", | ||
radius = radius, | ||
background = background, | ||
messageTextStyle = messageTextStyle, | ||
actionLabelTextStyle = actionLabelTextStyle, | ||
alignment = alignment, | ||
paddingValues = paddingValues, | ||
innerPaddingValues = innerPaddingValues, | ||
onAction = { snackbarData.dismiss() } | ||
) | ||
} | ||
|
||
} | ||
|
||
@Composable | ||
private fun SnackBarContent( | ||
messageText: String, | ||
actionLabelText: String, | ||
modifier: Modifier = Modifier, | ||
radius: Dp = 0.dp, | ||
background: Color = Color.Black, | ||
messageTextStyle: TextStyle = KoinTheme.typography.regular12.copy( | ||
color = Color.White | ||
), | ||
actionLabelTextStyle: TextStyle = KoinTheme.typography.regular12.copy( | ||
color = Color.White | ||
), | ||
alignment: Alignment = Alignment.BottomCenter, | ||
paddingValues: PaddingValues = PaddingValues(bottom = 20.dp, start = 10.dp, end = 10.dp), | ||
innerPaddingValues: PaddingValues = PaddingValues(horizontal = 10.dp, vertical = 16.dp), | ||
onAction: () -> Unit = {} | ||
) { | ||
Box( | ||
modifier = modifier | ||
.fillMaxSize() | ||
.padding(paddingValues), | ||
contentAlignment = alignment | ||
) { | ||
Box( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.clip(RoundedCornerShape(radius)) | ||
.background(background) | ||
.padding(innerPaddingValues) | ||
) { | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Spacer(modifier = Modifier.width(4.dp)) | ||
Text( | ||
text = messageText, | ||
style = messageTextStyle, | ||
modifier = Modifier.weight(1f), | ||
) | ||
Spacer(modifier = Modifier.weight(0.05f)) | ||
if (actionLabelText.isNotEmpty()) { | ||
Text( | ||
text = actionLabelText, | ||
style = actionLabelTextStyle, | ||
modifier = Modifier.weight(0.1f).noRippleClickable { onAction() } | ||
) | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
fun SnackbarHostState.dismissIfShown() { | ||
if (currentSnackbarData != null) { | ||
currentSnackbarData?.dismiss() | ||
} | ||
} | ||
|
||
suspend fun SnackbarHostState.showSnackBarWithDismiss( | ||
message: String, | ||
actionLabel: String = "", | ||
duration: SnackbarDuration = SnackbarDuration.Short | ||
) { | ||
dismissIfShown() | ||
showSnackbar( | ||
message = message, | ||
actionLabel = actionLabel, | ||
duration = duration | ||
) | ||
} | ||
|
||
@Preview(showBackground = true, showSystemUi = true) | ||
@Composable | ||
private fun SnackBarContentPreview() { | ||
SnackBarContent( | ||
messageText = "스낵바 메시지", | ||
actionLabelText = "닫기", | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.