# layouts/utility.html.erb <!DOCTYPE html> <html> <head> <title>Template</title> <meta title="viewport" content material="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag 'utility', media: 'all' %> </head> <physique> <div class="container"> <% until cellular? %> <%= link_to "Dwelling", root_path %> <%= link_to "Posts", posts_path %> <% finish %> <%= yield %> </div> </physique> </html>
# application_helper.rb module ApplicationHelper def cellular? request.user_agent.embrace?('DriftingRubyiOS') finish finish
# config/growth.rb config.hosts = nil
# swift package deal url https://github.com/hotwired/turbo-ios
# SceneDelegate.swift import UIKit import Turbo import WebKit class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? non-public lazy var navigationController = ViewController() let viewController = WebViewController() func scene(_ scene: UIScene, willConnectTo session: UISceneSession, choices connectionOptions: UIScene.ConnectionOptions) { guard let _ = (scene as? UIWindowScene) else { return } window!.rootViewController = navigationController navigationController.tabBar.delegate = self navigationController.pushViewController(viewController, animated: true) go to(url: URL(string: "https://35546c597679.ngrok.io")!) } non-public func go to(url: URL) { viewController.visitableURL = url session.go to(viewController) } non-public lazy var session: Session = { let configuration = WKWebViewConfiguration() configuration.applicationNameForUserAgent = "DriftingRubyiOS" let session = Session(webViewConfiguration: configuration) session.delegate = self return session }() func sceneDidDisconnect(_ scene: UIScene) { // Known as because the scene is being launched by the system. // This happens shortly after the scene enters the background, or when its session is discarded. // Launch any assets related to this scene that may be re-created the following time the scene connects. // The scene might re-connect later, as its session was not essentially discarded (see `utility:didDiscardSceneSessions` as a substitute). } func sceneDidBecomeActive(_ scene: UIScene) { // Known as when the scene has moved from an inactive state to an lively state. // Use this technique to restart any duties that have been paused (or not but began) when the scene was inactive. } func sceneWillResignActive(_ scene: UIScene) { // Known as when the scene will transfer from an lively state to an inactive state. // This will likely happen because of momentary interruptions (ex. an incoming telephone name). } func sceneWillEnterForeground(_ scene: UIScene) { // Known as because the scene transitions from the background to the foreground. // Use this technique to undo the adjustments made on coming into the background. } func sceneDidEnterBackground(_ scene: UIScene) { // Known as because the scene transitions from the foreground to the background. // Use this technique to save lots of information, launch shared assets, and retailer sufficient scene-specific state data // to revive the scene again to its present state. } } extension SceneDelegate: SessionDelegate { func session(_ session: Session, didProposeVisit proposal: VisitProposal) { go to(url: proposal.url) } func session(_ session: Session, didFailRequestForVisitable visitable: Visitable, error: Error) { print("didFailRequestForVisitable: (error)") } } extension SceneDelegate: UITabBarDelegate { func tabBar(_ tabBar: UITabBar, didSelect merchandise: UITabBarItem) { change(merchandise.tag) { case 0: residence() case 1: go to(url: URL(string: "https://35546c597679.ngrok.io/posts")!) default: break } } func residence() { go to(url: URL(string: "https://35546c597679.ngrok.io")!) } }
# WebViewController.swift import UIKit import Turbo class WebViewController: VisitableViewController { override func viewDidLoad() { tremendous.viewDidLoad() } override func visitableDidRender() { title = "Drifting Ruby" } }
# ViewController.swift import UIKit class ViewController: UINavigationController, UITabBarDelegate { let tabBar = UITabBar() let itemHome = UITabBarItem(tabBarSystemItem: .favorites, tag: 0) let itemPosts = UITabBarItem(tabBarSystemItem: .bookmarks, tag: 1) override func viewDidLoad() { tremendous.viewDidLoad() tabBar.body = CGRect(x: 0, y: self.view.body.peak - 75, width: self.view.body.width, peak: 49) tabBar.gadgets = [itemHome, itemPosts] self.view.addSubview(tabBar) } }