From bfe096c531b51b96a918c287dd230ae796391365 Mon Sep 17 00:00:00 2001 From: Donn Felker Date: Tue, 19 Mar 2024 11:46:36 -0400 Subject: [PATCH] Add Strada integration to WebBottomSheetFragment in demo --- .../features/web/WebBottomSheetFragment.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/demo/src/main/kotlin/dev/hotwire/turbo/demo/features/web/WebBottomSheetFragment.kt b/demo/src/main/kotlin/dev/hotwire/turbo/demo/features/web/WebBottomSheetFragment.kt index 0985677c..e74ccc0f 100644 --- a/demo/src/main/kotlin/dev/hotwire/turbo/demo/features/web/WebBottomSheetFragment.kt +++ b/demo/src/main/kotlin/dev/hotwire/turbo/demo/features/web/WebBottomSheetFragment.kt @@ -2,16 +2,50 @@ package dev.hotwire.turbo.demo.features.web import android.os.Bundle import android.view.View +import dev.hotwire.strada.BridgeDelegate import dev.hotwire.turbo.demo.R import dev.hotwire.turbo.demo.base.NavDestination +import dev.hotwire.turbo.demo.strada.bridgeComponentFactories import dev.hotwire.turbo.fragments.TurboWebBottomSheetDialogFragment import dev.hotwire.turbo.nav.TurboNavGraphDestination +import dev.hotwire.turbo.views.TurboWebView @TurboNavGraphDestination(uri = "turbo://fragment/web/modal/sheet") class WebBottomSheetFragment : TurboWebBottomSheetDialogFragment(), NavDestination { + + private val bridgeDelegate by lazy { + BridgeDelegate( + location = location, + destination = this, + componentFactories = bridgeComponentFactories + ) + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) setupMenu() + viewLifecycleOwner.lifecycle.addObserver(bridgeDelegate) + } + + override fun onDestroyView() { + super.onDestroyView() + viewLifecycleOwner.lifecycle.removeObserver(bridgeDelegate) + } + + override fun onColdBootPageStarted(location: String) { + bridgeDelegate.onColdBootPageStarted() + } + + override fun onColdBootPageCompleted(location: String) { + bridgeDelegate.onColdBootPageCompleted() + } + + override fun onWebViewAttached(webView: TurboWebView) { + bridgeDelegate.onWebViewAttached(webView) + } + + override fun onWebViewDetached(webView: TurboWebView) { + bridgeDelegate.onWebViewDetached() } override fun onFormSubmissionStarted(location: String) {