view GeoQuiz/Models/UserDataModel.swift @ 27:3f4b366d476d

add flag layout settings
author Dennis C. M. <dennis@denniscm.com>
date Thu, 10 Nov 2022 09:26:48 +0100
parents 425078c01194
children 9d6dd0e59c22
line wrap: on
line source

//
//  UserDataModel.swift
//  GeoQuiz
//
//  Created by Dennis Concepción Martín on 18/10/22.
//

import Foundation
import SwiftUI

struct UserDataModel: Codable {
    
    // Settings
    var haptics: Bool = true
    var sound: Bool = true
    var numberOfLives: Int = 25
    var guessTheFlagShape: GuessTheFlagShape = .respectAspectRatio
    
    // Profile
    var username: String = "Unnamed"
    var imageData: Data?
    
    var uiImage: UIImage? {
        guard let imageData = imageData else { return nil }
        return UIImage(data: imageData)
    }
}

enum GuessTheFlagShape: String, Codable, CaseIterable {
    case respectAspectRatio = "Original"
    case circular = "Circular"
    case rectangular = "Rectangular"
    
    var localizedName: LocalizedStringKey { LocalizedStringKey(rawValue) }
}