Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from you-apps/instance-selection
Browse files Browse the repository at this point in the history
feat: improve instance selection user experience
  • Loading branch information
Bnyro authored Sep 28, 2023
2 parents e5effaa + 87c8ec6 commit 207aa79
Showing 1 changed file with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ 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
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
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -74,5 +84,5 @@ fun InstanceSelectDialog(
}
}
}
}
)
}

0 comments on commit 207aa79

Please sign in to comment.