//
// Created by Matt Baer on 7/29/17.
// Copyright (c) 2017 A Bunch Tell. All rights reserved.
//

import Foundation

class Preferences {
    enum PostFont: String {
        case serif = "norm"
        case sans = "sans"
        case mono = "wrap"

        var typeface: String {
            switch self {
            case .serif:
                return "Lora"
            case .sans:
                return "Open Sans"
            case .mono:
                return "Hack"
            }
        }
    }

    class func getFontSize() -> CGFloat {
        let size = Int(UserDefaults.standard.string(forKey: "editor_text_size") ?? "16") ?? 16

        return CGFloat(size)
    }

    class func getFont() -> PostFont {
        return PostFont(rawValue: UserDefaults.standard.string(forKey: "editor_font") ?? PostFont.serif.rawValue) ?? PostFont.serif
    }

    class func setFont(_ font: PostFont) {
        UserDefaults.standard.set(font.rawValue, forKey: "editor_font")
    }
}
