Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling Base class with abstract composable #11

Closed
SzasznikaJanos opened this issue Oct 14, 2021 · 2 comments
Closed

Handling Base class with abstract composable #11

SzasznikaJanos opened this issue Oct 14, 2021 · 2 comments

Comments

@SzasznikaJanos
Copy link

SzasznikaJanos commented Oct 14, 2021

[ksp] com.ramcosta.composedestinations.codegen.commons.IllegalDestinationsSetup: Destination composable names must be unique: found multiple named 'Screen'

abstract class BaseScreen {

	protected abstract val viewModelClass: Class<VIEW_MODEL>

	@Composable
	protected abstract fun Screen(
		someInterface: SomeInterface,
		bundle: Bundle?
	)

...
}
class ScreenA: BaseScreen (){

....
        @Composable
	@Destination("routeA")
	override fun Screen(
		someInterface:SomeInterface,
		bundle: Bundle?
	) {

}

class ScreenB: BaseScreen (){

....
        @Composable
	@Destination("routeB")
	override fun Screen(
		someInterface:SomeInterface,
		bundle: Bundle?
	) {

}

Is there any way that we can give individual names for Composables?

Version 0.8.3-alpha05

@raamcosta
Copy link
Owner

raamcosta commented Oct 14, 2021

Hi @SzasznikaJanos ! 👋
Thanks for opening the issue 🙂

No, there is no way as of now. Besides, Compose Destinations would not able to call your "Screen" Composables. Because it would need to instantiate these classes to call them 🤔

I'm super curious, why do you need the base class? This is pretty much the same that happens with the library, we have an interface Destination which is the base class.
I guess my question is: what do you do with class BaseScreen? Do you put instances of it in a list or something like that?
What is "bundle" argument?

Also, I would advise against doing this type of thing because someday you may need some Screens to be extension functions of ColumnScope or AnimatedVisibilityScope or something like that. In your case that would not work.

In summary, you are fighting against the library instead of making use of its power 😄 💪

@raamcosta
Copy link
Owner

Im closing this issue. If you still think there is something to fix or improve, do let me know and I can reopen it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants