REFACTOR END

This commit is contained in:
2025-09-28 10:10:01 +03:00
parent 394e0040de
commit 9b914b2904
117 changed files with 3070 additions and 5447 deletions

View File

@@ -0,0 +1,42 @@
# План рефакторинга `app` модуля
## 1. Контекст
`app` модуль содержит `ui` код, который должен быть вынесен в `feature` модули. Это приводит к ошибкам сборки после рефакторинга `feature:dashboard`.
## 2. План действий
### Шаг 1: Удаление `ui` кода из `app`
Удалить пакет `app/src/main/java/com/homebox/lens/ui`.
### Шаг 2: Создание `feature` модулей
Создать следующие `feature` модули:
* `feature:inventorylist`
* `feature:itemdetails`
* `feature:itemedit`
* `feature:labeledit`
* `feature:labelslist`
* `feature:locationedit`
* `feature:locationslist`
* `feature:search`
* `feature:settings`
* `feature:setup`
### Шаг 3: Перемещение `ui` кода
Переместить `ui` код из `app` в соответствующие `feature` модули.
### Шаг 4: Обновление `app/build.gradle.kts`
Добавить зависимости от новых `feature` модулей в `app/build.gradle.kts`.
### Шаг 5: Обновление `settings.gradle.kts`
Включить новые `feature` модули в `settings.gradle.kts`.
### Шаг 6: Исправление `NavGraph.kt`
Исправить `NavGraph.kt` для использования экранов из `feature` модулей.

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<work_order>
<meta>
<version>1.0</version>
<timestamp>2025-09-26T14:08:01Z</timestamp>
<description>Рефакторинг app модуля.</description>
<priority>high</priority>
</meta>
<task>
<id>refactor_app_module</id>
<name>Рефакторинг app модуля</name>
<instructions>
<step>
<description>Удалить ui пакет из app модуля.</description>
<detail>
<!CDATA[
Удалить пакет app/src/main/java/com/homebox/lens/ui.
]>
</detail>
</step>
<step>
<description>Создать feature модули для каждого экрана.</description>
<detail>
<!CDATA[
Создать следующие feature модули:
- feature:inventorylist
- feature:itemdetails
- feature:itemedit
- feature:labeledit
- feature:labelslist
- feature:locationedit
- feature:locationslist
- feature:search
- feature:settings
- feature:setup
]>
</detail>
</step>
<step>
<description>Переместить ui код из app в соответствующие feature модули.</description>
</step>
<step>
<description>Обновить app/build.gradle.kts для добавления зависимостей от новых feature модулей.</description>
</step>
<step>
<description>Обновить settings.gradle.kts для включения новых feature модулей.</description>
</step>
<step>
<description>Исправить NavGraph.kt для использования экранов из feature модулей.</description>
</step>
</instructions>
</task>
</work_order>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<work_order>
<meta>
<version>1.0</version>
<timestamp>2025-09-26T13:23:47Z</timestamp>
<description>Исправление ошибок сборки в модуле feature:dashboard.</description>
<priority>high</priority>
</meta>
<task>
<id>fix_unresolved_references</id>
<name>Исправить неразрешенные ссылки в build.gradle.kts и .kt файлах</name>
<instructions>
<step>
<description>Убедиться, что Libs из buildSrc доступны для всех модулей.</description>
<detail>
<!CDATA[
Проблема "Unresolved reference: composeMaterialIconsExtended" в feature/dashboard/build.gradle.kts указывает на то, что Libs из buildSrc/src/main/java/Dependencies.kt не распознается модулем feature:dashboard.
Возможные причины:
1. Проблема с кэшем Gradle (уже пытались решить с помощью clean build).
2. Неправильная конфигурация buildSrc (проверили, kotlin-dsl используется).
3. Проблема с версиями Gradle или Kotlin.
Поскольку buildSrc должен быть автоматически доступен, необходимо убедиться, что его содержимое корректно скомпилировано и доступно для зависимых модулей.
]>
</detail>
</step>
<step>
<description>Проверить файл buildSrc/build.gradle.kts.</description>
<detail>
<!CDATA[
Убедиться, что buildSrc/build.gradle.kts содержит `plugins { `kotlin-dsl` }` и `repositories { mavenCentral() }`.
]>
</detail>
</step>
<step>
<description>Проверить файл feature/dashboard/build.gradle.kts.</description>
<detail>
<!CDATA[
Убедиться, что в файле feature/dashboard/build.gradle.kts правильно используются Libs.
В частности, строка `implementation(Libs.composeMaterialIconsExtended)` должна разрешаться.
]>
</detail>
</step>
<step>
<description>Исправить DashboardScreen.kt.</description>
<detail>
<!CDATA[
1. Заменить `homeboxLensTheme` на `HomeboxLensTheme`.
2. Проверить импорты для `ExperimentalLayoutApi`, `FlowRow` и `QrCodeScanner`. Они должны быть:
`import androidx.compose.foundation.layout.ExperimentalLayoutApi`
`import androidx.compose.foundation.layout.FlowRow`
`import androidx.compose.material.icons.automirrored.filled.QrCodeScanner`
]>
</detail>
</step&gt>
<step>
<description>Исправить MainScaffold.kt.</description>
<detail>
<!CDATA[
Проверить импорты для `AutoMirrored` и `ArrowBack`. Они должны быть:
`import androidx.compose.material.icons.AutoMirrored`
`import androidx.compose.material.icons.filled.ArrowBack`
Использование должно быть `Icons.AutoMirrored.Filled.ArrowBack`.
]>
</detail>
</step>
<step>
<description>Запустить сборку проекта.</description>
<detail>
<!CDATA[
После внесения всех изменений, запустить команду `./gradlew clean build` и убедиться, что сборка проходит без ошибок.
]>
</detail>
</step>
</instructions>
</task>
</work_order>

