ADD: Open Context Menu to allow importing new notes and creating to collections

This commit is contained in:
sebastian 2025-05-10 09:32:35 +02:00
parent 41ab187f04
commit 4a44f99b86

View File

@ -1,24 +1,96 @@
package come.stormborntales.notevault.ui.screens
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Divider
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.FabPosition
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Switch
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.boundsInWindow
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInWindow
import androidx.compose.ui.text.input.KeyboardType.Companion.Text
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Popup
@Composable
fun NotesScreen() {
var expanded by remember { mutableStateOf(false) }
}
// Anchor reference
Box(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
contentAlignment = Alignment.BottomEnd
) {
// This Box will be the anchor for the menu
Box {
var anchor by remember { mutableStateOf<androidx.compose.ui.geometry.Rect?>(null) }
FloatingActionButton(
onClick = { expanded = true },
modifier = Modifier
.onGloballyPositioned { coordinates ->
anchor = coordinates.boundsInWindow()
}
) {
Icon(Icons.Default.MoreVert, contentDescription = "Open menu")
}
anchor?.let {
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
// This attaches the dropdown directly to the FAB
offset = DpOffset(0.dp, 0.dp),
modifier = Modifier
.align(Alignment.TopEnd)
) {
DropdownMenuItem(
text = { Text("Option 1") },
onClick = {
expanded = false
// Handle Option 1
}
)
DropdownMenuItem(
text = { Text("Option 2") },
onClick = {
expanded = false
// Handle Option 2
}
)
}
}
}
}
}