Complete rename across all bundle IDs, App Groups, CloudKit containers, StoreKit product IDs, data store filenames, URL schemes, logger subsystems, Swift identifiers, user-facing strings (7 languages), file names, directory names, Xcode project, schemes, assets, and documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
60 lines
1.5 KiB
Swift
60 lines
1.5 KiB
Swift
//
|
|
// OnboardingData.swift
|
|
// Reflect (iOS)
|
|
//
|
|
// Created by Trey Tartt on 1/22/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UserNotifications
|
|
|
|
// this is getting passed around and filled out
|
|
// class and vars
|
|
final class OnboardingData: NSObject, ObservableObject, Codable {
|
|
@Published var date: Date = Date()
|
|
@Published var inputDay: DayOptions = .Today
|
|
|
|
enum CodingKeys: CodingKey {
|
|
case date, inputDay
|
|
}
|
|
|
|
func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
|
|
try container.encode(date, forKey: .date)
|
|
try container.encode(inputDay, forKey: .inputDay)
|
|
}
|
|
|
|
required init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
date = try container.decode(Date.self, forKey: .date)
|
|
inputDay = try container.decode(DayOptions.self, forKey: .inputDay)
|
|
}
|
|
|
|
override init() { }
|
|
}
|
|
|
|
extension OnboardingData: RawRepresentable {
|
|
convenience init?(rawValue: String) {
|
|
guard let data = rawValue.data(using: .utf8),
|
|
let result = try? JSONDecoder().decode(OnboardingData.self, from: data)
|
|
else {
|
|
return nil
|
|
}
|
|
self.init()
|
|
|
|
self.date = result.date
|
|
self.inputDay = result.inputDay
|
|
}
|
|
|
|
public var rawValue: String {
|
|
guard let data = try? JSONEncoder().encode(self),
|
|
let result = String(data: data, encoding: .utf8)
|
|
else {
|
|
return "[]"
|
|
}
|
|
return result
|
|
}
|
|
}
|