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

Split app into modules #131

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Split app into modules #131

wants to merge 13 commits into from

Conversation

mdrlzy
Copy link
Member

@mdrlzy mdrlzy commented Nov 16, 2024

Modules structure

ARK-Rate
├── app
├── core
│   ├── data
│   ├── db
│   ├── di
│   ├── domain
│   └── presentation
├── feature
│   ├── pairalert
│   ├── portfolio
│   ├── quick
│   ├── quickwidget
│   ├── search
│   └── settings
├── fiaticons
└── cryptoicons

Resources

All resources are located in :core:presentation. Keeping resources in feature modules and ensuring that they are not duplicated will be a mess. We can easily access them via type aliases.

CoreR.kt

typealias CoreRString = R.string
typealias CoreRDrawable = R.drawable

Navigation

Feature modules generate compose-destination classes. We collect them in app module and create a single graph manually.
compose-destinations library works in destinations mode

ksp {
    arg("compose-destinations.mode", "destinations")
}

DI

We have CoreComponent in :core:di that contains common dependencies with Singleton scope. Feature modules create own components that depend on CoreComponent with own scopes. App holds CoreComponent and provides it.

Feature component are stored in separate object called FeatureComponentHolder inside the module. This is the easiest way to reuse component between compose screens in module.

Notes

  • :core:di and :core:db needed to not expose :core:data module and implementation so feature modules only know about :core:domain and interfaces
  • Build config replaced with BuildConfigFields and BuildConfigFieldsProvider. BuildConfigFieldsProvider created in :core:data module and initialized in app module. So all modules can use the build config of app module.

),
)

override suspend fun getTimestamp(type: TimestampType) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to include return type here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give an argument? Other modules use TimestampRepo where return types are specified and don't know about TimestampRepoImpl. Also this is allowed by ktlint.


@Singleton
class TimestampRepoImpl @Inject constructor(private val dao: TimestampDao) : TimestampRepo {
override suspend fun rememberTimestamp(type: TimestampType) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to include return type here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as getTimestamp

.height(44.dp)
.border(
1.dp,
ArkColor.Border,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this is named ArkRateColor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see much difference, anyway we will refactor this to use colors from Theme to support dark theme

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

Successfully merging this pull request may close these issues.

2 participants