mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00

- 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.
58 lines
1.7 KiB
Swift
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: 🚧
|
|
}
|