1
- package com.squirtles.musicroad.pick.components
1
+ package com.squirtles.musicroad.common
2
2
3
3
import androidx.compose.foundation.layout.Arrangement
4
4
import androidx.compose.foundation.layout.Column
5
5
import androidx.compose.foundation.layout.Row
6
+ import androidx.compose.foundation.layout.RowScope
6
7
import androidx.compose.foundation.layout.fillMaxWidth
7
8
import androidx.compose.foundation.layout.padding
8
9
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -22,18 +23,18 @@ import androidx.compose.ui.text.font.FontWeight
22
23
import androidx.compose.ui.tooling.preview.Preview
23
24
import androidx.compose.ui.unit.dp
24
25
import com.squirtles.musicroad.R
25
- import com.squirtles.musicroad.common.VerticalSpacer
26
- import com.squirtles.musicroad.common.HorizontalSpacer
27
26
import com.squirtles.musicroad.ui.theme.Black
28
27
import com.squirtles.musicroad.ui.theme.MusicRoadTheme
29
28
import com.squirtles.musicroad.ui.theme.Primary
30
29
import com.squirtles.musicroad.ui.theme.White
31
30
32
31
@OptIn(ExperimentalMaterial3Api ::class )
33
32
@Composable
34
- fun DeletePickDialog (
33
+ internal fun MessageAlertDialog (
35
34
onDismissRequest : () -> Unit ,
36
- onDeletion : () -> Unit
35
+ title : String ,
36
+ body : String ,
37
+ buttons : @Composable RowScope .() -> Unit ,
37
38
) {
38
39
BasicAlertDialog (
39
40
onDismissRequest = { onDismissRequest() },
@@ -48,7 +49,7 @@ fun DeletePickDialog(
48
49
verticalArrangement = Arrangement .Center
49
50
) {
50
51
Text (
51
- text = stringResource( R .string.delete_pick_dialog_title) ,
52
+ text = title ,
52
53
color = Black ,
53
54
fontWeight = FontWeight .Bold ,
54
55
style = MaterialTheme .typography.bodyLarge
@@ -57,7 +58,7 @@ fun DeletePickDialog(
57
58
VerticalSpacer (8 )
58
59
59
60
Text (
60
- text = stringResource( R .string.delete_pick_dialog_body) ,
61
+ text = body ,
61
62
color = Black ,
62
63
style = MaterialTheme .typography.bodyLarge
63
64
)
@@ -67,45 +68,59 @@ fun DeletePickDialog(
67
68
Row (
68
69
modifier = Modifier .fillMaxWidth(),
69
70
horizontalArrangement = Arrangement .End ,
70
- verticalAlignment = Alignment .CenterVertically
71
- ) {
72
- TextButton (
73
- onClick = { onDismissRequest() },
74
- colors = ButtonDefaults .buttonColors().copy(
75
- containerColor = Color .Transparent ,
76
- contentColor = Black
77
- )
78
- ) {
79
- Text (stringResource(R .string.delete_pick_dialog_cancel))
80
- }
81
-
82
- HorizontalSpacer (8 )
83
-
84
- TextButton (
85
- onClick = { onDeletion() },
86
- colors = ButtonDefaults .buttonColors().copy(
87
- containerColor = Color .Transparent ,
88
- contentColor = Primary
89
- )
90
- ) {
91
- Text (
92
- text = stringResource(R .string.delete_pick_dialog_delete),
93
- fontWeight = FontWeight .Bold
94
- )
95
- }
96
- }
71
+ verticalAlignment = Alignment .CenterVertically ,
72
+ content = buttons
73
+ )
97
74
}
98
75
}
99
76
}
100
77
}
101
78
79
+ @Composable
80
+ internal fun DialogTextButton (
81
+ onClick : () -> Unit ,
82
+ text : String ,
83
+ textColor : Color = Black ,
84
+ buttonColor : Color = Color .Transparent ,
85
+ fontWeight : FontWeight ? = null,
86
+ ) {
87
+ TextButton (
88
+ onClick = onClick,
89
+ colors = ButtonDefaults .buttonColors().copy(
90
+ containerColor = buttonColor,
91
+ contentColor = textColor
92
+ )
93
+ ) {
94
+ Text (
95
+ text = text,
96
+ fontWeight = fontWeight,
97
+ )
98
+ }
99
+ }
100
+
102
101
@Preview(showBackground = true )
103
102
@Composable
104
- fun DeletePickDialogPreview () {
103
+ private fun DeletePickDialogPreview () {
105
104
MusicRoadTheme {
106
- DeletePickDialog (
105
+ MessageAlertDialog (
107
106
onDismissRequest = {},
108
- onDeletion = {}
107
+ title = stringResource(R .string.delete_pick_dialog_title),
108
+ body = stringResource(R .string.delete_pick_dialog_body),
109
+ buttons = {
110
+ DialogTextButton (
111
+ onClick = {},
112
+ text = " 취소"
113
+ )
114
+
115
+ HorizontalSpacer (8 )
116
+
117
+ DialogTextButton (
118
+ onClick = {},
119
+ text = " 삭제하기" ,
120
+ textColor = Primary ,
121
+ fontWeight = FontWeight .Bold
122
+ )
123
+ }
109
124
)
110
125
}
111
126
}
0 commit comments