Sha256: 1b6fb59e08471db38bc08cdc7743814287f537202809d7d9204d7ffad6fab7eb

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

import UIKit
import Turbo
import Strada
import WebKit

final class TurboWebViewController: VisitableViewController, ErrorPresenter, BridgeDestination {

    var pullToRefreshEnabled = true

    private lazy var bridgeDelegate: BridgeDelegate = {
        BridgeDelegate(location: visitableURL.absoluteString, destination: self, componentTypes: BridgeComponent.allTypes)
    }()

    private lazy var dismissModalButton = {
        UIBarButtonItem(image: UIImage(systemName: "chevron.down"), style: .plain, target: self, action: #selector(dismissModal))
    }()

    // MARK: View lifecycle

    override func viewDidLoad() {
        super.viewDidLoad()

        navigationItem.backButtonTitle = "Back"

        visitableView.allowsPullToRefresh = pullToRefreshEnabled

        if presentingViewController != nil {
            navigationItem.leftBarButtonItem = dismissModalButton
        }

        bridgeDelegate.onViewDidLoad()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        bridgeDelegate.onViewWillAppear()
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        bridgeDelegate.onViewDidAppear()
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        bridgeDelegate.onViewWillDisappear()
    }

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        bridgeDelegate.onViewDidDisappear()
    }

    // MARK: Visitable

    override func visitableDidRender() {
        title = title ?? visitableView.webView?.title
    }

    override func visitableDidActivateWebView(_ webView: WKWebView) {
        bridgeDelegate.webViewDidBecomeActive(webView)
    }

    override func visitableDidDeactivateWebView() {
        bridgeDelegate.webViewDidBecomeDeactivated()
    }

    // MARK: Actions

    @objc func dismissModal() {
        dismiss(animated: true)
    }
}

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
turbo-native-initializer-0.0.16 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Controllers/TurboWebViewController.swift
turbo-native-initializer-0.0.16 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Controllers/TurboWebViewController.swift