Skip to content

Commit

Permalink
🚚 Refactor alert dialog ui & back button ui
Browse files Browse the repository at this point in the history
  • Loading branch information
sukchan-0811 committed Nov 2, 2023
1 parent b08d9e1 commit eebad37
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.example.speechbuddy.R
import com.example.speechbuddy.ui.SpeechBuddyTheme

@Composable
fun BackButtonUi(
onBackClick: () -> Unit
){
) {
IconButton(onClick = onBackClick) {
Icon(
imageVector = Icons.Default.ArrowBack,
contentDescription = "Go back to settings page"
contentDescription = stringResource(id = R.string.back)
)
}
}

@Preview
@Composable
fun BackButtonUiPreview(){
SpeechBuddyTheme{
fun BackButtonUiPreview() {
SpeechBuddyTheme {
BackButtonUi(
onBackClick = {}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
package com.example.speechbuddy.compose.settings
package com.example.speechbuddy.compose.utils

import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.speechbuddy.ui.SpeechBuddyTheme

@Composable
fun AlertDialogUi(
onConfirmButtonClick: () -> Unit,
onDismissButtonClick: () -> Unit,
title: String,
content: String,
text: String,
dismissButtonText: String,
confirmButtonText: String,
dismissButtonText: String
onDismiss: () -> Unit,
onConfirm: () -> Unit
) {
AlertDialog(
title = {
Text(text = title)
},
text = {
Text(text = content)
},
onDismissRequest = {
onDismissButtonClick
},
onDismissRequest = onDismiss,
confirmButton = {
Button(
onClick = onConfirmButtonClick,
onClick = onConfirm,
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.error,
contentColor = MaterialTheme.colorScheme.onError,
Expand All @@ -42,7 +33,7 @@ fun AlertDialogUi(
},
dismissButton = {
Button(
onClick = onDismissButtonClick,
onClick = onDismiss,
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant,
contentColor = MaterialTheme.colorScheme.onSurfaceVariant
Expand All @@ -51,6 +42,12 @@ fun AlertDialogUi(
Text(dismissButtonText)
}
},
title = {
Text(text = title)
},
text = {
Text(text = text)
},
containerColor = MaterialTheme.colorScheme.inverseOnSurface
)
}
Expand All @@ -60,12 +57,12 @@ fun AlertDialogUi(
fun AlertDialogUiPreview() {
SpeechBuddyTheme {
AlertDialogUi(
onConfirmButtonClick = { /*TODO*/ },
onDismissButtonClick = { /*TODO*/ },
title = "title",
content = "content",
text = "text",
dismissButtonText = "dismiss",
confirmButtonText = "confirm",
dismissButtonText = "dismiss"
onDismiss = {},
onConfirm = {}
)
}
}
1 change: 1 addition & 0 deletions frontend/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@
<string name="version">버전</string>
<string name="developer_email">[email protected]</string>
<string name="stop_text">정지</string>
<string name="back">뒤로가기</string>
</resources>

0 comments on commit eebad37

Please sign in to comment.