@@ -8,8 +8,11 @@ import androidx.compose.animation.shrinkVertically
8
8
import androidx.compose.foundation.layout.Box
9
9
import androidx.compose.foundation.layout.Column
10
10
import androidx.compose.foundation.layout.padding
11
+ import androidx.compose.foundation.layout.size
11
12
import androidx.compose.material3.Button
13
+ import androidx.compose.material3.CircularProgressIndicator
12
14
import androidx.compose.material3.FilledTonalButton
15
+ import androidx.compose.material3.ProgressIndicatorDefaults
13
16
import androidx.compose.material3.Text
14
17
import androidx.compose.runtime.Composable
15
18
import androidx.compose.ui.Alignment
@@ -18,8 +21,8 @@ import androidx.compose.ui.graphics.Color
18
21
import androidx.compose.ui.res.dimensionResource
19
22
import androidx.compose.ui.res.stringResource
20
23
import androidx.compose.ui.tooling.preview.Preview
24
+ import androidx.compose.ui.unit.dp
21
25
import app.fyreplace.fyreplace.R
22
- import app.fyreplace.fyreplace.ui.views.SmallCircularProgressIndicator
23
26
24
27
@Composable
25
28
fun SubmitOrCancel (
@@ -36,7 +39,7 @@ fun SubmitOrCancel(
36
39
modifier = modifier
37
40
) {
38
41
Button (
39
- enabled = canSubmit,
42
+ enabled = canSubmit && ! isLoading ,
40
43
onClick = onSubmit
41
44
) {
42
45
Box {
@@ -47,7 +50,12 @@ fun SubmitOrCancel(
47
50
)
48
51
49
52
if (isLoading) {
50
- SmallCircularProgressIndicator (modifier = Modifier .align(Alignment .Center ))
53
+ CircularProgressIndicator (
54
+ strokeWidth = ProgressIndicatorDefaults .CircularStrokeWidth / 2 ,
55
+ modifier = Modifier
56
+ .size(24 .dp)
57
+ .align(Alignment .Center )
58
+ )
51
59
}
52
60
}
53
61
}
@@ -80,3 +88,17 @@ fun SubmitOrCancelPreview() {
80
88
modifier = Modifier .padding(dimensionResource(R .dimen.spacing_medium))
81
89
)
82
90
}
91
+
92
+ @Preview(showBackground = true )
93
+ @Composable
94
+ fun SubmitOrCancelLoadingPreview () {
95
+ SubmitOrCancel (
96
+ submitLabel = " Submit" ,
97
+ canSubmit = true ,
98
+ canCancel = true ,
99
+ isLoading = true ,
100
+ onSubmit = {},
101
+ onCancel = {},
102
+ modifier = Modifier .padding(dimensionResource(R .dimen.spacing_medium))
103
+ )
104
+ }
0 commit comments