-
Notifications
You must be signed in to change notification settings - Fork 0
Update dependencies & migrate to AGP9 #29
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9018c26
Update dependencies & migrate to AGP9
Syntey 766a0b1
Update arkitekt
Syntey df7c1b9
Remove unused variable
Syntey 419b10c
Fix test task
Syntey f4bb42c
Add Arkitekt API reference to CLAUDE.md
Syntey 65e7537
Remove source sets
Syntey 737db31
Fix test gradle task + clean CLAUDE.md
Syntey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code when working with code in this repository. | ||
|
|
||
| ## Common Commands | ||
|
|
||
| - `./gradlew lintCheck` - Run ktlint and detekt checks (same as CI) | ||
| - `./gradlew ktlintFormat` - Automatically fix code style issues | ||
| - `./gradlew test` - Run unit tests | ||
| - `./gradlew clean` - Remove all build artifacts | ||
|
|
||
| ## Module Structure | ||
|
|
||
| Single-module project with the main app under `:app`. Build logic lives in `buildSrc/` and `convention-plugins/`. | ||
|
|
||
| ## Architecture | ||
|
|
||
| **MVVM** with [Arkitekt](https://github.com/futuredapp/arkitekt) library: | ||
|
|
||
| 1. **ViewModel** (`*ViewModel.kt`) - extends `BaseViewModel<ViewState>`, implements `Actions` interface from the screen | ||
| 2. **ViewState** (`*ViewState.kt`) - holds mutable Compose state (`var counter by mutableIntStateOf(0)`) | ||
| 3. **Events** (`*Events.kt`) - sealed class of one-time events (navigation, toasts); collected via `EventsEffect` | ||
| 4. **Screen** (`*Screen.kt`) - Composable; receives `viewState`, collects events, delegates interactions to `Actions` | ||
|
|
||
| Actions are defined as a nested interface inside the Screen object: | ||
| ```kotlin | ||
| object HomeScreen { | ||
| interface Actions { | ||
| fun onIncrementCounter() | ||
| fun onNavigateToDetail() | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Arkitekt API Reference | ||
|
|
||
| ### `BaseCoreViewModel<VS>` | ||
| - `abstract val viewState: VS` — injected ViewState | ||
| - `sendEvent(event: Event<VS>)` — sends a one-time event to the UI layer | ||
|
|
||
| ### `BaseViewModel<VS>` (extends `BaseCoreViewModel`, implements `CoroutineScopeOwner`) | ||
| - Provides `coroutineScope` backed by `viewModelScope` | ||
| - Inherits all `CoroutineScopeOwner` extension functions below | ||
|
|
||
| ### Use cases | ||
| Always extend the Arkitekt base classes — never use plain `suspend` functions with `invoke()`: | ||
|
|
||
| ```kotlin | ||
| // UseCase<ARGS, RESULT> — single async operation | ||
| class SignInUseCase @Inject constructor(...) : UseCase<Unit, Unit>() { | ||
| override suspend fun build(args: Unit) { /* business logic */ } | ||
| } | ||
|
|
||
| // FlowUseCase<ARGS, T> — streaming operation | ||
| class ObserveSomethingUseCase @Inject constructor(...) : FlowUseCase<Unit, MyModel>() { | ||
| override fun build(args: Unit): Flow<MyModel> = /* … */ | ||
| } | ||
| ``` | ||
|
|
||
| ### `CoroutineScopeOwner` — use-case execution in ViewModels | ||
|
|
||
| ```kotlin | ||
| // Async execution with callbacks (preferred; cancels previous by default) | ||
| someUseCase.execute { | ||
| onStart { /* show loading */ } | ||
| onSuccess { value -> sendEvent(MyEvent) } // sendEvent is non-suspend, safe here | ||
| onError { throwable -> /* … */ } | ||
| } | ||
|
|
||
| // Suspend execution — use inside launchWithHandler for error handling | ||
| launchWithHandler { | ||
| val result = someUseCase.execute() // returns Result<T> | ||
| result.getOrNull() // or getOrThrow(), getOrDefault(), fold(…) | ||
| } | ||
|
|
||
| // Flow use case | ||
| someFlowUseCase.execute { | ||
| onStart { } | ||
| onNext { value -> } | ||
| onError { throwable -> } | ||
| onComplete { } | ||
| } | ||
| ``` | ||
|
|
||
| ### `EventsEffect` / `onEvent` | ||
| ```kotlin | ||
| EventsEffect { | ||
| onEvent<MyEvent> { /* handle */ } | ||
| } | ||
| ``` | ||
|
|
||
| ## Dependency Injection | ||
|
|
||
| **Hilt** throughout: | ||
| - `@HiltAndroidApp` on `App`, `@AndroidEntryPoint` on `AppActivity` | ||
| - `@HiltViewModel` on ViewModels, `@ViewModelScoped` on ViewState | ||
| - Modules: `ApplicationModule` (singletons), `NetworkModule` (Retrofit/OkHttp) | ||
|
|
||
| ## Build Flavors | ||
|
|
||
| Flavor dimension: `api` with three flavors: | ||
| - **mock** - local mock data | ||
| - **dev** - development API | ||
| - **prod** - production API | ||
|
|
||
| Build types: `debug`, `enterprise` (minified, debug key), `release` (minified, release key). | ||
|
|
||
| ## Code Style | ||
|
|
||
| - Max line length: **140 characters** | ||
| - Indent: **4 spaces**, trailing commas allowed | ||
| - Ktlint code style: `android_studio` | ||
| - Detekt config: `config/detekt.yml` | ||
|
|
||
| ## Naming Conventions | ||
|
|
||
| - `HomeViewModel`, `HomeViewState`, `HomeEvents`, `HomeScreen` | ||
| - Event objects: `NavigateToDetailEvent`, `NavigateBackEvent` | ||
| - Action methods: `onIncrementCounter()`, `onNavigateToDetail()` (prefix `on`) | ||
| - Composable functions: PascalCase; preview functions: `private fun HomePreview()` | ||
|
|
||
| ## Design System | ||
|
|
||
| Material3 via `MaterialTheme`. Colors, typography, shapes, and dimensions defined in `app/src/main/kotlin/.../ui/theme/`. | ||
|
|
||
| Use `Dimensions.kt` tokens for spacing — avoid raw `dp` literals where theme tokens exist. | ||
|
|
||
| ## Testing | ||
|
|
||
| - Unit tests: JUnit 4 + MockK | ||
| - Instrumented tests: AndroidJUnit4 | ||
| - Run unit tests: `./gradlew test` | ||
| - Run module tests: `./gradlew :app:test` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
app/src/main/kotlin/app/futured/androidprojecttemplate/tools/arch/BaseViewModel.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/detail/DetailViewModel.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/home/HomeViewModel.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need init script to remove / edit this after cloning the template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The architecture-related part is fine, but project and business-related part will get outdated as you init the project and start working on it. Maybe we could just delete template-related stuff from it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned it up a little bit 👍🏻