-
Notifications
You must be signed in to change notification settings - Fork 0
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
[feat] Custom SnackBar 제작 #23
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
app/src/main/java/org/android/bbangzip/presentation/component/snackbar/BbangZipSnackBar.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,37 @@ | ||
package org.android.bbangzip.presentation.component.snackbar | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun BbangZipSnackBar( | ||
text: String, | ||
textStyle: TextStyle, | ||
textColor: Color, | ||
containerColor: Color, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Box( | ||
modifier = | ||
modifier | ||
.padding(12.dp) | ||
.background(color = containerColor, shape = RoundedCornerShape(size = 16.dp)) | ||
.padding(vertical = 11.dp, horizontal = 24.dp), | ||
contentAlignment = Alignment.Center, | ||
) { | ||
Text( | ||
text = text, | ||
style = textStyle, | ||
color = textColor, | ||
) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...rc/main/java/org/android/bbangzip/presentation/component/snackbar/BbangZipSnackBarHost.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,26 @@ | ||
package org.android.bbangzip.presentation.component.snackbar | ||
|
||
import androidx.compose.material3.SnackbarHost | ||
import androidx.compose.material3.SnackbarHostState | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import org.android.bbangzip.ui.theme.BbangZipTheme | ||
|
||
@Composable | ||
fun BbangZipSnackBarHost( | ||
snackBarHostState: SnackbarHostState, | ||
modifier: Modifier = Modifier, | ||
) { | ||
SnackbarHost( | ||
modifier = modifier, | ||
hostState = snackBarHostState, | ||
snackbar = { data -> | ||
BbangZipSnackBar( | ||
text = data.visuals.message, | ||
textStyle = BbangZipTheme.typography.label2Bold, | ||
textColor = BbangZipTheme.colors.staticWhite_FFFFFF, | ||
containerColor = BbangZipTheme.colors.labelAlternative_282119_61, | ||
) | ||
}, | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,57 @@ package org.android.bbangzip.presentation.ui.subject | |
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.SnackbarHostState | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
import org.android.bbangzip.ui.theme.defaultBbangZipColors | ||
|
||
@Composable | ||
fun SubjectScreen( | ||
modifier: Modifier = Modifier, | ||
) { | ||
Column(modifier = Modifier.fillMaxSize().background(color = defaultBbangZipColors.backgroundNormal_FFFFFF)) { | ||
Column( | ||
modifier = | ||
modifier | ||
.fillMaxSize() | ||
.background(color = defaultBbangZipColors.backgroundNormal_FFFFFF), | ||
) { | ||
Text("subject 탭") | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun SubjectScreenPreview() { | ||
val snackBarHostState = remember { SnackbarHostState() } | ||
val coroutineScope = rememberCoroutineScope() | ||
Column( | ||
modifier = | ||
Modifier | ||
.fillMaxSize() | ||
.background(color = defaultBbangZipColors.backgroundNormal_FFFFFF), | ||
) { | ||
Text("subject 탭") | ||
Button( | ||
onClick = { | ||
coroutineScope.launch { | ||
val job = | ||
launch { | ||
snackBarHostState.currentSnackbarData?.dismiss() | ||
snackBarHostState.showSnackbar("안녕안녕") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
delay(2000) | ||
job.cancel() | ||
} | ||
}, | ||
) { Text("눌러") } | ||
} | ||
} | ||
// 위에 코드는 클릭마다 스낵바가뜨고 2초후에 사라지게 만든 코드입니다 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p5
좋다..