@@ -93,12 +93,15 @@ fun EditDeviceScreen(
9393 verticalArrangement = Arrangement .spacedBy(16 .dp)
9494 ) {
9595 item { DeviceHeader (device = device) }
96- item { IpAddressSection (
97- device = device,
98- selectedIp = device?.prefAddress,
99- onIpSelected = viewModel::setPreferredIp,
100- onAddCustomIpClick = { showCustomIpDialog = true }
101- ) }
96+ item {
97+ IpAddressSection (
98+ device = device,
99+ selectedIp = device?.prefAddress,
100+ onIpSelected = viewModel::setPreferredIp,
101+ onAddCustomIpClick = { showCustomIpDialog = true },
102+ onRemoveIp = viewModel::removeIp
103+ )
104+ }
102105 item { NetworksSection (viewModel = viewModel) }
103106 }
104107 }
@@ -230,7 +233,8 @@ private fun IpAddressSection(
230233 device : RemoteDeviceEntity ? ,
231234 selectedIp : String? ,
232235 onIpSelected : (String ) -> Unit ,
233- onAddCustomIpClick : () -> Unit
236+ onAddCustomIpClick : () -> Unit ,
237+ onRemoveIp : (String ) -> Unit
234238) {
235239 Text (
236240 " IP Addresses" ,
@@ -252,7 +256,8 @@ private fun IpAddressSection(
252256 IpAddressItem (
253257 ip = ip,
254258 isSelected = isSelected,
255- onSelect = { onIpSelected(ip) }
259+ onSelect = { onIpSelected(ip) },
260+ onRemove = { onRemoveIp(ip) }
256261 )
257262 }
258263
@@ -281,7 +286,8 @@ private fun IpAddressSection(
281286private fun IpAddressItem (
282287 ip : String ,
283288 isSelected : Boolean ,
284- onSelect : () -> Unit
289+ onSelect : () -> Unit ,
290+ onRemove : () -> Unit
285291) {
286292 Surface (
287293 modifier = Modifier
@@ -308,13 +314,12 @@ private fun IpAddressItem(
308314 verticalAlignment = Alignment .CenterVertically ,
309315 modifier = Modifier .weight(1f )
310316 ) {
311- Icon (
312- imageVector = Icons .Default .Lan ,
313- contentDescription = null ,
314- tint = if (isSelected)
315- MaterialTheme .colorScheme.primary
316- else MaterialTheme .colorScheme.onSurfaceVariant,
317- modifier = Modifier .size(20 .dp)
317+ RadioButton (
318+ selected = isSelected,
319+ onClick = onSelect,
320+ colors = RadioButtonDefaults .colors(
321+ selectedColor = MaterialTheme .colorScheme.primary
322+ )
318323 )
319324 Spacer (Modifier .width(12 .dp))
320325 Text (
@@ -328,13 +333,17 @@ private fun IpAddressItem(
328333 modifier = Modifier .weight(1f ).animateContentSize()
329334 )
330335 }
331- RadioButton (
332- selected = isSelected,
333- onClick = onSelect,
334- colors = RadioButtonDefaults .colors(
335- selectedColor = MaterialTheme .colorScheme.primary
336+ IconButton (
337+ onClick = onRemove,
338+ modifier = Modifier .size(24 .dp)
339+ ) {
340+ Icon (
341+ Icons .Default .Delete ,
342+ contentDescription = " Remove IP" ,
343+ tint = MaterialTheme .colorScheme.error,
344+ modifier = Modifier .size(20 .dp)
336345 )
337- )
346+ }
338347 }
339348 }
340349}
0 commit comments