package com.tt.honeyDue.storage

import platform.Foundation.NSUserDefaults

/**
 * iOS implementation of theme storage using NSUserDefaults.
 */
actual class ThemeStorageManager {
    private val defaults = NSUserDefaults.standardUserDefaults

    actual fun saveThemeId(themeId: String) {
        defaults.setObject(themeId, forKey = KEY_THEME_ID)
        defaults.synchronize()
    }

    actual fun getThemeId(): String? {
        return defaults.stringForKey(KEY_THEME_ID)
    }

    actual fun clearThemeId() {
        defaults.removeObjectForKey(KEY_THEME_ID)
        defaults.synchronize()
    }

    companion object {
        private const val KEY_THEME_ID = "theme_id"

        private val instance by lazy { ThemeStorageManager() }

        fun getInstance(): ThemeStorageManager = instance
    }
}
