package com.aegir.demo.ui

import android.content.Context
import android.content.SharedPreferences

/**
 * Lightweight SharedPreferences wrapper mirroring iOS UserDefaults keys.
 */
class AppPrefs(context: Context) {

    private val prefs: SharedPreferences =
        context.applicationContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)

    var lastBaseURL: String?
        get() = prefs.getString(KEY_LAST_BASE_URL, null)
        set(value) {
            prefs.edit().putString(KEY_LAST_BASE_URL, value).apply()
        }

    var lastVenueID: String?
        get() = prefs.getString(KEY_LAST_VENUE_ID, null)
        set(value) {
            prefs.edit().putString(KEY_LAST_VENUE_ID, value).apply()
        }

    companion object {
        private const val PREFS_NAME = "VenueList"
        private const val KEY_LAST_BASE_URL = "VenueList.lastBaseURL"
        private const val KEY_LAST_VENUE_ID = "VenueList.lastVenueID"
    }
}
