Files
comaps/iphone/Maps/Bridging/BridgeControllers.swift
Yannik Bloscheck bff4b2348a [ios] WIP: Switching main/map buttons to SwiftUI
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
2025-11-07 21:07:34 +01:00

55 lines
1.9 KiB
Swift

import SwiftUI
import UIKit
/// Class for accesing SwiftUI views from Objective-C code
@objc class BridgeControllers: NSObject {
/// The `ProfileView` for presentation in an alert
@objc static func profileAsAlert() -> UIViewController {
let profileBridgeController = UIHostingController(rootView: ProfileView(isPresentedAsAlert: true))
profileBridgeController.view.backgroundColor = .systemGroupedBackground
return profileBridgeController
}
/// The `RoutingOptionsView` for presentation in an alert
@objc static func routingOptions() -> UIViewController {
let routinOptionsBridgeController = UIHostingController(rootView: RoutingOptionsView())
routinOptionsBridgeController.view.backgroundColor = .systemGroupedBackground
return routinOptionsBridgeController
}
/// The `ControlsView` for presentation in an alert
@objc static func mapControls() -> UIViewController {
let controlsBridgeController = UIHostingController(rootView: ControlsView())
controlsBridgeController.view.backgroundColor = .clear
return controlsBridgeController
}
}
/// Class for using the SwiftUI `AboutView` in the interface builder
class AboutBridgeController: UIHostingController<AboutView> {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder, rootView: AboutView())
}
}
/// Class for using the SwiftUI `SettingsView` in the interface builder
class SettingsBridgeController: UIHostingController<SettingsView> {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder, rootView: SettingsView())
}
}
/// Class for using the SwiftUI `ProfileView` in the interface builder
class ProfileBridgeController: UIHostingController<ProfileView> {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder, rootView: ProfileView())
self.view.tintColor = .toolbarAccent
}
}