Skip to content

Commit

Permalink
Rename HotwireNavDestination -> HotwireDestination
Browse files Browse the repository at this point in the history
  • Loading branch information
jayohms committed Jun 13, 2024
1 parent fb840eb commit fd84192
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 38 deletions.
6 changes: 3 additions & 3 deletions demo/src/main/kotlin/dev/hotwire/demo/bridge/FormComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import dev.hotwire.core.bridge.BridgeDelegate
import dev.hotwire.core.bridge.Message
import dev.hotwire.demo.R
import dev.hotwire.demo.databinding.FormComponentSubmitBinding
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -21,8 +21,8 @@ import kotlinx.serialization.Serializable
*/
class FormComponent(
name: String,
private val delegate: BridgeDelegate<HotwireNavDestination>
) : BridgeComponent<HotwireNavDestination>(name, delegate) {
private val delegate: BridgeDelegate<HotwireDestination>
) : BridgeComponent<HotwireDestination>(name, delegate) {

private val submitButtonItemId = 37
private var submitMenuItem: MenuItem? = null
Expand Down
6 changes: 3 additions & 3 deletions demo/src/main/kotlin/dev/hotwire/demo/bridge/MenuComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dev.hotwire.core.bridge.BridgeComponent
import dev.hotwire.core.bridge.BridgeDelegate
import dev.hotwire.core.bridge.Message
import dev.hotwire.demo.databinding.MenuComponentBottomSheetBinding
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -19,8 +19,8 @@ import kotlinx.serialization.Serializable
*/
class MenuComponent(
name: String,
private val delegate: BridgeDelegate<HotwireNavDestination>
) : BridgeComponent<HotwireNavDestination>(name, delegate) {
private val delegate: BridgeDelegate<HotwireDestination>
) : BridgeComponent<HotwireDestination>(name, delegate) {

private val fragment: Fragment
get() = delegate.destination.fragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dev.hotwire.core.bridge.BridgeComponent
import dev.hotwire.core.bridge.BridgeDelegate
import dev.hotwire.core.bridge.Message
import dev.hotwire.demo.R
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -17,8 +17,8 @@ import kotlinx.serialization.Serializable
*/
class OverflowMenuComponent(
name: String,
private val delegate: BridgeDelegate<HotwireNavDestination>
) : BridgeComponent<HotwireNavDestination>(name, delegate) {
private val delegate: BridgeDelegate<HotwireDestination>
) : BridgeComponent<HotwireDestination>(name, delegate) {

private val fragment: Fragment
get() = delegate.destination.fragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.fragment.app.Fragment
import dev.hotwire.core.bridge.BridgeComponent
import dev.hotwire.core.bridge.BridgeComponentFactory
import dev.hotwire.core.config.Hotwire
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.fragments.HotwireWebBottomSheetFragment
import dev.hotwire.navigation.fragments.HotwireWebFragment
import dev.hotwire.navigation.routing.AppNavigationRouteDecisionHandler
Expand All @@ -26,8 +26,8 @@ internal object HotwireNavigation {
)

@Suppress("UNCHECKED_CAST")
var registeredBridgeComponentFactories: List<BridgeComponentFactory<HotwireNavDestination, BridgeComponent<HotwireNavDestination>>>
get() = Hotwire.config.registeredBridgeComponentFactories as List<BridgeComponentFactory<HotwireNavDestination, BridgeComponent<HotwireNavDestination>>>
var registeredBridgeComponentFactories: List<BridgeComponentFactory<HotwireDestination, BridgeComponent<HotwireDestination>>>
get() = Hotwire.config.registeredBridgeComponentFactories as List<BridgeComponentFactory<HotwireDestination, BridgeComponent<HotwireDestination>>>
set(value) { Hotwire.config.registeredBridgeComponentFactories = value }
}

Expand All @@ -43,7 +43,7 @@ fun Hotwire.registerRouteDecisionHandlers(decisionHandlers: List<Router.RouteDec
* Register bridge components that the app supports. Every possible bridge
* component, wrapped in a [BridgeComponentFactory], must be provided here.
*/
fun Hotwire.registerBridgeComponents(factories: List<BridgeComponentFactory<HotwireNavDestination, BridgeComponent<HotwireNavDestination>>>) {
fun Hotwire.registerBridgeComponents(factories: List<BridgeComponentFactory<HotwireDestination, BridgeComponent<HotwireDestination>>>) {
config.registeredBridgeComponentFactories = factories
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import dev.hotwire.navigation.routing.Router
* The primary interface that a navigable Fragment implements to provide the library with
* the information it needs to properly navigate.
*/
interface HotwireNavDestination : BridgeDestination {
interface HotwireDestination : BridgeDestination {
/**
* Gets the navigator instance associated with this destination.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ package dev.hotwire.navigation.destinations
* The interface that a navigable DialogFragment implements to provide the library with
* the information it needs to properly navigate.
*/
interface HotwireNavDialogDestination {
interface HotwireDialogDestination {
fun closeDialog()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import androidx.appcompat.widget.Toolbar
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import dev.hotwire.core.turbo.config.title
import dev.hotwire.navigation.R
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireNavDialogDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDialogDestination
import dev.hotwire.navigation.navigator.Navigator
import dev.hotwire.navigation.navigator.NavigatorHost

Expand All @@ -20,7 +20,7 @@ import dev.hotwire.navigation.navigator.NavigatorHost
* For web bottom sheet fragments, refer to [HotwireWebBottomSheetFragment].
*/
abstract class HotwireBottomSheetFragment : BottomSheetDialogFragment(),
HotwireNavDestination, HotwireNavDialogDestination {
HotwireDestination, HotwireDialogDestination {
override lateinit var navigator: Navigator
internal lateinit var delegate: HotwireFragmentDelegate

Expand Down Expand Up @@ -61,7 +61,7 @@ abstract class HotwireBottomSheetFragment : BottomSheetDialogFragment(),
* Use [registerForActivityResult] with the appropriate
* [androidx.activity.result.contract.ActivityResultContract] and its callback.
*
* Turbo provides the [HotwireNavDestination.activityResultLauncher] interface
* Turbo provides the [HotwireDestination.activityResultLauncher] interface
* to obtain registered result launchers from any destination.
*/
@Suppress("DEPRECATION")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dev.hotwire.core.turbo.config.context
import dev.hotwire.core.turbo.config.title
import dev.hotwire.core.turbo.nav.TurboNavPresentationContext
import dev.hotwire.navigation.R
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.navigator.Navigator
import dev.hotwire.navigation.navigator.NavigatorHost
import dev.hotwire.navigation.observers.HotwireWindowThemeObserver
Expand All @@ -21,7 +21,7 @@ import dev.hotwire.navigation.session.SessionModalResult
*
* For web fragments, refer to [HotwireWebFragment].
*/
abstract class HotwireFragment : Fragment(), HotwireNavDestination {
abstract class HotwireFragment : Fragment(), HotwireDestination {
override lateinit var navigator: Navigator
internal lateinit var delegate: HotwireFragmentDelegate

Expand Down Expand Up @@ -66,7 +66,7 @@ abstract class HotwireFragment : Fragment(), HotwireNavDestination {
* Use [registerForActivityResult] with the appropriate
* [androidx.activity.result.contract.ActivityResultContract] and its callback.
*
* Turbo provides the [HotwireNavDestination.activityResultLauncher] interface
* Turbo provides the [HotwireDestination.activityResultLauncher] interface
* to obtain registered result launchers from any destination.
*/
@Suppress("DEPRECATION")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.hotwire.navigation.fragments

import dev.hotwire.navigation.logging.logEvent
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.session.SessionModalResult
import dev.hotwire.navigation.session.SessionViewModel
import dev.hotwire.navigation.util.displayBackButton
Expand All @@ -12,7 +12,7 @@ import dev.hotwire.navigation.util.displayBackButtonAsCloseIcon
* to this class. Note: This class should not need to be used directly
* from within your app.
*/
class HotwireFragmentDelegate(private val navDestination: HotwireNavDestination) {
class HotwireFragmentDelegate(private val navDestination: HotwireDestination) {
private val fragment = navDestination.fragment
private val location = navDestination.location
private val navigator = navDestination.navigator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import dev.hotwire.core.turbo.visit.Visit
import dev.hotwire.core.turbo.visit.VisitAction
import dev.hotwire.core.turbo.visit.VisitDestination
import dev.hotwire.core.turbo.visit.VisitOptions
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.session.SessionModalResult
import dev.hotwire.navigation.util.dispatcherProvider
import dev.hotwire.navigation.views.TurboView
Expand All @@ -32,7 +32,7 @@ import kotlin.random.Random
*/
internal class HotwireWebFragmentDelegate(
private val delegate: HotwireFragmentDelegate,
private val navDestination: HotwireNavDestination,
private val navDestination: HotwireDestination,
private val callback: HotwireWebFragmentCallback
) : SessionCallback, VisitDestination {

Expand Down Expand Up @@ -129,8 +129,7 @@ internal class HotwireWebFragmentDelegate(
}

/**
* Should be called by the implementing Fragment during
* [dev.hotwire.core.turbo.nav.HotwireNavDestination.refresh]
* Should be called by the implementing Fragment during [HotwireDestination.refresh].
*/
fun refresh(displayProgress: Boolean) {
if (webView.url == null) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import dev.hotwire.core.turbo.session.Session
import dev.hotwire.core.turbo.visit.VisitAction
import dev.hotwire.core.turbo.visit.VisitOptions
import dev.hotwire.navigation.config.HotwireNavigation
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireNavDialogDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDialogDestination
import dev.hotwire.navigation.logging.logEvent
import dev.hotwire.navigation.routing.Router
import dev.hotwire.navigation.util.location
Expand All @@ -28,10 +28,10 @@ class Navigator(
private val navController = host.navController

/**
* Retrieves the currently active [HotwireNavDestination] on the backstack.
* Retrieves the currently active [HotwireDestination] on the backstack.
*/
val currentDestination: HotwireNavDestination
get() = host.childFragmentManager.primaryNavigationFragment as HotwireNavDestination?
val currentDestination: HotwireDestination
get() = host.childFragmentManager.primaryNavigationFragment as HotwireDestination?
?: throw IllegalStateException("No current destination found in NavigatorHost")

/**
Expand Down Expand Up @@ -74,7 +74,7 @@ class Navigator(
fun pop() {
navigateWhenReady {
val currentFragment = currentDestination.fragment
if (currentFragment is HotwireNavDialogDestination) {
if (currentFragment is HotwireDialogDestination) {
currentFragment.closeDialog()
} else {
navController.popBackStack()
Expand Down Expand Up @@ -150,7 +150,7 @@ class Navigator(

navigateWhenReady {
val currentFragment = currentDestination.fragment
if (currentFragment is HotwireNavDialogDestination) {
if (currentFragment is HotwireDialogDestination) {
currentFragment.closeDialog()
}

Expand Down Expand Up @@ -251,7 +251,7 @@ class Navigator(
)

navigateWhenReady {
val isDialog = currentDestination.fragment is HotwireNavDialogDestination
val isDialog = currentDestination.fragment is HotwireDialogDestination
if (isDialog) {
// Pop the backstack before sending the modal result, since the
// underlying fragment is still active and will receive the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
import androidx.annotation.RequiresApi
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import dev.hotwire.navigation.destinations.HotwireNavDestination
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.util.animateColorTo

internal class HotwireWindowThemeObserver(val destination: HotwireNavDestination) : DefaultLifecycleObserver {
internal class HotwireWindowThemeObserver(val destination: HotwireDestination) : DefaultLifecycleObserver {
private val window: Window?
get() = destination.fragment.activity?.window

Expand Down

0 comments on commit fd84192

Please sign in to comment.