Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d61ec9e1f2
4 changed files with 29 additions and 8 deletions
|
|
@ -1184,8 +1184,8 @@ fun EditSourceCompose(
|
||||||
onSave = {
|
onSave = {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
try {
|
try {
|
||||||
saveLauncher.launch(fileName)
|
val initialDir = solfaScreenModel.fileRepository.getAppPublicFolder().absolutePath
|
||||||
|
saveLauncher.launch(fileName, initialDir)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.InsertDriveFile
|
||||||
import androidx.compose.material.icons.automirrored.filled.Undo
|
import androidx.compose.material.icons.automirrored.filled.Undo
|
||||||
import androidx.compose.material.icons.filled.*
|
import androidx.compose.material.icons.filled.*
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
|
|
@ -284,7 +285,14 @@ fun MainScreenWithDrawer(
|
||||||
) {
|
) {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
saveLauncher.launch(fileName)
|
scope.launch {
|
||||||
|
try {
|
||||||
|
val initialDir = solfaScreenModel.fileRepository.getAppPublicFolder().absolutePath
|
||||||
|
saveLauncher.launch(fileName, initialDir)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
}, modifier = Modifier.alpha(0.45f)
|
}, modifier = Modifier.alpha(0.45f)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|
@ -483,16 +491,28 @@ fun MainScreenWithDrawer(
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (filteredSongs.isNotEmpty()) {
|
if (filteredSongs.isNotEmpty()) {
|
||||||
|
val sortedSongs = remember(filteredSongs) {
|
||||||
|
filteredSongs.sortedBy { item ->
|
||||||
|
item.path.startsWith("assets://")
|
||||||
|
}
|
||||||
|
}
|
||||||
LazyColumn(Modifier.fillMaxSize()) {
|
LazyColumn(Modifier.fillMaxSize()) {
|
||||||
itemsIndexed(filteredSongs, key = {_, item -> item.path}) { index, item ->
|
itemsIndexed(sortedSongs, key = {_, item -> item.path}) { index, item ->
|
||||||
val isFavorite = favoritePaths.contains(item)
|
val isFavorite = favoritePaths.contains(item)
|
||||||
ListItem(
|
ListItem(
|
||||||
|
leadingContent = {
|
||||||
|
Icon(
|
||||||
|
imageVector = if(item.path.startsWith("assets://")) Icons.Default.ArrowDropDownCircle else Icons.Default.Folder,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(30.dp)
|
||||||
|
)
|
||||||
|
},
|
||||||
headlineContent = { Text(item.title) },
|
headlineContent = { Text(item.title) },
|
||||||
supportingContent = { Text(item.contentTitle, maxLines = 1) },
|
supportingContent = { Text(item.contentTitle, maxLines = 1) },
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = { sharedScreenModel.toggleFavorite(item.path) },
|
onClick = { sharedScreenModel.toggleFavorite(item.path) },
|
||||||
modifier = Modifier.size(30.dp)
|
modifier = Modifier.size(25.dp)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Star,
|
imageVector = Icons.Default.Star,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package mg.dot.feufaro.ui
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
interface FileSaveLauncher {
|
interface FileSaveLauncher {
|
||||||
fun launch(defaultName: String)
|
fun launch(defaultName: String, initialDir: String?)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package mg.dot.feufaro.ui
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
@ -16,10 +17,10 @@ actual fun rememberFileSaveLauncher(
|
||||||
): FileSaveLauncher {
|
): FileSaveLauncher {
|
||||||
return remember {
|
return remember {
|
||||||
object : FileSaveLauncher {
|
object : FileSaveLauncher {
|
||||||
override fun launch(defaultName: String) {
|
override fun launch(defaultName: String, initialDir: String?) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val dialog = FileDialog(null as Frame?, "Sauvegarder la source", FileDialog.SAVE)
|
val dialog = FileDialog(null as Frame?, "Sauvegarder la source", FileDialog.SAVE)
|
||||||
dialog.directory = System.getProperty("user.home")
|
dialog.directory = initialDir
|
||||||
dialog.file = defaultName
|
dialog.file = defaultName
|
||||||
dialog.isVisible = true
|
dialog.isVisible = true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue