|
1 | | -package org.odk.collect.android.widgets.arbitraryfile |
| 1 | +package org.odk.collect.android.widgets |
2 | 2 |
|
3 | 3 | import androidx.compose.foundation.combinedClickable |
4 | 4 | import androidx.compose.foundation.layout.Arrangement |
5 | 5 | import androidx.compose.foundation.layout.Row |
6 | 6 | import androidx.compose.foundation.layout.Spacer |
7 | 7 | import androidx.compose.foundation.layout.fillMaxWidth |
8 | 8 | import androidx.compose.foundation.layout.width |
9 | | -import androidx.compose.material.icons.Icons |
10 | | -import androidx.compose.material.icons.filled.AttachFile |
11 | 9 | import androidx.compose.material3.Icon |
12 | 10 | import androidx.compose.material3.MaterialTheme |
13 | 11 | import androidx.compose.material3.Text |
14 | 12 | import androidx.compose.runtime.Composable |
15 | 13 | import androidx.compose.ui.Alignment |
16 | 14 | import androidx.compose.ui.Modifier |
17 | | -import androidx.compose.ui.platform.LocalContext |
| 15 | +import androidx.compose.ui.graphics.vector.ImageVector |
18 | 16 | import androidx.compose.ui.res.dimensionResource |
19 | | -import androidx.compose.ui.res.stringResource |
20 | 17 | import androidx.compose.ui.text.TextStyle |
21 | 18 | import androidx.compose.ui.unit.sp |
22 | | -import androidx.lifecycle.ViewModelProvider |
23 | 19 | import org.odk.collect.androidshared.R.dimen |
24 | 20 | import org.odk.collect.androidshared.ui.multiclicksafe.MultiClickGuard |
25 | | -import org.odk.collect.strings.R |
26 | 21 |
|
27 | 22 | @Composable |
28 | | -fun ArbitraryFileWidgetAnswer( |
| 23 | +fun TextWidgetAnswer( |
29 | 24 | modifier: Modifier, |
| 25 | + icon: ImageVector, |
30 | 26 | answer: String, |
31 | 27 | fontSize: Int, |
32 | | - viewModelProvider: ViewModelProvider, |
33 | | - onLongClick: () -> Unit |
| 28 | + onLongClick: () -> Unit, |
| 29 | + onClickLabel: String? = null, |
| 30 | + onClick: () -> Unit = {} |
34 | 31 | ) { |
35 | | - val context = LocalContext.current |
36 | | - val viewModel = viewModelProvider[ArbitraryFileWidgetAnswerViewModel::class] |
37 | | - |
38 | 32 | Row( |
39 | 33 | modifier = modifier |
40 | 34 | .fillMaxWidth() |
41 | 35 | .combinedClickable( |
42 | 36 | onClick = { |
43 | 37 | if (MultiClickGuard.allowClick()) { |
44 | | - viewModel.openFile(context, answer) |
| 38 | + onClick() |
45 | 39 | } |
46 | 40 | }, |
47 | 41 | onLongClick = onLongClick, |
48 | | - onClickLabel = stringResource(R.string.open_file) |
| 42 | + onClickLabel = onClickLabel |
49 | 43 | ), |
50 | 44 | verticalAlignment = Alignment.CenterVertically, |
51 | 45 | horizontalArrangement = Arrangement.Center |
52 | 46 | ) { |
53 | 47 | Icon( |
54 | | - imageVector = Icons.Default.AttachFile, |
| 48 | + imageVector = icon, |
55 | 49 | contentDescription = null, |
56 | 50 | tint = MaterialTheme.colorScheme.onSurface |
57 | 51 | ) |
|
0 commit comments