Skip to content

Commit

Permalink
Merge pull request #321 from donnfelker/task/web-bottom-sheet-turbo-s…
Browse files Browse the repository at this point in the history
…trada-integration

Add Strada integration to WebBottomSheetFragment in demo
  • Loading branch information
jayohms authored Mar 23, 2024
2 parents bb636d6 + bfe096c commit 2c76214
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 2c76214

Please sign in to comment.