Path: blob/a-new-beginning/Folium-iOS/Actors/WhatsNew/WhatsNewModel.swift
2 views
//
// LatestWhatsNewModel.swift
// Folium-iOS
//
// Created by Jarrod Norwell on 8/10/2025.
//
/*
MARK: 29/11/2025
- Cleaned up WhatsNewModel actor
- Changed strings to be clearer
*/
import OnboardingKit
import SwiftUI
import UIKit
fileprivate typealias OnboardingButtonConfiguration = OnboardingController.Onboarding.Button.Configuration
actor WhatsNewModel {
var applicationModel: ApplicationModel
init(applicationModel: ApplicationModel) {
self.applicationModel = applicationModel
}
@MainActor func whatsNew(controller: UIViewController) async {
let buttons: [OnboardingButtonConfiguration] = [
OnboardingButtonConfiguration(text: LocalisedCommon.continue) { button, controller in
await self.audio(controller: controller)
}
]
let viewController: OnboardingController = .init(configuration: .init(buttons: buttons,
colours: Color.vibrantRainbow,
image: UIImage(systemName: "sparkle"),
text: LocalisedWhatsNew.whatsNew,
secondaryText: LocalisedWhatsNew.whatsNewSecondaryText))
viewController.modalPresentationStyle = .fullScreen
controller.present(viewController, animated: true)
}
@MainActor func audio(controller: UIViewController) async {
let buttons: [OnboardingButtonConfiguration] = [
OnboardingButtonConfiguration(text: LocalisedCommon.continue) { button, controller in
await self.abxy(controller: controller)
}
]
let viewController: AudioController = AudioController(configuration: .init(buttons: buttons,
colours: Color.vibrantBlues,
image: UIImage(systemName: "speaker.wave.3.fill"),
useCustomSymbolEffect: true,
text: LocalisedWhatsNew.audio,
secondaryText: LocalisedWhatsNew.audioSecondaryText,
tertiaryText: LocalisedWhatsNew.madeToKiwi))
viewController.modalPresentationStyle = .fullScreen
controller.present(viewController, animated: true)
}
@MainActor func abxy(controller: UIViewController) async {
let buttons: [OnboardingButtonConfiguration] = [
OnboardingButtonConfiguration(text: LocalisedCommon.continue) { button, controller in
await self.whatsNewComplete(controller: controller)
}
]
let viewController: OnboardingController = .init(configuration: .init(buttons: buttons,
colours: Color.vibrantViolets,
image: UIImage(systemName: "circle.grid.cross.up.filled")?
.applyingSymbolConfiguration(UIImage.SymbolConfiguration(hierarchicalColor: .systemBackground)),
text: LocalisedWhatsNew.abxy,
secondaryText: LocalisedWhatsNew.abxySecondaryText))
viewController.modalPresentationStyle = .fullScreen
controller.present(viewController, animated: true)
}
@MainActor func whatsNewComplete(controller: UIViewController) async {
let buttons: [OnboardingButtonConfiguration] = [
OnboardingButtonConfiguration(image: UIImage(systemName: "square.grid.2x2")) { button, controller in
UserDefaults.standard.set(true, forKey: "folium.v1.39.whatsNewComplete")
let libraryController: LibraryController = LibraryController(applicationModel: await self.applicationModel)
let navigationController: UINavigationController = UINavigationController(rootViewController: libraryController)
navigationController.modalPresentationStyle = .fullScreen
controller.present(navigationController, animated: true)
}
]
let viewController: OnboardingController = .init(configuration: .init(buttons: buttons,
colours: Color.vibrantRainbow,
image: UIImage(systemName: "app.badge.checkmark.fill"),
text: LocalisedWhatsNew.whatsNewComplete,
secondaryText: LocalisedWhatsNew.whatsNewCompleteSecondaryText))
viewController.modalPresentationStyle = .fullScreen
controller.present(viewController, animated: true)
}
}