nextNoteVault #23

Merged
sebastian merged 57 commits from nextNoteVault into master 2025-05-10 06:23:23 +00:00
2 changed files with 166 additions and 74 deletions
Showing only changes of commit 5be8a19321 - Show all commits

View File

@ -4,10 +4,10 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-04-29T17:33:41.575251940Z"> <DropdownSelection timestamp="2025-05-03T07:36:08.121278195Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=R52N50NLGRT" /> <DeviceId pluginId="LocalEmulator" identifier="path=/home/sebastian/.android/avd/Small_Phone_API_36.avd" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>

View File

@ -8,9 +8,11 @@ import android.media.Image
import android.net.Uri import android.net.Uri
import android.util.Log import android.util.Log
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
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.filled.Add import androidx.compose.material.icons.filled.Add
@ -22,6 +24,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import come.stormborntales.notevault.FullscreenImageViewerActivity import come.stormborntales.notevault.FullscreenImageViewerActivity
@ -43,12 +46,14 @@ fun loadImageBitmap(context: Context, uriString: String): ImageBitmap? {
e.printStackTrace() e.printStackTrace()
null null
} }
} }@Composable
@Composable
fun NoteCard(note: NoteEntity, onDeleteNote: (NoteEntity) -> Unit, onEditNote: (NoteEntity) -> Unit) { fun NoteCard(note: NoteEntity, onDeleteNote: (NoteEntity) -> Unit, onEditNote: (NoteEntity) -> Unit) {
val context = LocalContext.current val context = LocalContext.current
val screenWidth = LocalConfiguration.current.screenWidthDp // Bildschirmbreite in dp
// Dynamische Bildgröße basierend auf der Bildschirmbreite
val imageSize = if (screenWidth < 400) 80.dp else 120.dp
Card( Card(
modifier = Modifier modifier = Modifier
@ -57,84 +62,171 @@ fun NoteCard(note: NoteEntity, onDeleteNote: (NoteEntity) -> Unit, onEditNote: (
shape = RoundedCornerShape(16.dp), shape = RoundedCornerShape(16.dp),
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp), elevation = CardDefaults.cardElevation(defaultElevation = 4.dp),
) { ) {
Row(modifier = Modifier.padding(16.dp)) { // Responsive Layout: Überprüfen, ob der Bildschirm schmaler als 360 dp ist
// Linkes Vorschaubild if (screenWidth < 400) {
AsyncImage( // Wenn der Bildschirm schmal ist, arrangiere die Elemente vertikal
model = note.imagePreview, Row(modifier = Modifier.padding(16.dp)) {
contentDescription = "Vorschaubild", AsyncImage(
modifier = Modifier model = note.imagePreview,
.size(120.dp) contentDescription = "Vorschaubild",
.clip(RoundedCornerShape(12.dp)) modifier = Modifier
) .size(imageSize)
.clip(RoundedCornerShape(12.dp))
// Rechte Info-Spalte
Column(
modifier = Modifier
.weight(1f)
.align(Alignment.CenterVertically)
.padding(start = 16.dp)
) {
Text(
text = note.title,
style = MaterialTheme.typography.titleMedium
) )
note.composer?.let {
Text("von $it", style = MaterialTheme.typography.labelMedium) Column(modifier = Modifier.padding(16.dp)) {
Text(
text = note.title,
style = MaterialTheme.typography.titleMedium
)
note.composer?.let {
Text("von $it", style = MaterialTheme.typography.labelMedium)
}
Spacer(modifier = Modifier.height(4.dp))
note.year?.let {
Text("Jahr: $it", style = MaterialTheme.typography.bodySmall)
}
note.genre?.let {
Text("Genre: $it", style = MaterialTheme.typography.bodySmall)
}
note.description?.let {
Text("Beschreibung: $it", style = MaterialTheme.typography.bodySmall, maxLines = 2)
}
Spacer(modifier = Modifier.height(16.dp)) // Abstand zwischen Text und Buttons
} }
}
// Buttons unter dem Text
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth().padding(16.dp),
) {
OutlinedButton(
onClick = {
val uris = ArrayList<Uri>()
note.images.forEach { uris.add(it.toUri()) }
Spacer(modifier = Modifier.height(4.dp)) val intent = Intent(context, FullscreenImageViewerActivity::class.java).apply {
putParcelableArrayListExtra("imageUris", ArrayList(uris))
note.year?.let { }
Text("Jahr: $it", style = MaterialTheme.typography.bodySmall) context.startActivity(intent)
} },
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp)
note.genre?.let {
Text("Genre: $it", style = MaterialTheme.typography.bodySmall)
}
note.description?.let {
Text("Beschreibung: $it", style = MaterialTheme.typography.bodySmall, maxLines = 2)
}
Spacer(modifier = Modifier.height(8.dp))
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) { ) {
OutlinedButton( Text("Anzeigen", style = MaterialTheme.typography.labelLarge)
onClick = { }
val uris = ArrayList<Uri>();
note.images.forEach { uris.add(it.toUri()) }
val intent = Intent(context, FullscreenImageViewerActivity::class.java).apply { OutlinedButton(
putParcelableArrayListExtra("imageUris", ArrayList(uris)) onClick = {
} onEditNote(note)
context.startActivity(intent) },
}, contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp)
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp) ) {
) { Text("Bearbeiten", style = MaterialTheme.typography.labelLarge)
Text("Anzeigen", style = MaterialTheme.typography.labelLarge) }
OutlinedButton(
onClick = {
onDeleteNote(note)
},
colors = ButtonDefaults.outlinedButtonColors(
contentColor = MaterialTheme.colorScheme.error
),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp)
) {
Text("Löschen", style = MaterialTheme.typography.labelLarge)
}
}
} else {
// Wenn der Bildschirm breiter als 360 dp ist, arrangiere die Elemente nebeneinander
Row(modifier = Modifier.padding(16.dp)) {
// Linkes Vorschaubild
AsyncImage(
model = note.imagePreview,
contentDescription = "Vorschaubild",
modifier = Modifier
.size(imageSize)
.clip(RoundedCornerShape(12.dp))
)
// Rechte Info-Spalte
Column(
modifier = Modifier
.weight(1f) // Damit die Spalte den verfügbaren Platz nutzt
.align(Alignment.CenterVertically)
.padding(start = 16.dp)
) {
Text(
text = note.title,
style = MaterialTheme.typography.titleMedium
)
note.composer?.let {
Text("von $it", style = MaterialTheme.typography.labelMedium)
} }
OutlinedButton(
onClick = { Spacer(modifier = Modifier.height(4.dp))
onEditNote(note)
Log.d("EditNote", "on Edit Note!") note.year?.let {
}, Text("Jahr: $it", style = MaterialTheme.typography.bodySmall)
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp)
) {
Text("Bearbeiten", style = MaterialTheme.typography.labelLarge)
} }
OutlinedButton(
onClick = { note.genre?.let {
onDeleteNote(note) Text("Genre: $it", style = MaterialTheme.typography.bodySmall)
}, }
colors = ButtonDefaults.outlinedButtonColors(
contentColor = MaterialTheme.colorScheme.error note.description?.let {
), Text("Beschreibung: $it", style = MaterialTheme.typography.bodySmall, maxLines = 2)
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp) }
Spacer(modifier = Modifier.height(8.dp))
// Buttons in einer Row anordnen
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth() // Stellt sicher, dass die Row den gesamten verfügbaren Platz einnimmt
) { ) {
Text("Löschen", style = MaterialTheme.typography.labelLarge) OutlinedButton(
onClick = {
val uris = ArrayList<Uri>()
note.images.forEach { uris.add(it.toUri()) }
val intent = Intent(context, FullscreenImageViewerActivity::class.java).apply {
putParcelableArrayListExtra("imageUris", ArrayList(uris))
}
context.startActivity(intent)
},
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp)
) {
Text("Anzeigen", style = MaterialTheme.typography.labelLarge)
}
OutlinedButton(
onClick = {
onEditNote(note)
},
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp)
) {
Text("Bearbeiten", style = MaterialTheme.typography.labelLarge)
}
OutlinedButton(
onClick = {
onDeleteNote(note)
},
colors = ButtonDefaults.outlinedButtonColors(
contentColor = MaterialTheme.colorScheme.error
),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 4.dp)
) {
Text("Löschen", style = MaterialTheme.typography.labelLarge)
}
} }
} }
} }