import Foundation

final class LocalizedPageSettings: ObservableObject {

    /// The title to show for the box on an empty page
    @Published
    var emptyPageTitle: String

    /// The text to show in the box on an empty page
    @Published
    var emptyPageText: String

    init(emptyPageTitle: String, emptyPageText: String) {
        self.emptyPageTitle = emptyPageTitle
        self.emptyPageText = emptyPageText
    }
}

// MARK: Storage

extension LocalizedPageSettings {

    convenience init(data: Data) {
        self.init(
            emptyPageTitle: data.emptyPageTitle,
            emptyPageText: data.emptyPageText)
    }

    var data: Data {
        .init(emptyPageTitle: emptyPageTitle,
              emptyPageText: emptyPageText)
    }

    struct Data: Codable, Equatable {
        let emptyPageTitle: String
        let emptyPageText: String
    }
}