View File

@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<WorkOrder>
<MetaData>
<OrderID>WO-FEAT-DASH-20250925-001</OrderID>
<Title>Refactor Dashboard Feature into a Separate Module</Title>
<Description>Extract the Dashboard screen, ViewModel, and related components from the app module into a new feature:dashboard module to improve modularity, isolation, and build performance.</Description>
<Priority>High</Priority>
<Status>зутвштп</Status>
<CreatedBy>Architect</CreatedBy>
<CreatedDate>2025-09-25</CreatedDate>
<EstimatedEffort>4-6 hours</EstimatedEffort>
</MetaData>
<Requirements>
<Functional>
<Item>
<ID>REQ-001</ID>
<Description>Create a new Android Library module named 'feature:dashboard' under the 'feature/dashboard' directory.</Description>
<AcceptanceCriteria>
<Criterion>The module builds successfully as an Android Library.</Criterion>
<Criterion>It includes plugins for Kotlin, Compose, and Hilt.</Criterion>
</AcceptanceCriteria>
</Item>
<Item>
<ID>REQ-002</ID>
<Description>Configure dependencies for the new module.</Description>
<AcceptanceCriteria>
<Criterion>Depends on ':domain' and ':data' modules.</Criterion>
<Criterion>Includes Compose UI, Navigation Compose, Hilt Navigation Compose, and other necessary AndroidX libraries.</Criterion>
<Criterion>No circular dependencies.</Criterion>
</AcceptanceCriteria>
</Item>
<Item>
<ID>REQ-003</ID>
<Description>Include the new module in settings.gradle.kts.</Description>
<AcceptanceCriteria>
<Criterion>Add 'include(":feature:dashboard")' to settings.gradle.kts.</Criterion>
<Criterion>The project syncs without errors.</Criterion>
</AcceptanceCriteria>
</Item>
<Item>
<ID>REQ-004</ID>
<Description>Move Dashboard-related files to the new module.</Description>
<AcceptanceCriteria>
<Criterion>Move DashboardScreen.kt, DashboardViewModel.kt, DashboardUiState.kt from app/src/main/java/com/homebox/lens/ui/screen/dashboard/ to feature/dashboard/src/main/java/com/homebox/lens/feature/dashboard/.</Criterion>
<Criterion>Update package declarations to 'com.homebox.lens.feature.dashboard'.</Criterion>
<Criterion>Ensure all imports are resolved correctly.</Criterion>
</AcceptanceCriteria>
</Item>
<Item>
<ID>REQ-005</ID>
<Description>Update app module dependencies.</Description>
<AcceptanceCriteria>
<Criterion>Add 'implementation(project(":feature:dashboard"))' to app/build.gradle.kts.</Criterion>
<Criterion>Remove any direct dependencies on moved files.</Criterion>
</AcceptanceCriteria>
</Item>
<Item>
<ID>REQ-006</ID>
<Description>Adapt navigation integration.</Description>
<AcceptanceCriteria>
<Criterion>Create a public composable function or NavGraphBuilder extension in the dashboard module for easy integration (e.g., addDashboardScreen).</Criterion>
<Criterion>Update NavGraph.kt in app to import and use the new navigation builder from feature:dashboard.</Criterion>
<Criterion>Navigation to/from Dashboard works unchanged.</Criterion>
</AcceptanceCriteria>
</Item>
<Item>
<ID>REQ-007</ID>
<Description>Ensure Hilt DI works across modules.</Description>
<AcceptanceCriteria>
<Criterion>DashboardViewModel injects dependencies correctly via Hilt.</Criterion>
<Criterion>No DI-related runtime errors.</Criterion>
</AcceptanceCriteria>
</Item>
<Item>
<ID>REQ-008</ID>
<Description>Verify build and runtime.</Description>
<AcceptanceCriteria>
<Criterion>The entire project builds successfully (./gradlew build).</Criterion>
<Criterion>Dashboard screen renders and functions as before.</Criterion>
<Criterion>No regressions in other features.</Criterion>
</AcceptanceCriteria>
</Item>
</Functional>
<NonFunctional>
<Item>
<ID>NF-001</ID>
<Description>Follow Semantic Enrichment Protocol for all code changes.</Description>
<AcceptanceCriteria>
<Criterion>All .kt files include [FILE] header, [SEMANTICS], anchors, contracts, and [END_FILE].</Criterion>
<Criterion>No stray comments; use [AI_NOTE] if needed.</Criterion>
</AcceptanceCriteria>
</Item>
<Item>
<ID>NF-002</ID>
<Description>Maintain code quality.</Description>
<AcceptanceCriteria>
<Criterion>Run ktlint and fix any issues.</Criterion>
<Criterion>Add or update unit tests if necessary.</Criterion>
</AcceptanceCriteria>
</Item>
</NonFunctional>
</Requirements>
<ImplementationGuidelines>
<Step>
<ID>STEP-001</ID>
<Description>Create directory structure: feature/dashboard/src/main/java/com/homebox/lens/feature/dashboard/.</Description>
</Step>
<Step>
<ID>STEP-002</ID>
<Description>Generate build.gradle.kts for the new module, mirroring app's Compose/Hilt setup but as library.</Description>
</Step>
<Step>
<ID>STEP-003</ID>
<Description>Update settings.gradle.kts.</Description>
</Step>
<Step>
<ID>STEP-004</ID>
<Description>Move files and update packages/imports.</Description>
</Step>
<Step>
<ID>STEP-005</ID>
<Description>Update app/build.gradle.kts dependencies.</Description>
</Step>
<Step>
<ID>STEP-006</ID>
<Description>Implement navigation extension in dashboard module and update NavGraph.kt.</Description>
<Example>
In dashboard: fun NavGraphBuilder.addDashboardScreen(navController: NavHostController) { composable("dashboard") { DashboardScreen(navController) } }
In app/NavGraph: import com.homebox.lens.feature.dashboard.addDashboardScreen; NavHost { addDashboardScreen(navController) }
</Example>
</Step>
<Step>
<ID>STEP-007</ID>
<Description>Sync project, build, and test runtime behavior.</Description>
</Step>
<Step>
<ID>STEP-008</ID>
<Description>Apply Semantic Enrichment to all modified/created files.</Description>
</Step>
</ImplementationGuidelines>
<TestingRequirements>
<UnitTests>
<Item>Ensure existing DashboardViewModel tests pass if any exist.</Item>
<Item>Add integration test for navigation if needed.</Item>
</UnitTests>
<IntegrationTests>
<Item>Verify app launches and navigates to Dashboard without errors.</Item>
</IntegrationTests>
</TestingRequirements>
<Risks>
<Risk>
<ID>RISK-001</ID>
<Description>Navigation breaks due to package changes.</Description>
<Mitigation>Test navigation immediately after move.</Mitigation>
</Risk>
<Risk>
<ID>RISK-002</ID>
<Description>Hilt injection fails across modules.</Description>
<Mitigation>Ensure shared modules (domain/data) provide dependencies.</Mitigation>
</Risk>
</Risks>
<SuccessCriteria>
<Item>Project builds and runs without errors.</Item>
<Item>Dashboard functionality unchanged.</Item>
<Item>New module is isolated and can be built independently.</Item>
<Item>All code follows Semantic Enrichment Protocol.</Item>
</SuccessCriteria>
</WorkOrder>

