Skip to content

Commit

Permalink
feat: 스낵바 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
rhkrwngud445 committed Jul 3, 2024
1 parent aea42b0 commit 972e307
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 27 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
applicationId = "com.withpeace.withpeace"
targetSdk = 34
versionCode = 7
versionName = "1.0.2"
versionCode = 8
versionName = "1.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
26 changes: 2 additions & 24 deletions app/src/main/java/com/withpeace/withpeace/WithpeaceApp.kt
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
package com.withpeace.withpeace

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.SnackbarResult
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.core.designsystem.ui.snackbar.CheonghaSnackbar
import com.withpeace.withpeace.core.designsystem.ui.snackbar.SnackbarState
import com.withpeace.withpeace.core.designsystem.ui.snackbar.SnackbarType
import com.withpeace.withpeace.navigation.WithpeaceNavHost
Expand Down Expand Up @@ -81,22 +74,7 @@ fun WithpeaceApp(
when (snackBarState.snackbarType) {
is SnackbarType.Navigator -> {}
is SnackbarType.Normal -> {
Row(
modifier = Modifier
.padding(horizontal = 24.dp)
.padding(bottom = 16.dp)
.imePadding()
.fillMaxWidth()
.clip(RoundedCornerShape(4.dp))
.background(WithpeaceTheme.colors.SnackbarBlack),
) {
Text(
modifier = Modifier.padding(vertical = 16.dp, horizontal = 24.dp),
style = WithpeaceTheme.typography.caption,
text = it.visuals.message,
color = WithpeaceTheme.colors.SystemWhite,
)
}
CheonghaSnackbar(data = it)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
package com.withpeace.withpeace.core.designsystem.ui.snackbar

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.SnackbarData
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme

@Composable
fun CheonghaSnackbar() {
fun CheonghaSnackbar(data: SnackbarData) {
Row(
modifier = Modifier
.padding(horizontal = 24.dp)
.padding(bottom = 16.dp)
.imePadding()
.fillMaxWidth()
.clip(RoundedCornerShape(4.dp))
.background(WithpeaceTheme.colors.SnackbarBlack),
) {
Text(
modifier = Modifier.padding(vertical = 16.dp, horizontal = 24.dp),
style = WithpeaceTheme.typography.caption,
text = data.visuals.message,
color = WithpeaceTheme.colors.SystemWhite,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.withpeace.withpeace.core.designsystem.ui.snackbar

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
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.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme

@Composable
fun NavigatorSnackbar(data: SnackbarState) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.padding(horizontal = 24.dp)
.padding(bottom = 16.dp)
.imePadding()
.fillMaxWidth()
.clip(RoundedCornerShape(4.dp))
.background(WithpeaceTheme.colors.SnackbarBlack),
) {
Text(
modifier = Modifier.padding(vertical = 16.dp, horizontal = 24.dp),
style = WithpeaceTheme.typography.caption,
text = data.message,
color = WithpeaceTheme.colors.SystemWhite,
)
Text(
modifier = Modifier.padding(vertical = 16.dp, horizontal = 24.dp),
style = WithpeaceTheme.typography.caption,
text = data.message,
color = WithpeaceTheme.colors.SubSkyBlue,
textDecoration = TextDecoration.Underline,
)
}
}

0 comments on commit 972e307

Please sign in to comment.