Skip to content

Commit

Permalink
Rename HotwireDestination annotation -> HotwireDestinationDeepLink
Browse files Browse the repository at this point in the history
  • Loading branch information
jayohms committed Jun 13, 2024
1 parent 6f6be7b commit fb840eb
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import android.view.ViewGroup
import android.widget.ImageView
import coil.load
import dev.hotwire.demo.R
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.navigation.fragments.HotwireFragment
import dev.hotwire.navigation.util.displayBackButtonAsCloseIcon

@HotwireDestination(uri = "turbo://fragment/image_viewer")
@HotwireDestinationDeepLink(uri = "turbo://fragment/image_viewer")
class ImageViewerFragment : HotwireFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_image_viewer, container, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import android.view.ViewGroup
import com.google.android.material.textview.MaterialTextView
import dev.hotwire.core.turbo.config.PathConfigurationProperties
import dev.hotwire.demo.R
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.navigation.fragments.HotwireBottomSheetFragment

@HotwireDestination(uri = "turbo://fragment/numbers/sheet")
@HotwireDestinationDeepLink(uri = "turbo://fragment/numbers/sheet")
class NumberBottomSheetFragment : HotwireBottomSheetFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_number_bottom_sheet, container, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dev.hotwire.demo.R
import dev.hotwire.demo.Urls
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.navigation.fragments.HotwireFragment

@HotwireDestination(uri = "turbo://fragment/numbers")
@HotwireDestinationDeepLink(uri = "turbo://fragment/numbers")
class NumbersFragment : HotwireFragment(), NumbersFragmentCallback {
private val numbersAdapter = NumbersAdapter(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import android.os.Bundle
import android.view.MenuItem
import android.view.View
import dev.hotwire.demo.R
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.navigation.fragments.HotwireWebBottomSheetFragment

@HotwireDestination(uri = "turbo://fragment/web/modal/sheet")
@HotwireDestinationDeepLink(uri = "turbo://fragment/web/modal/sheet")
class WebBottomSheetFragment : HotwireWebBottomSheetFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import dev.hotwire.core.turbo.visit.VisitAction.REPLACE
import dev.hotwire.core.turbo.visit.VisitOptions
import dev.hotwire.demo.R
import dev.hotwire.demo.Urls
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.navigation.fragments.HotwireWebFragment

@HotwireDestination(uri = "turbo://fragment/web")
@HotwireDestinationDeepLink(uri = "turbo://fragment/web")
open class WebFragment : HotwireWebFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dev.hotwire.core.turbo.errors.VisitError
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.demo.R

@HotwireDestination(uri = "turbo://fragment/web/home")
@HotwireDestinationDeepLink(uri = "turbo://fragment/web/home")
class WebHomeFragment : WebFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_web_home, container, false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.hotwire.demo.features.web

import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink

@HotwireDestination(uri = "turbo://fragment/web/modal")
@HotwireDestinationDeepLink(uri = "turbo://fragment/web/modal")
class WebModalFragment : WebFragment()
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import kotlin.reflect.full.findAnnotation
* Annotation for each Fragment that will be registered as a navigation destination.
*
* For example:
* `@HotwireDestination(uri = "turbo://fragment/search")`
* `@HotwireDestinationDeepLink(uri = "turbo://fragment/search")`
* `class SearchFragment : TurboWebFragment()`
*
* @property uri The URI to be registered with the Android Navigation component nav graph.
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
annotation class HotwireDestination(
annotation class HotwireDestinationDeepLink(
val uri: String
) {
companion object {
internal fun from(klass: KClass<out Any>): HotwireDestination {
internal fun from(klass: KClass<out Any>): HotwireDestinationDeepLink {
return requireNotNull(klass.findAnnotation()) {
"A HotwireDestination annotation is required for the destination: ${klass.simpleName}"
"A HotwireDestinationDeepLink annotation is required for the destination: ${klass.simpleName}"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import dev.hotwire.core.turbo.views.TurboWebChromeClient
import dev.hotwire.core.turbo.views.TurboWebView
import dev.hotwire.navigation.R
import dev.hotwire.navigation.config.HotwireNavigation
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.navigation.views.TurboView

/**
Expand All @@ -24,7 +24,7 @@ import dev.hotwire.navigation.views.TurboView
*
* For native bottom sheet fragments, refer to [HotwireBottomSheetFragment].
*/
@HotwireDestination(uri = "turbo://fragment/web/modal/sheet")
@HotwireDestinationDeepLink(uri = "turbo://fragment/web/modal/sheet")
open class HotwireWebBottomSheetFragment : HotwireBottomSheetFragment(), HotwireWebFragmentCallback {
private lateinit var webDelegate: HotwireWebFragmentDelegate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import dev.hotwire.core.turbo.views.TurboWebChromeClient
import dev.hotwire.core.turbo.views.TurboWebView
import dev.hotwire.navigation.R
import dev.hotwire.navigation.config.HotwireNavigation
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.navigation.session.SessionModalResult
import dev.hotwire.navigation.views.TurboView

Expand All @@ -24,7 +24,7 @@ import dev.hotwire.navigation.views.TurboView
*
* For native fragments, refer to [HotwireFragment].
*/
@HotwireDestination(uri = "turbo://fragment/web")
@HotwireDestinationDeepLink(uri = "turbo://fragment/web")
open class HotwireWebFragment : HotwireFragment(), HotwireWebFragmentCallback {
private lateinit var webDelegate: HotwireWebFragmentDelegate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.navigation.get
import dev.hotwire.core.turbo.config.PathConfiguration
import dev.hotwire.core.turbo.config.uri
import dev.hotwire.navigation.config.HotwireNavigation
import dev.hotwire.navigation.destinations.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import java.util.UUID
import kotlin.reflect.KClass
import kotlin.reflect.full.isSubclassOf
Expand All @@ -40,7 +40,7 @@ internal class NavigatorGraphBuilder(
val fragmentDestinations = registeredFragments.map {
FragmentDestination(
route = currentRoute.also { currentRoute++ }.toString(),
uri = HotwireDestination.from(it).uri.toUri(),
uri = HotwireDestinationDeepLink.from(it).uri.toUri(),
kClass = it
)
}
Expand Down Expand Up @@ -94,7 +94,7 @@ internal class NavigatorGraphBuilder(

private fun List<FragmentDestination>.startDestination(): FragmentDestination {
val startDestinationUri = pathConfiguration.properties(startLocation).uri ?:
HotwireDestination.from(HotwireNavigation.defaultFragmentDestination).uri.toUri()
HotwireDestinationDeepLink.from(HotwireNavigation.defaultFragmentDestination).uri.toUri()

return requireNotNull(firstOrNull { it.uri == startDestinationUri }) {
"A start Fragment destination was not found for uri: $startDestinationUri"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import dev.hotwire.core.turbo.nav.TurboNavQueryStringPresentation
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.HotwireDestination
import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink
import dev.hotwire.navigation.session.SessionModalResult
import dev.hotwire.navigation.util.location

Expand All @@ -35,7 +35,7 @@ internal class NavigatorRule(
pathConfiguration: PathConfiguration,
val controller: NavController
) {
val defaultUri = HotwireDestination.from(HotwireNavigation.defaultFragmentDestination).uri.toUri()
val defaultUri = HotwireDestinationDeepLink.from(HotwireNavigation.defaultFragmentDestination).uri.toUri()

// Current destination
val previousLocation = controller.previousBackStackEntry.location
Expand Down

0 comments on commit fb840eb

Please sign in to comment.