NewsBlur/clients/ios/Classes/TrainerViewController.swift
David Sinclair 51684a7812 #1247 (Mac Catalyst edition)
- Rewrote the trainer view using SwiftUI, to be native instead of a web view.
- Added a Feed class and other data enhancements to support this.
2024-04-04 20:06:11 -05:00

58 lines
1.7 KiB
Swift

//
// TrainerViewController.swift
// NewsBlur
//
// Created by David Sinclair on 2024-04-01.
// Copyright © 2024 NewsBlur. All rights reserved.
//
import SwiftUI
@objc class TrainerViewController: BaseViewController {
@objc var isStoryTrainer = false
@objc var isFeedLoaded = false
lazy var hostingController = makeHostingController()
var trainerView: TrainerView {
return hostingController.rootView
}
var storyCache: StoryCache {
return appDelegate.feedDetailViewController.storyCache
}
private func makeHostingController() -> UIHostingController<TrainerView> {
let trainerView = TrainerView(interaction: self, cache: storyCache)
let trainerController = UIHostingController(rootView: trainerView)
trainerController.view.translatesAutoresizingMaskIntoConstraints = false
return trainerController
}
override func viewDidLoad() {
super.viewDidLoad()
addChild(hostingController)
view.addSubview(hostingController.view)
hostingController.didMove(toParent: self)
NSLayoutConstraint.activate([
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
])
// changedLayout()
}
@objc func reload() {
trainerView.reload()
}
}
extension TrainerViewController: TrainerInteraction {
//TODO: 🚧
}