Skip to content

Commit 8762f0d

Browse files
committed
fix lint error
1 parent 04abc8b commit 8762f0d

9 files changed

Lines changed: 188 additions & 112 deletions

File tree

app/src/main/java/dev/bluehouse/enablevolte/components/BooleanPropertyView.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@ fun BooleanPropertyView(
4747
} else {
4848
Column(modifier = Modifier.padding(top = 12.dp, bottom = 12.dp)) {
4949
Text(text = label, fontSize = 18.sp, modifier = Modifier.padding(bottom = 4.dp))
50-
Text(text = if (toggled) { trueLabel } else { falseLabel }, fontSize = 14.sp, color = MaterialTheme.colorScheme.outline)
50+
Text(
51+
text =
52+
if (toggled) {
53+
trueLabel
54+
} else {
55+
falseLabel
56+
},
57+
fontSize = 14.sp,
58+
color = MaterialTheme.colorScheme.outline,
59+
)
5160
}
5261
}
5362
}

app/src/main/java/dev/bluehouse/enablevolte/components/Common.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ fun OnLifecycleEvent(onEvent: (owner: LifecycleOwner, event: Lifecycle.Event) ->
2222

2323
DisposableEffect(lifecycleOwner.value) {
2424
val lifecycle = lifecycleOwner.value.lifecycle
25-
val observer = LifecycleEventObserver { owner, event ->
26-
eventHandler.value(owner, event)
27-
}
25+
val observer =
26+
LifecycleEventObserver { owner, event ->
27+
eventHandler.value(owner, event)
28+
}
2829

2930
lifecycle.addObserver(observer)
3031
onDispose {

app/src/main/java/dev/bluehouse/enablevolte/components/KeyValueEditView.kt

Lines changed: 77 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ enum class ValueType {
5353
Unknown,
5454
}
5555

56-
data class ArrayValueType<T : ValueType>(val v: T)
56+
data class ArrayValueType<T : ValueType>(
57+
val v: T,
58+
)
5759

5860
@OptIn(ExperimentalMaterial3Api::class)
5961
@Composable
@@ -79,13 +81,18 @@ fun EditPropertyDialog(
7981
properties = DialogProperties(),
8082
) {
8183
Card(
82-
colors = CardDefaults.cardColors(
83-
containerColor = AlertDialogDefaults.containerColor,
84-
contentColor = AlertDialogDefaults.textContentColor,
85-
),
84+
colors =
85+
CardDefaults.cardColors(
86+
containerColor = AlertDialogDefaults.containerColor,
87+
contentColor = AlertDialogDefaults.textContentColor,
88+
),
8689
) {
8790
Column(modifier = Modifier.padding(20.dp)) {
88-
Text(stringResource(R.string.update_value), modifier = Modifier.padding(bottom = 16.dp), style = MaterialTheme.typography.titleMedium)
91+
Text(
92+
stringResource(R.string.update_value),
93+
modifier = Modifier.padding(bottom = 16.dp),
94+
style = MaterialTheme.typography.titleMedium,
95+
)
8996
if (availableKeys != null) {
9097
ExposedDropdownMenuBox(
9198
expanded = keyDropdownExpanded,
@@ -96,12 +103,13 @@ fun EditPropertyDialog(
96103
) {
97104
TextField(
98105
// The `menuAnchor` modifier must be passed to the text field for correctness.
99-
modifier = Modifier
100-
.menuAnchor()
101-
.fillMaxWidth()
102-
.onFocusChanged {
103-
onKeyDropdownExpandedChange(it.isFocused)
104-
},
106+
modifier =
107+
Modifier
108+
.menuAnchor()
109+
.fillMaxWidth()
110+
.onFocusChanged {
111+
onKeyDropdownExpandedChange(it.isFocused)
112+
},
105113
value = configKey,
106114
onValueChange = { onConfigKeyChange(it) },
107115
label = { Text(stringResource(R.string.property_name)) },
@@ -134,23 +142,31 @@ fun EditPropertyDialog(
134142
)
135143
}
136144
Row(
137-
modifier = Modifier
138-
.fillMaxWidth()
139-
.padding(top = 4.dp),
140-
verticalAlignment = if (selectedValueType == ValueType.Bool) { Alignment.CenterVertically } else { Alignment.Top },
145+
modifier =
146+
Modifier
147+
.fillMaxWidth()
148+
.padding(top = 4.dp),
149+
verticalAlignment =
150+
if (selectedValueType == ValueType.Bool) {
151+
Alignment.CenterVertically
152+
} else {
153+
Alignment.Top
154+
},
141155
) {
142156
ExposedDropdownMenuBox(
143157
expanded = valueTypeDropdownExpanded,
144158
onExpandedChange = { onValueDropdownExpandedChange(it) },
145-
modifier = Modifier
146-
.padding(bottom = 8.dp)
147-
.weight(1.0F),
159+
modifier =
160+
Modifier
161+
.padding(bottom = 8.dp)
162+
.weight(1.0F),
148163
) {
149164
TextField(
150165
// The `menuAnchor` modifier must be passed to the text field for correctness.
151-
modifier = Modifier
152-
.menuAnchor()
153-
.weight(1.0F),
166+
modifier =
167+
Modifier
168+
.menuAnchor()
169+
.weight(1.0F),
154170
readOnly = true,
155171
value = selectedValueType?.name ?: "",
156172
onValueChange = {},
@@ -182,26 +198,28 @@ fun EditPropertyDialog(
182198
Box(modifier = Modifier.weight(0.05F))
183199
Box(modifier = Modifier.weight(1.0F, fill = true)) {
184200
when (selectedValueType) {
185-
ValueType.Bool -> Row(
186-
modifier = Modifier.selectableGroup(),
187-
verticalAlignment = Alignment.CenterVertically,
188-
) {
189-
RadioButton(
190-
selected = value == "true",
191-
onClick = { onValueChange("true") },
192-
)
193-
Text(stringResource(R.string.true_))
194-
RadioButton(
195-
selected = value == "false",
196-
onClick = { onValueChange("false") },
201+
ValueType.Bool ->
202+
Row(
203+
modifier = Modifier.selectableGroup(),
204+
verticalAlignment = Alignment.CenterVertically,
205+
) {
206+
RadioButton(
207+
selected = value == "true",
208+
onClick = { onValueChange("true") },
209+
)
210+
Text(stringResource(R.string.true_))
211+
RadioButton(
212+
selected = value == "false",
213+
onClick = { onValueChange("false") },
214+
)
215+
Text(stringResource(R.string.false_))
216+
}
217+
ValueType.Int, ValueType.Long ->
218+
TextField(
219+
value = value,
220+
onValueChange = { onValueChange(it) },
221+
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
197222
)
198-
Text(stringResource(R.string.false_))
199-
}
200-
ValueType.Int, ValueType.Long -> TextField(
201-
value = value,
202-
onValueChange = { onValueChange(it) },
203-
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
204-
)
205223
is ValueType -> TextField(value = value, onValueChange = { onValueChange(it) })
206224
else -> Box(modifier = Modifier.fillMaxWidth())
207225
}
@@ -217,9 +235,10 @@ fun EditPropertyDialog(
217235
TextButton(
218236
border = if (selectedValueType != null) BorderStroke(0.5.dp, MaterialTheme.colorScheme.primary) else null,
219237
shape = ButtonDefaults.outlinedShape,
220-
colors = ButtonDefaults.filledTonalButtonColors(
221-
containerColor = MaterialTheme.colorScheme.primary,
222-
),
238+
colors =
239+
ButtonDefaults.filledTonalButtonColors(
240+
containerColor = MaterialTheme.colorScheme.primary,
241+
),
223242
onClick = {
224243
if (onUpdate(configKey, selectedValueType, value)) {
225244
dismissDialog()
@@ -234,7 +253,11 @@ fun EditPropertyDialog(
234253
}
235254

236255
@Composable
237-
fun KeyValueEditView(label: String, availableKeys: Iterable<String>? = null, onUpdate: ((String, ValueType?, String) -> Boolean)) {
256+
fun KeyValueEditView(
257+
label: String,
258+
availableKeys: Iterable<String>? = null,
259+
onUpdate: ((String, ValueType?, String) -> Boolean),
260+
) {
238261
var configKey by rememberSaveable { mutableStateOf("") }
239262
var selectedValueType: ValueType? by rememberSaveable { mutableStateOf(null) }
240263
var value by rememberSaveable { mutableStateOf("") }
@@ -246,16 +269,17 @@ fun KeyValueEditView(label: String, availableKeys: Iterable<String>? = null, onU
246269
LaunchedEffect(configKey) {
247270
if (availableKeys != null) {
248271
withContext(Dispatchers.Default) {
249-
filteringOptions = if (configKey.length >= 3) {
250-
val filteredItems = availableKeys.filter { it.contains(configKey, ignoreCase = false) }
251-
if (filteredItems.size > 7) {
252-
filteredItems.subList(0, 7)
272+
filteringOptions =
273+
if (configKey.length >= 3) {
274+
val filteredItems = availableKeys.filter { it.contains(configKey, ignoreCase = false) }
275+
if (filteredItems.size > 7) {
276+
filteredItems.subList(0, 7)
277+
} else {
278+
filteredItems
279+
}
253280
} else {
254-
filteredItems
281+
listOf()
255282
}
256-
} else {
257-
listOf()
258-
}
259283
}
260284
}
261285
}

app/src/main/java/dev/bluehouse/enablevolte/components/LoadingDialog.kt

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ fun InfiniteLoadingDialog() {
3232
properties = DialogProperties(),
3333
) {
3434
Box(
35-
modifier = Modifier
36-
.fillMaxSize()
37-
.padding(20.dp),
35+
modifier =
36+
Modifier
37+
.fillMaxSize()
38+
.padding(20.dp),
3839
contentAlignment = Alignment.Center,
3940
) {
4041
Card(
41-
colors = CardDefaults.cardColors(
42-
containerColor = AlertDialogDefaults.containerColor,
43-
contentColor = AlertDialogDefaults.textContentColor,
44-
),
42+
colors =
43+
CardDefaults.cardColors(
44+
containerColor = AlertDialogDefaults.containerColor,
45+
contentColor = AlertDialogDefaults.textContentColor,
46+
),
4547
modifier = Modifier.fillMaxWidth(),
4648
) {
4749
Row(
@@ -57,32 +59,38 @@ fun InfiniteLoadingDialog() {
5759
}
5860

5961
@Composable
60-
fun FiniteLoadingDialog(current: Int, total: Int) {
62+
fun FiniteLoadingDialog(
63+
current: Int,
64+
total: Int,
65+
) {
6166
Dialog(
6267
onDismissRequest = { },
6368
properties = DialogProperties(),
6469
) {
6570
Box(
66-
modifier = Modifier
67-
.fillMaxSize()
68-
.padding(20.dp),
71+
modifier =
72+
Modifier
73+
.fillMaxSize()
74+
.padding(20.dp),
6975
contentAlignment = Alignment.Center,
7076
) {
7177
Card(
72-
colors = CardDefaults.cardColors(
73-
containerColor = AlertDialogDefaults.containerColor,
74-
contentColor = AlertDialogDefaults.textContentColor,
75-
),
78+
colors =
79+
CardDefaults.cardColors(
80+
containerColor = AlertDialogDefaults.containerColor,
81+
contentColor = AlertDialogDefaults.textContentColor,
82+
),
7683
modifier = Modifier.fillMaxWidth(),
7784
) {
7885
Box(modifier = Modifier.padding(16.dp)) {
7986
Column {
8087
Text(stringResource(R.string.loading), fontWeight = FontWeight.Bold, fontSize = 24.sp)
8188
LinearProgressIndicator(
82-
modifier = Modifier
83-
.semantics(mergeDescendants = true) {}
84-
.padding(top = 24.dp, bottom = 4.dp)
85-
.fillMaxWidth(),
89+
modifier =
90+
Modifier
91+
.semantics(mergeDescendants = true) {}
92+
.padding(top = 24.dp, bottom = 4.dp)
93+
.fillMaxWidth(),
8694
progress = current.toFloat() / total,
8795
)
8896
Text(stringResource(R.string.loaded, current, total))

app/src/main/java/dev/bluehouse/enablevolte/components/RadioSelectPropertyView.kt

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,19 @@ fun RadioSelectPropertyUpdateDialog(
4242
var newIndex by remember { mutableIntStateOf(selectedIndex ?: 0) }
4343
BasicAlertDialog(onDismissRequest = onClose) {
4444
Surface(
45-
modifier = Modifier
46-
.wrapContentWidth()
47-
.wrapContentHeight(),
45+
modifier =
46+
Modifier
47+
.wrapContentWidth()
48+
.wrapContentHeight(),
4849
shape = RoundedCornerShape(10),
4950
color = MaterialTheme.colorScheme.surface,
5051
) {
5152
Column(modifier = Modifier.padding(all = 16.dp).fillMaxWidth()) {
52-
Text(text = stringResource(R.string.update_value), style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(bottom = 24.dp))
53+
Text(
54+
text = stringResource(R.string.update_value),
55+
style = MaterialTheme.typography.titleMedium,
56+
modifier = Modifier.padding(bottom = 24.dp),
57+
)
5358
values.forEachIndexed { index, s ->
5459
Row(verticalAlignment = Alignment.CenterVertically) {
5560
RadioButton(selected = newIndex == index, onClick = { newIndex = index })
@@ -68,9 +73,10 @@ fun RadioSelectPropertyUpdateDialog(
6873
TextButton(
6974
border = BorderStroke(0.5.dp, MaterialTheme.colorScheme.primary),
7075
shape = ButtonDefaults.outlinedShape,
71-
colors = ButtonDefaults.filledTonalButtonColors(
72-
containerColor = MaterialTheme.colorScheme.primary,
73-
),
76+
colors =
77+
ButtonDefaults.filledTonalButtonColors(
78+
containerColor = MaterialTheme.colorScheme.primary,
79+
),
7480
onClick = {
7581
onUpdate(newIndex)
7682
onClose()
@@ -85,7 +91,12 @@ fun RadioSelectPropertyUpdateDialog(
8591
}
8692

8793
@Composable
88-
fun RadioSelectPropertyView(label: String, values: Array<String>, selectedIndex: Int?, onUpdate: ((Int) -> Unit)? = null) {
94+
fun RadioSelectPropertyView(
95+
label: String,
96+
values: Array<String>,
97+
selectedIndex: Int?,
98+
onUpdate: ((Int) -> Unit)? = null,
99+
) {
89100
var openDialog by rememberSaveable { mutableStateOf(false) }
90101

91102
if (onUpdate != null) {
@@ -104,17 +115,18 @@ fun RadioSelectPropertyView(label: String, values: Array<String>, selectedIndex:
104115
}
105116
}
106117

107-
val values = arrayOf(
108-
"Phasellus sit amet urna ut.",
109-
"Nullam sit amet diam sagittis, fermentum purus sed, blandit felis.",
110-
"Nulla sed velit ac nibh fermentum efficitur.",
111-
"Sed pharetra nibh at nisi lacinia imperdiet.",
112-
"Nullam sollicitudin elit et hendrerit malesuada.",
113-
"Cras in nulla sed nulla accumsan vehicula eget id augue.",
114-
"Duis in urna quis massa bibendum sollicitudin.",
115-
"Maecenas vel elit at libero sagittis tristique.",
116-
"Vestibulum tempor felis a ex cursus, ut molestie lectus porttitor.",
117-
)
118+
val values =
119+
arrayOf(
120+
"Phasellus sit amet urna ut.",
121+
"Nullam sit amet diam sagittis, fermentum purus sed, blandit felis.",
122+
"Nulla sed velit ac nibh fermentum efficitur.",
123+
"Sed pharetra nibh at nisi lacinia imperdiet.",
124+
"Nullam sollicitudin elit et hendrerit malesuada.",
125+
"Cras in nulla sed nulla accumsan vehicula eget id augue.",
126+
"Duis in urna quis massa bibendum sollicitudin.",
127+
"Maecenas vel elit at libero sagittis tristique.",
128+
"Vestibulum tempor felis a ex cursus, ut molestie lectus porttitor.",
129+
)
118130

119131
@Preview
120132
@Composable

0 commit comments

Comments
 (0)