diff --git a/app/src/main/java/app/suhasdissa/mellowmusic/ui/components/ListSelectDialog.kt b/app/src/main/java/app/suhasdissa/mellowmusic/ui/components/ListSelectDialog.kt index 02519146..0e2ced6f 100644 --- a/app/src/main/java/app/suhasdissa/mellowmusic/ui/components/ListSelectDialog.kt +++ b/app/src/main/java/app/suhasdissa/mellowmusic/ui/components/ListSelectDialog.kt @@ -2,9 +2,7 @@ package app.suhasdissa.mellowmusic.ui.components import android.view.SoundEffectConstants import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -12,18 +10,20 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.AlertDialog import androidx.compose.material3.RadioButton import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalView import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Dialog import app.suhasdissa.mellowmusic.R import app.suhasdissa.mellowmusic.utils.Pref import app.suhasdissa.mellowmusic.utils.rememberPreference @@ -37,14 +37,21 @@ fun InstanceSelectDialog( val optionsList = Pref.pipedInstances val view = LocalView.current - Dialog(onDismissRequest = { onDismissRequest.invoke() }) { - Surface( - modifier = Modifier.width(300.dp), - shape = RoundedCornerShape(10.dp) - ) { - Column(modifier = Modifier.padding(10.dp)) { - Text(stringResource(R.string.select_server)) - Spacer(modifier = Modifier.height(10.dp)) + AlertDialog( + onDismissRequest = { onDismissRequest.invoke() }, + confirmButton = { + TextButton(onClick = { onDismissRequest.invoke() }) { + Text(text = stringResource(android.R.string.cancel)) + } + }, + title = { + Text(stringResource(R.string.select_server)) + }, + text = { + Surface( + modifier = Modifier.width(300.dp), + shape = RoundedCornerShape(10.dp) + ) { LazyColumn(modifier = Modifier.height(500.dp)) { itemsIndexed(items = optionsList) { index, item -> Row( @@ -55,15 +62,18 @@ fun InstanceSelectDialog( selectedOption = index onSelectionChange(item.name) }) - .padding(horizontal = 16.dp), + .clip(RoundedCornerShape(20.dp)) + .clickable { + selectedOption = index + onSelectionChange(item.name) + onDismissRequest.invoke() + } + .padding(horizontal = 6.dp, vertical = 12.dp), verticalAlignment = Alignment.CenterVertically ) { RadioButton( selected = (index == selectedOption), - onClick = { - selectedOption = index - onSelectionChange(item.name) - } + onClick = null ) Text( text = item.name, @@ -74,5 +84,5 @@ fun InstanceSelectDialog( } } } - } + ) }