ADD: Datastructure for Note Collections
This commit is contained in:
parent
ad8e180134
commit
41ab187f04
1
.idea/.gitignore
vendored
1
.idea/.gitignore
vendored
@ -6,3 +6,4 @@
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
/AndroidProjectSystem.xml
|
||||
|
@ -45,6 +45,7 @@ import come.stormborntales.notevault.data.local.entity.NoteEntity
|
||||
import come.stormborntales.notevault.data.repository.NoteRepository
|
||||
import come.stormborntales.notevault.ui.screens.AddNoteDialog
|
||||
import come.stormborntales.notevault.ui.screens.MainScreen
|
||||
import come.stormborntales.notevault.ui.screens.NotesScreen
|
||||
import come.stormborntales.notevault.ui.screens.SettingsScreen
|
||||
import come.stormborntales.notevault.ui.theme.NoteVaultTheme
|
||||
import come.stormborntales.notevault.ui.viewmodel.NoteViewModel
|
||||
@ -90,6 +91,7 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
val navItems = listOf(
|
||||
"Home" to "main",
|
||||
"Notes" to "notes",
|
||||
"Einstellungen" to "settings"
|
||||
)
|
||||
|
||||
@ -203,6 +205,9 @@ class MainActivity : ComponentActivity() {
|
||||
composable("settings") {
|
||||
SettingsScreen()
|
||||
}
|
||||
composable("notes") {
|
||||
NotesScreen()
|
||||
}
|
||||
}
|
||||
|
||||
if (showDialog) {
|
||||
|
@ -7,9 +7,10 @@ import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import come.stormborntales.notevault.data.local.dao.NoteDao
|
||||
import come.stormborntales.notevault.data.local.entity.NoteCollection
|
||||
import come.stormborntales.notevault.data.local.entity.NoteEntity
|
||||
|
||||
@Database(entities = [NoteEntity::class], version = 1)
|
||||
@Database(entities = [NoteEntity::class, NoteCollection::class], version = 1)
|
||||
@TypeConverters(UriListConverter::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun noteDao(): NoteDao
|
||||
|
@ -0,0 +1,11 @@
|
||||
package come.stormborntales.notevault.data.local.entity
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity("note_collections")
|
||||
data class NoteCollection(
|
||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
||||
var name: String,
|
||||
var parentId: Int? = null
|
||||
)
|
@ -1,9 +1,16 @@
|
||||
package come.stormborntales.notevault.data.local.entity
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "notes")
|
||||
@Entity(tableName = "notes",
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = NoteCollection::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["collectionId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)])
|
||||
data class NoteEntity(
|
||||
@PrimaryKey(autoGenerate = true) val id: Int = 0,
|
||||
var title: String,
|
||||
@ -12,5 +19,6 @@ data class NoteEntity(
|
||||
var year: Int?,
|
||||
var genre: String?,
|
||||
var description: String?,
|
||||
val imagePreview: String
|
||||
)
|
||||
val imagePreview: String,
|
||||
val collectionId: Int?
|
||||
)
|
@ -0,0 +1,24 @@
|
||||
package come.stormborntales.notevault.ui.screens
|
||||
|
||||
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.padding
|
||||
import androidx.compose.material3.Divider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
|
||||
@Composable
|
||||
fun NotesScreen() {
|
||||
|
||||
}
|
@ -93,7 +93,8 @@ class NoteViewModel(
|
||||
year = year,
|
||||
genre = genre,
|
||||
description = description,
|
||||
imagePreview = preview_image_path.toString()
|
||||
imagePreview = preview_image_path.toString(),
|
||||
collectionId = null
|
||||
)
|
||||
|
||||
repository.insert(note)
|
||||
|
Loading…
Reference in New Issue
Block a user