View File

@@ -0,0 +1,80 @@
# Work Order: Update Item Creation and Edit to Full API Compliance
## METADATA
- **FEATURE_NAME**: Item Creation and Edit Screen Enhancement
- **REQUESTED_BY**: user
- **TIMESTAMP**: 2025-09-25T07:15:00Z
## OVERVIEW
This work order outlines the steps required to update the Item creation and editing functionality in the Homebox Lens mobile application to fully comply with the Homebox API specification. This includes enhancing the UI to capture all required fields and updating the ViewModel to correctly map these fields to the domain models.
## REQUIREMENTS GAPS
Current implementation in `app/src/main/java/com/homebox/lens/ui/screen/itemedit/ItemEditScreen.kt` and `app/src/main/java/com/homebox/lens/ui/screen/itemedit/ItemEditViewModel.kt` only handles a subset of the fields defined in `tech_spec/api_summary.md`.
Missing UI fields for `Item`:
- `assetId`
- `notes`
- `serialNumber`
- `value`
- `purchasePrice`
- `purchaseDate`
- `warrantyUntil`
- `parentId`
Missing ViewModel mappings:
- All the above fields are hardcoded to `null` in `ItemCreate` and `ItemUpdate` objects.
## STEPS
### STEP 1: Enhance UI Layer (ItemEditScreen.kt)
#### Description
Update the `ItemEditScreen` composable to include input fields for all missing item properties.
#### Action
- Add `TextField` or appropriate input components for `assetId`, `notes`, `serialNumber`, `value`, `purchasePrice`.
- Add `DatePicker` components for `purchaseDate` and `warrantyUntil`.
- Add `TextField` for `parentId`.
- Implement a multi-select component for `labelIds` to allow selecting multiple labels from a list.
- Ensure `locationId` selection is properly implemented (verify existing functionality).
### STEP 2: Update ViewModel Layer (ItemEditViewModel.kt)
#### Description
Update `ItemEditViewModel` to handle the new UI fields and correctly map them to domain models.
#### Action
- Update `ItemEditUiState` sealed interface or data class to include all new fields from STEP 1.
- Add corresponding handler functions like `onAssetIdChanged`, `onNotesChanged`, etc., to update the UI state.
- Modify `createItem` and `updateItem` functions to properly map all fields from `uiState` to `ItemCreate` and `ItemUpdate` domain models instead of hardcoding them to `null`.
### STEP 3: Integrate QR Scanner with Item Creation
#### Description
Modify the QR scanner feature to automatically populate the `assetId` field when navigating to the item creation screen.
#### Action
- Update `ScanScreen` to navigate to `ItemEditScreen` with the scanned barcode as pre-filled `assetId`.
- Add navigation logic in `ScanViewModel` to handle the transition.
- Ensure `ItemEditScreen` can receive and use this pre-filled value.
### STEP 4: Update Project Manifest
#### Description
Update `tech_spec/PROJECT_MANIFEST.xml` to reflect the changes in item creation/editing functionality.
#### Action
- Add a new `<FEATURE>` entry for "Item Creation and Edit Enhancement" or update the existing one if it already covers item creation.
- Include all relevant components, classes, and properties in the manifest.
### STEP 5: Create Engineer Task
#### Description
Create a task for the engineer to implement the outlined changes.
#### Action
- Save this work order to a file in the `tasks` directory.
- Switch to Engineer and provide this work order as a task.