package com.example.pencilmuse.models

import android.content.Context

class NotesManager(context: Context) {
    private val prefs = context.getSharedPreferences("NOTES_PREFS", Context.MODE_PRIVATE)

    fun saveNote(note: String) {
        val editor = prefs.edit()
        val currentNotes = loadNotes()
        val updatedNotes = currentNotes.toMutableList().apply { add(note) }
        editor.putStringSet("NOTES", updatedNotes.toSet())
        editor.apply()
    }

    fun loadNotes(): List<String> {
        return prefs.getStringSet("NOTES", emptySet())?.toList() ?: emptyList()
    }

    fun removeNote(note: String) {
        val currentNotes = loadNotes()
        val updatedNotes = currentNotes.filter { it != note }.toSet()
        val editor = prefs.edit()
        editor.putStringSet("NOTES", updatedNotes)
        editor.apply()
    }

}