Skip to content

Commit

Permalink
Add Strada integration to WebBottomSheetFragment in demo
Browse files Browse the repository at this point in the history
  • Loading branch information
donnfelker committed Mar 19, 2024
1 parent e0176f8 commit bfe096c
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bfe096c

Please sign in to comment.