Issue
I'm working on modularizing a test application with Android Compose and have the application stuff woking well, however it seems that if you want to add custom theming like colors and fonts you run into problems.
So as example under the app/src/main/java/com/xx/myapp/theme/ we extend Color.kt
val Green900 = Color(0XFF242d2d)
val Green800 = Color(0XFF354242)
val Colors.green800: Color
@Composable
get() = Green800
val Colors.green700: Color
@Composable
get() = Green700
Now trying to use these in any of the "Modules" is not possible and the only way I can see is to duplicate the whole theme structure in each module which seems stupid?
So if I have a module in the structure as example components/src/main/java/com/xx/components/BottomNavBar.kt I cannot use
selectedContentColor = MaterialTheme.colors.gray800,
unless I duplicate the Color.kt inside this module OR I include the "app" module inside the build.gradle.kts for this module...
"implementation"(project(Modules.app))
which will cause a "Circular dependency" if I'm not mistaken
Any suggestions on how to manage this without duplication?
Thanks J
Solution
From what I have understood one way to do it is to have a module only for the shared definitions in such a way that you do not need to import the entire app module. This shared module will of course be imported by the app module as well.
More in general everytime you have a circular dependency you need to check whether the solution can be to split the modules in smaller ones in such a way that you break the circle.
Answered By - kingston
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.