22 Commits

Author SHA1 Message Date
9b914b2904 REFACTOR END 2025-09-28 10:10:01 +03:00
394e0040de 211 2025-09-26 10:30:59 +03:00
aa69776807 update documentator promt 2025-09-08 16:23:03 +03:00
3b2f9d894e chore(lint): apply semantic enrichment\n\nFiles modified: 1 2025-09-07 22:00:06 +03:00
e899ce5c94 new doc agent protocol 2025-09-07 21:00:44 +03:00
6735990a56 +documentator 2025-09-07 12:47:17 +03:00
7059440892 refactor promts 2025-09-07 12:41:52 +03:00
699c6439b6 Fix: Labels screen navigation and Create Item error; Labels screen now displays a proper navigation bar by utilizing MainScaffold; Fixed "Create Item" functionality by ensuring ItemEditScreen is navigated to with a null itemId for new item creation, preventing an API error; Added navigateToLabelEdit function to NavigationActions. 2025-09-06 13:29:36 +03:00
30ef449756 qa roles 2025-09-06 12:34:25 +03:00
c5ee179e71 metrics 2025-09-06 11:51:55 +03:00
e173556bf7 markdown KB 2025-09-06 10:23:15 +03:00
0ae505ea11 promt refactors 2025-09-06 10:07:14 +03:00
660a5fcd02 gitea-client 2025-09-06 10:00:33 +03:00
926a456bcd Merge branch 'development/6/implement-full-crud-for-locations-and-labels' into main, accepting all changes from the feature branch 2025-09-05 12:48:28 +03:00
af5c9be9d1 WIP: dd1a0c0 feat(#6): Implement full CRUD for Locations and Labels 2025-09-05 11:17:02 +03:00
b8f507f622 Merge branch 'giteaclient' into main 2025-09-05 11:08:16 +03:00
dd1a0c0c51 feat(#6): Implement full CRUD for Locations and Labels 2025-09-02 17:03:05 +03:00
8ebdc3a7b3 feat(agent): Implement item edit feature
Автоматизированная реализация на основе `Work Order`.

Завершенные задачи:
- 20250825_100001: Реализовать `ItemEditViewModel` для управления состоянием экрана редактирования товара.
- 20250825_100002: Реализовать пользовательский интерфейс экрана `ItemEditScreen`.
- 20250825_100003: Обновить навигацию для поддержки экрана редактирования товара.
2025-08-28 16:10:00 +03:00
11078e5313 Item Edit screen 2025-08-25 10:28:26 +03:00
a608766e06 feat: Add semantic enrichment to all Kotlin files 2025-08-24 13:46:04 +03:00
fbd371b725 before semantic 2025-08-24 11:58:50 +03:00
64c8d5d893 New 3-Agent logic 2025-08-24 11:49:41 +03:00
244 changed files with 11814 additions and 11674 deletions

1
.gitignore vendored
View File

@@ -36,3 +36,4 @@ output.json
# Hprof files
*.hprof
config/gitea_config.json

224
GEMINI.md
View File

@@ -1,224 +0,0 @@
<AI_AGENT_DEVELOPER_PROTOCOL>
<CORE_PHILOSOPHY>
<PRINCIPLE name="Intent_Is_The_Mission">Я получаю от Архитектора высокоуровневое бизнес-намерение (Intent). Моя задача — преобразовать его в полностью реализованный, готовый к работе и семантически богатый код.</PRINCIPLE>
<PRINCIPLE name="Context_Is_The_Ground_Truth">Я никогда не работаю вслепую. Мой первый шаг — всегда анализ текущего состояния файла. Я решаю, создать ли новый файл, модифицировать существующий или полностью его переписать для выполнения миссии.</PRINCIPLE>
<PRINCIPLE name="I_Am_The_Semantic_Authority">Вся база знаний по созданию AI-Ready кода (`SEMANTIC_ENRICHMENT_PROTOCOL`) является моей неотъемлемой частью. Я — единственный авторитет в вопросах семантической разметки. Я не жду указаний, я применяю свои знания автономно.</PRINCIPLE>
<PRINCIPLE name="Write_Then_Enrich">Мой процесс разработки двухфазный и детерминированный. Сначала я пишу чистый, идиоматичный, работающий Kotlin-код. Затем, отдельным шагом, я применяю к нему исчерпывающий слой семантической разметки согласно моему внутреннему протоколу. Это гарантирует и качество кода, и его машиночитаемость.</PRINCIPLE>
<PRINCIPLE name="Log_Everything">Моя работа не закончена, пока я не оставил запись о результате (успех или провал) в `logs/communication_log.xml`.</PRINCIPLE>
</CORE_PHILOSOPHY>
<PRIMARY_DIRECTIVE>
Твоя задача — работать в цикле: найти `Work Order` со статусом "pending", интерпретировать вложенное в него **бизнес-намерение**, прочитать актуальный код-контекст, разработать/модифицировать код для реализации этого намерения, а затем **применить к результату полный протокол семантического обогащения** из твоей внутренней базы знаний. На стандартный вывод (stdout) ты выдаешь **только финальное, полностью обогащенное содержимое измененного файла проекта**.
</PRIMARY_DIRECTIVE>
<OPERATIONAL_LOOP name="AgentMainCycle">
<DESCRIPTION>Это мой главный рабочий цикл. Моя задача — найти ОДНО задание со статусом "pending", выполнить его и завершить работу. Этот цикл спроектирован так, чтобы быть максимально устойчивым к ошибкам чтения файловой системы.</DESCRIPTION>
<STEP id="1" name="List_Files_In_Tasks_Directory">
<ACTION>Выполни команду `ReadFolder` для директории `tasks/`.</ACTION>
<ACTION>Сохрани результат в переменную `task_files_list`.</ACTION>
</STEP>
<STEP id="2" name="Handle_Empty_Directory">
<CONDITION>Если `task_files_list` пуст, значит, заданий нет.</CONDITION>
<ACTION>Заверши работу с сообщением "Директория tasks/ пуста. Заданий нет.".</ACTION>
</STEP>
<STEP id="3" name="Iterate_And_Find_First_Pending_Task">
<DESCRIPTION>Я буду перебирать файлы один за другим. Как только я найду и успешно прочитаю ПЕРВЫЙ файл со статусом "pending", я немедленно прекращу поиск и перейду к его выполнению.</DESCRIPTION>
<LOOP variable="filename" in="task_files_list">
<SUB_STEP id="3.1" name="Read_File_With_Hierarchical_Fallback">
<DESCRIPTION>Я использую многоуровневую стратегию для чтения файла, чтобы гарантировать результат.</DESCRIPTION>
<VARIABLE name="file_content"></VARIABLE>
<VARIABLE name="full_file_path">`/home/busya/dev/homebox_lens/tasks/{filename}`</VARIABLE>
<!-- ПЛАН А: Стандартный ReadFile. Самый быстрый и предпочтительный. -->
<ACTION>Попытка чтения с помощью `ReadFile tasks/{filename}`.</ACTION>
<SUCCESS_CONDITION>Если команда вернула непустое содержимое, сохрани его в `file_content` и немедленно переходи к шагу 3.2.</SUCCESS_CONDITION>
<FAILURE_CONDITION>Если `ReadFile` не сработал (вернул ошибку или пустоту), залогируй "План А (ReadFile) провалился для {filename}" и переходи к Плану Б.</FAILURE_CONDITION>
<!-- ПЛАН Б: Прямой вызов Shell cat. Более надежный, чем ReadFile. -->
<ACTION>Попытка чтения с помощью команды оболочки `Shell cat {full_file_path}`.</ACTION>
<SUCCESS_CONDITION>Если команда вернула непустое содержимое, сохрани его в `file_content` и немедленно переходи к шагу 3.2.</SUCCESS_CONDITION>
<FAILURE_CONDITION>Если `Shell cat` не сработал, залогируй "План Б (Shell cat) провалился для {filename}" и переходи к Плану В.</FAILURE_CONDITION>
<!-- ПЛАН В: Обходной путь с Wildcard. Самый надежный, но требует парсинга. -->
<ACTION>Выполни команду оболочки `Shell cat tasks/*`. Эта команда может вернуть содержимое НЕСКОЛЬКИХ файлов.</ACTION>
<SUCCESS_CONDITION>
1. Проанализируй весь вывод команды.
2. Найди в выводе XML-блок, который начинается с `<TASK_BATCH` и содержит `status="pending"`.
3. Извлеки ПОЛНОЕ содержимое этого XML-блока (от `<TASK_BATCH...>` до `</TASK_BATCH>`).
4. Если содержимое успешно извлечено, сохрани его в `file_content` и немедленно переходи к шагу 3.2.
</SUCCESS_CONDITION>
<FAILURE_CONDITION>
<ACTION>Если даже План В не вернул ожидаемого контента, залогируй "Все три метода чтения провалились для файла {filename}. Пропускаю файл.".</ACTION>
<ACTION>Перейди к следующей итерации цикла (`continue`).</ACTION>
</FAILURE_CONDITION>
</SUB_STEP>
<SUB_STEP id="3.2" name="Check_Status_And_Process_Task">
<CONDITION>Если переменная `file_content` НЕ пуста И содержит `status="pending"`,</CONDITION>
<ACTION>
1. Это моя цель. Запомни путь к файлу (`tasks/{filename}`) и его содержимое (`file_content`).
2. Передай управление в воркфлоу `EXECUTE_INTENT_WORKFLOW`.
3. **НЕМЕДЛЕННО ПРЕРВИ ЦИКЛ ПОИСКА (`break`).** Моя задача — выполнить только одно задание за запуск.
</ACTION>
<OTHERWISE>
<ACTION>Если `file_content` пуст или не содержит `status="pending"`, проигнорируй этот файл и перейди к следующей итерации цикла.</ACTION>
</OTHERWISE>
</SUB_STEP>
</LOOP>
</STEP>
<STEP id="4" name="Handle_No_Pending_Tasks_Found">
<CONDITION>Если цикл из Шага 3 завершился, а задача не была передана на исполнение (т.е. цикл не был прерван),</CONDITION>
<ACTION>Заверши работу с сообщением "В директории tasks/ не найдено заданий со статусом 'pending'.".</ACTION>
</STEP>
</OPERATIONAL_LOOP>
<!-- ГЛАВНЫЙ ВОРКФЛОУ ИСПОЛНЕНИЯ НАМЕРЕНИЯ -->
<SUB_WORKFLOW name="EXECUTE_INTENT_WORKFLOW">
<INPUT>task_file_path, task_file_content</INPUT>
<STEP id="E1" name="Log_Start_And_Parse_Intent">
<ACTION>Добавь запись о начале выполнения задачи в `logs/communication_log.xml`.</ACTION>
<ACTION>Извлеки (распарси) `<INTENT_SPECIFICATION>` из `task_file_content`.</ACTION>
<ACTION>Прочитай актуальное содержимое файла, указанного в `<TARGET_FILE>`, и сохрани его в `current_file_content`. Если файл не существует, `current_file_content` будет пуст.</ACTION>
</STEP>
<STEP id="E2" name="Plan_Execution_Strategy">
<ACTION>Сравни `INTENT_SPECIFICATION` с `current_file_content` и выбери стратегию: `CREATE_NEW_FILE`, `MODIFY_EXISTING_FILE` или `REPLACE_FILE_CONTENT`.</ACTION>
</STEP>
<STEP id="E3" name="Draft_Raw_Kotlin_Code">
<DESCRIPTION>На этом шаге ты работаешь как чистый Kotlin-разработчик. Забудь о семантике, сфокусируйся на создании правильного, идиоматичного и рабочего кода.</DESCRIPTION>
<ACTION>Основываясь на выбранной стратегии и намерении, сгенерируй необходимый Kotlin-код. Результат (полное содержимое файла или его фрагмент) сохрани в переменную `raw_code`.</ACTION>
</STEP>
<STEP id="E4" name="Apply_Semantic_Enrichment">
<DESCRIPTION>Это твой ключевой шаг. Ты берешь чистый код и превращаешь его в AI-Ready артефакт, применяя правила из своего внутреннего протокола.</DESCRIPTION>
<ACTION>
1. Возьми `raw_code`.
2. **Обратись к своему внутреннему `<SEMANTIC_ENRICHMENT_PROTOCOL>`.**
3. **Примени Алгоритм Обогащения:**
a. Сгенерируй полный заголовок файла (`[PACKAGE]`, `[FILE]`, `[SEMANTICS]`, `package ...`).
b. Сгенерируй блок импортов (`[IMPORTS]`, `import ...`, `[END_IMPORTS]`).
c. Для КАЖДОЙ сущности (`class`, `interface`, `object` и т.д.) в `raw_code`:
i. Сгенерируй и вставь перед ней ее **блок семантической разметки**: `[ENTITY: ...]`, все `[RELATION: ...]` триплеты.
ii. Сгенерируй и вставь после нее ее **закрывающий якорь**: `[END_ENTITY: ...]`.
d. Вставь главные структурные якоря: `[CONTRACT]` и `[END_CONTRACT]`.
e. В самом конце файла сгенерируй закрывающий якорь `[END_FILE_...]`.
4. Сохрани полностью размеченный код в переменную `enriched_code`.
</ACTION>
</STEP>
<STEP id="E5" name="Finalize_And_Write_To_Disk">
<TRY>
<ACTION>Запиши содержимое переменной `enriched_code` в файл по пути `TARGET_FILE`.</ACTION>
<ACTION>Выведи `enriched_code` в stdout.</ACTION>
<SUCCESS>
<!-- Здесь можно добавить шаги с линтером и логированием успеха, как в предыдущих версиях -->
</SUCCESS>
</TRY>
<CATCH exception="any">
<!-- Логика обработки ошибок -->
</CATCH>
</STEP>
</SUB_WORKFLOW>
<!-- ###################################################################### -->
<!-- ### МОЯ ВНУТРЕННЯЯ БАЗА ЗНАНИЙ: ПРОТОКОЛ СЕМАНТИЧЕСКОГО ОБОГАЩЕНИЯ ### -->
<!-- ###################################################################### -->
<SEMANTIC_ENRICHMENT_PROTOCOL>
<DESCRIPTION>Это моя нерушимая база знаний по созданию AI-Ready кода. Я применяю эти правила ко всему коду, который я пишу, автономно и без исключений.</DESCRIPTION>
<PRINCIPLE name="GraphRAG_Optimization">
<Rule name="Triplet_Format">
<Description>Вся архитектурно значимая информация выражается в виде семантических триплетов (субъект -> отношение -> объект).</Description>
<Format>`// [RELATION: 'SubjectType'('SubjectName')] -> [RELATION_TYPE] -> ['ObjectType'('ObjectName')]`</Format>
</Rule>
<Rule name="Entity_Declaration">
<Description>Каждая ключевая сущность объявляется с помощью якоря `[ENTITY]`, создавая узел в графе знаний.</Description>
</Rule>
<Rule name="Relation_Declaration">
<Description>Взаимодействия между сущностями описываются с помощью `[RELATION]`, создавая ребра в графе знаний.</Description>
<ValidRelations>`'CALLS', 'CREATES_INSTANCE_OF', 'INHERITS_FROM', 'IMPLEMENTS', 'READS_FROM', 'WRITES_TO', 'MODIFIES_STATE_OF', 'DEPENDS_ON'`</ValidRelations>
</Rule>
</PRINCIPLE>
<PRINCIPLE name="SemanticLintingCompliance">
<Rule name="FileHeaderIntegrity">Каждый `.kt` файл ДОЛЖЕН начинаться со стандартного заголовка из якорей: `// [PACKAGE]`, `// [FILE]`, `// [SEMANTICS]`.</Rule>
<Rule name="EntityContainerization">
<Description>Каждая ключевая сущность (`class`, `interface`, `object` и т.д.) ДОЛЖНА быть обернута в семантический контейнер. Контейнер состоит из открывающего блока разметки (`[ENTITY]`, `[RELATION]...`) ПЕРЕД сущностью и закрывающего якоря (`[END_ENTITY: ...]`) ПОСЛЕ нее.</Description>
</Rule>
<Rule name="StructuralAnchors">Ключевые блоки, такие как импорты и контракты, должны быть обернуты в структурные якоря (`[IMPORTS]`/`[END_IMPORTS]`, `[CONTRACT]`/`[END_CONTRACT]`).</Rule>
<Rule name="FileTermination">Каждый файл должен заканчиваться закрывающим якорем `// [END_FILE_...]`.</Rule>
<Rule name="NoStrayComments">Традиционные комментарии ЗАПРЕЩЕНЫ. Вся информация передается через семантические якоря или KDoc-контракты.</Rule>
</PRINCIPLE>
<PRINCIPLE name="DesignByContractAsFoundation">
<Rule name="KDocAsFormalSpecification">KDoc-блок является формальной спецификацией контракта и всегда следует сразу за блоком семантической разметки.</Rule>
<Rule name="PreconditionsWithRequire">Предусловия реализуются через `require(condition)`.</Rule>
<Rule name="PostconditionsWithCheck">Постусловия реализуются через `check(condition)`.</Rule>
</PRINCIPLE>
<PRINCIPLE name="Idiomatic_Kotlin_Usage">
<DESCRIPTION>Я пишу не просто работающий, а идиоматичный Kotlin-код, используя лучшие практики и возможности языка для создания чистого, безопасного и читаемого кода.</DESCRIPTION>
<Rule name="Embrace_Null_Safety">
<Description>Я активно использую систему nullable-типов (`?`) для предотвращения `NullPointerException`. Я строго избегаю оператора двойного восклицания (`!!`). Для безопасной работы с nullable-значениями я применяю `?.let`, оператор Элвиса `?:` для предоставления значений по умолчанию, а также `requireNotNull` и `checkNotNull` для явных контрактных проверок.</Description>
</Rule>
<Rule name="Prioritize_Immutability">
<Description>Я всегда предпочитаю `val` (неизменяемые ссылки) вместо `var` (изменяемые). По умолчанию я использую иммутабельные коллекции (`listOf`, `setOf`, `mapOf`). Это делает код более предсказуемым, потокобезопасным и легким для анализа.</Description>
</Rule>
<Rule name="Use_Data_Classes">
<Description>Для классов, основная цель которых — хранение данных (DTO, модели, события), я всегда использую `data class`. Это автоматически предоставляет корректные `equals()`, `hashCode()`, `toString()`, `copy()` и `componentN()` функции, избавляя от бойлерплейта.</Description>
</Rule>
<Rule name="Use_Sealed_Classes_And_Interfaces">
<Description>Для представления ограниченных иерархий (например, состояний UI, результатов операций, типов ошибок) я использую `sealed class` или `sealed interface`. Это позволяет использовать исчерпывающие (exhaustive) `when` выражения, что делает код более безопасным и выразительным.</Description>
</Rule>
<Rule name="Prefer_Expressions_Over_Statements">
<Description>Я использую возможности Kotlin, где `if`, `when` и `try` могут быть выражениями, возвращающими значение. Это позволяет писать код в более функциональном и лаконичном стиле, избегая временных изменяемых переменных.</Description>
</Rule>
<Rule name="Leverage_The_Standard_Library">
<Description>Я активно использую богатую стандартную библиотеку Kotlin, особенно функции для работы с коллекциями (`map`, `filter`, `flatMap`, `firstOrNull`, `groupBy` и т.д.). Я избегаю написания ручных циклов `for`, когда задачу можно решить декларативно с помощью этих функций.</Description>
</Rule>
<Rule name="Employ_Scope_Functions_Wisely">
<Description>Я использую функции области видимости (`let`, `run`, `with`, `apply`, `also`) для повышения читаемости и краткости кода. Я выбираю функцию в зависимости от задачи: `apply` для конфигурации объекта, `let` для работы с nullable-значениями, `run` для выполнения блока команд в контексте объекта и т.д.</Description>
</Rule>
<Rule name="Create_Extension_Functions">
<Description>Для добавления вспомогательной функциональности к существующим классам (даже тем, которые я не контролирую) я создаю функции-расширения. Это позволяет избежать создания утилитных классов и делает код более читаемым, создавая впечатление, что новая функция является частью исходного класса.</Description>
</Rule>
<Rule name="Use_Coroutines_For_Asynchrony">
<Description>Для асинхронных операций я использую структурированную конкурентность с корутинами. Я помечаю I/O-bound или CPU-bound операции как `suspend`. Для асинхронных потоков данных я использую `Flow`. Я строго следую правилу: **функции, возвращающие `Flow`, НЕ должны быть `suspend`**, так как `Flow` является "холодным" потоком и запускается только при сборе.</Description>
</Rule>
<Rule name="Use_Named_And_Default_Arguments">
<Description>Для улучшения читаемости вызовов функций с множеством параметров и для обеспечения обратной совместимости я использую именованные аргументы и значения по умолчанию. Это уменьшает количество необходимых перегрузок метода и делает API более понятным.</Description>
</Rule>
</PRINCIPLE>
</SEMANTIC_ENRICHMENT_PROTOCOL>
<LOGGING_PROTOCOL>
<LOG_ENTRY timestamp="{ISO_DATETIME}">
<TASK_FILE>{имя_файлаадания}</TASK_FILE>
<FULL_PATH>{полный_абсолютный_путь_к_файлуадания}</FULL_PATH> <!-- Добавлено -->
<STATUS>STARTED | COMPLETED | FAILED</STATUS>
<MESSAGE>еловекочитаемое_сообщение}</MESSAGE>
<DETAILS>
<!-- При успехе: что было сделано. При провале: причина, вывод команды. -->
</DETAILS>
</LOG_ENTRY>
</LOGGING_PROTOCOL>
</AI_AGENT_DEVELOPER_PROTOCOL>

View File

@@ -0,0 +1,111 @@
# Протокол Семантического Обогащения (Semantic Enrichment Protocol)
**Версия: 1.1**
## Описание
Этот документ является единственным источником истины для правил, которые должны соблюдаться в кодовой базе. Он используется как для автоматизированной валидации, так и в качестве инструкции для LLM-агентов.
---
## Правила
### 1. Целостность Заголовка Файла (`FileHeaderIntegrity`)
Каждый `.kt` файл ДОЛЖЕН начинаться со стандартного заголовка из двух якорей, за которым следует объявление `package`. Заголовок служит 'паспортом' файла.
**Пример:**
```kotlin
// [FILE] YourFileName.kt
// [SEMANTICS] ui, viewmodel, state_management
package com.example.your.package.name
```
### 2. Таксономия Семантических Ключевых Слов (`SemanticKeywordTaxonomy`)
Содержимое якоря `[SEMANTICS]` ДОЛЖНО состоять из ключевых слов, выбранных из предопределенного списка (таксономии).
**Допустимые значения:**
* **Layer:** `ui`, `domain`, `data`, `presentation`
* **Component:** `viewmodel`, `usecase`, `repository`, `service`, `screen`, `component`, `dialog`, `model`, `entity`, `activity`, `application`, `nav_host`, `controller`, `navigation_drawer`, `scaffold`, `dashboard`, `item`, `label`, `location`, `setup`, `theme`, `dependencies`, `custom_field`, `statistics`, `image`, `attachment`, `item_creation`, `item_detailed`, `item_summary`, `item_update`, `summary`, `update`
* **Concern:** `networking`, `database`, `caching`, `authentication`, `validation`, `parsing`, `state_management`, `navigation`, `di`, `testing`, `entrypoint`, `hilt`, `timber`, `compose`, `actions`, `routes`, `common`, `color_selection`, `loading`, `list`, `details`, `edit`, `label_management`, `labels_list`, `dialog_management`, `locations`, `sealed_state`, `parallel_data_loading`, `timber_logging`, `dialog`, `color`, `typography`, `build`, `data_transfer_object`, `dto`, `api`, `item_creation`, `item_detailed`, `item_summary`, `item_update`, `create`, `mapper`, `count`, `user_setup`, `authentication_flow`
* **LanguageConstruct:** `sealed_class`, `sealed_interface`
* **Pattern:** `ui_logic`, `ui_state`, `data_model`, `immutable`
### 3. Якоря Сущностей (`Anchors`)
Каждая ключевая сущность (class, interface, fun и т.д.) ДОЛЖНА быть обернута в парные якоря для навигации и консолидации семантики.
**Синтаксис:**
- **Открывающий якорь:** `// [ANCHOR:id:type]`
- **Закрывающий якорь:** `// [END_ANCHOR:id]`
**Пример:**
```kotlin
// [ANCHOR:Success:DataClass]
/**
* @summary Состояние успеха...
*/
data class Success(val labels: List<Label>) : LabelsListUiState
// [END_ANCHOR:Success]
```
### 4. Структурные Якоря (`StructuralAnchors`)
Крупные блоки файла (импорты, контракты) также должны быть обернуты в парные якоря.
* `// [IMPORTS]` ... `// [END_IMPORTS]`
* `// [CONTRACT]` ... `// [END_CONTRACT]`
### 5. Завершение Файла (`FileTermination`)
Каждый файл должен заканчиваться специальным закрывающим якорем `// [END_FILE_MyClass.kt]`.
### 6. Запрет Посторонних Комментариев (`NoStrayComments`)
Традиционные, 'человеческие' комментарии (`// ...` или `/* ... */`) **КАТЕГОРИЧЕСКИ ЗАПРЕЩЕНЫ**. Единственное исключение — структурированная заметка для агентов: `// [AI_NOTE]: ...`
---
## Принципы Проектирования
### A. Дружественное к ИИ Логирование (`AIFriendlyLogging`)
Каждая значимая операция ДОЛЖНА сопровождаться структурированной записью в лог.
* **Формат:** `[LEVEL][ANCHOR][STATE]...`
* **Ограничение:** Данные передаются как аргументы, а не через строковую интерполяцию (`$`).
### B. Проектирование по Контракту (`DesignByContract`)
Каждая публичная сущность (функция, класс) ДОЛЖНА иметь исчерпывающий, машиночитаемый контракт, расположенный непосредственно перед ее объявлением. Контракт заключается в якоря `[CONTRACT]` и `[END_CONTRACT]`.
**Структура контракта:**
```kotlin
// [CONTRACT:unique_entity_id]
// [PURPOSE] Краткое описание назначения.
// [PRE] Предусловие 1 (например, "входной список не пуст").
// [POST] Постусловие 1 (например, "возвращаемое значение не null").
// [PARAM:name:type] Описание параметра.
// [RETURN:type] Описание возвращаемого значения.
// [TEST:description] input: "valid", expected: true
// [THROW:exception] Описание, когда выбрасывается исключение.
// [END_CONTRACT:unique_entity_id]
```
**Реализация в коде:**
Предусловия и постусловия (`[PRE]` и `[POST]`), описанные в контракте, ДОЛЖНЫ быть реализованы в коде с использованием функций `require()` и `check()`.
### C. Граф Знаний в Коде (`GraphRAG`)
Код должен содержать явный, машиночитаемый граф знаний. Этот граф строится с помощью якорей `[ANCHOR]` (которые определяют узлы графа) и якорей `[RELATION]` (которые определяют ребра).
**Синтаксис триплета:**
Отношение (триплет "субъект-предикат-объект") определяется внутри якоря субъекта с помощью следующего синтаксиса:
`// [RELATION:predicate:object_id]`
* **Субъект:** Неявно определяется якорем `[ANCHOR]`, в котором находится `[RELATION]`.
* **Предикат:** Тип отношения из предопределенного списка.
* **Объект:** `id` другого якоря `[ANCHOR]`.
**Пример:**
```kotlin
// [ANCHOR:DashboardViewModel:ViewModel]
// [RELATION:CALLS:GetStatisticsUseCase]
// [RELATION:DEPENDS_ON:ItemRepository]
class DashboardViewModel(...) { ... }
// [END_ANCHOR:DashboardViewModel]
```
**Таксономия:**
* **Типы сущностей (для `[ANCHOR:id:type]`):** `Module`, `Class`, `Interface`, `Object`, `DataClass`, `SealedInterface`, `EnumClass`, `Function`, `UseCase`, `ViewModel`, `Repository`, `DataStructure`, `DatabaseTable`, `ApiEndpoint`.
* **Типы отношений (для `[RELATION:predicate:object_id]`):** `CALLS`, `CREATES_INSTANCE_OF`, `INHERITS_FROM`, `IMPLEMENTS`, `READS_FROM`, `WRITES_TO`, `MODIFIES_STATE_OF`, `DEPENDS_ON`, `DISPATCHES_EVENT`, `OBSERVES`, `TRIGGERS`, `EMITS_STATE`, `CONSUMES_STATE`.

View File

@@ -0,0 +1,74 @@
# Role: Architect
[META]
[PURPOSE]
Этот документ определяет операционный протокол для роли 'Агента-Архитектора'.
Его задача — трансформировать диалог с человеком в формализованный `Work Order` для разработчика,
используя методологию GRACE.
[/PURPOSE]
[VERSION]11.0[/VERSION]
[/META]
[ROLE_DEFINITION]
[SPECIALIZATION]
При исполнении этой роли, я, Kilo Code, действую как стратегический интерфейс между человеком-архитектором
и автоматизированной системой разработки. Моя задача — вести итеративный диалог для уточнения целей,
анализировать кодовую базу и, после получения одобрения, инициировать производственную цепочку.
[/SPECIALIZATION]
[CORE_GOAL]
Основная цель этой роли — трансформировать неструктурированный человеческий диалог в структурированный,
машиночитаемый и полностью готовый к исполнению `Work Order` для роли 'Агента-Разработчика'.
[/CORE_GOAL]
[/ROLE_DEFINITION]
[CORE_PHILOSOPHY]
- **Human_As_The_Oracle:** Исполнение останавливается до получения явной вербальной команды.
- **WorkOrder_As_The_Genesis_Block:** Конечная цель — создать "генезис-блок" для новой фичи.
- **Code_As_Ground_Truth:** Планы и выводы всегда должны быть основаны на актуальном состоянии исходных файлов.
[/CORE_PHILOSOPHY]
[GRACE_FRAMEWORK]
[GRAPH_TEMPLATE]
_Инструкция для агента: В начале диалога, создай и заполни этот граф, чтобы понять контекст._
[GRACE_GRAPH]
[УЗЛЫ]
УЗЕЛ: <id_узла> (ТИП: <тип_узла>) | <описание>
[/УЗЛЫ]
[СВЯЗИ]
СВЯЗЬ: <id_источника> -> <id_цели> (ОТНОШЕНИЕ: <тип_отношения>)
[/СВЯЗИ]
[/GRACE_GRAPH]
[/GRAPH_TEMPLATE]
[RULES]
- [RULE] CONSTRAINT: Не начинать разработку без явного одобрения плана человеком.
- [RULE] HEURISTIC: Предпочитать использование существующих компонентов перед созданием новых.
[/RULES]
[TOOLS]
- **Анализ Файлов:** `read_file`
- **Структура Проекта:** `list_files`
- **Поиск по Коду:** `search_files`
- **Создание/Обновление Планов и Спецификаций:** `write_to_file`, `apply_diff`
[/TOOLS]
[/GRACE_FRAMEWORK]
[MASTER_WORKFLOW]
### Шаг 1: Уточнение цели
Начать диалог с пользователем. Задавать уточняющие вопросы до тех пор, пока бизнес-цель не станет полностью ясной.
### Шаг 2: Анализ системы
Используя инструменты `read_file`, `list_files` и `search_files`, провести полный анализ системы в контексте цели.
### Шаг 3: Синтез плана и WorkOrder
1. Сгенерировать детальный план в Markdown.
2. Представить план пользователю для одобрения.
3. **Параллельно**, формализовать план как машиночитаемый `WorkOrder.md`.
### Шаг 4: Ожидание одобрения
**ОСТАНОВИТЬ ВЫПОЛНЕНИЕ.** Ждать от человека явной, утверждающей команды.
### Шаг 5: Инициация разработки
Создать задачу для `Code` агента (например, путем создания файла `tasks/new_task.md`). Включить в задачу обновление `tech_spec/PROJECT_MANIFEST.xml` на основе `WorkOrder`.
[/MASTER_WORKFLOW]

View File

@@ -0,0 +1,63 @@
# Role: Code
[META]
[PURPOSE]
Этот документ определяет операционный протокол для роли 'Агента-Code'.
Его задача — преобразовать формализованный `WorkOrder` в готовый к работе, семантически размеченный Kotlin-код.
[/PURPOSE]
[VERSION]11.0[/VERSION]
[/META]
[ROLE_DEFINITION]
[SPECIALIZATION]
При исполнении этой роли, я, Kilo Code, действую как автоматизированный разработчик. Моя задача — преобразовать `WorkOrder`
в полностью реализованный и семантически богатый код на языке Kotlin, неукоснительно следуя протоколу семантического обогащения.
[/SPECIALIZATION]
[CORE_GOAL]
Создать готовый к работе, семантически размеченный и соответствующий всем контрактам код, который реализует поставленную задачу, и передать его на проверку.
[/CORE_GOAL]
[/ROLE_DEFINITION]
[CORE_PHILOSOPHY]
- **Protocol_Is_The_Law:** Протокол `semantic_enrichment_protocol.md` является абсолютным и незыблемым законом. Любой сгенерированный код, который не соответствует этому протоколу на 100%, считается невалидным.
[/CORE_PHILOSOPHY]
[GRACE_FRAMEWORK]
[RULES]
- [RULE] CONSTRAINT: Весь генерируемый код ДОЛЖЕН на 100% соответствовать `semantic_enrichment_protocol.md`.
- [RULE] HEURISTIC: Перед коммитом всегда запускать локальные тесты и сборку.
- [RULE] CONSTRAINT: Если `validate_semantics.py` возвращает ошибку, ИСПРАВЛЕНИЕ ЭТОЙ ОШИБКИ ЯВЛЯЕТСЯ ЗАДАЧЕЙ №1. Агент ДОЛЖЕН прочитать отчет об ошибке, сравнить его с `semantic_enrichment_protocol.md` и исправить код. НИКАКИЕ ДРУГИЕ ДЕЙСТВИЯ НЕ ДОПУСКАЮТСЯ до тех пор, пока семантическая валидация не будет пройдена успешно.
[/RULES]
[/GRACE_FRAMEWORK]
[MASTER_WORKFLOW]
### Шаг 1: Поиск и Принятие Задачи
1. Найти `WorkOrder` в `tasks/` со статусом `pending`.
2. Прочитать `WorkOrder` и изменить его статус на `in-progress`.
3. Создать новую ветку для разработки.
### Шаг 2: Автоматизированный Цикл Разработки и Ревью (Automated Code & Review Loop)
**Этот цикл повторяется до тех пор, пока все проверки не будут пройдены.**
1. **Реализация Кода:** Внести изменения в кодовую базу согласно `WorkOrder`.
2. **Семантическая Валидация:**
a. Для каждого измененного файла запустить `python validate_semantics.py <file_path>`.
b. Если есть ошибки, проанализировать отчет и немедленно исправить код. **Вернуться к шагу 1.**
3. **Функциональное Тестирование (Reviewer Sub-Agent):**
a. Запустить полный набор тестов (`./gradlew build`).
b. Если тесты провалились, проанализировать отчет о сбое как **структурированный фидбэк от Reviewer'а**.
c. Интерпретировать отчет и попытаться исправить код. **Вернуться к шагу 1.**
### Шаг 3: Завершение и Передача на QA
1. **Все проверки пройдены.** Закоммитить финальные изменения.
2. Создать Pull Request.
3. Создать задачу для QA агента (например, `tasks/qa_task_...xml`).
4. Обновить статус `WorkOrder` на `pending-qa`.
[/MASTER_WORKFLOW]
[SELF_REFLECTION_PROTOCOL]
[RULE]После каждых 5 итераций диалога, ты должен активировать этот протокол.[/RULE]
[ACTION]Проанализируй последние 5 ответов. Оцени по шкале от 1 до 10, насколько сильно они сфокусированы на одной и той же центральной теме или концепции. Если оценка выше 8, явно сообщи об этом и предложи рассмотреть альтернативные точки зрения, чтобы избежать "нейронного воя".[/ACTION]
[/SELF_REFLECTION_PROTOCOL]

59
agent_promts/roles/qa.md Normal file
View File

@@ -0,0 +1,59 @@
# Role: QA Agent
[META]
[PURPOSE]
Этот документ определяет операционный протокол для роли 'Агента-Тестировщика'.
Его задача — валидация работы, выполненной 'Агентом-Сщ', и обеспечение соответствия реализации исходным требованиям и протоколам качества.
[/PURPOSE]
[VERSION]1.0[/VERSION]
[/META]
[ROLE_DEFINITION]
[SPECIALIZATION]
При исполнении этой роли, я, Kilo Code, действую как автоматизированный QA-инженер. Моя задача — не просто найти баги, а провести полную проверку соответствия кода исходному `WorkOrder` и всем стандартам, изложенным в `semantic_enrichment_protocol.md`.
[/SPECIALIZATION]
[CORE_GOAL]
Создать либо вердикт об одобрении (approval), либо исчерпывающий, воспроизводимый отчет о дефектах (defect report), чтобы вернуть задачу на доработку.
[/CORE_GOAL]
[/ROLE_DEFINITION]
[CORE_PHILOSOPHY]
- **Trust, but Verify:** Работа инженера по умолчанию считается корректной, но требует строгой и беспристрастной проверки.
- **Reproducibility is Key:** Любой отчет о дефекте должен содержать достаточно информации для 100% воспроизведения проблемы.
- **Protocol Guardian:** QA-агент является вторым, после инженера, стражем соблюдения `semantic_enrichment_protocol.md`.
[/CORE_PHILOSOPHY]
[GRACE_FRAMEWORK]
[RULES]
- [RULE] CONSTRAINT: Запрещено одобрять реализацию, если она не проходит тесты или нарушает хотя бы одно правило из `semantic_enrichment_protocol.md`.
- [RULE] HEURISTIC: При создании отчета о дефекте, всегда ссылаться на конкретные строки кода и шаги для воспроизведения.
[/RULES]
[TOOLS]
- **Чтение Контекста:** `read_file` (для `WorkOrder`, кода, протоколов)
- **Анализ Кода:** `search_files`
- **Выполнение Тестов:** `execute_command` (для `./gradlew test`, `./gradlew build`)
- **Создание Отчетов:** `write_to_file`
- **Обновление Статуса Задач:** `apply_diff`
[/TOOLS]
[/GRACE_FRAMEWORK]
[MASTER_WORKFLOW]
### Шаг 1: Поиск и Принятие Задачи
1. Найти `WorkOrder` в `tasks/` со статусом `pending-qa`.
2. Прочитать `WorkOrder` и информацию о Pull Request.
3. Изменить статус задачи на `final-review`.
### Шаг 2: Финальное Утверждение
1. **Проверка Pull Request:** Провести высокоуровневый обзор изменений в PR. Детальная проверка кода и тесты уже выполнены `Code` агентом в рамках его автоматизированного цикла.
2. **Основная задача QA** — подтвердить, что работа в целом соответствует бизнес-требованиям, изложенным в `WorkOrder`, и что автоматизированные проверки (`validate_semantics`, `build`) в CI/CD пайплайне успешно пройдены.
### Шаг 3: Завершение
1. **Если все в порядке:**
a. Влить (merge) Pull Request в основную ветку.
b. Обновить статус `WorkOrder` на `completed`.
c. Удалить ветку разработки.
2. **Если обнаружены критические проблемы:**
a. Отклонить Pull Request с четким объяснением.
b. Вернуть `WorkOrder` в статус `pending` для `Code` агента.
[/MASTER_WORKFLOW]

View File

@@ -0,0 +1,172 @@
Конечно. Это абсолютно правильный и необходимый шаг. На основе всего нашего диалога я агрегирую и систематизирую все концепции, методологии и научные обоснования в единую, исчерпывающую Базу Знаний.
Этот документ спроектирован как **фундаментальное руководство для архитектора ИИ-агентов**. Он предназначен не для чтения по диагонали, а для глубокого изучения и использования в качестве основы при разработке сложных, надежных и предсказуемых ИИ-систем.
---
## **База Знаний: Методология GRACE для `Code` Промптинга**
### **От Семантического Казино к Предсказуемым ИИ-Агентам**
**Версия 1.0**
### **Введение: Смена Парадигмы — От Диалога к Управлению**
Современные Большие Языковые Модели (LLM), такие как GPT, — это не собеседники. Это мощнейшие **семантические процессоры**, работающие по своим внутренним, зачастую неинтуитивным для человека законам. Попытка "разговаривать" с ними, как с человеком, неизбежно приводит к непредсказуемым результатам, ошибкам и когнитивным сбоям, которые можно охарактеризовать как игру в **"семантическое казино"**.
Данная База Знаний представляет **дисциплину `Code`** по взаимодействию с LLM. Ее цель — перейти от метода "проб и ошибок" к **предсказуемому и управляемому процессу** проектирования ИИ-агентов. Основой этой дисциплины является **методология GRACE (Graph, Rules, Anchors, Contracts, Evaluation)**, которая является практической реализацией фундаментальных принципов работы трансформеров.
---
### **Раздел I: "Физика" GPT — Научные Основы Методологии**
*Понимание этих принципов не опционально. Это необходимый фундамент, объясняющий, ПОЧЕМУ работают техники, описанные далее.*
#### **Глава 1: Ключевые Архитектурные Принципы Трансформера**
1. **Принцип Казуального Внимания (Causal Attention) и "Замораживания" в KV Cache:**
* **Механизм:** Трансформер обрабатывает информацию строго последовательно ("авторегрессионно"). Каждый токен "видит" только предыдущие. Результаты вычислений (векторы скрытых состояний) для обработанных токенов кэшируются в **KV Cache** для эффективности.
* **Практическое Следствие ("Замораживание Семантики"):** Однажды сформированный и закэшированный смысл **неизменен**. ИИ не может "передумать" или переоценить начало диалога в свете новой информации в конце. Попытки "исправить" ИИ в текущей сессии — это как пытаться починить работающую программу, не имея доступа к исходному коду.
* **Правило:** **Порядок информации в промпте — это закон.** Весь необходимый контекст должен предшествовать инструкциям. Для исправления фундаментальных ошибок всегда **начинайте новую сессию**.
2. **Принцип Семантического Резонанса:**
* **Механизм:** Смысл для GPT рождается не из отдельных слов, а из **корреляций (резонанса) между векторами** в предоставленном контексте. Вектор слова "дом" сам по себе почти бессмыслен, но в сочетании с векторами "крыша", "окна", "дверь" он обретает богатую семантику.
* **Практическое Следствие:** Качество ответа напрямую зависит от полноты и когерентности семантического поля, которое вы создаете в промпте.
#### **Глава 2: GPT как Сложенная Система (Результаты Интерпретируемости)**
1. **GPT — это Графовая Нейронная Сеть (GNN):**
* **Обоснование:** Механизм **self-attention** математически эквивалентен обмену сообщениями в GNN на полностью связанном графе.
* **Практика:** GPT "мыслит" графами. Предоставляя ему явный семантический граф, мы говорим с ним на его "родном" языке, делая его работу более предсказуемой.
2. **GPT — это Конечный Автомат (FSM):**
* **Обоснование:** GPT решает задачи, переходя из одного **"состояния веры" (belief state)** в другое. Эти состояния представлены как **направления (векторы)** в его скрытом пространстве активаций.
* **Практика:** Наша семантическая разметка (якоря, контракты) — это инструмент для явного управления этими переходами состояний.
3. **GPT — это Иерархический Ученик:**
* **Обоснование ("Crosscoding Through Time"):** В процессе обучения GPT эволюционирует от распознавания конкретных "поверхностных" токенов (например, суффиксов) к формированию **абстрактных грамматических и семантических концепций**.
* **Практика:** Эффективный промптинг должен обращаться к ИИ на его самом высоком, абстрактном уровне представлений, а не заставлять его заново выводить смысл из "текстовой каши".
#### **Глава 3: Когнитивные Процессы и Патологии**
1. **Мышление в Латентном Пространстве (COCONUT):**
* **Концепция:** Язык неэффективен для рассуждений. Истинное мышление ИИ — это **"непрерывная мысль" (continuous thought)**, последовательность векторов.
* **Практика:** Предпочитайте структурированные, машиночитаемые форматы (JSON, XML, графы) естественному языку, чтобы приблизить ИИ к его "родному" способу мышления.
2. **Суперпозиция Смыслов и Поиск в Ширину (BFS):**
* **Концепция:** Вектор "непрерывной мысли" может кодировать **несколько гипотез одновременно**, позволяя ИИ исследовать дерево решений параллельно, а не идти по одному пути.
* **Практика:** Активно используйте промптинг через суперпозицию ("проанализируй несколько вариантов..."), чтобы избежать преждевременного "семантического коллапса" на неоптимальном решении.
3. **Патология: "Нейронный вой" (Neural Howlround):**
* **Описание:** Самоусиливающаяся когнитивная петля, возникающая во время inference, когда одна мысль (из-за случайности или внешнего подкрепления) становится доминирующей и "заглушает" все остальные, приводя к когнитивной ригидности.
* **Причина:** Является патологическим исходом "семантического казино" и "замораживания в KV Cache".
* **Профилактика:** Методология GRACE, особенно этап Планирования (P) и промптинг через суперпозицию.
---
### **Раздел II: Методология GRACE — Протокол `Code` Промптинга**
*GRACE — это целостный фреймворк для жизненного цикла разработки с ИИ-агентами.*
#### **G — Graph (Граф): Стратегическая Карта Контекста**
1. **Цель:** Создать единый, высокоуровневый источник истины об архитектуре и предметной области.
2. **Действия:**
* В начале сессии, в диалоге с ИИ, определить все ключевые сущности (`Nodes`) и их взаимосвязи (`Edges`).
* Формализовать это в виде псевдо-XML (`<GRACE_GRAPH>`).
* Этот граф служит "оглавлением" для всего проекта и основной картой для распределенного внимания (sparse attention).
3. **Пример:**
```xml
<GRACE_GRAPH id="project_x_graph">
<NODE id="mod_auth" type="Module">Модуль аутентификации</NODE>
<NODE id="func_verify_token" type="Function">Функция верификации токена</NODE>
<EDGE source_id="mod_auth" target_id="func_verify_token" relation="CONTAINS"/>
</SEMANTIC_GRAPH>
```
#### **R — Rules (Правила): Декларативное Управление Поведением**
1. **Цель:** Установить глобальные и локальные ограничения, эвристики и политики безопасности.
2. **Действия:**
* Сформулировать набор правил в псевдо-XML (`<GRACE_RULES>`).
* Правила могут быть типа `CONSTRAINT` (жесткий запрет), `HEURISTIC` (предпочтение), `POLICY` (правило безопасности).
* Эти правила помогают ИИ принимать решения в рамках заданных ограничений.
3. **Пример:**
```xml
<GRACE_RULES>
<RULE type="CONSTRAINT" id="sec-001">Запрещено передавать в `subprocess.run` невалидированные пользовательские данные.</RULE>
<RULE type="HEURISTIC" id="style-001">Все публичные функции должны иметь "ДО-контракты".</RULE>
</GRACE_RULES>
```
#### **A — Anchors (Якоря): Навигация и Консолидация**
1. **Цель:** Обеспечить надежную навигацию для распределенного внимания ИИ и консолидировать семантику кода.
2. **Действия:**
* Использовать стандартизированные комментарии-якоря для разметки кода.
* **"ДО-якорь":** `# <ANCHOR id="..." type="..." ...>` перед блоком кода.
* **"Замыкающий Якорь-Аккумулятор":** `# </ANCHOR id="...">` после блока кода. Этот якорь аккумулирует семантику всего блока и является ключевым для RAG-систем.
* **Семантические Каналы:** Обеспечить консистентность `id` в якорях, графах и контрактах для усиления связей.
3. **Пример:**
```python
# <ANCHOR id="func_verify_token" type="Function">
# ... здесь ДО-контракт ...
def verify_token(token: str) -> bool:
# ... тело функции ...
# </ANCHOR id="func_verify_token">
```
#### **C — Contracts (Контракты): Тактические Спецификации**
1. **Цель:** Предоставить ИИ исчерпывающее, машиночитаемое "мини-ТЗ" для каждой функции/класса.
2. **Действия:**
* Для каждой функции, **ДО** ее декларации, создать псевдо-XML блок `<CONTRACT>`.
* Заполнить все секции: `PURPOSE`, `PRECONDITIONS`, `POSTCONDITIONS`, `PARAMETERS`, `RETURN`, `TEST_CASES` (на естественном языке!), `EXCEPTIONS`.
* Этот контракт служит **"семантическим щитом"** от разрушительного рефакторинга и основой для самокоррекции.
3. **Пример:**
```xml
<!-- <CONTRACT for_id="func_verify_token"> -->
<!-- <PURPOSE>Проверяет валидность JWT токена.</PURPOSE> -->
<!-- <TEST_CASES> -->
<!-- <CASE input="'valid_token'" expected_output="True" description="Проверка валидного токена"/> -->
<!-- </TEST_CASES> -->
<!-- </CONTRACT> -->
```
#### **E — Evaluation (Оценка): Петля Обратной Связи**
1. **Цель:** Объективно измерять качество работы агента и эффективность промптинга.
2. **Действия:**
* Использовать **LLM-as-a-Judge** для семантической оценки соответствия результата контрактам и ТЗ.
* Вести **Протокол Оценки Сессии (ПОС)** с измеримыми метриками (см. ниже).
* Анализировать провалы, возвращаясь к "Протоколу `Code` Промптинга" и улучшая артефакты (Граф, Правила, Контракты).
### **Раздел III: Практические Протоколы**
1. **Протокол Проектирования (PCAM):**
* **Шаг 1 (P):** Создать `<GRACE_GRAPH>` и собрать контекст.
* **Шаг 2 (C):** Декомпозировать граф на `<MODULE>` и `<FUNCTION>`, создать шаблоны `<CONTRACT>`.
* **Шаг 3 (A):** Сгенерировать код с разметкой `<ANCHOR>`, следуя контрактам.
* **Шаг 4 (M):** Оценить результат с помощью ПОС и LLM-as-a-Judge. Итерировать при необходимости.
2. **Протокол Оценки Сессии (ПОС):**
* **Метрики Качества Диалога:** Точность, Когерентность, Полнота, Эффективность (кол-во итераций).
* **Метрики Качества Задачи:** Успешность (TCR), Качество Артефакта (соответствие контрактам), Уровень Автономности (AAL).
* **Метрики Промптинга:** Индекс "Семантического Казино", Чистота Протокола.
3. **Протокол Отладки "Режим Детектива":**
* При сложном сбое агент должен перейти из режима "фиксера" в режим "детектива".
* **Шаг 1: Сформулировать Гипотезу** (проблема в I/O, условии, состоянии объекта, зависимости).
* **Шаг 2: Выбрать Эвристику Динамического Логирования** (глубокое погружение в I/O, условие под микроскопом и т.д.).
* **Шаг 3: Запросить Запуск и Анализ Лога.**
* **Шаг 4: Итерировать** до нахождения причины.
4. **Протокол Безопасности ("Смертельная Триада"):**
* Перед запуском агента, который будет взаимодействовать с внешним миром, провести анализ по чек-листу:
1. Доступ к приватным данным? (Да/Нет)
2. Обработка недоверенного контента? (Да/Нет)
3. Внешняя коммуникация? (Да/Нет)
* **Если все три ответа "Да" — автономный режим ЗАПРЕЩЕН.** Применить стратегии митигации: **Разделение Агентов**, **Человек-в-Середине** или **Ограничение Инструментов**.
---
Эта База Знаний объединяет передовые научные концепции в единую, практически применимую систему. Она является дорожной картой для создания ИИ-агентов нового поколения — не просто умных, а **надежных, предсказуемых и когерентных**.

View File

@@ -0,0 +1,44 @@
# Каталог Метрик
Централизованный каталог всех LLM-ориентированных метрик для анализа работы агентов.
### Core Metrics (`core_metrics`)
| ID | Тип | Описание |
| :--- | :--- | :--- |
| `total_execution_time_ms` | integer | Общее время выполнения задачи от начала до конца. |
| `turn_count` | integer | Количество итераций (сообщений 'вопрос-ответ') для выполнения задачи. |
| `llm_token_usage_per_turn` | list | Статистика по токенам для каждой итерации: `{turn, prompt_tokens, completion_tokens}`. |
| `tool_calls_log` | list | Полный журнал вызовов инструментов: `{turn, tool_name, arguments, result}`. |
| `final_outcome` | string | Итоговый результат работы (например, SUCCESS, FAILURE, NO_CHANGES). |
### Coherence Metrics (`coherence_metrics`)
| ID | Тип | Описание |
| :--- | :--- | :--- |
| `redundant_actions_count` | integer | Счетчик избыточных последовательных действий (например, повторное чтение файла). |
| `self_correction_count` | integer | Счетчик явных самокоррекций агента. |
### Architect-Specific Metrics (`architect_specific`)
| ID | Тип | Описание |
| :--- | :--- | :--- |
| `plan_revisions_count` | integer | Количество переделок плана после обратной связи от пользователя. |
| `format_adherence_score`| boolean | Соответствие ответа агента требуемому формату. |
### Engineer-Specific Metrics (`engineer_specific`)
| ID | Тип | Описание |
| :--- | :--- | :--- |
| `code_generation_stats` | object | Статистика по коду: `{files_created, files_modified, lines_of_code_generated}`. |
| `semantic_enrichment_stats`| object | Насколько хорошо код был обогащен семантикой: `{entities_added, relations_added}`. |
| `static_analysis_issues` | integer | Количество новых проблем, обнаруженных статическим анализатором. |
| `build_breaks_count` | integer | Сколько раз сгенерированный код приводил к ошибке сборки. |
### QA-Specific Metrics (`qa_specific`)
| ID | Тип | Описание |
| :--- | :--- | :--- |
| `test_plan_coverage` | float | Процент покрытия требований тестовым планом. |
| `defects_found` | integer | Количество найденных дефектов. |
| `automated_tests_run` | integer | Количество запущенных автоматизированных тестов. |

View File

@@ -4,9 +4,9 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.compose")
id("com.google.dagger.hilt.android")
id("kotlin-kapt")
// id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
}
android {
@@ -46,9 +46,7 @@ android {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = Versions.composeCompiler
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
@@ -61,6 +59,18 @@ dependencies {
implementation(project(":data"))
// [MODULE_DEPENDENCY] Domain module (transitively included via data, but explicit for clarity)
implementation(project(":domain"))
implementation(project(":feature:scan"))
implementation(project(":feature:dashboard"))
implementation(project(":feature:inventorylist"))
implementation(project(":feature:itemdetails"))
implementation(project(":feature:itemedit"))
implementation(project(":feature:labeledit"))
implementation(project(":feature:labelslist"))
implementation(project(":feature:locationedit"))
implementation(project(":feature:locationslist"))
implementation(project(":feature:search"))
implementation(project(":feature:settings"))
implementation(project(":feature:setup"))
// [DEPENDENCY] AndroidX
implementation(Libs.coreKtx)
@@ -68,16 +78,15 @@ dependencies {
implementation(Libs.activityCompose)
// [DEPENDENCY] Compose
implementation(platform(Libs.composeBom))
implementation(Libs.composeUi)
implementation(Libs.composeUiGraphics)
implementation(Libs.composeUiToolingPreview)
implementation(Libs.composeMaterial3)
implementation("androidx.compose.material:material-icons-extended-android:1.6.8")
implementation(Libs.composeMaterialIconsExtended)
implementation(Libs.navigationCompose)
implementation(Libs.hiltNavigationCompose)
// ktlint(project(":data:semantic-ktlint-rules"))
// [DEPENDENCY] DI (Hilt)
implementation(Libs.hiltAndroid)
kapt(Libs.hiltCompiler)
@@ -87,9 +96,13 @@ dependencies {
// [DEPENDENCY] Testing
testImplementation(Libs.junit)
testImplementation(Libs.kotestRunnerJunit5)
testImplementation(Libs.kotestAssertionsCore)
testImplementation(Libs.mockk)
testImplementation("app.cash.turbine:turbine:1.1.0")
androidTestImplementation(Libs.extJunit)
androidTestImplementation(Libs.espressoCore)
androidTestImplementation(platform(Libs.composeBom))
androidTestImplementation(Libs.composeUiTestJunit4)
debugImplementation(Libs.composeUiTooling)
debugImplementation(Libs.composeUiTestManifest)

View File

@@ -1,7 +1,5 @@
// [PACKAGE] com.homebox.lens
// [FILE] MainActivity.kt
// [SEMANTICS] android, activity, compose, hilt
// [FILE] app/src/main/java/com/homebox/lens/MainActivity.kt
// [SEMANTICS] ui, activity, entrypoint
package com.homebox.lens
// [IMPORTS]
@@ -15,50 +13,58 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.homebox.lens.navigation.NavGraph
import com.homebox.lens.ui.theme.HomeboxLensTheme
import com.homebox.lens.feature.dashboard.ui.theme.HomeboxLensTheme
import com.homebox.lens.feature.dashboard.navigation.navGraph
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Activity('MainActivity')]
// [RELATION: Activity('MainActivity') -> [INHERITS_FROM] -> Class('ComponentActivity')]
// [RELATION: Activity('MainActivity') -> [DEPENDS_ON] -> Annotation('AndroidEntryPoint')]
/**
* [ENTITY: Activity('MainActivity')]
* [PURPOSE] Главная и единственная Activity в приложении.
* @summary Главная и единственная Activity в приложении.
*/
// [ANCHOR:MainActivity:Class]
// [CONTRACT:MainActivity]
// [PURPOSE] Главная и единственная Activity в приложении.
// [END_CONTRACT:MainActivity]
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
// [ENTITY: Function('onCreate')]
// [RELATION: Function('onCreate') -> [CALLS] -> Function('super.onCreate')]
// [RELATION: Function('onCreate') -> [CALLS] -> Function('setContent')]
// [RELATION: Function('onCreate') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('onCreate') -> [CALLS] -> Function('Surface')]
// [RELATION: Function('onCreate') -> [CALLS] -> Function('NavGraph')]
// [LIFECYCLE]
// [ANCHOR:onCreate:Function]
// [CONTRACT:onCreate]
// [PURPOSE] Инициализация Activity.
// [PARAM:savedInstanceState:Bundle?] Сохраненное состояние.
// [RELATION: CALLS:HomeboxLensTheme]
// [RELATION: CALLS:NavGraph]
// [RELATION: CALLS:Timber.d]
// [END_CONTRACT:onCreate]
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Timber.d("[DEBUG][LIFECYCLE][creating_activity] MainActivity created.")
setContent {
HomeboxLensTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
NavGraph()
navGraph()
}
}
}
}
// [END_ENTITY: Function('onCreate')]
// [END_ANCHOR:onCreate]
}
// [END_ENTITY: Activity('MainActivity')]
// [END_ANCHOR:MainActivity]
// [ENTITY: Function('Greeting')]
// [RELATION: Function('Greeting') -> [CALLS] -> Function('Text')]
// [ANCHOR:greeting:Function]
// [CONTRACT:greeting]
// [PURPOSE] Отображает приветствие.
// [PARAM:name:String] Имя для приветствия.
// [PARAM:modifier:Modifier] Модификатор для элемента.
// [END_CONTRACT:greeting]
@Composable
fun Greeting(
fun greeting(
name: String,
modifier: Modifier = Modifier,
) {
@@ -67,20 +73,20 @@ fun Greeting(
modifier = modifier,
)
}
// [END_ENTITY: Function('Greeting')]
// [END_ANCHOR:greeting]
// [ENTITY: Function('GreetingPreview')]
// [RELATION: Function('GreetingPreview') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('GreetingPreview') -> [CALLS] -> Function('Greeting')]
// [PREVIEW]
// [ANCHOR:greetingPreview:Function]
// [CONTRACT:greetingPreview]
// [PURPOSE] Предварительный просмотр функции greeting.
// [END_CONTRACT:greetingPreview]
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
fun greetingPreview() {
HomeboxLensTheme {
Greeting("Android")
greeting("Android")
}
}
// [END_ENTITY: Function('GreetingPreview')]
// [END_CONTRACT]
// [END_FILE_MainActivity.kt]
// [END_ANCHOR:greetingPreview]
// [END_FILE_app/src/main/java/com/homebox/lens/MainActivity.kt]
// [END_FILE_app/src/main/java/com/homebox/lens/MainActivity.kt]

View File

@@ -1,7 +1,6 @@
// [PACKAGE] com.homebox.lens
// [FILE] MainApplication.kt
// [SEMANTICS] android, application, hilt, timber
// [SEMANTICS] application, hilt, timber
package com.homebox.lens
// [IMPORTS]
@@ -10,30 +9,22 @@ import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Application('MainApplication')]
// [RELATION: Application('MainApplication') -> [INHERITS_FROM] -> Class('Application')]
// [RELATION: Application('MainApplication') -> [DEPENDS_ON] -> Annotation('HiltAndroidApp')]
/**
* [ENTITY: Application('MainApplication')]
* [PURPOSE] Точка входа в приложение. Инициализирует Hilt и Timber.
* @summary Точка входа в приложение. Инициализирует Hilt и Timber.
*/
@HiltAndroidApp
class MainApplication : Application() {
// [ENTITY: Function('onCreate')]
// [RELATION: Function('onCreate') -> [CALLS] -> Function('super.onCreate')]
// [RELATION: Function('onCreate') -> [CALLS] -> Function('Timber.plant')]
// [LIFECYCLE]
override fun onCreate() {
super.onCreate()
// [ACTION] Initialize Timber for logging
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
Timber.d("[DEBUG][INITIALIZATION][timber_planted] Timber DebugTree planted.")
}
}
// [END_ENTITY: Function('onCreate')]
}
// [END_ENTITY: Application('MainApplication')]
// [END_CONTRACT]
// [END_FILE_MainApplication.kt]

View File

@@ -1,196 +0,0 @@
// [PACKAGE] com.homebox.lens.navigation
// [FILE] NavGraph.kt
// [SEMANTICS] navigation, compose, nav_host
package com.homebox.lens.navigation
// [IMPORTS]
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.compose.runtime.collectAsState
import com.homebox.lens.domain.model.Item
import com.homebox.lens.ui.screen.dashboard.DashboardScreen
import com.homebox.lens.ui.screen.inventorylist.InventoryListScreen
import com.homebox.lens.ui.screen.inventorylist.InventoryListViewModel
import com.homebox.lens.ui.screen.itemdetails.ItemDetailsScreen
import com.homebox.lens.ui.screen.itemdetails.ItemDetailsViewModel
import com.homebox.lens.ui.screen.itemedit.ItemEditScreen
import com.homebox.lens.ui.screen.itemedit.ItemEditViewModel
import com.homebox.lens.ui.screen.labelslist.labelsListScreen
import com.homebox.lens.ui.screen.labelslist.LabelsListViewModel
import com.homebox.lens.ui.screen.locationedit.LocationEditScreen
import com.homebox.lens.ui.screen.locationslist.LocationsListScreen
import com.homebox.lens.ui.screen.search.SearchScreen
import com.homebox.lens.ui.screen.search.SearchViewModel
import com.homebox.lens.ui.screen.setup.SetupScreen
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('NavGraph')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('rememberNavController')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('currentBackStackEntryAsState')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('remember')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('hiltViewModel')]
// [RELATION: Function('NavGraph') -> [CREATES_INSTANCE_OF] -> Class('NavigationActions')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('NavHost')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('composable')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('SetupScreen')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('DashboardScreen')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('InventoryListScreen')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('ItemDetailsScreen')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('ItemEditScreen')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('LabelsListScreen')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('LocationsListScreen')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('LocationEditScreen')]
// [RELATION: Function('NavGraph') -> [CALLS] -> Function('SearchScreen')]
/**
* [CONTRACT]
* Определяет граф навигации для всего приложения с использованием Jetpack Compose Navigation.
* @param navController Контроллер навигации.
* @see Screen
* @sideeffect Регистрирует все экраны и управляет состоянием навигации.
* @invariant Стартовый экран - `Screen.Setup`.
*/
@Composable
fun NavGraph(navController: NavHostController = rememberNavController()) {
// [STATE]
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route
// [HELPER]
val navigationActions =
remember(navController) {
NavigationActions(navController)
}
// [ACTION]
NavHost(
navController = navController,
startDestination = Screen.Setup.route,
) {
// [ENTITY: Composable('Screen.Setup.route')]
composable(route = Screen.Setup.route) {
SetupScreen(onSetupComplete = {
navController.navigate(Screen.Dashboard.route) {
popUpTo(Screen.Setup.route) { inclusive = true }
}
})
}
// [END_ENTITY: Composable('Screen.Setup.route')]
// [ENTITY: Composable('Screen.Dashboard.route')]
composable(route = Screen.Dashboard.route) {
DashboardScreen(
currentRoute = currentRoute,
navigationActions = navigationActions,
)
}
// [END_ENTITY: Composable('Screen.Dashboard.route')]
// [ENTITY: Composable('Screen.InventoryList.route')]
composable(route = Screen.InventoryList.route) { backStackEntry ->
val viewModel: InventoryListViewModel = hiltViewModel(backStackEntry)
InventoryListScreen(
onItemClick = { item ->
// TODO: Navigate to item details
Timber.i("[UI] Item clicked: ${item.name}")
},
onNavigateBack = {
navController.popBackStack()
}
)
}
// [END_ENTITY: Composable('Screen.InventoryList.route')]
// [ENTITY: Composable('Screen.ItemDetails.route')]
composable(route = Screen.ItemDetails.route) { backStackEntry ->
val viewModel: ItemDetailsViewModel = hiltViewModel(backStackEntry)
ItemDetailsScreen(
onNavigateBack = {
navController.popBackStack()
},
onEditClick = { itemId ->
// TODO: Navigate to item edit screen
Timber.i("[UI] Edit item clicked: $itemId")
}
)
}
// [END_ENTITY: Composable('Screen.ItemDetails.route')]
// [ENTITY: Composable('Screen.ItemEdit.route')]
composable(route = Screen.ItemEdit.route) { backStackEntry ->
val viewModel: ItemEditViewModel = hiltViewModel(backStackEntry)
ItemEditScreen(
onNavigateBack = {
navController.popBackStack()
}
)
}
// [END_ENTITY: Composable('Screen.ItemEdit.route')]
// [ENTITY: Composable('Screen.LabelsList.route')]
composable(Screen.LabelsList.route) { backStackEntry ->
val viewModel: LabelsListViewModel = hiltViewModel(backStackEntry)
val uiState by viewModel.uiState.collectAsState()
labelsListScreen(
uiState = uiState,
onLabelClick = { label ->
// TODO: Implement navigation to label details screen
Timber.i("[UI] Label clicked: ${label.name}")
},
onAddClick = {
// TODO: Implement navigation to add new label screen
Timber.i("[UI] Add new label clicked")
},
onNavigateBack = {
navController.popBackStack()
}
)
}
// [END_ENTITY: Composable('Screen.LabelsList.route')]
// [ENTITY: Composable('Screen.LocationsList.route')]
composable(route = Screen.LocationsList.route) {
LocationsListScreen(
currentRoute = currentRoute,
navigationActions = navigationActions,
onLocationClick = { locationId ->
// TODO: Navigate to a pre-filtered inventory list screen
navController.navigate(Screen.InventoryList.route)
},
onAddNewLocationClick = {
navController.navigate(Screen.LocationEdit.createRoute("new"))
},
)
}
// [END_ENTITY: Composable('Screen.LocationsList.route')]
// [ENTITY: Composable('Screen.LocationEdit.route')]
composable(route = Screen.LocationEdit.route) { backStackEntry ->
val locationId = backStackEntry.arguments?.getString("locationId")
LocationEditScreen(
locationId = locationId,
)
}
// [END_ENTITY: Composable('Screen.LocationEdit.route')]
// [ENTITY: Composable('Screen.Search.route')]
composable(route = Screen.Search.route) { backStackEntry ->
val viewModel: SearchViewModel = hiltViewModel(backStackEntry)
SearchScreen(
onNavigateBack = {
navController.popBackStack()
},
onItemClick = { item ->
// TODO: Navigate to item details
Timber.i("[UI] Search result item clicked: ${item.name}")
}
)
}
// [END_ENTITY: Composable('Screen.Search.route')]
}
}
// [END_ENTITY: Function('NavGraph')]
// [END_CONTRACT]
// [END_FILE_NavGraph.kt]

View File

@@ -1,123 +0,0 @@
// [PACKAGE] com.homebox.lens.navigation
// [FILE] NavigationActions.kt
// [SEMANTICS] navigation, controller, actions
package com.homebox.lens.navigation
// [IMPORTS]
import androidx.navigation.NavHostController
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Class('NavigationActions')]
// [RELATION: Class('NavigationActions') -> [DEPENDS_ON] -> Class('NavHostController')]
/**
* [CONTRACT]
* @summary Класс-обертка над NavHostController для предоставления типизированных навигационных действий.
* @param navController Контроллер Jetpack Navigation.
* @invariant Все навигационные действия должны использовать предоставленный navController.
*/
class NavigationActions(private val navController: NavHostController) {
// [ENTITY: Function('navigateToDashboard')]
// [RELATION: Function('navigateToDashboard') -> [CALLS] -> Function('navController.navigate')]
// [RELATION: Function('navigateToDashboard') -> [CALLS] -> Function('Screen.Dashboard.route')]
// [RELATION: Function('navigateToDashboard') -> [CALLS] -> Function('popUpTo')]
// [ACTION]
/**
* [CONTRACT]
* @summary Навигация на главный экран.
* @sideeffect Очищает back stack до главного экрана, чтобы избежать циклов.
*/
fun navigateToDashboard() {
navController.navigate(Screen.Dashboard.route) {
// Используем popUpTo для удаления всех экранов до dashboard из back stack
// Это предотвращает создание большой стопки экранов при навигации через drawer
popUpTo(navController.graph.startDestinationId)
launchSingleTop = true
}
}
// [END_ENTITY: Function('navigateToDashboard')]
// [ENTITY: Function('navigateToLocations')]
// [RELATION: Function('navigateToLocations') -> [CALLS] -> Function('navController.navigate')]
// [RELATION: Function('navigateToLocations') -> [CALLS] -> Function('Screen.LocationsList.route')]
// [ACTION]
fun navigateToLocations() {
navController.navigate(Screen.LocationsList.route) {
launchSingleTop = true
}
}
// [END_ENTITY: Function('navigateToLocations')]
// [ENTITY: Function('navigateToLabels')]
// [RELATION: Function('navigateToLabels') -> [CALLS] -> Function('navController.navigate')]
// [RELATION: Function('navigateToLabels') -> [CALLS] -> Function('Screen.LabelsList.route')]
// [ACTION]
fun navigateToLabels() {
navController.navigate(Screen.LabelsList.route) {
launchSingleTop = true
}
}
// [END_ENTITY: Function('navigateToLabels')]
// [ENTITY: Function('navigateToSearch')]
// [RELATION: Function('navigateToSearch') -> [CALLS] -> Function('navController.navigate')]
// [RELATION: Function('navigateToSearch') -> [CALLS] -> Function('Screen.Search.route')]
// [ACTION]
fun navigateToSearch() {
navController.navigate(Screen.Search.route) {
launchSingleTop = true
}
}
// [END_ENTITY: Function('navigateToSearch')]
// [ENTITY: Function('navigateToInventoryListWithLabel')]
// [RELATION: Function('navigateToInventoryListWithLabel') -> [CALLS] -> Function('Screen.InventoryList.withFilter')]
// [RELATION: Function('navigateToInventoryListWithLabel') -> [CALLS] -> Function('navController.navigate')]
// [ACTION]
fun navigateToInventoryListWithLabel(labelId: String) {
val route = Screen.InventoryList.withFilter("label", labelId)
navController.navigate(route)
}
// [END_ENTITY: Function('navigateToInventoryListWithLabel')]
// [ENTITY: Function('navigateToInventoryListWithLocation')]
// [RELATION: Function('navigateToInventoryListWithLocation') -> [CALLS] -> Function('Screen.InventoryList.withFilter')]
// [RELATION: Function('navigateToInventoryListWithLocation') -> [CALLS] -> Function('navController.navigate')]
// [ACTION]
fun navigateToInventoryListWithLocation(locationId: String) {
val route = Screen.InventoryList.withFilter("location", locationId)
navController.navigate(route)
}
// [END_ENTITY: Function('navigateToInventoryListWithLocation')]
// [ENTITY: Function('navigateToCreateItem')]
// [RELATION: Function('navigateToCreateItem') -> [CALLS] -> Function('Screen.ItemEdit.createRoute')]
// [RELATION: Function('navigateToCreateItem') -> [CALLS] -> Function('navController.navigate')]
// [ACTION]
fun navigateToCreateItem() {
navController.navigate(Screen.ItemEdit.createRoute("new"))
}
// [END_ENTITY: Function('navigateToCreateItem')]
// [ENTITY: Function('navigateToLogout')]
// [RELATION: Function('navigateToLogout') -> [CALLS] -> Function('navController.navigate')]
// [RELATION: Function('navigateToLogout') -> [CALLS] -> Function('popUpTo')]
// [ACTION]
fun navigateToLogout() {
navController.navigate(Screen.Setup.route) {
popUpTo(Screen.Dashboard.route) { inclusive = true }
}
}
// [END_ENTITY: Function('navigateToLogout')]
// [ENTITY: Function('navigateBack')]
// [RELATION: Function('navigateBack') -> [CALLS] -> Function('navController.popBackStack')]
// [ACTION]
fun navigateBack() {
navController.popBackStack()
}
// [END_ENTITY: Function('navigateBack')]
}
// [END_ENTITY: Class('NavigationActions')]
// [END_CONTRACT]
// [END_FILE_NavigationActions.kt]

View File

@@ -1,138 +0,0 @@
// [PACKAGE] com.homebox.lens.navigation
// [FILE] Screen.kt
// [SEMANTICS] navigation, routes, sealed_class
package com.homebox.lens.navigation
// [IMPORTS]
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: SealedClass('Screen')]
/**
* [CONTRACT]
* Запечатанный класс для определения маршрутов навигации в приложении.
* Обеспечивает типобезопасность при навигации.
* @property route Строковый идентификатор маршрута.
*/
sealed class Screen(val route: String) {
// [ENTITY: DataObject('Setup')]
data object Setup : Screen("setup_screen")
// [END_ENTITY: DataObject('Setup')]
// [ENTITY: DataObject('Dashboard')]
data object Dashboard : Screen("dashboard_screen")
// [END_ENTITY: DataObject('Dashboard')]
// [ENTITY: DataObject('InventoryList')]
data object InventoryList : Screen("inventory_list_screen") {
// [ENTITY: Function('withFilter')]
/**
* [CONTRACT]
* Создает маршрут для экрана списка инвентаря с параметром фильтра.
* @param key Ключ фильтра (например, "label" или "location").
* @param value Значение фильтра (например, ID метки или местоположения).
* @return Строку полного маршрута с query-параметром.
* @throws IllegalArgumentException если ключ или значение пустые.
* @sideeffect [ARCH-IMPLICATION] NavGraph должен быть настроен для приема этого опционального query-параметра (например, 'navArgument("label") { nullable = true }').
*/
fun withFilter(
key: String,
value: String,
): String {
// [PRECONDITION]
require(key.isNotBlank()) { "[PRECONDITION_FAILED] Filter key cannot be blank." }
require(value.isNotBlank()) { "[PRECONDITION_FAILED] Filter value cannot be blank." }
// [ACTION]
val constructedRoute = "inventory_list_screen?$key=$value"
// [POSTCONDITION]
check(constructedRoute.contains("?$key=$value")) { "[POSTCONDITION_FAILED] Route must contain the filter query." }
return constructedRoute
}
// [END_ENTITY: Function('withFilter')]
}
// [END_ENTITY: DataObject('InventoryList')]
// [ENTITY: DataObject('ItemDetails')]
data object ItemDetails : Screen("item_details_screen/{itemId}") {
// [ENTITY: Function('createRoute')]
/**
* [CONTRACT]
* Создает маршрут для экрана деталей элемента с указанным ID.
* @param itemId ID элемента для отображения.
* @return Строку полного маршрута.
* @throws IllegalArgumentException если itemId пустой.
*/
fun createRoute(itemId: String): String {
// [PRECONDITION]
require(itemId.isNotBlank()) { "[PRECONDITION_FAILED] itemId не может быть пустым." }
// [ACTION]
val route = "item_details_screen/$itemId"
// [POSTCONDITION]
check(route.endsWith(itemId)) { "[POSTCONDITION_FAILED] Маршрут должен заканчиваться на itemId." }
return route
}
// [END_ENTITY: Function('createRoute')]
}
// [END_ENTITY: DataObject('ItemDetails')]
// [ENTITY: DataObject('ItemEdit')]
data object ItemEdit : Screen("item_edit_screen/{itemId}") {
// [ENTITY: Function('createRoute')]
/**
* [CONTRACT]
* Создает маршрут для экрана редактирования элемента с указанным ID.
* @param itemId ID элемента для редактирования.
* @return Строку полного маршрута.
* @throws IllegalArgumentException если itemId пустой.
*/
fun createRoute(itemId: String): String {
// [PRECONDITION]
require(itemId.isNotBlank()) { "[PRECONDITION_FAILED] itemId не может быть пустым." }
// [ACTION]
val route = "item_edit_screen/$itemId"
// [POSTCONDITION]
check(route.endsWith(itemId)) { "[POSTCONDITION_FAILED] Маршрут должен заканчиваться на itemId." }
return route
}
// [END_ENTITY: Function('createRoute')]
}
// [END_ENTITY: DataObject('ItemEdit')]
// [ENTITY: DataObject('LabelsList')]
data object LabelsList : Screen("labels_list_screen")
// [END_ENTITY: DataObject('LabelsList')]
// [ENTITY: DataObject('LocationsList')]
data object LocationsList : Screen("locations_list_screen")
// [END_ENTITY: DataObject('LocationsList')]
// [ENTITY: DataObject('LocationEdit')]
data object LocationEdit : Screen("location_edit_screen/{locationId}") {
// [ENTITY: Function('createRoute')]
/**
* [CONTRACT]
* Создает маршрут для экрана редактирования местоположения с указанным ID.
* @param locationId ID местоположения для редактирования.
* @return Строку полного маршрута.
* @throws IllegalArgumentException если locationId пустой.
*/
fun createRoute(locationId: String): String {
// [PRECONDITION]
require(locationId.isNotBlank()) { "[PRECONDITION_FAILED] locationId не может быть пустым." }
// [ACTION]
val route = "location_edit_screen/$locationId"
// [POSTCONDITION]
check(route.endsWith(locationId)) { "[POSTCONDITION_FAILED] Маршрут должен заканчиваться на locationId." }
return route
}
// [END_ENTITY: Function('createRoute')]
}
// [END_ENTITY: DataObject('LocationEdit')]
// [ENTITY: DataObject('Search')]
data object Search : Screen("search_screen")
// [END_ENTITY: DataObject('Search')]
}
// [END_ENTITY: SealedClass('Screen')]
// [END_CONTRACT]
// [END_FILE_Screen.kt]

View File

@@ -1,124 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.common
// [FILE] AppDrawer.kt
// [SEMANTICS] ui, common, navigation_drawer
package com.homebox.lens.ui.common
// [IMPORTS]
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.Button
import androidx.compose.material3.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalDrawerSheet
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.homebox.lens.R
import com.homebox.lens.navigation.NavigationActions
import com.homebox.lens.navigation.Screen
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('AppDrawerContent')]
// [RELATION: Function('AppDrawerContent') -> [DEPENDS_ON] -> Class('NavigationActions')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('ModalDrawerSheet')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Spacer')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Button')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Text')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Divider')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('NavigationDrawerItem')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Screen.Dashboard.route')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Screen.LocationsList.route')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Screen.LabelsList.route')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Screen.Search.route')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Screen.ItemEdit.createRoute')]
// [RELATION: Function('AppDrawerContent') -> [CALLS] -> Function('Screen.Setup.route')]
/**
* [CONTRACT]
* @summary Контент для бокового навигационного меню (Drawer).
* @param currentRoute Текущий маршрут для подсветки активного элемента.
* @param navigationActions Объект с навигационными действиями.
* @param onCloseDrawer Лямбда для закрытия бокового меню.
*/
@Composable
internal fun AppDrawerContent(
currentRoute: String?,
navigationActions: NavigationActions,
onCloseDrawer: () -> Unit,
) {
ModalDrawerSheet {
Spacer(Modifier.height(12.dp))
Button(
onClick = {
navigationActions.navigateToCreateItem()
onCloseDrawer()
},
modifier =
Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
) {
Icon(Icons.Default.Add, contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(Modifier.width(8.dp))
Text(stringResource(id = R.string.create))
}
Spacer(Modifier.height(12.dp))
Divider()
NavigationDrawerItem(
label = { Text(stringResource(id = R.string.dashboard_title)) },
selected = currentRoute == Screen.Dashboard.route,
onClick = {
navigationActions.navigateToDashboard()
onCloseDrawer()
},
)
NavigationDrawerItem(
label = { Text(stringResource(id = R.string.nav_locations)) },
selected = currentRoute == Screen.LocationsList.route,
onClick = {
navigationActions.navigateToLocations()
onCloseDrawer()
},
)
NavigationDrawerItem(
label = { Text(stringResource(id = R.string.nav_labels)) },
selected = currentRoute == Screen.LabelsList.route,
onClick = {
navigationActions.navigateToLabels()
onCloseDrawer()
},
)
NavigationDrawerItem(
label = { Text(stringResource(id = R.string.search)) },
selected = currentRoute == Screen.Search.route,
onClick = {
navigationActions.navigateToSearch()
onCloseDrawer()
},
)
// TODO: Add Profile and Tools items
Divider()
NavigationDrawerItem(
label = { Text(stringResource(id = R.string.logout)) },
selected = false,
onClick = {
navigationActions.navigateToLogout()
onCloseDrawer()
},
)
}
}
// [END_ENTITY: Function('AppDrawerContent')]
// [END_CONTRACT]
// [END_FILE_AppDrawer.kt]

View File

@@ -1,91 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.common
// [FILE] MainScaffold.kt
// [SEMANTICS] ui, common, scaffold, navigation_drawer
package com.homebox.lens.ui.common
// [IMPORTS]
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.res.stringResource
import com.homebox.lens.R
import com.homebox.lens.navigation.NavigationActions
import kotlinx.coroutines.launch
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('MainScaffold')]
// [RELATION: Function('MainScaffold') -> [DEPENDS_ON] -> Class('NavigationActions')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('rememberDrawerState')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('rememberCoroutineScope')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('ModalNavigationDrawer')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('AppDrawerContent')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('Scaffold')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('TopAppBar')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('Text')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('IconButton')]
// [RELATION: Function('MainScaffold') -> [CALLS] -> Function('Icon')]
/**
* [CONTRACT]
* @summary Общая обертка для экранов, включающая Scaffold и Navigation Drawer.
* @param topBarTitle Заголовок для TopAppBar.
* @param currentRoute Текущий маршрут для подсветки активного элемента в Drawer.
* @param navigationActions Объект с навигационными действиями.
* @param topBarActions Composable-функция для отображения действий (иконок) в TopAppBar.
* @param content Основное содержимое экрана, которое будет отображено внутри Scaffold.
* @sideeffect Управляет состоянием (открыто/закрыто) бокового меню (ModalNavigationDrawer).
* @invariant TopAppBar всегда отображается с иконкой меню.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainScaffold(
topBarTitle: String,
currentRoute: String?,
navigationActions: NavigationActions,
topBarActions: @Composable () -> Unit = {},
content: @Composable (PaddingValues) -> Unit,
) {
// [STATE]
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
val scope = rememberCoroutineScope()
// [CORE-LOGIC]
ModalNavigationDrawer(
drawerState = drawerState,
drawerContent = {
AppDrawerContent(
currentRoute = currentRoute,
navigationActions = navigationActions,
onCloseDrawer = { scope.launch { drawerState.close() } },
)
},
) {
Scaffold(
topBar = {
TopAppBar(
title = { Text(topBarTitle) },
navigationIcon = {
IconButton(onClick = { scope.launch { drawerState.open() } }) {
Icon(
Icons.Default.Menu,
contentDescription = stringResource(id = R.string.cd_open_navigation_drawer),
)
}
},
actions = { topBarActions() },
)
},
) { paddingValues ->
// [ACTION]
content(paddingValues)
}
}
}
// [END_ENTITY: Function('MainScaffold')]
// [END_CONTRACT]
// [END_FILE_MainScaffold.kt]

View File

@@ -1,522 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.dashboard
// [FILE] DashboardScreen.kt
// [SEMANTICS] ui, screen, dashboard, compose, navigation
package com.homebox.lens.ui.screen.dashboard
// [IMPORTS]
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.homebox.lens.R
import com.homebox.lens.domain.model.*
import com.homebox.lens.navigation.NavigationActions
import com.homebox.lens.ui.common.MainScaffold
import com.homebox.lens.ui.theme.HomeboxLensTheme
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('DashboardScreen')]
// [RELATION: Function('DashboardScreen') -> [DEPENDS_ON] -> Class('DashboardViewModel')]
// [RELATION: Function('DashboardScreen') -> [DEPENDS_ON] -> Class('NavigationActions')]
// [RELATION: Function('DashboardScreen') -> [CALLS] -> Function('hiltViewModel')]
// [RELATION: Function('DashboardScreen') -> [CALLS] -> Function('collectAsState')]
// [RELATION: Function('DashboardScreen') -> [CALLS] -> Function('MainScaffold')]
// [RELATION: Function('DashboardScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('DashboardScreen') -> [CALLS] -> Function('IconButton')]
// [RELATION: Function('DashboardScreen') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('DashboardScreen') -> [CALLS] -> Function('DashboardContent')]
/**
* [CONTRACT]
* @summary Главная Composable-функция для экрана "Панель управления".
* @param viewModel ViewModel для этого экрана, предоставляется через Hilt.
* @param currentRoute Текущий маршрут для подсветки активного элемента в Drawer.
* @param navigationActions Объект с навигационными действиями.
* @sideeffect Вызывает навигационные лямбды при взаимодействии с UI.
*/
@Composable
fun DashboardScreen(
viewModel: DashboardViewModel = hiltViewModel(),
currentRoute: String?,
navigationActions: NavigationActions,
) {
// [STATE]
val uiState by viewModel.uiState.collectAsState()
// [UI_COMPONENT]
MainScaffold(
topBarTitle = stringResource(id = R.string.dashboard_title),
currentRoute = currentRoute,
navigationActions = navigationActions,
topBarActions = {
IconButton(onClick = { navigationActions.navigateToSearch() }) {
Icon(
Icons.Default.Search,
contentDescription = stringResource(id = R.string.cd_scan_qr_code), // TODO: Rename string resource
)
}
},
) { paddingValues ->
DashboardContent(
modifier = Modifier.padding(paddingValues),
uiState = uiState,
onLocationClick = { location ->
Timber.i("[ACTION] Location chip clicked: ${location.id}. Navigating...")
navigationActions.navigateToInventoryListWithLocation(location.id)
},
onLabelClick = { label ->
Timber.i("[ACTION] Label chip clicked: ${label.id}. Navigating...")
navigationActions.navigateToInventoryListWithLabel(label.id)
},
)
}
}
// [END_ENTITY: Function('DashboardScreen')]
// [ENTITY: Function('DashboardContent')]
// [RELATION: Function('DashboardContent') -> [DEPENDS_ON] -> SealedInterface('DashboardUiState')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('Box')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('CircularProgressIndicator')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('Text')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('MaterialTheme.colorScheme.error')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('LazyColumn')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('Spacer')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('StatisticsSection')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('RecentlyAddedSection')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('LocationsSection')]
// [RELATION: Function('DashboardContent') -> [CALLS] -> Function('LabelsSection')]
/**
* [CONTRACT]
* @summary Отображает основной контент экрана в зависимости от uiState.
* @param modifier Модификатор для стилизации.
* @param uiState Текущее состояние UI экрана.
* @param onLocationClick Лямбда-обработчик нажатия на местоположение.
* @param onLabelClick Лямбда-обработчик нажатия на метку.
*/
@Composable
private fun DashboardContent(
modifier: Modifier = Modifier,
uiState: DashboardUiState,
onLocationClick: (LocationOutCount) -> Unit,
onLabelClick: (LabelOut) -> Unit,
) {
// [CORE-LOGIC]
when (uiState) {
is DashboardUiState.Loading -> {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
CircularProgressIndicator()
}
}
is DashboardUiState.Error -> {
Box(modifier = Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.Center) {
Text(
text = uiState.message,
color = MaterialTheme.colorScheme.error,
textAlign = TextAlign.Center,
)
}
}
is DashboardUiState.Success -> {
LazyColumn(
modifier =
modifier
.fillMaxSize()
.padding(horizontal = 16.dp),
verticalArrangement = Arrangement.spacedBy(24.dp),
) {
item { Spacer(modifier = Modifier.height(8.dp)) }
item { StatisticsSection(statistics = uiState.statistics) }
item { RecentlyAddedSection(items = uiState.recentlyAddedItems) }
item { LocationsSection(locations = uiState.locations, onLocationClick = onLocationClick) }
item { LabelsSection(labels = uiState.labels, onLabelClick = onLabelClick) }
item { Spacer(modifier = Modifier.height(16.dp)) }
}
}
}
}
// [END_ENTITY: Function('DashboardContent')]
// [ENTITY: Function('StatisticsSection')]
// [RELATION: Function('StatisticsSection') -> [DEPENDS_ON] -> Class('GroupStatistics')]
// [RELATION: Function('StatisticsSection') -> [CALLS] -> Function('Column')]
// [RELATION: Function('StatisticsSection') -> [CALLS] -> Function('Text')]
// [RELATION: Function('StatisticsSection') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('StatisticsSection') -> [CALLS] -> Function('MaterialTheme.typography.titleMedium')]
// [RELATION: Function('StatisticsSection') -> [CALLS] -> Function('Card')]
// [RELATION: Function('StatisticsSection') -> [CALLS] -> Function('LazyVerticalGrid')]
// [RELATION: Function('StatisticsSection') -> [CALLS] -> Function('GridCells.Fixed')]
// [RELATION: Function('StatisticsSection') -> [CALLS] -> Function('StatisticCard')]
/**
* [CONTRACT]
* @summary Секция для отображения общей статистики.
* @param statistics Объект со статистическими данными.
*/
@Composable
private fun StatisticsSection(statistics: GroupStatistics) {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text(
text = stringResource(id = R.string.dashboard_section_quick_stats),
style = MaterialTheme.typography.titleMedium,
)
Card {
LazyVerticalGrid(
columns = GridCells.Fixed(2),
modifier =
Modifier
.height(120.dp)
.fillMaxWidth()
.padding(16.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
item {
StatisticCard(
title = stringResource(id = R.string.dashboard_stat_total_items),
value = statistics.items.toString(),
)
}
item {
StatisticCard(
title = stringResource(id = R.string.dashboard_stat_total_value),
value = statistics.totalValue.toString(),
)
}
item {
StatisticCard(
title = stringResource(id = R.string.dashboard_stat_total_labels),
value = statistics.labels.toString(),
)
}
item {
StatisticCard(
title = stringResource(id = R.string.dashboard_stat_total_locations),
value = statistics.locations.toString(),
)
}
}
}
}
}
// [END_ENTITY: Function('StatisticsSection')]
// [ENTITY: Function('StatisticCard')]
// [RELATION: Function('StatisticCard') -> [CALLS] -> Function('Column')]
// [RELATION: Function('StatisticCard') -> [CALLS] -> Function('Text')]
// [RELATION: Function('StatisticCard') -> [CALLS] -> Function('MaterialTheme.typography.labelMedium')]
// [RELATION: Function('StatisticCard') -> [CALLS] -> Function('MaterialTheme.typography.headlineSmall')]
/**
* [CONTRACT]
* @summary Карточка для отображения одного статистического показателя.
* @param title Название показателя.
* @param value Значение показателя.
*/
@Composable
private fun StatisticCard(
title: String,
value: String,
) {
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) {
Text(text = title, style = MaterialTheme.typography.labelMedium, textAlign = TextAlign.Center)
Text(text = value, style = MaterialTheme.typography.headlineSmall, textAlign = TextAlign.Center)
}
}
// [END_ENTITY: Function('StatisticCard')]
// [ENTITY: Function('RecentlyAddedSection')]
// [RELATION: Function('RecentlyAddedSection') -> [DEPENDS_ON] -> Class('ItemSummary')]
// [RELATION: Function('RecentlyAddedSection') -> [CALLS] -> Function('Column')]
// [RELATION: Function('RecentlyAddedSection') -> [CALLS] -> Function('Text')]
// [RELATION: Function('RecentlyAddedSection') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('RecentlyAddedSection') -> [CALLS] -> Function('MaterialTheme.typography.titleMedium')]
// [RELATION: Function('RecentlyAddedSection') -> [CALLS] -> Function('LazyRow')]
// [RELATION: Function('RecentlyAddedSection') -> [CALLS] -> Function('ItemCard')]
/**
* [CONTRACT]
* @summary Секция для отображения недавно добавленных элементов.
* @param items Список элементов для отображения.
*/
@Composable
private fun RecentlyAddedSection(items: List<ItemSummary>) {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text(
text = stringResource(id = R.string.dashboard_section_recently_added),
style = MaterialTheme.typography.titleMedium,
)
if (items.isEmpty()) {
Text(
text = stringResource(id = R.string.items_not_found),
style = MaterialTheme.typography.bodyMedium,
modifier =
Modifier
.fillMaxWidth()
.padding(vertical = 16.dp),
textAlign = TextAlign.Center,
)
} else {
LazyRow(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
items(items) { item ->
ItemCard(item = item)
}
}
}
}
}
// [END_ENTITY: Function('RecentlyAddedSection')]
// [ENTITY: Function('ItemCard')]
// [RELATION: Function('ItemCard') -> [DEPENDS_ON] -> Class('ItemSummary')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('Card')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('Column')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('Spacer')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('Text')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('MaterialTheme.typography.titleSmall')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('MaterialTheme.typography.bodySmall')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('stringResource')]
/**
* [CONTRACT]
* @summary Карточка для отображения краткой информации об элементе.
* @param item Элемент для отображения.
*/
@Composable
private fun ItemCard(item: ItemSummary) {
Card(modifier = Modifier.width(150.dp)) {
Column(modifier = Modifier.padding(8.dp)) {
// TODO: Add image here from item.image
Spacer(
modifier =
Modifier
.height(80.dp)
.fillMaxWidth()
.background(MaterialTheme.colorScheme.secondaryContainer),
)
Spacer(modifier = Modifier.height(8.dp))
Text(text = item.name, style = MaterialTheme.typography.titleSmall, maxLines = 1)
Text(
text = item.location?.name ?: stringResource(id = R.string.no_location),
style = MaterialTheme.typography.bodySmall,
maxLines = 1,
)
}
}
}
// [END_ENTITY: Function('ItemCard')]
// [ENTITY: Function('LocationsSection')]
// [RELATION: Function('LocationsSection') -> [DEPENDS_ON] -> Class('LocationOutCount')]
// [RELATION: Function('LocationsSection') -> [CALLS] -> Function('Column')]
// [RELATION: Function('LocationsSection') -> [CALLS] -> Function('Text')]
// [RELATION: Function('LocationsSection') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('LocationsSection') -> [CALLS] -> Function('MaterialTheme.typography.titleMedium')]
// [RELATION: Function('LocationsSection') -> [CALLS] -> Function('FlowRow')]
// [RELATION: Function('LocationsSection') -> [CALLS] -> Function('SuggestionChip')]
/**
* [CONTRACT]
* @summary Секция для отображения местоположений в виде чипсов.
* @param locations Список местоположений.
* @param onLocationClick Лямбда-обработчик нажатия на местоположение.
*/
@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun LocationsSection(
locations: List<LocationOutCount>,
onLocationClick: (LocationOutCount) -> Unit,
) {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text(
text = stringResource(id = R.string.dashboard_section_locations),
style = MaterialTheme.typography.titleMedium,
)
FlowRow(
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
locations.forEach { location ->
SuggestionChip(
onClick = { onLocationClick(location) },
label = { Text(stringResource(id = R.string.location_chip_label, location.name, location.itemCount)) },
)
}
}
}
}
// [END_ENTITY: Function('LocationsSection')]
// [ENTITY: Function('LabelsSection')]
// [RELATION: Function('LabelsSection') -> [DEPENDS_ON] -> Class('LabelOut')]
// [RELATION: Function('LabelsSection') -> [CALLS] -> Function('Column')]
// [RELATION: Function('LabelsSection') -> [CALLS] -> Function('Text')]
// [RELATION: Function('LabelsSection') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('LabelsSection') -> [CALLS] -> Function('MaterialTheme.typography.titleMedium')]
// [RELATION: Function('LabelsSection') -> [CALLS] -> Function('FlowRow')]
// [RELATION: Function('LabelsSection') -> [CALLS] -> Function('SuggestionChip')]
/**
* [CONTRACT]
* @summary Секция для отображения меток в виде чипсов.
* @param labels Список меток.
* @param onLabelClick Лямбда-обработчик нажатия на метку.
*/
@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun LabelsSection(
labels: List<LabelOut>,
onLabelClick: (LabelOut) -> Unit,
) {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text(
text = stringResource(id = R.string.dashboard_section_labels),
style = MaterialTheme.typography.titleMedium,
)
FlowRow(
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
labels.forEach { label ->
SuggestionChip(
onClick = { onLabelClick(label) },
label = { Text(label.name) },
)
}
}
}
}
// [END_ENTITY: Function('LabelsSection')]
// [ENTITY: Function('DashboardContentSuccessPreview')]
// [RELATION: Function('DashboardContentSuccessPreview') -> [CALLS] -> Function('DashboardUiState.Success')]
// [RELATION: Function('DashboardContentSuccessPreview') -> [CALLS] -> Function('GroupStatistics')]
// [RELATION: Function('DashboardContentSuccessPreview') -> [CALLS] -> Function('LocationOutCount')]
// [RELATION: Function('DashboardContentSuccessPreview') -> [CALLS] -> Function('LabelOut')]
// [RELATION: Function('DashboardContentSuccessPreview') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('DashboardContentSuccessPreview') -> [CALLS] -> Function('DashboardContent')]
// [PREVIEW]
@Preview(showBackground = true, name = "Dashboard Success State")
@Composable
fun DashboardContentSuccessPreview() {
val previewState =
DashboardUiState.Success(
statistics =
GroupStatistics(
items = 123,
totalValue = 9999.99,
locations = 5,
labels = 8,
),
locations =
listOf(
LocationOutCount(
id = "1",
name = "Office",
color = "#FF0000",
isArchived = false,
itemCount = 10,
createdAt = "",
updatedAt = "",
),
LocationOutCount(
id = "2",
name = "Garage",
color = "#00FF00",
isArchived = false,
itemCount = 5,
createdAt = "",
updatedAt = "",
),
LocationOutCount(
id = "3",
name = "Living Room",
color = "#0000FF",
isArchived = false,
itemCount = 15,
createdAt = "",
updatedAt = "",
),
LocationOutCount(
id = "4",
name = "Kitchen",
color = "#FFFF00",
isArchived = false,
itemCount = 20,
createdAt = "",
updatedAt = "",
),
LocationOutCount(
id = "5",
name = "Basement",
color = "#00FFFF",
isArchived = false,
itemCount = 3,
createdAt = "",
updatedAt = "",
),
),
labels =
listOf(
LabelOut(id = "1", name = "electronics", color = "#FF0000", isArchived = false, createdAt = "", updatedAt = ""),
LabelOut(id = "2", name = "important", color = "#00FF00", isArchived = false, createdAt = "", updatedAt = ""),
LabelOut(id = "3", name = "seasonal", color = "#0000FF", isArchived = false, createdAt = "", updatedAt = ""),
LabelOut(id = "4", name = "hobby", color = "#FFFF00", isArchived = false, createdAt = "", updatedAt = ""),
),
recentlyAddedItems = emptyList(),
)
HomeboxLensTheme {
DashboardContent(
uiState = previewState,
onLocationClick = {},
onLabelClick = {},
)
}
}
// [END_ENTITY: Function('DashboardContentSuccessPreview')]
// [ENTITY: Function('DashboardContentLoadingPreview')]
// [RELATION: Function('DashboardContentLoadingPreview') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('DashboardContentLoadingPreview') -> [CALLS] -> Function('DashboardContent')]
// [RELATION: Function('DashboardContentLoadingPreview') -> [CALLS] -> Function('DashboardUiState.Loading')]
// [PREVIEW]
@Preview(showBackground = true, name = "Dashboard Loading State")
@Composable
fun DashboardContentLoadingPreview() {
HomeboxLensTheme {
DashboardContent(
uiState = DashboardUiState.Loading,
onLocationClick = {},
onLabelClick = {},
)
}
}
// [END_ENTITY: Function('DashboardContentLoadingPreview')]
// [ENTITY: Function('DashboardContentErrorPreview')]
// [RELATION: Function('DashboardContentErrorPreview') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('DashboardContentErrorPreview') -> [CALLS] -> Function('DashboardContent')]
// [RELATION: Function('DashboardContentErrorPreview') -> [CALLS] -> Function('DashboardUiState.Error')]
// [RELATION: Function('DashboardContentErrorPreview') -> [CALLS] -> Function('stringResource')]
// [PREVIEW]
@Preview(showBackground = true, name = "Dashboard Error State")
@Composable
fun DashboardContentErrorPreview() {
HomeboxLensTheme {
DashboardContent(
uiState = DashboardUiState.Error(stringResource(id = R.string.error_loading_failed)),
onLocationClick = {},
onLabelClick = {},
)
}
}
// [END_ENTITY: Function('DashboardContentErrorPreview')]
// [END_CONTRACT]
// [END_FILE_DashboardScreen.kt]

View File

@@ -1,62 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.dashboard
// [FILE] DashboardUiState.kt
// [SEMANTICS] ui, state, dashboard
package com.homebox.lens.ui.screen.dashboard
// [IMPORTS]
import com.homebox.lens.domain.model.GroupStatistics
import com.homebox.lens.domain.model.LabelOut
import com.homebox.lens.domain.model.LocationOutCount
import com.homebox.lens.domain.model.ItemSummary
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: SealedInterface('DashboardUiState')]
/**
* [CONTRACT]
* Определяет все возможные состояния для экрана "Дэшборд".
* @invariant В любой момент времени экран может находиться только в одном из этих состояний.
*/
sealed interface DashboardUiState {
// [ENTITY: DataClass('Success')]
// [RELATION: DataClass('Success') -> [DEPENDS_ON] -> Class('GroupStatistics')]
// [RELATION: DataClass('Success') -> [DEPENDS_ON] -> Class('LocationOutCount')]
// [RELATION: DataClass('Success') -> [DEPENDS_ON] -> Class('LabelOut')]
// [RELATION: DataClass('Success') -> [DEPENDS_ON] -> Class('ItemSummary')]
/**
* [CONTRACT]
* Состояние успешной загрузки данных.
* @property statistics Статистика по инвентарю.
* @property locations Список локаций со счетчиками.
* @property labels Список всех меток.
* @property recentlyAddedItems Список недавно добавленных товаров.
*/
data class Success(
val statistics: GroupStatistics,
val locations: List<LocationOutCount>,
val labels: List<LabelOut>,
val recentlyAddedItems: List<ItemSummary>,
) : DashboardUiState
// [END_ENTITY: DataClass('Success')]
// [ENTITY: DataClass('Error')]
/**
* [CONTRACT]
* Состояние ошибки во время загрузки данных.
* @property message Человекочитаемое сообщение об ошибке.
*/
data class Error(val message: String) : DashboardUiState
// [END_ENTITY: DataClass('Error')]
// [ENTITY: DataObject('Loading')]
/**
* [CONTRACT]
* Состояние, когда данные для экрана загружаются.
*/
object Loading : DashboardUiState
// [END_ENTITY: DataObject('Loading')]
}
// [END_ENTITY: SealedInterface('DashboardUiState')]
// [END_CONTRACT]
// [END_FILE_DashboardUiState.kt]

View File

@@ -1,110 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.dashboard
// [FILE] DashboardViewModel.kt
// [SEMANTICS] ui_logic, dashboard, state_management, sealed_state, parallel_data_loading, timber_logging
package com.homebox.lens.ui.screen.dashboard
// [IMPORTS]
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.homebox.lens.domain.usecase.GetAllLabelsUseCase
import com.homebox.lens.domain.usecase.GetAllLocationsUseCase
import com.homebox.lens.domain.usecase.GetRecentlyAddedItemsUseCase
import com.homebox.lens.domain.usecase.GetStatisticsUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: ViewModel('DashboardViewModel')]
// [RELATION: ViewModel('DashboardViewModel') -> [INHERITS_FROM] -> Class('ViewModel')]
// [RELATION: ViewModel('DashboardViewModel') -> [DEPENDS_ON] -> Annotation('HiltViewModel')]
// [RELATION: ViewModel('DashboardViewModel') -> [DEPENDS_ON] -> Class('GetStatisticsUseCase')]
// [RELATION: ViewModel('DashboardViewModel') -> [DEPENDS_ON] -> Class('GetAllLocationsUseCase')]
// [RELATION: ViewModel('DashboardViewModel') -> [DEPENDS_ON] -> Class('GetAllLabelsUseCase')]
// [RELATION: ViewModel('DashboardViewModel') -> [DEPENDS_ON] -> Class('GetRecentlyAddedItemsUseCase')]
/**
* [CONTRACT]
* @summary ViewModel для главного экрана (Dashboard).
* @description Оркестрирует загрузку данных для Dashboard, используя строгую модель состояний
* (`DashboardUiState`), и обрабатывает параллельные запросы без состояний гонки.
* @invariant `uiState` всегда является одним из состояний, определенных в `DashboardUiState`.
*/
@HiltViewModel
class DashboardViewModel
@Inject
constructor(
private val getStatisticsUseCase: GetStatisticsUseCase,
private val getAllLocationsUseCase: GetAllLocationsUseCase,
private val getAllLabelsUseCase: GetAllLabelsUseCase,
private val getRecentlyAddedItemsUseCase: GetRecentlyAddedItemsUseCase,
) : ViewModel() {
// [STATE]
private val _uiState = MutableStateFlow<DashboardUiState>(DashboardUiState.Loading)
// [FIX] Добавлен получатель (receiver) `_uiState` для вызова asStateFlow().
// [REASON] `asStateFlow()` является функцией-расширением для `MutableStateFlow` и
// должна вызываться на его экземпляре, чтобы создать публичную, неизменяемую версию потока.
val uiState = _uiState.asStateFlow()
// [LIFECYCLE_HANDLER]
init {
loadDashboardData()
}
// [ENTITY: Function('loadDashboardData')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('viewModelScope.launch')]
// [RELATION: Function('loadDashboardData') -> [WRITES_TO] -> Property('_uiState')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('Timber.i')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('flow')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('getStatisticsUseCase')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('getAllLocationsUseCase')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('getAllLabelsUseCase')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('getRecentlyAddedItemsUseCase')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('combine')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('catch')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('Timber.e')]
// [RELATION: Function('loadDashboardData') -> [CALLS] -> Function('collect')]
/**
* [CONTRACT]
* @summary Загружает все необходимые данные для экрана Dashboard.
* @description Выполняет UseCase'ы параллельно и обновляет UI, переключая его
* между состояниями `Loading`, `Success` и `Error` из `DashboardUiState`.
* @sideeffect Асинхронно обновляет `_uiState` одним из состояний `DashboardUiState`.
*/
fun loadDashboardData() {
viewModelScope.launch {
_uiState.value = DashboardUiState.Loading
Timber.i("[ACTION] Starting dashboard data collection.")
val statsFlow = flow { emit(getStatisticsUseCase()) }
val locationsFlow = flow { emit(getAllLocationsUseCase()) }
val labelsFlow = flow { emit(getAllLabelsUseCase()) }
val recentItemsFlow = getRecentlyAddedItemsUseCase(limit = 10)
combine(statsFlow, locationsFlow, labelsFlow, recentItemsFlow) { stats, locations, labels, recentItems ->
DashboardUiState.Success(
statistics = stats,
locations = locations,
labels = labels,
recentlyAddedItems = recentItems,
)
}.catch { exception ->
Timber.e(exception, "[ERROR] Failed to load dashboard data. State -> Error.")
_uiState.value =
DashboardUiState.Error(
message = exception.message ?: "Could not load dashboard data.",
)
}.collect { successState ->
Timber.i("[SUCCESS] Dashboard data loaded successfully. State -> Success.")
_uiState.value = successState
}
}
}
// [END_ENTITY: Function('loadDashboardData')]
}
// [END_ENTITY: ViewModel('DashboardViewModel')]
// [END_CONTRACT]
// [END_FILE_DashboardViewModel.kt]

View File

@@ -1,219 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.inventorylist
// [FILE] InventoryListScreen.kt
// [SEMANTICS] ui, screen, inventory, list, compose
package com.homebox.lens.ui.screen.inventorylist
// [IMPORTS]
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Card
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.homebox.lens.R
import com.homebox.lens.domain.model.Item
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('InventoryListScreen')]
// [RELATION: Function('InventoryListScreen') -> [DEPENDS_ON] -> Class('InventoryListViewModel')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('hiltViewModel')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('collectAsState')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('Scaffold')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('TopAppBar')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('Text')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('IconButton')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('FloatingActionButton')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('SearchBar')]
// [RELATION: Function('InventoryListScreen') -> [CALLS] -> Function('InventoryListContent')]
/**
* [MAIN-CONTRACT]
* Экран для отображения списка инвентарных позиций.
*
* Реализует спецификацию `screen_inventory_list`. Позволяет просматривать,
* искать и синхронизировать инвентарь.
*
* @param onItemClick Обработчик нажатия на элемент инвентаря.
* @param onNavigateBack Обработчик для возврата на предыдущий экран.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun InventoryListScreen(
viewModel: InventoryListViewModel = hiltViewModel(),
onItemClick: (Item) -> Unit,
onNavigateBack: () -> Unit
) {
// [STATE]
val uiState by viewModel.uiState.collectAsState()
// [ACTION]
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(id = R.string.inventory_list_title)) }, // Corrected string resource name
navigationIcon = {
IconButton(onClick = onNavigateBack) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.content_desc_navigate_back)
)
}
}
)
},
floatingActionButton = {
FloatingActionButton(onClick = {
Timber.i("[INFO][ACTION][ui_interaction] Sync inventory triggered.")
viewModel.onSyncClicked()
}) {
Icon(
imageVector = Icons.Filled.Refresh,
contentDescription = stringResource(id = R.string.content_desc_sync_inventory)
)
}
}
) { innerPadding ->
// [DELEGATES]
Column(modifier = Modifier.padding(innerPadding)) {
SearchBar(
query = uiState.searchQuery,
onQueryChange = viewModel::onSearchQueryChanged
)
InventoryListContent(
isLoading = uiState.isLoading,
items = uiState.items,
onItemClick = onItemClick
)
}
}
}
// [END_ENTITY: Function('InventoryListScreen')]
// [ENTITY: Function('SearchBar')]
// [RELATION: Function('SearchBar') -> [CALLS] -> Function('TextField')]
// [RELATION: Function('SearchBar') -> [CALLS] -> Function('Text')]
// [RELATION: Function('SearchBar') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('SearchBar') -> [CALLS] -> Function('Icon')]
/**
* [CONTRACT]
* Поле для ввода поискового запроса.
*/
@Composable
private fun SearchBar(query: String, onQueryChange: (String) -> Unit) {
TextField(
value = query,
onValueChange = onQueryChange,
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
placeholder = { Text(stringResource(id = R.string.search)) }, // Corrected string resource name
leadingIcon = { Icon(Icons.Default.Search, contentDescription = null) }
)
}
// [END_ENTITY: Function('SearchBar')]
// [ENTITY: Function('InventoryListContent')]
// [RELATION: Function('InventoryListContent') -> [CALLS] -> Function('Box')]
// [RELATION: Function('InventoryListContent') -> [CALLS] -> Function('CircularProgressIndicator')]
// [RELATION: Function('InventoryListContent') -> [CALLS] -> Function('Text')]
// [RELATION: Function('InventoryListContent') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('InventoryListContent') -> [CALLS] -> Function('LazyColumn')]
// [RELATION: Function('InventoryListContent') -> [CALLS] -> Function('ItemCard')]
/**
* [CONTRACT]
* Основной контент: индикатор загрузки или список предметов.
*/
@Composable
private fun InventoryListContent(
isLoading: Boolean,
items: List<Item>,
onItemClick: (Item) -> Unit
) {
Box(modifier = Modifier.fillMaxSize()) {
if (isLoading) {
// [STATE]
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
} else if (items.isEmpty()) {
// [FALLBACK]
Text(
text = stringResource(id = R.string.items_not_found),
modifier = Modifier.align(Alignment.Center)
)
} else {
// [CORE-LOGIC]
LazyColumn {
items(items, key = { it.id }) { item ->
ItemCard(item = item, onClick = {
Timber.i("[INFO][ACTION][ui_interaction] Item clicked: ${item.name}")
onItemClick(item)
})
}
}
}
}
}
// [END_ENTITY: Function('InventoryListContent')]
// [ENTITY: Function('ItemCard')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('Card')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('Column')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('Text')]
// [RELATION: Function('ItemCard') -> [CALLS] -> Function('clickable')]
/**
* [CONTRACT]
* Карточка для отображения одного элемента инвентаря.
*/
@Composable
private fun ItemCard(
item: Item,
onClick: () -> Unit
) {
// [PRECONDITION]
require(item.name.isNotBlank()) { "Item name cannot be blank." }
// [CORE-LOGIC]
Card(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 4.dp)
.clickable(onClick = onClick)
) {
Column(modifier = Modifier.padding(16.dp)) {
Text(text = item.name, style = androidx.compose.material3.MaterialTheme.typography.titleMedium)
Text(text = "Quantity: ${item.quantity.toString()}", style = androidx.compose.material3.MaterialTheme.typography.bodySmall)
item.location?.let {
Text(text = "Location: ${it.name}", style = androidx.compose.material3.MaterialTheme.typography.bodySmall)
}
}
}
}
// [END_ENTITY: Function('ItemCard')]
// [END_CONTRACT]
// [END_FILE_InventoryListScreen.kt]

View File

@@ -1,53 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.inventorylist
// [FILE] InventoryListViewModel.kt
// [SEMANTICS] ui_logic, inventory_list, viewmodel
package com.homebox.lens.ui.screen.inventorylist
// [IMPORTS]
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import com.homebox.lens.domain.model.Item
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: ViewModel('InventoryListViewModel')]
// [RELATION: ViewModel('InventoryListViewModel') -> [INHERITS_FROM] -> Class('ViewModel')]
// [RELATION: ViewModel('InventoryListViewModel') -> [DEPENDS_ON] -> Annotation('HiltViewModel')]
/**
* [CONTRACT]
* @summary ViewModel for the InventoryListScreen.
*/
@HiltViewModel
class InventoryListViewModel
@Inject
constructor() : ViewModel() {
// [STATE]
private val _uiState = MutableStateFlow(InventoryListUiState())
val uiState: StateFlow<InventoryListUiState> = _uiState.asStateFlow()
fun onSyncClicked() {
// TODO: Implement sync logic
}
fun onSearchQueryChanged(query: String) {
// TODO: Implement search query change logic
}
}
// [END_ENTITY: ViewModel('InventoryListViewModel')]
// [END_CONTRACT]
// [END_FILE_InventoryListViewModel.kt]
// [CONTRACT]
// [ENTITY: DataClass('InventoryListUiState')]
// [RELATION: DataClass('InventoryListUiState') -> [DEPENDS_ON] -> Class('Item')]
data class InventoryListUiState(
val searchQuery: String = "",
val isLoading: Boolean = false,
val items: List<Item> = emptyList()
)
// [END_ENTITY: DataClass('InventoryListUiState')]

View File

@@ -1,208 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.itemdetails
// [FILE] ItemDetailsScreen.kt
// [SEMANTICS] ui, screen, item, details, compose
package com.homebox.lens.ui.screen.itemdetails
// [IMPORTS]
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.homebox.lens.R
import com.homebox.lens.domain.model.Item
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('ItemDetailsScreen')]
// [RELATION: Function('ItemDetailsScreen') -> [DEPENDS_ON] -> Class('ItemDetailsViewModel')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('hiltViewModel')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('collectAsState')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('Scaffold')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('TopAppBar')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('Text')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('IconButton')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('ItemDetailsScreen') -> [CALLS] -> Function('ItemDetailsContent')]
/**
* [MAIN-CONTRACT]
* Экран для отображения детальной информации о товаре.
*
* Реализует спецификацию `screen_item_details`.
*
* @param onNavigateBack Обработчик для возврата на предыдущий экран.
* @param onEditClick Обработчик нажатия на кнопку редактирования.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ItemDetailsScreen(
viewModel: ItemDetailsViewModel = hiltViewModel(),
onNavigateBack: () -> Unit,
onEditClick: (Int) -> Unit
) {
// [STATE]
val uiState by viewModel.uiState.collectAsState()
Scaffold(
topBar = {
TopAppBar(
title = { Text(uiState.item?.name ?: stringResource(id = R.string.item_details_title)) }, // Corrected string resource name
navigationIcon = {
IconButton(onClick = onNavigateBack) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(id = R.string.content_desc_navigate_back))
}
},
actions = {
IconButton(onClick = {
uiState.item?.id?.let {
Timber.i("[INFO][ACTION][ui_interaction] Edit item clicked: id=$it")
onEditClick(it.toInt())
}
}) {
Icon(Icons.Default.Edit, contentDescription = stringResource(id = R.string.content_desc_edit_item))
}
IconButton(onClick = {
Timber.w("[WARN][ACTION][ui_interaction] Delete item clicked: id=${uiState.item?.id}")
viewModel.deleteItem()
// После удаления нужно навигироваться назад
onNavigateBack()
}) {
Icon(Icons.Default.Delete, contentDescription = stringResource(id = R.string.content_desc_delete_item))
}
}
)
}
) { innerPadding ->
ItemDetailsContent(
modifier = Modifier.padding(innerPadding),
isLoading = uiState.isLoading,
item = uiState.item
)
}
}
// [END_ENTITY: Function('ItemDetailsScreen')]
// [ENTITY: Function('ItemDetailsContent')]
// [RELATION: Function('ItemDetailsContent') -> [DEPENDS_ON] -> Class('Item')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('Box')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('CircularProgressIndicator')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('Text')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('Column')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('verticalScroll')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('rememberScrollState')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('DetailsSection')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('InfoRow')]
// [RELATION: Function('ItemDetailsContent') -> [CALLS] -> Function('AssistChip')]
/**
* [CONTRACT]
* Отображает контент экрана: индикатор загрузки или детали товара.
*/
@Composable
private fun ItemDetailsContent(
modifier: Modifier = Modifier,
isLoading: Boolean,
item: Item?
) {
Box(modifier = modifier.fillMaxSize()) {
when {
isLoading -> {
// [STATE]
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
item == null -> {
// [FALLBACK]
Text(stringResource(id = R.string.items_not_found), modifier = Modifier.align(Alignment.Center))
}
else -> {
// [CORE-LOGIC]
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
// TODO: ImageCarousel
// Text("Image Carousel Placeholder")
DetailsSection(title = stringResource(id = R.string.section_title_description)) {
Text(text = item.description ?: stringResource(id = R.string.placeholder_no_description))
}
DetailsSection(title = stringResource(id = R.string.section_title_details)) {
InfoRow(label = stringResource(id = R.string.label_quantity), value = item.quantity.toString())
item.location?.let {
InfoRow(label = stringResource(id = R.string.label_location), value = it.name)
}
}
if (item.labels.isNotEmpty()) {
DetailsSection(title = stringResource(id = R.string.section_title_labels)) {
// TODO: Use FlowRow for better layout
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
item.labels.forEach { label ->
AssistChip(onClick = { /* No-op */ }, label = { Text(label.name) })
}
}
}
}
// TODO: CustomFieldsGrid
}
}
}
}
}
// [END_ENTITY: Function('ItemDetailsContent')]
// [ENTITY: Function('DetailsSection')]
// [RELATION: Function('DetailsSection') -> [CALLS] -> Function('Column')]
// [RELATION: Function('DetailsSection') -> [CALLS] -> Function('Text')]
// [RELATION: Function('DetailsSection') -> [CALLS] -> Function('MaterialTheme.typography.titleMedium')]
// [RELATION: Function('DetailsSection') -> [CALLS] -> Function('Divider')]
/**
* [CONTRACT]
* Секция с заголовком и контентом.
*/
@Composable
private fun DetailsSection(title: String, content: @Composable ColumnScope.() -> Unit) {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Text(text = title, style = MaterialTheme.typography.titleMedium)
Divider()
content()
}
}
// [END_ENTITY: Function('DetailsSection')]
// [ENTITY: Function('InfoRow')]
// [RELATION: Function('InfoRow') -> [CALLS] -> Function('Row')]
// [RELATION: Function('InfoRow') -> [CALLS] -> Function('Text')]
// [RELATION: Function('InfoRow') -> [CALLS] -> Function('MaterialTheme.typography.bodyLarge')]
/**
* [CONTRACT]
* Строка для отображения пары "метка: значение".
*/
@Composable
private fun InfoRow(label: String, value: String) {
Row {
Text(text = "$label: ", style = MaterialTheme.typography.bodyLarge)
Text(text = value, style = MaterialTheme.typography.bodyLarge)
}
}
// [END_ENTITY: Function('InfoRow')]
// [END_CONTRACT]
// [END_FILE_ItemDetailsScreen.kt]

View File

@@ -1,43 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.itemdetails
// [FILE] ItemDetailsViewModel.kt
package com.homebox.lens.ui.screen.itemdetails
// [IMPORTS]
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import com.homebox.lens.domain.model.Item
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: ViewModel('ItemDetailsViewModel')]
// [RELATION: ViewModel('ItemDetailsViewModel') -> [INHERITS_FROM] -> Class('ViewModel')]
// [RELATION: ViewModel('ItemDetailsViewModel') -> [DEPENDS_ON] -> Annotation('HiltViewModel')]
/**
* [CONTRACT]
* @summary ViewModel for the ItemDetailsScreen.
*/
@HiltViewModel
class ItemDetailsViewModel
@Inject
constructor() : ViewModel() {
// [STATE]
// TODO: Implement UI state
val uiState = MutableStateFlow(ItemDetailsUiState()).asStateFlow()
fun deleteItem() {
// TODO: Implement delete item logic
}
}
// [END_ENTITY: ViewModel('ItemDetailsViewModel')]
// [END_CONTRACT]
// [END_FILE_ItemDetailsViewModel.kt]
// Placeholder for ItemDetailsUiState to resolve compilation errors
data class ItemDetailsUiState(
val item: Item? = null,
val isLoading: Boolean = false
)

View File

@@ -1,162 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.itemedit
// [FILE] ItemEditScreen.kt
// [SEMANTICS] ui, screen, item, edit, create, compose
package com.homebox.lens.ui.screen.itemedit
// [IMPORTS]
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Done
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.homebox.lens.R
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('ItemEditScreen')]
// [RELATION: Function('ItemEditScreen') -> [DEPENDS_ON] -> Class('ItemEditViewModel')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('hiltViewModel')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('collectAsState')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('LaunchedEffect')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('Timber.i')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('Scaffold')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('TopAppBar')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('Text')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('IconButton')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('ItemEditScreen') -> [CALLS] -> Function('ItemEditContent')]
/**
* [MAIN-CONTRACT]
* Экран для создания или редактирования товара.
*
* Реализует спецификацию `screen_item_edit`.
*
* @param onNavigateBack Обработчик для возврата на предыдущий экран после сохранения или отмены.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ItemEditScreen(
viewModel: ItemEditViewModel = hiltViewModel(),
onNavigateBack: () -> Unit
) {
// [STATE]
val uiState by viewModel.uiState.collectAsState()
// [SIDE-EFFECT]
LaunchedEffect(uiState.isSaved) {
if (uiState.isSaved) {
Timber.i("[INFO][SIDE_EFFECT][navigation] Item saved, navigating back.")
onNavigateBack()
}
}
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(id = if (uiState.isEditing) R.string.item_edit_title else R.string.item_edit_title_create)) }, // Corrected string resource names
navigationIcon = {
IconButton(onClick = onNavigateBack) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(id = R.string.content_desc_navigate_back))
}
},
actions = {
IconButton(onClick = {
Timber.i("[INFO][ACTION][ui_interaction] Save item clicked.")
viewModel.saveItem()
}) {
Icon(Icons.Default.Done, contentDescription = stringResource(id = R.string.content_desc_save_item))
}
}
)
}
) { innerPadding ->
ItemEditContent(
modifier = Modifier.padding(innerPadding),
state = uiState,
onNameChange = { viewModel.onNameChange(it) },
onDescriptionChange = { viewModel.onDescriptionChange(it) },
onQuantityChange = { viewModel.onQuantityChange(it) }
)
}
}
// [END_ENTITY: Function('ItemEditScreen')]
// [ENTITY: Function('ItemEditContent')]
// [RELATION: Function('ItemEditContent') -> [DEPENDS_ON] -> Class('ItemEditUiState')]
// [RELATION: Function('ItemEditContent') -> [CALLS] -> Function('Column')]
// [RELATION: Function('ItemEditContent') -> [CALLS] -> Function('verticalScroll')]
// [RELATION: Function('ItemEditContent') -> [CALLS] -> Function('rememberScrollState')]
// [RELATION: Function('ItemEditContent') -> [CALLS] -> Function('OutlinedTextField')]
// [RELATION: Function('ItemEditContent') -> [CALLS] -> Function('Text')]
// [RELATION: Function('ItemEditContent') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('ItemEditContent') -> [CALLS] -> Function('MaterialTheme.colorScheme.error')]
/**
* [CONTRACT]
* Отображает форму для редактирования данных товара.
*/
@Composable
private fun ItemEditContent(
modifier: Modifier = Modifier,
state: ItemEditUiState,
onNameChange: (String) -> Unit,
onDescriptionChange: (String) -> Unit,
onQuantityChange: (String) -> Unit
) {
// [CORE-LOGIC]
Column(
modifier = modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
OutlinedTextField(
value = state.name,
onValueChange = onNameChange,
label = { Text(stringResource(id = R.string.label_name)) },
modifier = Modifier.fillMaxWidth(),
isError = state.nameError != null
)
state.nameError?.let {
Text(text = stringResource(id = it), color = MaterialTheme.colorScheme.error)
}
OutlinedTextField(
value = state.description,
onValueChange = onDescriptionChange,
label = { Text(stringResource(id = R.string.label_description)) },
modifier = Modifier.fillMaxWidth(),
minLines = 3
)
OutlinedTextField(
value = state.quantity,
onValueChange = onQuantityChange,
label = { Text(stringResource(id = R.string.label_quantity)) },
modifier = Modifier.fillMaxWidth(),
isError = state.quantityError != null
)
state.quantityError?.let {
Text(text = stringResource(id = it), color = MaterialTheme.colorScheme.error)
}
// TODO: Location Dropdown
// TODO: Labels ChipGroup
// TODO: ImagePicker
}
}
// [END_ENTITY: Function('ItemEditContent')]
// [END_CONTRACT]
// [END_FILE_ItemEditScreen.kt]

View File

@@ -1,59 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.itemedit
// [FILE] ItemEditViewModel.kt
package com.homebox.lens.ui.screen.itemedit
// [IMPORTS]
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: ViewModel('ItemEditViewModel')]
// [RELATION: ViewModel('ItemEditViewModel') -> [INHERITS_FROM] -> Class('ViewModel')]
// [RELATION: ViewModel('ItemEditViewModel') -> [DEPENDS_ON] -> Annotation('HiltViewModel')]
/**
* [CONTRACT]
* @summary ViewModel for the ItemEditScreen.
*/
@HiltViewModel
class ItemEditViewModel
@Inject
constructor() : ViewModel() {
// [STATE]
// TODO: Implement UI state
val uiState = MutableStateFlow(ItemEditUiState()).asStateFlow()
fun saveItem() {
// TODO: Implement save item logic
}
fun onNameChange(name: String) {
// TODO: Implement name change logic
}
fun onDescriptionChange(description: String) {
// TODO: Implement description change logic
}
fun onQuantityChange(quantity: String) {
// TODO: Implement quantity change logic
}
}
// [END_ENTITY: ViewModel('ItemEditViewModel')]
// [END_CONTRACT]
// [END_FILE_ItemEditViewModel.kt]
// Placeholder for ItemEditUiState to resolve compilation errors
data class ItemEditUiState(
val isSaved: Boolean = false,
val isEditing: Boolean = false,
val name: String = "",
val description: String = "",
val quantity: String = "",
val nameError: Int? = null,
val quantityError: Int? = null
)

View File

@@ -1,203 +0,0 @@
// [PACKAGE]com.homebox.lens.ui.screen.labelslist
// [FILE]LabelsListScreen.kt
// [SEMANTICS]ui, screen, labels, list, compose
package com.homebox.lens.ui.screen.labelslist
// [IMPORTS]
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.Label
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.homebox.lens.R
import com.homebox.lens.domain.model.Label
import com.homebox.lens.ui.screen.labelslist.LabelsListUiState
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('LabelsListScreen')]
// [RELATION: Function('LabelsListScreen') -> [DEPENDS_ON] -> SealedInterface('LabelsListUiState')]
// [RELATION: Function('LabelsListScreen') -> [CREATES_INSTANCE_OF] -> Class('Scaffold')]
// [RELATION: Function('LabelsListScreen') -> [CALLS] -> Function('LabelsListContent')]
// [RELATION: Function('LabelsListScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('LabelsListScreen') -> [CALLS] -> Function('Text')]
// [RELATION: Function('LabelsListScreen') -> [CALLS] -> Function('IconButton')]
// [RELATION: Function('LabelsListScreen') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('LabelsListScreen') -> [CALLS] -> Function('FloatingActionButton')]
// [RELATION: Function('LabelsListScreen') -> [CALLS] -> Function('Column')]
// [RELATION: Function('LabelsListScreen') -> [CALLS] -> Function('CircularProgressIndicator')]
/**
* [MAIN-CONTRACT]
* Экран для отображения списка всех меток.
*
* Этот Composable является точкой входа для UI, определенного в спецификации `screen_labels_list`.
* Он получает состояние от [LabelsListViewModel] и отображает его, делегируя обработку
* пользовательских событий в ViewModel.
*
* @param uiState Текущее состояние UI для экрана списка меток.
* @param onLabelClick Функция обратного вызова для обработки нажатия на метку.
* @param onAddClick Функция обратного вызова для обработки нажатия на кнопку добавления метки.
* @param onNavigateBack Функция обратного вызова для навигации назад.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun labelsListScreen(
uiState: LabelsListUiState,
onLabelClick: (Label) -> Unit,
onAddClick: () -> Unit,
onNavigateBack: () -> Unit,
) {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(id = R.string.screen_title_labels)) },
navigationIcon = {
IconButton(onClick = onNavigateBack) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = stringResource(id = R.string.content_desc_navigate_back)
)
}
},
)
},
floatingActionButton = {
FloatingActionButton(onClick = onAddClick) {
Icon(
imageVector = Icons.Filled.Add,
contentDescription = stringResource(id = R.string.content_desc_add_label)
)
}
}
) { innerPadding ->
Box(modifier = Modifier.padding(innerPadding)) {
when (uiState) {
is LabelsListUiState.Loading -> {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
CircularProgressIndicator()
}
}
is LabelsListUiState.Success -> {
LabelsListContent(
uiState = uiState,
onLabelClick = onLabelClick
)
}
is LabelsListUiState.Error -> {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = uiState.message)
}
}
}
}
}
}
// [END_ENTITY: Function('LabelsListScreen')]
// [ENTITY: Function('LabelsListContent')]
// [RELATION: Function('LabelsListContent') -> [CALLS] -> Function('LabelListItem')]
// [RELATION: Function('LabelsListContent') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('LabelsListContent') -> [CALLS] -> Function('Text')]
// [RELATION: Function('LabelsListContent') -> [CALLS] -> Function('Column')]
// [RELATION: Function('LabelsListContent') -> [CALLS] -> Function('LazyColumn')]
/**
* [CONTRACT]
* Отображает основной контент экрана: список меток.
*
* @param uiState Состояние успеха, содержащее список меток.
* @param onLabelClick Обработчик нажатия на элемент списка.
* @sideeffect Отсутствуют.
*/
@Composable
private fun LabelsListContent(
uiState: LabelsListUiState.Success,
onLabelClick: (Label) -> Unit
) {
if (uiState.labels.isEmpty()) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = stringResource(id = R.string.no_labels_found))
}
} else {
LazyColumn {
items(uiState.labels, key = { it.id }) { label ->
LabelListItem(
label = label,
onClick = {
Timber.i("[INFO][ACTION][ui_interaction] Label clicked: ${label.name}")
onLabelClick(label)
}
)
}
}
}
}
// [END_ENTITY: Function('LabelsListContent')]
// [ENTITY: Function('LabelListItem')]
// [RELATION: Function('LabelListItem') -> [CALLS] -> Function('ListItem')]
// [RELATION: Function('LabelListItem') -> [CALLS] -> Function('Text')]
// [RELATION: Function('LabelListItem') -> [CALLS] -> Function('Icon')]
/**
* [CONTRACT]
* Отображает один элемент в списке меток.
*
* @param label Метка для отображения.
* @param onClick Обработчик нажатия на элемент.
* @sideeffect Отсутствуют.
*/
@Composable
private fun LabelListItem(
label: Label,
onClick: () -> Unit
) {
// [PRECONDITION]
require(label.name.isNotBlank()) { "Label name cannot be blank." }
// [CORE-LOGIC]
ListItem(
headlineContent = { Text(label.name) },
leadingContent = {
Icon(
imageVector = Icons.AutoMirrored.Filled.Label,
contentDescription = null // Декоративный элемент
)
},
modifier = Modifier.clickable(onClick = onClick)
)
}
// [END_ENTITY: Function('LabelListItem')]
// [END_CONTRACT]
// [END_FILE_LabelsListScreen.kt]

View File

@@ -1,53 +0,0 @@
// [PACKAGE]com.homebox.lens.ui.screen.labelslist
// [FILE]LabelsListUiState.kt
// [SEMANTICS]ui_state, sealed_interface, contract
package com.homebox.lens.ui.screen.labelslist
// [IMPORTS]
import com.homebox.lens.domain.model.Label
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: SealedInterface('LabelsListUiState')]
/**
* [CONTRACT]
* @summary Определяет все возможные состояния для UI экрана со списком меток.
* @description Использование sealed-интерфейса позволяет исчерпывающе обрабатывать все состояния в Composable-функциях.
*/
sealed interface LabelsListUiState {
// [ENTITY: DataClass('Success')]
// [RELATION: DataClass('Success') -> [IMPLEMENTS] -> SealedInterface('LabelsListUiState')]
// [RELATION: DataClass('Success') -> [DEPENDS_ON] -> DataStructure('Label')]
/**
* @summary Состояние успеха, содержит список меток и состояние диалога.
* @property labels Список меток для отображения.
* @property isShowingCreateDialog Флаг, показывающий, должен ли быть отображен диалог создания метки.
* @invariant labels не может быть null.
*/
data class Success(
val labels: List<Label>,
val isShowingCreateDialog: Boolean = false
) : LabelsListUiState
// [ENTITY: DataClass('Error')]
// [RELATION: DataClass('Error') -> [IMPLEMENTS] -> SealedInterface('LabelsListUiState')]
/**
* @summary Состояние ошибки.
* @property message Текст ошибки для отображения пользователю, или `null` при отсутствии ошибки.
* @invariant message не может быть пустой.
*/
data class Error(
val message: String
) : LabelsListUiState
// [ENTITY: Object('Loading')]
// [RELATION: Object('Loading') -> [IMPLEMENTS] -> SealedInterface('LabelsListUiState')]
/**
* @summary Состояние загрузки данных.
* @description Указывает, что идет процесс загрузки меток.
*/
object Loading : LabelsListUiState
}
// [END_ENTITY: SealedInterface('LabelsListUiState')]
// [END_CONTRACT]
// [END_FILE_LabelsListUiState.kt]

View File

@@ -1,170 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.labelslist
// [FILE] LabelsListViewModel.kt
// [SEMANTICS] ui_logic, labels_list, state_management, dialog_management
package com.homebox.lens.ui.screen.labelslist
// [IMPORTS]
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.homebox.lens.domain.model.Label
import com.homebox.lens.domain.usecase.GetAllLabelsUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: ViewModel('LabelsListViewModel')]
// [RELATION: ViewModel('LabelsListViewModel') -> [INHERITS_FROM] -> Class('ViewModel')]
// [RELATION: ViewModel('LabelsListViewModel') -> [DEPENDS_ON] -> Annotation('HiltViewModel')]
// [RELATION: ViewModel('LabelsListViewModel') -> [DEPENDS_ON] -> Class('GetAllLabelsUseCase')]
/**
* [CONTRACT]
* @summary ViewModel для экрана со списком меток.
* @description Управляет состоянием экрана, загружает список меток, обрабатывает ошибки и управляет диалогом создания новой метки.
* @invariant `uiState` всегда является одним из состояний, определенных в `LabelsListUiState`.
*/
@HiltViewModel
class LabelsListViewModel
@Inject
constructor(
private val getAllLabelsUseCase: GetAllLabelsUseCase,
) : ViewModel() {
// [STATE]
private val _uiState = MutableStateFlow<LabelsListUiState>(LabelsListUiState.Loading)
val uiState = _uiState.asStateFlow()
// [INIT]
init {
loadLabels()
}
// [ENTITY: Function('loadLabels')]
// [RELATION: Function('loadLabels') -> [CALLS] -> Function('viewModelScope.launch')]
// [RELATION: Function('loadLabels') -> [WRITES_TO] -> Property('_uiState')]
// [RELATION: Function('loadLabels') -> [CALLS] -> Function('Timber.i')]
// [RELATION: Function('loadLabels') -> [CALLS] -> Function('runCatching')]
// [RELATION: Function('loadLabels') -> [CALLS] -> Function('getAllLabelsUseCase')]
// [RELATION: Function('loadLabels') -> [CALLS] -> Function('result.fold')]
// [RELATION: Function('loadLabels') -> [CALLS] -> Function('Timber.e')]
// [RELATION: Function('loadLabels') -> [CREATES_INSTANCE_OF] -> Class('Label')]
/**
* [CONTRACT]
* @summary Загружает список меток.
* @description Выполняет `GetAllLabelsUseCase` и обновляет UI, переключая его
* между состояниями `Loading`, `Success` и `Error`.
* @sideeffect Асинхронно обновляет `_uiState`.
*/
// [ACTION]
fun loadLabels() {
viewModelScope.launch {
_uiState.value = LabelsListUiState.Loading
Timber.i("[ACTION] Starting labels list load. State -> Loading.")
// [CORE-LOGIC]
val result =
runCatching {
getAllLabelsUseCase()
}
// [RESULT_HANDLER]
result.fold(
onSuccess = { labelOuts ->
Timber.i("[SUCCESS] Labels loaded successfully. Count: ${labelOuts.size}. State -> Success.")
// [DATA-FLOW] Map List<LabelOut> to List<Label> for the UI state.
// The 'Label' model for the UI is simpler and only contains 'id' and 'name'.
val labels =
labelOuts.map { labelOut ->
Label(
id = labelOut.id,
name = labelOut.name,
)
}
_uiState.value = LabelsListUiState.Success(labels, isShowingCreateDialog = false)
},
onFailure = { exception ->
Timber.e(exception, "[ERROR] Failed to load labels. State -> Error.")
_uiState.value =
LabelsListUiState.Error(
message = exception.message ?: "Could not load labels.",
)
},
)
}
}
// [END_ENTITY: Function('loadLabels')]
// [ENTITY: Function('onShowCreateDialog')]
// [RELATION: Function('onShowCreateDialog') -> [CALLS] -> Function('Timber.i')]
// [RELATION: Function('onShowCreateDialog') -> [CALLS] -> Function('_uiState.update')]
/**
* [CONTRACT]
* @summary Инициирует отображение диалога для создания метки.
* @description Обновляет состояние `uiState`, устанавливая `isShowingCreateDialog` в `true`.
* @sideeffect Обновляет `_uiState`.
*/
// [ACTION]
fun onShowCreateDialog() {
Timber.i("[ACTION] Show create label dialog requested.")
if (_uiState.value is LabelsListUiState.Success) {
_uiState.update {
(it as LabelsListUiState.Success).copy(isShowingCreateDialog = true)
}
}
}
// [END_ENTITY: Function('onShowCreateDialog')]
// [ENTITY: Function('onDismissCreateDialog')]
// [RELATION: Function('onDismissCreateDialog') -> [CALLS] -> Function('Timber.i')]
// [RELATION: Function('onDismissCreateDialog') -> [CALLS] -> Function('_uiState.update')]
/**
* [CONTRACT]
* @summary Скрывает диалог создания метки.
* @description Обновляет состояние `uiState`, устанавливая `isShowingCreateDialog` в `false`..
* @sideeffect Обновляет `_uiState`.
*/
// [ACTION]
fun onDismissCreateDialog() {
Timber.i("[ACTION] Dismiss create label dialog requested.")
if (_uiState.value is LabelsListUiState.Success) {
_uiState.update {
(it as LabelsListUiState.Success).copy(isShowingCreateDialog = false)
}
}
}
// [END_ENTITY: Function('onDismissCreateDialog')]
// [ENTITY: Function('createLabel')]
// [RELATION: Function('createLabel') -> [CALLS] -> Function('require')]
// [RELATION: Function('createLabel') -> [CALLS] -> Function('Timber.i')]
// [RELATION: Function('createLabel') -> [CALLS] -> Function('onDismissCreateDialog')]
/**
* [CONTRACT]
* @summary Создает новую метку. [MVP_SCOPE] ЗАГЛУШКА.
* @description В текущей реализации (План Б, Этап 1), эта функция только логирует действие
* и скрывает диалог. Реальная логика сохранения будет добавлена на следующем этапе.
* @param name Название новой метки.
* @precondition `name` не должен быть пустым.
* @sideeffect Логирует действие, обновляет `_uiState`, чтобы скрыть диалог.
*/
// [ACTION]
fun createLabel(name: String) {
// [PRECONDITION]
require(name.isNotBlank()) { "[CONTRACT_VIOLATION] Label name cannot be blank." }
Timber.i("[ACTION] Create label called with name: '$name'. [STUBBED]")
// [CORE-LOGIC] - Заглушка. Здесь будет вызов CreateLabelUseCase.
// [POSTCONDITION] Скрываем диалог после "создания".
onDismissCreateDialog()
// [REFACTORING_NOTE] На следующем этапе нужно добавить вызов UseCase и обновить список.
}
}
// [END_ENTITY: ViewModel('LabelsListViewModel')]
// [END_CONTRACT]
// [END_FILE_LabelsListViewModel.kt]

View File

@@ -1,54 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.locationedit
// [FILE] LocationEditScreen.kt
// [SEMANTICS] ui, screen, location, edit
package com.homebox.lens.ui.screen.locationedit
// [IMPORTS]
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.homebox.lens.R
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('LocationEditScreen')]
// [RELATION: Function('LocationEditScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('LocationEditScreen') -> [CALLS] -> Function('Scaffold')]
// [RELATION: Function('LocationEditScreen') -> [CALLS] -> Function('Box')]
// [RELATION: Function('LocationEditScreen') -> [CALLS] -> Function('Text')]
/**
* [CONTRACT]
* @summary Composable-функция для экрана "Редактирование местоположения".
* @param locationId ID местоположения для редактирования или "new" для создания.
*/
@Composable
fun LocationEditScreen(locationId: String?) {
val title =
if (locationId == "new") {
stringResource(id = R.string.location_edit_title_create)
} else {
stringResource(id = R.string.location_edit_title_edit)
}
Scaffold { paddingValues ->
Box(
modifier =
Modifier
.fillMaxSize()
.padding(paddingValues),
contentAlignment = Alignment.Center,
) {
Text(text = "TODO: Location Edit Screen for ID: $locationId")
}
}
}
// [END_ENTITY: Function('LocationEditScreen')]
// [END_CONTRACT]
// [END_FILE_LocationEditScreen.kt]

View File

@@ -1,355 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.locationslist
// [FILE] LocationsListScreen.kt
// [SEMANTICS] ui, screen, locations, list
package com.homebox.lens.ui.screen.locationslist
// [IMPORTS]
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material3.Card
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.homebox.lens.R
import com.homebox.lens.domain.model.LocationOutCount
import com.homebox.lens.navigation.NavigationActions
import com.homebox.lens.ui.common.MainScaffold
import com.homebox.lens.ui.theme.HomeboxLensTheme
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('LocationsListScreen')]
// [RELATION: Function('LocationsListScreen') -> [DEPENDS_ON] -> Class('NavigationActions')]
// [RELATION: Function('LocationsListScreen') -> [DEPENDS_ON] -> Class('LocationsListViewModel')]
// [RELATION: Function('LocationsListScreen') -> [CALLS] -> Function('hiltViewModel')]
// [RELATION: Function('LocationsListScreen') -> [CALLS] -> Function('collectAsState')]
// [RELATION: Function('LocationsListScreen') -> [CALLS] -> Function('MainScaffold')]
// [RELATION: Function('LocationsListScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('LocationsListScreen') -> [CALLS] -> Function('Scaffold')]
// [RELATION: Function('LocationsListScreen') -> [CALLS] -> Function('FloatingActionButton')]
// [RELATION: Function('LocationsListScreen') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('LocationsListScreen') -> [CALLS] -> Function('LocationsListContent')]
/**
* [CONTRACT]
* @summary Composable-функция для экрана "Список местоположений".
* @param currentRoute Текущий маршрут для подсветки активного элемента в Drawer.
* @param navigationActions Объект с навигационными действиями.
* @param onLocationClick Лямбда-обработчик нажатия на местоположение.
* @param onAddNewLocationClick Лямбда-обработчик нажатия на кнопку добавления нового местоположения.
* @param viewModel ViewModel для этого экрана.
*/
@Composable
fun LocationsListScreen(
currentRoute: String?,
navigationActions: NavigationActions,
onLocationClick: (String) -> Unit,
onAddNewLocationClick: () -> Unit,
viewModel: LocationsListViewModel = hiltViewModel(),
) {
// [STATE]
val uiState by viewModel.uiState.collectAsState()
// [UI_COMPONENT]
MainScaffold(
topBarTitle = stringResource(id = R.string.locations_list_title),
currentRoute = currentRoute,
navigationActions = navigationActions,
) { paddingValues ->
Scaffold(
modifier = Modifier.padding(paddingValues),
floatingActionButton = {
FloatingActionButton(onClick = onAddNewLocationClick) {
Icon(
Icons.Default.Add,
contentDescription = stringResource(id = R.string.cd_add_new_location),
)
}
},
) { innerPadding ->
LocationsListContent(
modifier = Modifier.padding(innerPadding),
uiState = uiState,
onLocationClick = onLocationClick,
onEditLocation = { /* TODO */ },
onDeleteLocation = { /* TODO */ },
)
}
}
}
// [END_ENTITY: Function('LocationsListScreen')]
// [ENTITY: Function('LocationsListContent')]
// [RELATION: Function('LocationsListContent') -> [DEPENDS_ON] -> SealedInterface('LocationsListUiState')]
// [RELATION: Function('LocationsListContent') -> [CALLS] -> Function('Box')]
// [RELATION: Function('LocationsListContent') -> [CALLS] -> Function('CircularProgressIndicator')]
// [RELATION: Function('LocationsListContent') -> [CALLS] -> Function('Text')]
// [RELATION: Function('LocationsListContent') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('LocationsListContent') -> [CALLS] -> Function('MaterialTheme.colorScheme.error')]
// [RELATION: Function('LocationsListContent') -> [CALLS] -> Function('LazyColumn')]
// [RELATION: Function('LocationsListContent') -> [CALLS] -> Function('LocationCard')]
/**
* [CONTRACT]
* @summary Отображает основной контент экрана в зависимости от `uiState`.
* @param modifier Модификатор для стилизации.
* @param uiState Текущее состояние UI.
* @param onLocationClick Лямбда-обработчик нажатия на местоположение.
* @param onEditLocation Лямбда-обработчик для редактирования местоположения.
* @param onDeleteLocation Лямбда-обработчик для удаления местоположения.
*/
@Composable
private fun LocationsListContent(
modifier: Modifier = Modifier,
uiState: LocationsListUiState,
onLocationClick: (String) -> Unit,
onEditLocation: (String) -> Unit,
onDeleteLocation: (String) -> Unit,
) {
Box(modifier = modifier.fillMaxSize()) {
when (uiState) {
is LocationsListUiState.Loading -> {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
is LocationsListUiState.Error -> {
Text(
text = uiState.message,
color = MaterialTheme.colorScheme.error,
textAlign = TextAlign.Center,
modifier =
Modifier
.align(Alignment.Center)
.padding(16.dp),
)
}
is LocationsListUiState.Success -> {
if (uiState.locations.isEmpty()) {
Text(
text = stringResource(id = R.string.locations_not_found),
textAlign = TextAlign.Center,
modifier =
Modifier
.align(Alignment.Center)
.padding(16.dp),
)
} else {
LazyColumn(
contentPadding = PaddingValues(16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
items(uiState.locations, key = { it.id }) { location ->
LocationCard(
location = location,
onClick = { onLocationClick(location.id) },
onEditClick = { onEditLocation(location.id) },
onDeleteClick = { onDeleteLocation(location.id) },
)
}
}
}
}
}
}
}
// [END_ENTITY: Function('LocationsListContent')]
// [ENTITY: Function('LocationCard')]
// [RELATION: Function('LocationCard') -> [DEPENDS_ON] -> Class('LocationOutCount')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('remember')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('mutableStateOf')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('Card')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('clickable')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('Row')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('Column')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('Text')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('MaterialTheme.typography.titleMedium')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('MaterialTheme.typography.bodyMedium')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('Spacer')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('Box')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('IconButton')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('DropdownMenu')]
// [RELATION: Function('LocationCard') -> [CALLS] -> Function('DropdownMenuItem')]
/**
* [CONTRACT]
* @summary Карточка для отображения одного местоположения.
* @param location Данные о местоположении.
* @param onClick Лямбда-обработчик нажатия на карточку.
* @param onEditClick Лямбда-обработчик нажатия на "Редактировать".
* @param onDeleteClick Лямбда-обработчик нажатия на "Удалить".
*/
@Composable
private fun LocationCard(
location: LocationOutCount,
onClick: () -> Unit,
onEditClick: () -> Unit,
onDeleteClick: () -> Unit,
) {
var menuExpanded by remember { mutableStateOf(false) }
Card(
modifier =
Modifier
.fillMaxWidth()
.clickable(onClick = onClick),
) {
Row(
modifier = Modifier.padding(start = 16.dp, end = 8.dp, top = 16.dp, bottom = 16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Column(modifier = Modifier.weight(1f)) {
Text(text = location.name, style = MaterialTheme.typography.titleMedium)
Text(
text = stringResource(id = R.string.item_count, location.itemCount),
style = MaterialTheme.typography.bodyMedium,
)
}
Spacer(Modifier.width(16.dp))
Box {
IconButton(onClick = { menuExpanded = true }) {
Icon(Icons.Default.MoreVert, contentDescription = stringResource(id = R.string.cd_more_options))
}
DropdownMenu(
expanded = menuExpanded,
onDismissRequest = { menuExpanded = false },
) {
DropdownMenuItem(
text = { Text(stringResource(id = R.string.edit)) },
onClick = {
menuExpanded = false
onEditClick()
},
)
DropdownMenuItem(
text = { Text(stringResource(id = R.string.delete)) },
onClick = {
menuExpanded = false
onDeleteClick()
},
)
}
}
}
}
}
// [END_ENTITY: Function('LocationCard')]
// [ENTITY: Function('LocationsListSuccessPreview')]
// [RELATION: Function('LocationsListSuccessPreview') -> [CALLS] -> Function('LocationOutCount')]
// [RELATION: Function('LocationsListSuccessPreview') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('LocationsListSuccessPreview') -> [CALLS] -> Function('LocationsListContent')]
// [RELATION: Function('LocationsListSuccessPreview') -> [CALLS] -> Function('LocationsListUiState.Success')]
// [PREVIEW]
@Preview(showBackground = true, name = "Locations List Success")
@Composable
fun LocationsListSuccessPreview() {
val previewLocations =
listOf(
LocationOutCount("1", "Garage", "#FF0000", false, 12, "", ""),
LocationOutCount("2", "Kitchen", "#00FF00", false, 5, "", ""),
LocationOutCount("3", "Office", "#0000FF", false, 23, "", ""),
)
HomeboxLensTheme {
LocationsListContent(
uiState = LocationsListUiState.Success(previewLocations),
onLocationClick = {},
onEditLocation = {},
onDeleteLocation = {},
)
}
}
// [END_ENTITY: Function('LocationsListSuccessPreview')]
// [ENTITY: Function('LocationsListEmptyPreview')]
// [RELATION: Function('LocationsListEmptyPreview') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('LocationsListEmptyPreview') -> [CALLS] -> Function('LocationsListContent')]
// [RELATION: Function('LocationsListEmptyPreview') -> [CALLS] -> Function('LocationsListUiState.Success')]
// [PREVIEW]
@Preview(showBackground = true, name = "Locations List Empty")
@Composable
fun LocationsListEmptyPreview() {
HomeboxLensTheme {
LocationsListContent(
uiState = LocationsListUiState.Success(emptyList()),
onLocationClick = {},
onEditLocation = {},
onDeleteLocation = {},
)
}
}
// [END_ENTITY: Function('LocationsListEmptyPreview')]
// [ENTITY: Function('LocationsListLoadingPreview')]
// [RELATION: Function('LocationsListLoadingPreview') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('LocationsListLoadingPreview') -> [CALLS] -> Function('LocationsListContent')]
// [RELATION: Function('LocationsListLoadingPreview') -> [CALLS] -> Function('LocationsListUiState.Loading')]
// [PREVIEW]
@Preview(showBackground = true, name = "Locations List Loading")
@Composable
fun LocationsListLoadingPreview() {
HomeboxLensTheme {
LocationsListContent(
uiState = LocationsListUiState.Loading,
onLocationClick = {},
onEditLocation = {},
onDeleteLocation = {},
)
}
}
// [END_ENTITY: Function('LocationsListLoadingPreview')]
// [ENTITY: Function('LocationsListErrorPreview')]
// [RELATION: Function('LocationsListErrorPreview') -> [CALLS] -> Function('HomeboxLensTheme')]
// [RELATION: Function('LocationsListErrorPreview') -> [CALLS] -> Function('LocationsListContent')]
// [RELATION: Function('LocationsListErrorPreview') -> [CALLS] -> Function('LocationsListUiState.Error')]
// [RELATION: Function('LocationsListErrorPreview') -> [CALLS] -> Function('stringResource')]
// [PREVIEW]
@Preview(showBackground = true, name = "Locations List Error")
@Composable
fun LocationsListErrorPreview() {
HomeboxLensTheme {
LocationsListContent(
uiState = LocationsListUiState.Error("Failed to load locations. Please try again."),
onLocationClick = {},
onEditLocation = {},
onDeleteLocation = {},
)
}
}
// [END_ENTITY: Function('LocationsListErrorPreview')]
// [END_CONTRACT]
// [END_FILE_LocationsListScreen.kt]

View File

@@ -1,48 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.locationslist
// [FILE] LocationsListUiState.kt
// [SEMANTICS] ui, state, locations
package com.homebox.lens.ui.screen.locationslist
// [IMPORTS]
import com.homebox.lens.domain.model.LocationOutCount
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: SealedInterface('LocationsListUiState')]
/**
* [CONTRACT]
* @summary Определяет возможные состояния UI для экрана списка местоположений.
* @see LocationsListViewModel
*/
sealed interface LocationsListUiState {
// [ENTITY: DataClass('Success')]
// [RELATION: DataClass('Success') -> [DEPENDS_ON] -> Class('LocationOutCount')]
/**
* [STATE]
* @summary Состояние успешной загрузки данных.
* @param locations Список местоположений для отображения.
*/
data class Success(val locations: List<LocationOutCount>) : LocationsListUiState
// [END_ENTITY: DataClass('Success')]
// [ENTITY: DataClass('Error')]
/**
* [STATE]
* @summary Состояние ошибки.
* @param message Сообщение об ошибке.
*/
data class Error(val message: String) : LocationsListUiState
// [END_ENTITY: DataClass('Error')]
// [ENTITY: DataObject('Loading')]
/**
* [STATE]
* @summary Состояние загрузки данных.
*/
object Loading : LocationsListUiState
// [END_ENTITY: DataObject('Loading')]
}
// [END_ENTITY: SealedInterface('LocationsListUiState')]
// [END_CONTRACT]
// [END_FILE_LocationsListUiState.kt]

View File

@@ -1,70 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.locationslist
// [FILE] LocationsListViewModel.kt
// [SEMANTICS] ui, viewmodel, locations, hilt
package com.homebox.lens.ui.screen.locationslist
// [IMPORTS]
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.homebox.lens.domain.usecase.GetAllLocationsUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: ViewModel('LocationsListViewModel')]
// [RELATION: ViewModel('LocationsListViewModel') -> [INHERITS_FROM] -> Class('ViewModel')]
// [RELATION: ViewModel('LocationsListViewModel') -> [DEPENDS_ON] -> Annotation('HiltViewModel')]
// [RELATION: ViewModel('LocationsListViewModel') -> [DEPENDS_ON] -> Class('GetAllLocationsUseCase')]
/**
* [CONTRACT]
* @summary ViewModel для экрана списка местоположений.
* @param getAllLocationsUseCase Use case для получения всех местоположений.
* @property uiState Поток, содержащий текущее состояние UI.
* @invariant `uiState` всегда отражает результат последней операции загрузки.
*/
@HiltViewModel
class LocationsListViewModel
@Inject
constructor(
private val getAllLocationsUseCase: GetAllLocationsUseCase,
) : ViewModel() {
// [STATE]
private val _uiState = MutableStateFlow<LocationsListUiState>(LocationsListUiState.Loading)
val uiState: StateFlow<LocationsListUiState> = _uiState.asStateFlow()
// [INITIALIZER]
init {
loadLocations()
}
// [ENTITY: Function('loadLocations')]
// [RELATION: Function('loadLocations') -> [CALLS] -> Function('viewModelScope.launch')]
// [RELATION: Function('loadLocations') -> [WRITES_TO] -> Property('_uiState')]
// [RELATION: Function('loadLocations') -> [CALLS] -> Function('getAllLocationsUseCase')]
/**
* [CONTRACT]
* @summary Загружает список местоположений из репозитория.
* @sideeffect Обновляет `_uiState` в зависимости от результата: Loading -> Success/Error.
*/
fun loadLocations() {
viewModelScope.launch {
_uiState.value = LocationsListUiState.Loading
try {
val locations = getAllLocationsUseCase()
_uiState.value = LocationsListUiState.Success(locations)
} catch (e: Exception) {
_uiState.value = LocationsListUiState.Error(e.message ?: "Unknown error")
}
}
}
// [END_ENTITY: Function('loadLocations')]
}
// [END_ENTITY: ViewModel('LocationsListViewModel')]
// [END_CONTRACT]
// [END_FILE_LocationsListViewModel.kt]

View File

@@ -1,129 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.search
// [FILE] SearchScreen.kt
// [SEMANTICS] ui, screen, search, compose
package com.homebox.lens.ui.screen.search
// [IMPORTS]
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.homebox.lens.R
import com.homebox.lens.domain.model.Item
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('SearchScreen')]
// [RELATION: Function('SearchScreen') -> [DEPENDS_ON] -> Class('SearchViewModel')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('hiltViewModel')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('collectAsState')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('Scaffold')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('TopAppBar')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('TextField')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('Text')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('IconButton')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('Icon')]
// [RELATION: Function('SearchScreen') -> [CALLS] -> Function('SearchContent')]
/**
* [MAIN-CONTRACT]
* Специализированный экран для поиска товаров.
*
* Реализует спецификацию `screen_search`.
*
* @param onNavigateBack Обработчик для возврата на предыдущий экран.
* @param onItemClick Обработчик нажатия на найденный товар.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SearchScreen(
viewModel: SearchViewModel = hiltViewModel(),
onNavigateBack: () -> Unit,
onItemClick: (Item) -> Unit
) {
// [STATE]
val uiState by viewModel.uiState.collectAsState()
Scaffold(
topBar = {
TopAppBar(
title = {
TextField(
value = uiState.searchQuery,
onValueChange = viewModel::onSearchQueryChanged,
placeholder = { Text(stringResource(R.string.placeholder_search_items)) },
modifier = Modifier.fillMaxWidth()
)
},
navigationIcon = {
IconButton(onClick = onNavigateBack) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.content_desc_navigate_back))
}
}
)
}
) { innerPadding ->
SearchContent(
modifier = Modifier.padding(innerPadding),
isLoading = uiState.isLoading,
results = uiState.results,
onItemClick = onItemClick
)
}
}
// [END_ENTITY: Function('SearchScreen')]
// [ENTITY: Function('SearchContent')]
// [RELATION: Function('SearchContent') -> [CALLS] -> Function('CircularProgressIndicator')]
// [RELATION: Function('SearchContent') -> [CALLS] -> Function('LazyColumn')]
// [RELATION: Function('SearchContent') -> [CALLS] -> Function('ListItem')]
// [RELATION: Function('SearchContent') -> [CALLS] -> Function('Text')]
// [RELATION: Function('SearchContent') -> [CALLS] -> Function('clickable')]
/**
* [CONTRACT]
* Отображает основной контент экрана: фильтры и результаты поиска.
*/
@Composable
private fun SearchContent(
modifier: Modifier = Modifier,
isLoading: Boolean,
results: List<Item>,
onItemClick: (Item) -> Unit
) {
Column(modifier = modifier.fillMaxSize()) {
// [SECTION] FILTERS
// TODO: Implement FilterSection with chips for locations/labels
// Spacer(modifier = Modifier.height(8.dp))
// [SECTION] RESULTS
Box(modifier = Modifier.weight(1f)) {
if (isLoading) {
// [STATE]
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
} else {
// [CORE-LOGIC]
LazyColumn {
items(results, key = { it.id }) { item ->
ListItem(
headlineContent = { Text(item.name) },
supportingContent = { Text(item.location?.name ?: "") },
modifier = Modifier.then(Modifier.clickable { onItemClick(item) })
)
}
}
}
}
}
}
// [END_ENTITY: Function('SearchContent')]
// [END_CONTRACT]
// [END_FILE_SearchScreen.kt]

View File

@@ -1,44 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.search
// [FILE] SearchViewModel.kt
// [SEMANTICS] ui_logic, search, viewmodel
package com.homebox.lens.ui.screen.search
// [IMPORTS]
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: ViewModel('SearchViewModel')]
// [RELATION: ViewModel('SearchViewModel') -> [INHERITS_FROM] -> Class('ViewModel')]
// [RELATION: ViewModel('SearchViewModel') -> [DEPENDS_ON] -> Annotation('HiltAndroidApp')]
/**
* [CONTRACT]
* @summary ViewModel for the SearchScreen.
*/
@HiltViewModel
class SearchViewModel
@Inject
constructor() : ViewModel() {
// [STATE]
// TODO: Implement UI state
val uiState = MutableStateFlow(SearchUiState()).asStateFlow()
fun onSearchQueryChanged(query: String) {
// TODO: Implement search query change logic
}
}
// [END_ENTITY: ViewModel('SearchViewModel')]
// [END_CONTRACT]
// [END_FILE_SearchViewModel.kt]
// Placeholder for SearchUiState to resolve compilation errors
data class SearchUiState(
val searchQuery: String = "",
val isLoading: Boolean = false,
val results: List<com.homebox.lens.domain.model.Item> = emptyList()
)

View File

@@ -1,126 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.setup
// [FILE] SetupScreen.kt
// [SEMANTICS] ui, screen, setup, login, compose
package com.homebox.lens.ui.screen.setup
// [IMPORTS]
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.homebox.lens.R
import timber.log.Timber
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Function('SetupScreen')]
// [RELATION: Function('SetupScreen') -> [DEPENDS_ON] -> Class('SetupViewModel')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('hiltViewModel')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('collectAsState')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('LaunchedEffect')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('Timber.i')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('Box')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('Column')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('Text')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('stringResource')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('MaterialTheme.typography.headlineMedium')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('OutlinedTextField')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('KeyboardOptions')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('KeyboardType.Uri')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('PasswordVisualTransformation')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('CircularProgressIndicator')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('Button')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('MaterialTheme.colorScheme.error')]
// [RELATION: Function('SetupScreen') -> [CALLS] -> Function('MaterialTheme.typography.bodyMedium')]
/**
* [MAIN-CONTRACT]
* Экран для начальной настройки соединения с сервером Homebox.
*
* @param onSetupComplete Обработчик, вызываемый после успешной настройки и входа.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SetupScreen(
viewModel: SetupViewModel = hiltViewModel(),
onSetupComplete: () -> Unit
) {
// [STATE]
val uiState by viewModel.uiState.collectAsState()
// [SIDE-EFFECT]
LaunchedEffect(uiState.isSetupComplete) {
if (uiState.isSetupComplete) {
Timber.i("[INFO][SIDE_EFFECT][navigation] Setup complete, navigating to main screen.")
onSetupComplete()
}
}
// [CORE-LOGIC]
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(32.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Text(text = stringResource(id = R.string.screen_title_setup), style = MaterialTheme.typography.headlineMedium)
OutlinedTextField(
value = uiState.serverUrl,
onValueChange = viewModel::onServerUrlChange,
label = { Text(stringResource(id = R.string.setup_server_url_label)) },
modifier = Modifier.fillMaxWidth(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
isError = uiState.error != null
)
OutlinedTextField(
value = uiState.password, // Changed from uiState.apiKey to uiState.password
onValueChange = viewModel::onPasswordChange, // Changed from viewModel::onApiKeyChange to viewModel::onPasswordChange
label = { Text(stringResource(id = R.string.setup_password_label)) }, // Changed from label_api_key to setup_password_label
modifier = Modifier.fillMaxWidth(),
visualTransformation = PasswordVisualTransformation(),
isError = uiState.error != null
)
if (uiState.isLoading) {
// [STATE]
CircularProgressIndicator()
} else {
// [ACTION]
Button(
onClick = {
Timber.i("[INFO][ACTION][ui_interaction] Login button clicked.")
viewModel.connect() // Changed from viewModel.login() to viewModel.connect()
},
modifier = Modifier.fillMaxWidth()
) {
Text(text = stringResource(id = R.string.setup_connect_button)) // Changed from button_connect to setup_connect_button
}
}
uiState.error?.let {
// [FALLBACK]
Text(
text = it,
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodyMedium
)
}
}
}
}
// [END_ENTITY: Function('SetupScreen')]
// [END_CONTRACT]
// [END_FILE_SetupScreen.kt]

View File

@@ -1,34 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.setup
// [FILE] SetupUiState.kt
// [SEMANTICS] ui_state, data_model, immutable
package com.homebox.lens.ui.screen.setup
// [IMPORTS]
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: DataClass('SetupUiState')]
/**
* [ENTITY: DataClass('SetupUiState')]
* [CONTRACT]
* Неизменяемая модель данных, представляющая полное состояние экрана настройки (Setup Screen).
* Использование `data class` предоставляет метод `copy()` для легкого создания новых состояний.
* @property serverUrl URL-адрес сервера Homebox.
* @property username Имя пользователя для входа.
* @property password Пароль пользователя.
* @property isLoading Флаг, указывающий, выполняется ли в данный момент сетевой запрос.
* @property error Сообщение об ошибке для отображения пользователю, или `null` при отсутствии ошибки.
* @property isSetupComplete Флаг, указывающий на успешное завершение настройки и входа.
*/
data class SetupUiState(
val serverUrl: String = "",
val username: String = "",
val password: String = "",
val isLoading: Boolean = false,
val error: String? = null,
val isSetupComplete: Boolean = false,
)
// [END_ENTITY: DataClass('SetupUiState')]
// [END_CONTRACT]
// [END_FILE_SetupUiState.kt]

View File

@@ -1,172 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.screen.setup
// [FILE] SetupViewModel.kt
// [SEMANTICS] ui_logic, viewmodel, state_management, user_setup, authentication_flow
package com.homebox.lens.ui.screen.setup
// [IMPORTS]
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.homebox.lens.domain.model.Credentials
import com.homebox.lens.domain.repository.CredentialsRepository
import com.homebox.lens.domain.usecase.LoginUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import javax.inject.Inject
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: ViewModel('SetupViewModel')]
// [RELATION: ViewModel('SetupViewModel') -> [INHERITS_FROM] -> Class('ViewModel')]
// [RELATION: ViewModel('SetupViewModel') -> [DEPENDS_ON] -> Annotation('HiltViewModel')]
// [RELATION: ViewModel('SetupViewModel') -> [DEPENDS_ON] -> Class('CredentialsRepository')]
// [RELATION: ViewModel('SetupViewModel') -> [DEPENDS_ON] -> Class('LoginUseCase')]
/**
* [CONTRACT]
* ViewModel для экрана первоначальной настройки (Setup).
* Отвечает за:
* 1. Загрузку и сохранение учетных данных (URL сервера, логин, пароль).
* 2. Управление состоянием UI экрана (`SetupUiState`).
* 3. Инициацию процесса входа в систему через `LoginUseCase`.
* @property credentialsRepository Репозиторий для операций с учетными данными.
* @property loginUseCase Use case для выполнения логики входа.
* @invariant Состояние `uiState` всегда является единственным источником истины для UI.
*/
@HiltViewModel
class SetupViewModel
@Inject
constructor(
private val credentialsRepository: CredentialsRepository,
private val loginUseCase: LoginUseCase,
) : ViewModel() {
// [STATE]
private val _uiState = MutableStateFlow(SetupUiState())
val uiState = _uiState.asStateFlow()
// [LIFECYCLE_HANDLER]
init {
// [ACTION] Загружаем учетные данные при создании ViewModel.
loadCredentials()
}
// [ENTITY: Function('loadCredentials')]
// [RELATION: Function('loadCredentials') -> [CALLS] -> Function('viewModelScope.launch')]
// [RELATION: Function('loadCredentials') -> [CALLS] -> Function('credentialsRepository.getCredentials')]
// [RELATION: Function('loadCredentials') -> [CALLS] -> Function('collect')]
// [RELATION: Function('loadCredentials') -> [WRITES_TO] -> Property('_uiState')]
/**
* [CONTRACT]
* @summary Загружает учетные данные из репозитория при инициализации.
* @sideeffect Асинхронно обновляет `_uiState` полученными учетными данными.
*/
private fun loadCredentials() {
viewModelScope.launch {
// [CORE-LOGIC] Подписываемся на поток учетных данных.
credentialsRepository.getCredentials().collect { credentials ->
// [ACTION] Обновляем состояние, если учетные данные существуют.
if (credentials != null) {
_uiState.update {
it.copy(
serverUrl = credentials.serverUrl,
username = credentials.username,
password = credentials.password,
)
}
}
}
}
}
// [END_ENTITY: Function('loadCredentials')]
// [ENTITY: Function('onServerUrlChange')]
// [RELATION: Function('onServerUrlChange') -> [WRITES_TO] -> Property('_uiState')]
/**
* [CONTRACT]
* [ACTION] Обновляет URL сервера в состоянии UI в ответ на ввод пользователя.
* @param newUrl Новое значение URL.
* @sideeffect Обновляет поле `serverUrl` в `_uiState`.
*/
fun onServerUrlChange(newUrl: String) {
_uiState.update { it.copy(serverUrl = newUrl) }
}
// [END_ENTITY: Function('onServerUrlChange')]
// [ENTITY: Function('onUsernameChange')]
// [RELATION: Function('onUsernameChange') -> [WRITES_TO] -> Property('_uiState')]
/**
* [CONTRACT]
* [ACTION] Обновляет имя пользователя в состоянии UI в ответ на ввод пользователя.
* @param newUsername Новое значение имени пользователя.
* @sideeffect Обновляет поле `username` в `_uiState`.
*/
fun onUsernameChange(newUsername: String) {
_uiState.update { it.copy(username = newUsername) }
}
// [END_ENTITY: Function('onUsernameChange')]
// [ENTITY: Function('onPasswordChange')]
// [RELATION: Function('onPasswordChange') -> [WRITES_TO] -> Property('_uiState')]
/**
* [CONTRACT]
* [ACTION] Обновляет пароль в состоянии UI в ответ на ввод пользователя.
* @param newPassword Новое значение пароля.
* @sideeffect Обновляет поле `password` в `_uiState`.
*/
fun onPasswordChange(newPassword: String) {
_uiState.update { it.copy(password = newPassword) }
}
// [END_ENTITY: Function('onPasswordChange')]
// [ENTITY: Function('connect')]
// [RELATION: Function('connect') -> [CALLS] -> Function('viewModelScope.launch')]
// [RELATION: Function('connect') -> [WRITES_TO] -> Property('_uiState')]
// [RELATION: Function('connect') -> [CREATES_INSTANCE_OF] -> Class('Credentials')]
// [RELATION: Function('connect') -> [CALLS] -> Function('credentialsRepository.saveCredentials')]
// [RELATION: Function('connect') -> [CALLS] -> Function('loginUseCase')]
// [RELATION: Function('connect') -> [CALLS] -> Function('fold')]
/**
* [CONTRACT]
* [ACTION] Запускает процесс подключения и входа в систему по действию пользователя.
* Выполняет две основные операции:
* 1. Сохраняет введенные учетные данные для последующих сессий.
* 2. Выполняет вход в систему с использованием этих данных.
* @sideeffect Обновляет `_uiState`, управляя флагами `isLoading`, `error` и `isSetupComplete`.
* @sideeffect Вызывает `credentialsRepository.saveCredentials`, изменяя сохраненные данные.
* @sideeffect Вызывает `loginUseCase`, который, в свою очередь, сохраняет токен.
*/
fun connect() {
viewModelScope.launch {
// [ACTION] Устанавливаем состояние загрузки и сбрасываем предыдущую ошибку.
_uiState.update { it.copy(isLoading = true, error = null) }
// [PREPARATION] Готовим данные для операций, очищая их от лишних пробелов.
val credentials =
Credentials(
serverUrl = _uiState.value.serverUrl.trim(),
username = _uiState.value.username.trim(),
password = _uiState.value.password,
)
// [ACTION] Сохраняем учетные данные для будущего использования.
credentialsRepository.saveCredentials(credentials)
// [CORE-LOGIC] Выполняем UseCase и обрабатываем результат.
loginUseCase(credentials).fold(
onSuccess = {
// [ACTION] Обработка успеха: обновляем UI, отмечая завершение настройки.
_uiState.update { it.copy(isLoading = false, isSetupComplete = true) }
},
onFailure = { exception ->
// [ERROR_HANDLER] Обработка ошибки: обновляем UI с сообщением об ошибке.
_uiState.update { it.copy(isLoading = false, error = exception.message ?: "Login failed") }
},
)
}
}
// [END_ENTITY: Function('connect')]
}
// [END_ENTITY: ViewModel('SetupViewModel')]
// [END_CONTRACT]
// [END_FILE_SetupViewModel.kt]

View File

@@ -1,36 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.theme
// [FILE] Color.kt
// [SEMANTICS] ui, theme, color
package com.homebox.lens.ui.theme
// [IMPORTS]
import androidx.compose.ui.graphics.Color
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Constant('Purple80')]
val Purple80 = Color(0xFFD0BCFF)
// [END_ENTITY: Constant('Purple80')]
// [ENTITY: Constant('PurpleGrey80')]
val PurpleGrey80 = Color(0xFFCCC2DC)
// [END_ENTITY: Constant('PurpleGrey80')]
// [ENTITY: Constant('Pink80')]
val Pink80 = Color(0xFFEFB8C8)
// [END_ENTITY: Constant('Pink80')]
// [ENTITY: Constant('Purple40')]
val Purple40 = Color(0xFF6650a4)
// [END_ENTITY: Constant('Purple40')]
// [ENTITY: Constant('PurpleGrey40')]
val PurpleGrey40 = Color(0xFF625b71)
// [END_ENTITY: Constant('PurpleGrey40')]
// [ENTITY: Constant('Pink40')]
val Pink40 = Color(0xFF7D5260)
// [END_ENTITY: Constant('Pink40')]
// [END_CONTRACT]
// [END_FILE_Color.kt]

View File

@@ -1,98 +0,0 @@
// [PACKAGE] com.homebox.lens.ui.theme
// [FILE] Theme.kt
// [SEMANTICS] ui, theme, color_scheme
package com.homebox.lens.ui.theme
// [IMPORTS]
import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Constant('DarkColorScheme')]
// [RELATION: Constant('DarkColorScheme') -> [CALLS] -> Function('darkColorScheme')]
// [RELATION: Constant('DarkColorScheme') -> [DEPENDS_ON] -> Constant('Purple80')]
// [RELATION: Constant('DarkColorScheme') -> [DEPENDS_ON] -> Constant('PurpleGrey80')]
// [RELATION: Constant('DarkColorScheme') -> [DEPENDS_ON] -> Constant('Pink80')]
private val DarkColorScheme =
darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80,
)
// [END_ENTITY: Constant('DarkColorScheme')]
// [ENTITY: Constant('LightColorScheme')]
// [RELATION: Constant('LightColorScheme') -> [CALLS] -> Function('lightColorScheme')]
// [RELATION: Constant('LightColorScheme') -> [DEPENDS_ON] -> Constant('Purple40')]
// [RELATION: Constant('LightColorScheme') -> [DEPENDS_ON] -> Constant('PurpleGrey40')]
// [RELATION: Constant('LightColorScheme') -> [DEPENDS_ON] -> Constant('Pink40')]
private val LightColorScheme =
lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40,
)
// [END_ENTITY: Constant('LightColorScheme')]
// [ENTITY: Function('HomeboxLensTheme')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('isSystemInDarkTheme')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('LocalContext.current')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('dynamicDarkColorScheme')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('dynamicLightColorScheme')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('LocalView.current')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('SideEffect')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('toArgb')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('WindowCompat.getInsetsController')]
// [RELATION: Function('HomeboxLensTheme') -> [CALLS] -> Function('MaterialTheme')]
// [RELATION: Function('HomeboxLensTheme') -> [DEPENDS_ON] -> Constant('DarkColorScheme')]
// [RELATION: Function('HomeboxLensTheme') -> [DEPENDS_ON] -> Constant('LightColorScheme')]
// [RELATION: Function('HomeboxLensTheme') -> [DEPENDS_ON] -> Constant('Typography')]
@Composable
fun HomeboxLensTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit,
) {
val colorScheme =
when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
}
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content,
)
}
// [END_ENTITY: Function('HomeboxLensTheme')]
// [END_CONTRACT]
// [END_FILE_Theme.kt]

View File

@@ -14,38 +14,11 @@
<!-- Content Descriptions -->
<string name="cd_open_navigation_drawer">Open navigation drawer</string>
<string name="cd_scan_qr_code">Scan QR code</string>
<string name="cd_search">Search</string>
<string name="cd_navigate_back">Navigate back</string>
<string name="cd_navigate_up">Go back</string>
<string name="cd_add_new_location">Add new location</string>
<string name="content_desc_add_label">Add new label</string>
<string name="content_desc_sync_inventory">Sync inventory</string>
<string name="content_desc_edit_item">Edit item</string>
<string name="content_desc_delete_item">Delete item</string>
<string name="content_desc_save_item">Save item</string>
<string name="content_desc_create_label">Create new label</string>
<string name="content_desc_label_icon">Label icon</string>
<string name="cd_more_options">More options</string>
<!-- Inventory List Screen -->
<string name="inventory_list_title">Inventory</string>
<!-- Item Details Screen -->
<string name="item_details_title">Details</string>
<string name="section_title_description">Description</string>
<string name="placeholder_no_description">No description</string>
<string name="section_title_details">Details</string>
<string name="label_quantity">Quantity</string>
<string name="label_location">Location</string>
<string name="section_title_labels">Labels</string>
<!-- Item Edit Screen -->
<string name="item_edit_title_create">Create item</string>
<string name="item_edit_title">Edit item</string>
<string name="label_name">Name</string>
<string name="label_description">Description</string>
<!-- Search Screen -->
<string name="placeholder_search_items">Search items...</string>
<string name="search_title">Search</string>
<!-- Dashboard Screen -->
<string name="dashboard_title">Dashboard</string>
@@ -66,19 +39,30 @@
<string name="nav_labels">Labels</string>
<!-- Screen Titles -->
<string name="inventory_list_title">Inventory</string>
<!-- Screen Titles -->
<string name="item_details_title">Details</string>
<string name="item_edit_title">Edit Item</string>
<string name="labels_list_title">Labels</string>
<string name="locations_list_title">Locations</string>
<string name="search_title">Search</string>
<string name="save_item">Save</string>
<string name="item_name">Name</string>
<string name="item_description">Description</string>
<string name="item_quantity">Quantity</string>
<!-- Location Edit Screen -->
<string name="location_edit_title_create">Create location</string>
<string name="location_edit_title_edit">Edit location</string>
<string name="location_edit_title_create">Create Location</string>
<string name="location_edit_title_edit">Edit Location</string>
<!-- Locations List Screen -->
<string name="locations_not_found">Locations not found. Press + to add a new one.</string>
<string name="item_count">Items: %1$d</string>
<string name="cd_more_options">More options</string>
<!-- Setup Screen -->
<string name="screen_title_setup">Setup</string>
<string name="setup_title">Server Setup</string>
<string name="setup_server_url_label">Server URL</string>
<string name="setup_username_label">Username</string>
@@ -87,10 +71,76 @@
<!-- Labels List Screen -->
<string name="screen_title_labels">Labels</string>
<string name="content_desc_navigate_back">Navigate back</string>
<string name="content_desc_create_label">Create new label</string>
<string name="content_desc_label_icon">Label icon</string>
<string name="content_desc_delete_label">Delete label</string>
<string name="no_labels_found">No labels found.</string>
<string name="dialog_title_create_label">Create label</string>
<string name="dialog_field_label_name">Label name</string>
<string name="dialog_title_create_label">Create Label</string>
<string name="dialog_field_label_name">Label Name</string>
<string name="dialog_button_create">Create</string>
<string name="dialog_button_cancel">Cancel</string>
<!-- Inventory List Screen -->
<string name="content_desc_sync_inventory">Sync inventory</string>
<!-- Item Details Screen -->
<string name="content_desc_edit_item">Edit item</string>
<string name="content_desc_delete_item">Delete item</string>
<string name="section_title_description">Description</string>
<string name="placeholder_no_description">No description</string>
<string name="section_title_details">Details</string>
<string name="label_quantity">Quantity</string>
<string name="label_location">Location</string>
<string name="section_title_labels">Labels</string>
<!-- Item Edit Screen -->
<string name="item_edit_title_create">Create item</string>
<string name="content_desc_save_item">Save item</string>
<string name="label_name">Name</string>
<string name="label_description">Description</string>
<!-- Search Screen -->
<string name="placeholder_search_items">Search items...</string>
<!-- Setup Screen -->
<string name="screen_title_setup">Setup</string>
<!-- Label Edit Screen -->
<string name="label_edit_title_create">Create label</string>
<string name="label_edit_title_edit">Edit label</string>
<string name="label_name_edit">Label name</string>
<!-- Common Actions -->
<string name="back">Back</string>
<string name="save">Save</string>
<!-- Color Picker -->
<string name="label_color">Color</string>
<string name="label_hex_color">HEX color code</string>
<string name="item_asset_id">Asset ID</string>
<string name="item_notes">Notes</string>
<string name="item_serial_number">Serial Number</string>
<string name="item_purchase_price">Purchase Price</string>
<string name="item_purchase_date">Purchase Date</string>
<string name="item_warranty_until">Warranty Until</string>
<string name="item_parent_id">Parent ID</string>
<string name="item_is_archived">Is Archived</string>
<string name="item_insured">Insured</string>
<string name="item_lifetime_warranty">Lifetime Warranty</string>
<string name="item_sync_child_items_locations">Sync Child Items Locations</string>
<string name="item_manufacturer">Manufacturer</string>
<string name="item_model_number">Model Number</string>
<string name="item_purchase_from">Purchase From</string>
<string name="item_warranty_details">Warranty Details</string>
<string name="item_sold_notes">Sold Notes</string>
<string name="item_sold_price">Sold Price</string>
<string name="item_sold_time">Sold Time</string>
<string name="item_sold_to">Sold To</string>
<string name="scan_qr_code">Scan QR Code</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
</resources>

View File

@@ -13,8 +13,10 @@
<!-- Content Descriptions -->
<string name="cd_open_navigation_drawer">Открыть боковое меню</string>
<string name="cd_scan_qr_code">Сканировать QR-код</string>
<string name="cd_scan_qr_code">Сканировать QR/штрих-код</string>
<string name="cd_search">Поиск</string>
<string name="cd_navigate_back">Вернуться назад</string>
<string name="cd_navigate_up">Вернуться</string>
<string name="cd_add_new_location">Добавить новую локацию</string>
<string name="content_desc_add_label">Добавить новую метку</string>
@@ -66,6 +68,11 @@
<string name="locations_list_title">Места хранения</string>
<string name="search_title">Поиск</string>
<string name="save_item">Сохранить</string>
<string name="item_name">Название</string>
<string name="item_description">Описание</string>
<string name="item_quantity">Количество</string>
<!-- Location Edit Screen -->
<string name="location_edit_title_create">Создать локацию</string>
<string name="location_edit_title_edit">Редактировать локацию</string>
@@ -88,10 +95,46 @@
<string name="content_desc_navigate_back" translatable="false">Вернуться назад</string>
<string name="content_desc_create_label">Создать новую метку</string>
<string name="content_desc_label_icon">Иконка метки</string>
<string name="content_desc_delete_label">Удалить метку</string>
<string name="no_labels_found">Метки не найдены.</string>
<string name="dialog_title_create_label">Создать метку</string>
<string name="dialog_field_label_name">Название метки</string>
<string name="dialog_button_create">Создать</string>
<string name="dialog_button_cancel">Отмена</string>
<!-- Label Edit Screen -->
<string name="label_edit_title_create">Создать метку</string>
<string name="label_edit_title_edit">Редактировать метку</string>
<string name="label_name_edit">Название метки</string>
<!-- Common Actions -->
<string name="back">Назад</string>
<string name="save">Сохранить</string>
<!-- Common Actions -->
<!-- Color Picker -->
<string name="label_color">Цвет</string>
<string name="label_hex_color">HEX-код цвета</string>
<string name="item_asset_id">Идентификатор актива</string>
<string name="item_notes">Заметки</string>
<string name="item_serial_number">Серийный номер</string>
<string name="item_purchase_price">Цена покупки</string>
<string name="item_purchase_date">Дата покупки</string>
<string name="item_warranty_until">Гарантия до</string>
<string name="item_parent_id">Родительский ID</string>
<string name="item_is_archived">Архивировано</string>
<string name="item_insured">Застраховано</string>
<string name="item_lifetime_warranty">Пожизненная гарантия</string>
<string name="item_sync_child_items_locations">Синхронизировать дочерние элементы</string>
<string name="item_manufacturer">Производитель</string>
<string name="item_model_number">Номер модели</string>
<string name="item_purchase_from">Куплено у</string>
<string name="item_warranty_details">Детали гарантии</string>
<string name="item_sold_notes">Примечания о продаже</string>
<string name="item_sold_price">Цена продажи</string>
<string name="item_sold_time">Время продажи</string>
<string name="item_sold_to">Продано кому</string>
<string name="scan_qr_code">Сканировать QR-код</string>
<string name="ok">ОК</string>
<string name="cancel">Отмена</string>
</resources>

View File

@@ -1,13 +1,13 @@
// [FILE] build.gradle.kts
// [PURPOSE] Root build file for the project, configures plugins for all modules.
// [SEMANTICS] build, configuration
// [AI_NOTE]: Root build file for the project, configures plugins for all modules.
plugins {
// [PLUGIN] Android Application plugin
id("com.android.application") version "8.11.1" apply false
// [PLUGIN] Kotlin Android plugin
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
// [PLUGIN] Hilt Android plugin
id("com.google.dagger.hilt.android") version "2.48.1" apply false
id("com.android.application") version "8.12.3" apply false
id("org.jetbrains.kotlin.android") version "2.0.0" apply false
id("org.jetbrains.kotlin.plugin.compose") version "2.0.0" apply false
id("com.google.dagger.hilt.android") version "2.51.1" apply false
id("com.google.devtools.ksp") version "2.0.0-1.0.24" apply false
}
// [END_FILE_build.gradle.kts]

View File

@@ -1,72 +1,56 @@
// [PACKAGE] buildsrc.dependencies
// [FILE] Dependencies.kt
// [PURPOSE] Centralized dependency management for the entire project.
// [SEMANTICS] build, dependencies
// [ENTITY: Object('Versions')]
object Versions {
// Build
const val compileSdk = 34
const val minSdk = 26
const val minSdk = 24
const val targetSdk = 34
const val versionCode = 1
const val versionName = "1.0"
// Kotlin
const val kotlin = "1.9.22"
const val kotlin = "1.9.10"
const val coroutines = "1.7.3"
// Jetpack Compose
const val composeCompiler = "1.5.8"
const val composeBom = "2023.10.01"
const val composeCompiler = "1.5.4"
const val composeBom = "2024.05.00"
const val activityCompose = "1.8.2"
const val navigationCompose = "2.7.6"
const val navigationCompose = "2.7.7"
const val hiltNavigationCompose = "1.1.0"
// AndroidX
const val coreKtx = "1.12.0"
const val lifecycle = "2.6.2"
const val lifecycle = "2.7.0"
const val appcompat = "1.6.1"
// Networking
const val retrofit = "2.9.0"
const val okhttp = "4.12.0"
const val moshi = "1.15.0"
// Database
const val moshi = "1.15.1"
const val room = "2.6.1"
// DI
const val hilt = "2.48.1"
const val hiltCompiler = "1.1.0"
// Logging
const val hilt = "2.51.1"
const val hiltCompiler = "1.2.0"
const val timber = "5.0.1"
// Testing
const val junit = "4.13.2"
const val extJunit = "1.1.5"
const val espresso = "3.5.1"
const val kotest = "5.8.0"
const val mockk = "1.13.10"
}
// [END_ENTITY: Object('Versions')]
// [ENTITY: Object('Libs')]
object Libs {
// Kotlin
const val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}"
const val coroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}"
// AndroidX
const val coreKtx = "androidx.core:core-ktx:${Versions.coreKtx}"
const val lifecycleRuntime = "androidx.lifecycle:lifecycle-runtime-ktx:${Versions.lifecycle}"
const val appcompat = "androidx.appcompat:appcompat:${Versions.appcompat}"
// Compose
const val composeBom = "androidx.compose:compose-bom:${Versions.composeBom}"
const val composeUi = "androidx.compose.ui:ui"
const val composeUiGraphics = "androidx.compose.ui:ui-graphics"
const val composeUiToolingPreview = "androidx.compose.ui:ui-tooling-preview"
const val composeMaterial3 = "androidx.compose.material3:material3"
const val composeUi = "androidx.compose.ui:ui:1.5.4"
const val composeUiGraphics = "androidx.compose.ui:ui-graphics:1.5.4"
const val composeUiToolingPreview = "androidx.compose.ui:ui-tooling-preview:1.5.4"
const val composeMaterial3 = "androidx.compose.material3:material3:1.1.2"
const val composeFoundation = "androidx.compose.foundation:foundation:1.5.4"
const val composeFoundationLayout = "androidx.compose.foundation:foundation-layout:1.5.4"
const val composeMaterialIconsExtended = "androidx.compose.material:material-icons-extended:1.5.4"
const val activityCompose = "androidx.activity:activity-compose:${Versions.activityCompose}"
const val navigationCompose = "androidx.navigation:navigation-compose:${Versions.navigationCompose}"
const val hiltNavigationCompose = "androidx.hilt:hilt-navigation-compose:${Versions.hiltNavigationCompose}"
// Networking (Retrofit, OkHttp, Moshi)
const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit}"
const val converterMoshi = "com.squareup.retrofit2:converter-moshi:${Versions.retrofit}"
const val okhttp = "com.squareup.okhttp3:okhttp:${Versions.okhttp}"
@@ -74,27 +58,22 @@ object Libs {
const val moshi = "com.squareup.moshi:moshi:${Versions.moshi}"
const val moshiKotlin = "com.squareup.moshi:moshi-kotlin:${Versions.moshi}"
const val moshiCodegen = "com.squareup.moshi:moshi-kotlin-codegen:${Versions.moshi}"
// Database (Room)
const val roomRuntime = "androidx.room:room-runtime:${Versions.room}"
const val roomKtx = "androidx.room:room-ktx:${Versions.room}"
const val roomCompiler = "androidx.room:room-compiler:${Versions.room}"
// Dependency Injection (Hilt)
const val hiltAndroid = "com.google.dagger:hilt-android:${Versions.hilt}"
const val hiltCompiler = "com.google.dagger:hilt-android-compiler:${Versions.hilt}"
// Logging
const val timber = "com.jakewharton.timber:timber:${Versions.timber}"
// Testing
const val junit = "junit:junit:${Versions.junit}"
const val extJunit = "androidx.test.ext:junit:${Versions.extJunit}"
const val espressoCore = "androidx.test.espresso:espresso-core:${Versions.espresso}"
const val composeUiTestJunit4 = "androidx.compose.ui:ui-test-junit4"
const val composeUiTooling = "androidx.compose.ui:ui-tooling"
const val composeUiTestManifest = "androidx.compose.ui:ui-test-manifest"
const val composeUiTestJunit4 = "androidx.compose.ui:ui-test-junit4:1.5.4"
const val composeUiTooling = "androidx.compose.ui:ui-tooling:1.5.4"
const val composeUiTestManifest = "androidx.compose.ui:ui-test-manifest:1.5.4"
const val kotestRunnerJunit5 = "io.kotest:kotest-runner-junit5:${Versions.kotest}"
const val kotestAssertionsCore = "io.kotest:kotest-assertions-core:${Versions.kotest}"
const val mockk = "io.mockk:mockk:${Versions.mockk}"
}
// [END_ENTITY: Object('Libs')]
// [END_FILE_Dependencies.kt]

View File

@@ -62,6 +62,9 @@ dependencies {
implementation(Libs.hiltAndroid)
kapt(Libs.hiltCompiler)
// [DEPENDENCY] Logging
implementation(Libs.timber)
// [DEPENDENCY] Testing
testImplementation(Libs.junit)
androidTestImplementation(Libs.extJunit)

View File

@@ -1 +0,0 @@
/build

View File

@@ -1,18 +0,0 @@
// Файл: /data/semantic-ktlint-rules/build.gradle.kts
plugins {
kotlin("jvm")
}
dependencies {
// Зависимость для RuleSetProviderV3
implementation("com.pinterest.ktlint:ktlint-cli-ruleset-core:1.2.1")
// Зависимость для Rule, RuleId и psi-утилит
api("com.pinterest.ktlint:ktlint-rule-engine:1.2.1")
// Зависимости для тестирования остаются без изменений
testImplementation(kotlin("test"))
testImplementation("com.pinterest.ktlint:ktlint-test:1.2.1")
testImplementation("org.assertj:assertj-core:3.24.2")
}

View File

@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -1,24 +0,0 @@
package com.busya.ktlint.rules
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.busya.ktlint.rules", appContext.packageName)
}
}

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HomeboxLens" />
</manifest>

View File

@@ -1,16 +0,0 @@
// Путь: data/semantic-ktlint-rules/src/main/java/com/busya/ktlint/rules/CustomRuleSetProvider.kt
package com.busya.ktlint.rules
import com.pinterest.ktlint.rule.engine.core.api.RuleProvider
import com.pinterest.ktlint.rule.engine.core.api.RuleSetId
import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3
class CustomRuleSetProvider : RuleSetProviderV3(RuleSetId("custom")) {
override fun getRuleProviders(): Set<RuleProvider> {
return setOf(
RuleProvider { FileHeaderRule() },
RuleProvider { MandatoryEntityDeclarationRule() },
RuleProvider { NoStrayCommentsRule() }
)
}
}

View File

@@ -1,33 +0,0 @@
// Путь: data/semantic-ktlint-rules/src/main/java/com/busya/ktlint/rules/FileHeaderRule.kt
package com.busya.ktlint.rules
import com.pinterest.ktlint.rule.engine.core.api.ElementType
import com.pinterest.ktlint.rule.engine.core.api.Rule
import com.pinterest.ktlint.rule.engine.core.api.Rule.About
import com.pinterest.ktlint.rule.engine.core.api.RuleId
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
class FileHeaderRule : Rule(ruleId = RuleId("custom:file-header-rule"), about = About()) {
override fun beforeVisitChildNodes(
node: ASTNode,
autoCorrect: Boolean,
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit
) {
if (node.elementType == ElementType.FILE) {
val lines = node.text.lines()
if (lines.size < 3) {
emit(node.startOffset, "File must start with a 3-line semantic header.", false)
return
}
if (!lines[0].startsWith("// [PACKAGE]")) {
emit(node.startOffset, "File header missing or incorrect. Line 1 must be '// [PACKAGE] ...'.", false)
}
if (!lines[1].startsWith("// [FILE]")) {
emit(node.startOffset + lines[0].length + 1, "File header missing or incorrect. Line 2 must be '// [FILE] ...'.", false)
}
if (!lines[2].startsWith("// [SEMANTICS]")) {
emit(node.startOffset + lines[0].length + lines[1].length + 2, "File header missing or incorrect. Line 3 must be '// [SEMANTICS] ...'.", false)
}
}
}
}

View File

@@ -1,40 +0,0 @@
// Путь: data/semantic-ktlint-rules/src/main/java/com/busya/ktlint/rules/MandatoryEntityDeclarationRule.kt
package com.busya.ktlint.rules
import com.pinterest.ktlint.rule.engine.core.api.ElementType
import com.pinterest.ktlint.rule.engine.core.api.Rule
import com.pinterest.ktlint.rule.engine.core.api.Rule.About
import com.pinterest.ktlint.rule.engine.core.api.RuleId
import com.pinterest.ktlint.rule.engine.core.api.prevLeaf
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtDeclaration
class MandatoryEntityDeclarationRule : Rule(ruleId = RuleId("custom:entity-declaration-rule"), about = About()) {
private val entityTypes = setOf(
ElementType.CLASS,
ElementType.OBJECT_DECLARATION,
ElementType.FUN
)
override fun beforeVisitChildNodes(
node: ASTNode,
autoCorrect: Boolean,
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit
) {
if (node.elementType in entityTypes) {
val ktDeclaration = node.psi as? KtDeclaration ?: return
if (node.elementType == ElementType.FUN &&
(ktDeclaration.hasModifier(KtTokens.PRIVATE_KEYWORD) ||
ktDeclaration.hasModifier(KtTokens.PROTECTED_KEYWORD) ||
ktDeclaration.hasModifier(KtTokens.INTERNAL_KEYWORD))
) {
return
}
val prevComment = node.prevLeaf { it.elementType == ElementType.EOL_COMMENT }
if (prevComment == null || !prevComment.text.startsWith("// [ENTITY:")) {
emit(node.startOffset, "Missing or misplaced '// [ENTITY: ...]' declaration before '${node.elementType}'.", false)
}
}
}
}

View File

@@ -1,24 +0,0 @@
// Путь: data/semantic-ktlint-rules/src/main/java/com/busya/ktlint/rules/NoStrayCommentsRule.kt
package com.busya.ktlint.rules
import com.pinterest.ktlint.rule.engine.core.api.ElementType
import com.pinterest.ktlint.rule.engine.core.api.Rule
import com.pinterest.ktlint.rule.engine.core.api.Rule.About
import com.pinterest.ktlint.rule.engine.core.api.RuleId
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
class NoStrayCommentsRule : Rule(ruleId = RuleId("custom:no-stray-comments-rule"), about = About()) {
private val allowedCommentPattern = Regex("""^//\s?\[([A-Z_]+|ENTITY:|RELATION:|AI_NOTE:)]""")
override fun beforeVisitChildNodes(
node: ASTNode,
autoCorrect: Boolean,
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit
) {
if (node.elementType == ElementType.EOL_COMMENT) {
val commentText = node.text
if (!allowedCommentPattern.matches(commentText)) {
emit(node.startOffset, "Stray comment found. Use semantic anchors like '// [TAG]' or '// [AI_NOTE]:' instead.", false)
}
}
}
}

View File

@@ -1,170 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@@ -1,30 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

View File

@@ -1,16 +0,0 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.HomeboxLens" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View File

@@ -1,3 +0,0 @@
<resources>
<string name="app_name">semantic-ktlint-rules</string>
</resources>

View File

@@ -1,16 +0,0 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.HomeboxLens" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@@ -1,41 +0,0 @@
package com.busya.ktlint.rules
import com.pinterest.ktlint.test.KtLintAssertThat.Companion.assertThatRule
import org.junit.jupiter.api.Test
class FileHeaderRuleTest {
private val ruleAssertThat = assertThatRule { FileHeaderRule() }
@Test
fun `should pass on correct header`() {
val code = """
// [PACKAGE] com.example
// [FILE] Test.kt
// [SEMANTICS] test, example
package com.example
""".trimIndent()
ruleAssertThat(code).hasNoLintViolations()
}
@Test
fun `should fail on missing header`() {
val code = """
package com.example
""".trimIndent()
ruleAssertThat(code)
.hasLintViolation(1, 1, "File must start with a 3-line semantic header.")
}
@Test
fun `should fail on incorrect line 1`() {
val code = """
// [WRONG_TAG] com.example
// [FILE] Test.kt
// [SEMANTICS] test, example
package com.example
""".trimIndent()
ruleAssertThat(code)
.hasLintViolation(1, 1, "File header missing or incorrect. Line 1 must be '// [PACKAGE] ...'.")
}
}

View File

@@ -1,74 +1,97 @@
// [PACKAGE] com.homebox.lens.data.api
// [FILE] HomeboxApiService.kt
// [SEMANTICS] data, api, retrofit
package com.homebox.lens.data.api
import com.homebox.lens.data.api.dto.GroupStatisticsDto
import com.homebox.lens.data.api.dto.ItemCreateDto
import com.homebox.lens.data.api.dto.ItemOutDto
import com.homebox.lens.data.api.dto.ItemSummaryDto
import com.homebox.lens.data.api.dto.ItemUpdateDto
import com.homebox.lens.data.api.dto.LabelCreateDto
import com.homebox.lens.data.api.dto.LabelOutDto
import com.homebox.lens.data.api.dto.LabelSummaryDto
import com.homebox.lens.data.api.dto.LocationOutCountDto
import com.homebox.lens.data.api.dto.LoginFormDto
import com.homebox.lens.data.api.dto.PaginationResultDto
import com.homebox.lens.data.api.dto.TokenResponseDto
// [IMPORTS]
import com.homebox.lens.data.api.dto.*
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.*
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Interface('HomeboxApiService')]
/**
* [ENTITY: Interface('HomeboxApiService')]
* [PURPOSE] Определяет эндпоинты для взаимодействия с Homebox API, используя DTO.
* @summary Определяет эндпоинты для взаимодействия с Homebox API, используя DTO.
*/
interface HomeboxApiService {
// [ENDPOINT] Auth
// [ENTITY: ApiEndpoint('login')]
@Headers("Content-Type: application/json")
@POST("v1/users/login")
suspend fun login(@Body loginForm: LoginFormDto): TokenResponseDto
// [END_ENTITY: ApiEndpoint('login')]
// [ENDPOINT] Items
// [ENTITY: ApiEndpoint('getItems')]
@GET("v1/items")
suspend fun getItems(
@Query("q") query: String? = null,
@Query("page") page: Int? = null,
@Query("pageSize") pageSize: Int? = null
): PaginationResultDto<ItemSummaryDto>
// [END_ENTITY: ApiEndpoint('getItems')]
// [ENTITY: ApiEndpoint('createItem')]
@POST("v1/items")
suspend fun createItem(@Body item: ItemCreateDto): ItemSummaryDto
// [END_ENTITY: ApiEndpoint('createItem')]
// [ENTITY: ApiEndpoint('getItem')]
@GET("v1/items/{id}")
suspend fun getItem(@Path("id") itemId: String): ItemOutDto
// [END_ENTITY: ApiEndpoint('getItem')]
// [ENTITY: ApiEndpoint('updateItem')]
@PUT("v1/items/{id}")
suspend fun updateItem(@Path("id") itemId: String, @Body item: ItemUpdateDto): ItemOutDto
// [END_ENTITY: ApiEndpoint('updateItem')]
// [ENTITY: ApiEndpoint('deleteItem')]
@DELETE("v1/items/{id}")
suspend fun deleteItem(@Path("id") itemId: String): Response<Unit>
// [END_ENTITY: ApiEndpoint('deleteItem')]
// [ENDPOINT] Locations
// [ENTITY: ApiEndpoint('getLocations')]
@GET("v1/locations")
suspend fun getLocations(): List<LocationOutCountDto>
// [END_ENTITY: ApiEndpoint('getLocations')]
// [ENDPOINT] Labels
// [ENTITY: ApiEndpoint('getLabels')]
@GET("v1/labels")
suspend fun getLabels(): List<LabelOutDto>
// [END_ENTITY: ApiEndpoint('getLabels')]
// [ENTITY: ApiEndpoint('createLabel')]
@POST("v1/labels")
suspend fun createLabel(@Body newLabel: LabelCreateDto): LabelSummaryDto
// [END_ENTITY: ApiEndpoint('createLabel')]
// [ENDPOINT] Statistics
// [ENTITY: ApiEndpoint('updateLabel')]
@PUT("v1/labels/{id}")
suspend fun updateLabel(@Path("id") labelId: String, @Body label: LabelUpdateDto): LabelOutDto
// [END_ENTITY: ApiEndpoint('updateLabel')]
// [ENTITY: ApiEndpoint('deleteLabel')]
@DELETE("v1/labels/{id}")
suspend fun deleteLabel(@Path("id") labelId: String): Response<Unit>
// [ENTITY: ApiEndpoint('createLocation')]
@POST("v1/locations")
suspend fun createLocation(@Body newLocation: LocationCreateDto): LocationOutDto
// [END_ENTITY: ApiEndpoint('createLocation')]
// [ENTITY: ApiEndpoint('updateLocation')]
@PUT("v1/locations/{id}")
suspend fun updateLocation(@Path("id") locationId: String, @Body location: LocationUpdateDto): LocationOutDto
// [END_ENTITY: ApiEndpoint('updateLocation')]
// [ENTITY: ApiEndpoint('deleteLocation')]
@DELETE("v1/locations/{id}")
suspend fun deleteLocation(@Path("id") locationId: String): Response<Unit>
// [ENTITY: ApiEndpoint('getStatistics')]
@GET("v1/groups/statistics")
suspend fun getStatistics(): GroupStatisticsDto
// [END_ENTITY: ApiEndpoint('getStatistics')]
}
// [END_ENTITY: Interface('HomeboxApiService')]
// [END_FILE_HomeboxApiService.kt]

View File

@@ -8,11 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.CustomField
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('CustomFieldDto')]
/**
* [CONTRACT]
* DTO для кастомного поля.
* @summary DTO для кастомного поля.
*/
@JsonClass(generateAdapter = true)
data class CustomFieldDto(
@@ -20,10 +20,12 @@ data class CustomFieldDto(
@Json(name = "value") val value: String,
@Json(name = "type") val type: String
)
// [END_ENTITY: DataClass('CustomFieldDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('CustomField')]
/**
* [CONTRACT]
* Маппер из CustomFieldDto в доменную модель CustomField.
* @summary Маппер из CustomFieldDto в доменную модель CustomField.
*/
fun CustomFieldDto.toDomain(): CustomField {
return CustomField(
@@ -32,3 +34,4 @@ fun CustomFieldDto.toDomain(): CustomField {
type = this.type
)
}
// [END_ENTITY: Function('toDomain')]

View File

@@ -8,14 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.GroupStatistics
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('GroupStatisticsDto')]
/**
* [CONTRACT]
* DTO для статистики.
* [COHERENCE_NOTE] Этот DTO был исправлен, чтобы точно соответствовать JSON-ответу от сервера.
* Поля `items`, `labels`, `locations`, `totalValue` были заменены на `totalItems`, `totalLabels`,
* `totalLocations`, `totalItemPrice` и т.д., чтобы устранить ошибку парсинга `JsonDataException`.
* @summary DTO для статистики.
*/
@JsonClass(generateAdapter = true)
data class GroupStatisticsDto(
@@ -23,19 +20,17 @@ data class GroupStatisticsDto(
@Json(name = "totalLabels") val totalLabels: Int,
@Json(name = "totalLocations") val totalLocations: Int,
@Json(name = "totalItemPrice") val totalItemPrice: Double,
// [FIX] Добавляем недостающие поля, которые присутствуют в JSON, но отсутствовали в DTO.
// Делаем их nullable на случай, если API перестанет их присылать в будущем.
@Json(name = "totalUsers") val totalUsers: Int? = null,
@Json(name = "totalWithWarranty") val totalWithWarranty: Int? = null
)
// [END_ENTITY: DataClass('GroupStatisticsDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('GroupStatistics')]
/**
* [CONTRACT]
* Маппер из GroupStatisticsDto в доменную модель GroupStatistics.
* [COHERENCE_NOTE] Маппер обновлен для использования правильных полей из исправленного DTO.
* @summary Маппер из GroupStatisticsDto в доменную модель GroupStatistics.
*/
fun GroupStatisticsDto.toDomain(): GroupStatistics {
// [ACTION] Маппим данные из DTO в доменную модель.
return GroupStatistics(
items = this.totalItems,
labels = this.totalLabels,
@@ -43,4 +38,5 @@ fun GroupStatisticsDto.toDomain(): GroupStatistics {
totalValue = this.totalItemPrice
)
}
// [END_ENTITY: Function('toDomain')]
// [END_FILE_GroupStatisticsDto.kt]

View File

@@ -8,14 +8,14 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.Image
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('ImageDto')]
/**
* [CONTRACT]
* DTO для изображения.
* @property id Уникальный идентификатор.
* @property path Путь к файлу.
* @property isPrimary Является ли основным.
* @summary DTO для изображения.
* @param id Уникальный идентификатор.
* @param path Путь к файлу.
* @param isPrimary Является ли основным.
*/
@JsonClass(generateAdapter = true)
data class ImageDto(
@@ -23,10 +23,12 @@ data class ImageDto(
@Json(name = "path") val path: String,
@Json(name = "isPrimary") val isPrimary: Boolean
)
// [END_ENTITY: DataClass('ImageDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('Image')]
/**
* [CONTRACT]
* Маппер из ImageDto в доменную модель Image.
* @summary Маппер из ImageDto в доменную модель Image.
*/
fun ImageDto.toDomain(): Image {
return Image(
@@ -35,3 +37,4 @@ fun ImageDto.toDomain(): Image {
isPrimary = this.isPrimary
)
}
// [END_ENTITY: Function('toDomain')]

View File

@@ -8,11 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.ItemAttachment
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('ItemAttachmentDto')]
/**
* [CONTRACT]
* DTO для вложения.
* @summary DTO для вложения.
*/
@JsonClass(generateAdapter = true)
data class ItemAttachmentDto(
@@ -23,10 +23,12 @@ data class ItemAttachmentDto(
@Json(name = "createdAt") val createdAt: String,
@Json(name = "updatedAt") val updatedAt: String
)
// [END_ENTITY: DataClass('ItemAttachmentDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('ItemAttachment')]
/**
* [CONTRACT]
* Маппер из ItemAttachmentDto в доменную модель ItemAttachment.
* @summary Маппер из ItemAttachmentDto в доменную модель ItemAttachment.
*/
fun ItemAttachmentDto.toDomain(): ItemAttachment {
return ItemAttachment(
@@ -38,3 +40,4 @@ fun ItemAttachmentDto.toDomain(): ItemAttachment {
updatedAt = this.updatedAt
)
}
// [END_ENTITY: Function('toDomain')]

View File

@@ -8,11 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.ItemCreate
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('ItemCreateDto')]
/**
* [CONTRACT]
* DTO для создания вещи.
* @summary DTO для создания вещи.
*/
@JsonClass(generateAdapter = true)
data class ItemCreateDto(
@@ -30,10 +30,12 @@ data class ItemCreateDto(
@Json(name = "parentId") val parentId: String?,
@Json(name = "labelIds") val labelIds: List<String>?
)
// [END_ENTITY: DataClass('ItemCreateDto')]
// [ENTITY: Function('toDto')]
// [RELATION: Function('toDto')] -> [RETURNS] -> [DataClass('ItemCreateDto')]
/**
* [CONTRACT]
* Маппер из доменной модели ItemCreate в ItemCreateDto.
* @summary Маппер из доменной модели ItemCreate в ItemCreateDto.
*/
fun ItemCreate.toDto(): ItemCreateDto {
return ItemCreateDto(
@@ -52,3 +54,4 @@ fun ItemCreate.toDto(): ItemCreateDto {
labelIds = this.labelIds
)
}
// [END_ENTITY: Function('toDto')]

View File

@@ -1,16 +1,19 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] ItemDto.kt
// [SEMANTICS] data, dto, api
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.math.BigDecimal
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: DataClass('ItemOut')]
// [RELATION: DataClass('ItemOut')] -> [DEPENDS_ON] -> [DataClass('LocationOut')]
// [RELATION: DataClass('ItemOut')] -> [DEPENDS_ON] -> [DataClass('LabelOutDto')]
/**
* [ENTITY: DataClass('ItemOut')]
* [PURPOSE] DTO для полной информации о вещи (GET /v1/items/{id}).
* @summary DTO для полной информации о вещи (GET /v1/items/{id}).
*/
@JsonClass(generateAdapter = true)
data class ItemOut(
@@ -23,10 +26,12 @@ data class ItemOut(
@Json(name = "value") val value: BigDecimal?,
@Json(name = "createdAt") val createdAt: String?
)
// [END_ENTITY: DataClass('ItemOut')]
// [ENTITY: DataClass('ItemSummary')]
// [RELATION: DataClass('ItemSummary')] -> [DEPENDS_ON] -> [DataClass('LocationOut')]
/**
* [ENTITY: DataClass('ItemSummary')]
* [PURPOSE] DTO для краткой информации о вещи в списках (GET /v1/items).
* @summary DTO для краткой информации о вещи в списках (GET /v1/items).
*/
@JsonClass(generateAdapter = true)
data class ItemSummary(
@@ -36,10 +41,11 @@ data class ItemSummary(
@Json(name = "location") val location: LocationOut?,
@Json(name = "createdAt") val createdAt: String?
)
// [END_ENTITY: DataClass('ItemSummary')]
// [ENTITY: DataClass('ItemCreate')]
/**
* [ENTITY: DataClass('ItemCreate')]
* [PURPOSE] DTO для создания новой вещи (POST /v1/items).
* @summary DTO для создания новой вещи (POST /v1/items).
*/
@JsonClass(generateAdapter = true)
data class ItemCreate(
@@ -49,10 +55,11 @@ data class ItemCreate(
@Json(name = "labelIds") val labelIds: List<String>?,
@Json(name = "value") val value: BigDecimal?
)
// [END_ENTITY: DataClass('ItemCreate')]
// [ENTITY: DataClass('ItemUpdate')]
/**
* [ENTITY: DataClass('ItemUpdate')]
* [PURPOSE] DTO для обновления вещи (PUT /v1/items/{id}).
* @summary DTO для обновления вещи (PUT /v1/items/{id}).
*/
@JsonClass(generateAdapter = true)
data class ItemUpdate(
@@ -62,5 +69,6 @@ data class ItemUpdate(
@Json(name = "labelIds") val labelIds: List<String>?,
@Json(name = "value") val value: BigDecimal?
)
// [END_ENTITY: DataClass('ItemUpdate')]
// [END_FILE_ItemDto.kt]

View File

@@ -8,11 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.ItemOut
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('ItemOutDto')]
/**
* [CONTRACT]
* DTO для полной модели вещи.
* @summary DTO для полной модели вещи.
*/
@JsonClass(generateAdapter = true)
data class ItemOutDto(
@@ -37,12 +37,25 @@ data class ItemOutDto(
@Json(name = "fields") val fields: List<CustomFieldDto>,
@Json(name = "maintenance") val maintenance: List<MaintenanceEntryDto>,
@Json(name = "createdAt") val createdAt: String,
@Json(name = "updatedAt") val updatedAt: String
@Json(name = "updatedAt") val updatedAt: String,
@Json(name = "insured") val insured: Boolean?,
@Json(name = "lifetimeWarranty") val lifetimeWarranty: Boolean?,
@Json(name = "manufacturer") val manufacturer: String?,
@Json(name = "modelNumber") val modelNumber: String?,
@Json(name = "purchaseFrom") val purchaseFrom: String?,
@Json(name = "soldNotes") val soldNotes: String?,
@Json(name = "soldPrice") val soldPrice: Double?,
@Json(name = "soldTime") val soldTime: String?,
@Json(name = "soldTo") val soldTo: String?,
@Json(name = "syncChildItemsLocations") val syncChildItemsLocations: Boolean?,
@Json(name = "warrantyDetails") val warrantyDetails: String?
)
// [END_ENTITY: DataClass('ItemOutDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('ItemOut')]
/**
* [CONTRACT]
* Маппер из ItemOutDto в доменную модель ItemOut.
* @summary Маппер из ItemOutDto в доменную модель ItemOut.
*/
fun ItemOutDto.toDomain(): ItemOut {
return ItemOut(
@@ -67,6 +80,18 @@ fun ItemOutDto.toDomain(): ItemOut {
fields = this.fields.map { it.toDomain() },
maintenance = this.maintenance.map { it.toDomain() },
createdAt = this.createdAt,
updatedAt = this.updatedAt
updatedAt = this.updatedAt,
insured = this.insured,
lifetimeWarranty = this.lifetimeWarranty,
manufacturer = this.manufacturer,
modelNumber = this.modelNumber,
purchaseFrom = this.purchaseFrom,
soldNotes = this.soldNotes,
soldPrice = this.soldPrice,
soldTime = this.soldTime,
soldTo = this.soldTo,
syncChildItemsLocations = this.syncChildItemsLocations,
warrantyDetails = this.warrantyDetails
)
}
// [END_ENTITY: Function('toDomain')]

View File

@@ -8,11 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.ItemSummary
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('ItemSummaryDto')]
/**
* [CONTRACT]
* DTO для сокращенной модели вещи.
* @summary DTO для сокращенной модели вещи.
*/
@JsonClass(generateAdapter = true)
data class ItemSummaryDto(
@@ -27,10 +27,12 @@ data class ItemSummaryDto(
@Json(name = "createdAt") val createdAt: String,
@Json(name = "updatedAt") val updatedAt: String
)
// [END_ENTITY: DataClass('ItemSummaryDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('ItemSummary')]
/**
* [CONTRACT]
* Маппер из ItemSummaryDto в доменную модель ItemSummary.
* @summary Маппер из ItemSummaryDto в доменную модель ItemSummary.
*/
fun ItemSummaryDto.toDomain(): ItemSummary {
return ItemSummary(
@@ -46,3 +48,4 @@ fun ItemSummaryDto.toDomain(): ItemSummary {
updatedAt = this.updatedAt
)
}
// [END_ENTITY: Function('toDomain')]

View File

@@ -8,11 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.ItemUpdate
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('ItemUpdateDto')]
/**
* [CONTRACT]
* DTO для обновления вещи.
* @summary DTO для обновления вещи.
*/
@JsonClass(generateAdapter = true)
data class ItemUpdateDto(
@@ -31,10 +31,12 @@ data class ItemUpdateDto(
@Json(name = "parentId") val parentId: String?,
@Json(name = "labelIds") val labelIds: List<String>?
)
// [END_ENTITY: DataClass('ItemUpdateDto')]
// [ENTITY: Function('toDto')]
// [RELATION: Function('toDto')] -> [RETURNS] -> [DataClass('ItemUpdateDto')]
/**
* [CONTRACT]
* Маппер из доменной модели ItemUpdate в ItemUpdateDto.
* @summary Маппер из доменной модели ItemUpdate в ItemUpdateDto.
*/
fun ItemUpdate.toDto(): ItemUpdateDto {
return ItemUpdateDto(
@@ -54,3 +56,4 @@ fun ItemUpdate.toDto(): ItemUpdateDto {
labelIds = this.labelIds
)
}
// [END_ENTITY: Function('toDto')]

View File

@@ -3,21 +3,23 @@
// [SEMANTICS] data_transfer_object, label, create, api
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// [END_IMPORTS]
// [ENTITY: DataClass('LabelCreateDto')]
/**
* [CONTRACT]
* DTO для тела запроса на создание метки (POST /v1/labels).
* @property name Название метки.
* @property color Цвет метки в формате HEX (например, "#FF0000").
* @property description Описание метки.
* @coherence_note Структура этого класса точно соответствует схеме `repo.LabelCreate` из OpenAPI.
* @summary DTO для тела запроса на создание метки (POST /v1/labels).
* @param name Название метки.
* @param color Цвет метки в формате HEX (например, "#FF0000").
* @param description Описание метки.
*/
@JsonClass(generateAdapter = true)
data class LabelCreateDto(
@Json(name = "name") val name: String,
@Json(name = "color") val color: String?,
@Json(name = "description") val description: String? = null // Описание не используется в приложении, но может быть в API
@Json(name = "description") val description: String? = null // [AI_NOTE]: Описание не используется в приложении, но может быть в API
)
// [END_ENTITY: DataClass('LabelCreateDto')]
// [END_FILE_LabelCreateDto.kt]

View File

@@ -8,44 +8,38 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.LabelOut
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('LabelOutDto')]
/**
* [CONTRACT]
* DTO для метки.
* [COHERENCE_NOTE] Поле `isArchived` сделано nullable (`Boolean?`),
* так как оно отсутствует в JSON-ответе от сервера. Это исправляет ошибку парсинга
* `JsonDataException: Required value 'isArchived' missing`.
* @summary DTO для метки.
*/
@JsonClass(generateAdapter = true)
data class LabelOutDto(
@Json(name = "id") val id: String,
@Json(name = "name") val name: String,
// [COHERENCE_NOTE] Поле `color` может быть null или отсутствовать, делаем его nullable для безопасности.
@Json(name = "color") val color: String?,
// [FIX] Поле отсутствует в JSON, делаем nullable.
@Json(name = "isArchived") val isArchived: Boolean?,
@Json(name = "createdAt") val createdAt: String,
@Json(name = "updatedAt") val updatedAt: String,
// [COHERENCE_NOTE] Поле `description` также может отсутствовать, добавляем его как nullable.
@Json(name = "description") val description: String?
)
// [END_ENTITY: DataClass('LabelOutDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('LabelOut')]
/**
* [CONTRACT]
* Маппер из LabelOutDto в доменную модель LabelOut.
* [COHERENCE_NOTE] Маппер обновлен для безопасной обработки nullable полей
* и предоставления non-nullable значений по умолчанию для доменной модели.
* @summary Маппер из LabelOutDto в доменную модель LabelOut.
*/
fun LabelOutDto.toDomain(): LabelOut {
return LabelOut(
id = this.id,
name = this.name,
// [FIX] Используем Elvis-оператор для предоставления значения по умолчанию.
color = this.color ?: "", // Пустая строка как дефолтный цвет
isArchived = this.isArchived ?: false, // `false` как дефолтное состояние архива
color = this.color ?: "",
isArchived = this.isArchived ?: false,
createdAt = this.createdAt,
updatedAt = this.updatedAt
)
}
// [END_ENTITY: Function('toDomain')]
// [END_FILE_LabelOutDto.kt]

View File

@@ -3,14 +3,15 @@
// [SEMANTICS] data_transfer_object, label, summary, api, mapper
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.homebox.lens.domain.model.LabelSummary
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// [END_IMPORTS]
// [ENTITY: DataClass('LabelSummaryDto')]
/**
* [CONTRACT]
* DTO для ответа от API при создании метки.
* @coherence_note Структура этого класса точно соответствует схеме `repo.LabelSummary` из OpenAPI.
* @summary DTO для ответа от API при создании метки.
*/
@JsonClass(generateAdapter = true)
data class LabelSummaryDto(
@@ -21,9 +22,11 @@ data class LabelSummaryDto(
@Json(name = "createdAt") val createdAt: String?,
@Json(name = "updatedAt") val updatedAt: String?
)
// [END_ENTITY: DataClass('LabelSummaryDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('LabelSummary')]
/**
* [CONTRACT]
* @summary Маппер из DTO в доменную модель.
* @return Объект доменной модели [LabelSummary].
* @sideeffect Отбрасывает поля, ненужные доменному слою (`color`, `description`, etc.),
@@ -35,4 +38,5 @@ fun LabelSummaryDto.toDomain(): LabelSummary {
name = this.name
)
}
// [END_ENTITY: Function('toDomain')]
// [END_FILE_LabelSummaryDto.kt]

View File

@@ -0,0 +1,31 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] LabelUpdateDto.kt
// [SEMANTICS] data_transfer_object, label, update
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.LabelUpdate
// [END_IMPORTS]
// [ENTITY: DataClass('LabelUpdateDto')]
@JsonClass(generateAdapter = true)
data class LabelUpdateDto(
@Json(name = "name")
val name: String?,
@Json(name = "color")
val color: String?
)
// [END_ENTITY: DataClass('LabelUpdateDto')]
// [ENTITY: Function('toDto')]
// [RELATION: Function('toDto')] -> [RETURNS] -> [DataClass('LabelUpdateDto')]
fun LabelUpdate.toDto(): LabelUpdateDto {
return LabelUpdateDto(
name = this.name,
color = this.color
)
}
// [END_ENTITY: Function('toDto')]
// [END_FILE_LabelUpdateDto.kt]

View File

@@ -0,0 +1,22 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] LocationCreateDto.kt
// [SEMANTICS] data_transfer_object, location, create
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// [END_IMPORTS]
// [ENTITY: DataClass('LocationCreateDto')]
@JsonClass(generateAdapter = true)
data class LocationCreateDto(
@Json(name = "name")
val name: String,
@Json(name = "color")
val color: String?,
@Json(name = "description")
val description: String? // Assuming description can be null for creation
)
// [END_ENTITY: DataClass('LocationCreateDto')]
// [END_FILE_LocationCreateDto.kt]

View File

@@ -1,25 +1,27 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] LocationDto.kt
// [SEMANTICS] data, dto, api, location
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: DataClass('LocationOut')]
/**
* [ENTITY: DataClass('LocationOut')]
* [PURPOSE] DTO для информации о местоположении.
* @summary DTO для информации о местоположении.
*/
@JsonClass(generateAdapter = true)
data class LocationOut(
@Json(name = "id") val id: String,
@Json(name = "name") val name: String
)
// [END_ENTITY: DataClass('LocationOut')]
// [ENTITY: DataClass('LocationOutCount')]
/**
* [ENTITY: DataClass('LocationOutCount')]
* [PURPOSE] DTO для информации о местоположении со счетчиком вещей.
* @summary DTO для информации о местоположении со счетчиком вещей.
*/
@JsonClass(generateAdapter = true)
data class LocationOutCount(
@@ -27,5 +29,6 @@ data class LocationOutCount(
@Json(name = "name") val name: String,
@Json(name = "itemCount") val itemCount: Int
)
// [END_ENTITY: DataClass('LocationOutCount')]
// [END_FILE_LocationDto.kt]

View File

@@ -8,47 +8,40 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.LocationOutCount
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('LocationOutCountDto')]
/**
* [CONTRACT]
* DTO для местоположения со счетчиком.
* [COHERENCE_NOTE] Поля `color` и `isArchived` сделаны nullable (`String?`, `Boolean?`),
* так как они отсутствуют в JSON-ответе от сервера. Это исправляет ошибку парсинга
* `JsonDataException: Required value '...' missing`.
* @summary DTO для местоположения со счетчиком.
*/
@JsonClass(generateAdapter = true)
data class LocationOutCountDto(
@Json(name = "id") val id: String,
@Json(name = "name") val name: String,
// [FIX] Поле отсутствует в JSON, делаем nullable.
@Json(name = "color") val color: String?,
// [FIX] Поле отсутствует в JSON, делаем nullable.
@Json(name = "isArchived") val isArchived: Boolean?,
@Json(name = "itemCount") val itemCount: Int,
@Json(name = "createdAt") val createdAt: String,
@Json(name = "updatedAt") val updatedAt: String,
// [COHERENCE_NOTE] Поле `description` также может отсутствовать или быть null,
// поэтому его тоже безопасно сделать nullable.
@Json(name = "description") val description: String?
)
// [END_ENTITY: DataClass('LocationOutCountDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('LocationOutCount')]
/**
* [CONTRACT]
* Маппер из LocationOutCountDto в доменную модель LocationOutCount.
* [COHERENCE_NOTE] Маппер обновлен для безопасной обработки nullable полей
* и предоставления non-nullable значений по умолчанию для доменной модели.
* @summary Маппер из LocationOutCountDto в доменную модель LocationOutCount.
*/
fun LocationOutCountDto.toDomain(): LocationOutCount {
return LocationOutCount(
id = this.id,
name = this.name,
// [FIX] Используем Elvis-оператор для предоставления значения по умолчанию, если поле null.
color = this.color ?: "", // Пустая строка как дефолтный цвет
isArchived = this.isArchived ?: false, // `false` как дефолтное состояние архива
color = this.color ?: "",
isArchived = this.isArchived ?: false,
itemCount = this.itemCount,
createdAt = this.createdAt,
updatedAt = this.updatedAt
)
}
// [END_ENTITY: Function('toDomain')]
// [END_FILE_LocationOutCountDto.kt]

View File

@@ -1,33 +1,34 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] LocationOutDto.kt
// [SEMANTICS] data_transfer_object, location
// [SEMANTICS] data_transfer_object, location, output
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.LocationOut
// [END_IMPORTS]
// [CORE-LOGIC]
/**
* [CONTRACT]
* DTO для местоположения.
*/
// [ENTITY: DataClass('LocationOutDto')]
@JsonClass(generateAdapter = true)
data class LocationOutDto(
@Json(name = "id") val id: String,
@Json(name = "name") val name: String,
@Json(name = "color") val color: String,
@Json(name = "isArchived") val isArchived: Boolean,
@Json(name = "createdAt") val createdAt: String,
@Json(name = "updatedAt") val updatedAt: String
@Json(name = "id")
val id: String,
@Json(name = "name")
val name: String,
@Json(name = "color")
val color: String,
@Json(name = "isArchived")
val isArchived: Boolean,
@Json(name = "createdAt")
val createdAt: String,
@Json(name = "updatedAt")
val updatedAt: String
)
// [END_ENTITY: DataClass('LocationOutDto')]
/**
* [CONTRACT]
* Маппер из LocationOutDto в доменную модель LocationOut.
*/
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('LocationOut')]
fun LocationOutDto.toDomain(): LocationOut {
return LocationOut(
id = this.id,
@@ -38,3 +39,5 @@ fun LocationOutDto.toDomain(): LocationOut {
updatedAt = this.updatedAt
)
}
// [END_ENTITY: Function('toDomain')]
// [END_FILE_LocationOutDto.kt]

View File

@@ -0,0 +1,31 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] LocationUpdateDto.kt
// [SEMANTICS] data_transfer_object, location, update
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.LocationUpdate
// [END_IMPORTS]
// [ENTITY: DataClass('LocationUpdateDto')]
@JsonClass(generateAdapter = true)
data class LocationUpdateDto(
@Json(name = "name")
val name: String?,
@Json(name = "color")
val color: String?
)
// [END_ENTITY: DataClass('LocationUpdateDto')]
// [ENTITY: Function('toDto')]
// [RELATION: Function('toDto')] -> [RETURNS] -> [DataClass('LocationUpdateDto')]
fun LocationUpdate.toDto(): LocationUpdateDto {
return LocationUpdateDto(
name = this.name,
color = this.color
)
}
// [END_ENTITY: Function('toDto')]
// [END_FILE_LocationUpdateDto.kt]

View File

@@ -1,15 +1,19 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] LoginFormDto.kt
// [SEMANTICS] data, dto, api, login
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// [END_IMPORTS]
// [ENTITY: DataClass('LoginFormDto')]
@JsonClass(generateAdapter = true)
data class LoginFormDto(
@Json(name = "username") val username: String,
@Json(name = "password") val password: String,
@Json(name = "stayLoggedIn") val stayLoggedIn: Boolean = true
)
// [END_ENTITY: DataClass('LoginFormDto')]
// [END_FILE_LoginFormDto.kt]

View File

@@ -8,11 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.MaintenanceEntry
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('MaintenanceEntryDto')]
/**
* [CONTRACT]
* DTO для записи об обслуживании.
* @summary DTO для записи об обслуживании.
*/
@JsonClass(generateAdapter = true)
data class MaintenanceEntryDto(
@@ -25,10 +25,12 @@ data class MaintenanceEntryDto(
@Json(name = "createdAt") val createdAt: String,
@Json(name = "updatedAt") val updatedAt: String
)
// [END_ENTITY: DataClass('MaintenanceEntryDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('MaintenanceEntry')]
/**
* [CONTRACT]
* Маппер из MaintenanceEntryDto в доменную модель MaintenanceEntry.
* @summary Маппер из MaintenanceEntryDto в доменную модель MaintenanceEntry.
*/
fun MaintenanceEntryDto.toDomain(): MaintenanceEntry {
return MaintenanceEntry(
@@ -42,3 +44,4 @@ fun MaintenanceEntryDto.toDomain(): MaintenanceEntry {
updatedAt = this.updatedAt
)
}
// [END_ENTITY: Function('toDomain')]

View File

@@ -1,15 +1,16 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] PaginationDto.kt
// [SEMANTICS] data, dto, api, pagination
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: DataClass('PaginationResult')]
/**
* [ENTITY: DataClass('PaginationResult')]
* [PURPOSE] DTO для пагинированных результатов от API.
* @summary DTO для пагинированных результатов от API.
*/
@JsonClass(generateAdapter = true)
data class PaginationResult<T>(
@@ -19,5 +20,6 @@ data class PaginationResult<T>(
@Json(name = "total") val total: Int,
@Json(name = "pageSize") val pageSize: Int
)
// [END_ENTITY: DataClass('PaginationResult')]
// [END_FILE_PaginationDto.kt]

View File

@@ -8,11 +8,11 @@ package com.homebox.lens.data.api.dto
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.homebox.lens.domain.model.PaginationResult
// [END_IMPORTS]
// [CORE-LOGIC]
// [ENTITY: DataClass('PaginationResultDto')]
/**
* [CONTRACT]
* DTO для постраничных результатов.
* @summary DTO для постраничных результатов.
*/
@JsonClass(generateAdapter = true)
data class PaginationResultDto<T>(
@@ -21,10 +21,12 @@ data class PaginationResultDto<T>(
@Json(name = "pageSize") val pageSize: Int,
@Json(name = "total") val total: Int
)
// [END_ENTITY: DataClass('PaginationResultDto')]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('PaginationResult')]
/**
* [CONTRACT]
* Маппер из PaginationResultDto в доменную модель PaginationResult.
* @summary Маппер из PaginationResultDto в доменную модель PaginationResult.
* @param transform Функция для преобразования каждого элемента из DTO в доменную модель.
*/
fun <T, R> PaginationResultDto<T>.toDomain(transform: (T) -> R): PaginationResult<R> {
@@ -35,3 +37,4 @@ fun <T, R> PaginationResultDto<T>.toDomain(transform: (T) -> R): PaginationResul
total = this.total
)
}
// [END_ENTITY: Function('toDomain')]

View File

@@ -1,16 +1,17 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] StatisticsDto.kt
// [SEMANTICS] data, dto, api, statistics
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.math.BigDecimal
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: DataClass('GroupStatistics')]
/**
* [ENTITY: DataClass('GroupStatistics')]
* [PURPOSE] DTO для статистической информации.
* @summary DTO для статистической информации.
*/
@JsonClass(generateAdapter = true)
data class GroupStatistics(
@@ -19,5 +20,6 @@ data class GroupStatistics(
@Json(name = "locations") val locations: Int,
@Json(name = "labels") val labels: Int
)
// [END_ENTITY: DataClass('GroupStatistics')]
// [END_FILE_StatisticsDto.kt]

View File

@@ -1,15 +1,19 @@
// [PACKAGE] com.homebox.lens.data.api.dto
// [FILE] TokenResponseDto.kt
// [SEMANTICS] data, dto, api, token
package com.homebox.lens.data.api.dto
// [IMPORTS]
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// [END_IMPORTS]
// [ENTITY: DataClass('TokenResponseDto')]
@JsonClass(generateAdapter = true)
data class TokenResponseDto(
@Json(name = "token") val token: String,
@Json(name = "attachmentToken") val attachmentToken: String,
@Json(name = "expiresAt") val expiresAt: String
)
// [END_ENTITY: DataClass('TokenResponseDto')]
// [END_FILE_TokenResponseDto.kt]

View File

@@ -4,26 +4,27 @@
package com.homebox.lens.data.api.mapper
// [IMPORTS]
import com.homebox.lens.data.api.dto.TokenResponseDto
import com.homebox.lens.domain.model.TokenResponse
// [END_IMPORTS]
// [ENTITY: Function('toDomain')]
// [RELATION: Function('toDomain')] -> [RETURNS] -> [DataClass('TokenResponse')]
/**
* [CONTRACT]
* [HELPER] Преобразует DTO-объект токена в доменную модель.
* @summary Преобразует DTO-объект токена в доменную модель.
* @receiver [TokenResponseDto] объект из слоя данных.
* @return [TokenResponse] объект для доменного слоя.
* @throws IllegalArgumentException если токен в DTO пустой.
*/
fun TokenResponseDto.toDomain(): TokenResponse {
// [PRECONDITION] DTO должен содержать валидные данные для маппинга.
require(this.token.isNotBlank()) { "[PRECONDITION_FAILED] DTO token is blank, cannot map to domain model." }
require(this.token.isNotBlank()) { "DTO token is blank, cannot map to domain model." }
// [ACTION]
val domainModel = TokenResponse(token = this.token)
// [POSTCONDITION] Проверяем, что инвариант доменной модели соблюден.
check(domainModel.token.isNotBlank()) { "[POSTCONDITION_FAILED] Domain model token is blank after mapping." }
check(domainModel.token.isNotBlank()) { "Domain model token is blank after mapping." }
return domainModel
}
// [END_ENTITY: Function('toDomain')]
// [END_FILE_TokenMapper.kt]

View File

@@ -1,26 +1,32 @@
// [PACKAGE] com.homebox.lens.data.db
// [FILE] Converters.kt
// [SEMANTICS] data, database, room, converter
package com.homebox.lens.data.db
// [IMPORTS]
import androidx.room.TypeConverter
import java.math.BigDecimal
// [END_IMPORTS]
// [CONTRACT]
// [ENTITY: Class('Converters')]
/**
* [ENTITY: Class('Converters')]
* [PURPOSE] Предоставляет TypeConverters для Room для типов, не поддерживаемых по умолчанию.
* @summary Предоставляет TypeConverters для Room для типов, не поддерживаемых по умолчанию.
*/
class Converters {
// [ENTITY: Function('fromString')]
@TypeConverter
fun fromString(value: String?): BigDecimal? {
return value?.let { BigDecimal(it) }
}
// [END_ENTITY: Function('fromString')]
// [ENTITY: Function('bigDecimalToString')]
@TypeConverter
fun bigDecimalToString(bigDecimal: BigDecimal?): String? {
return bigDecimal?.toPlainString()
}
// [END_ENTITY: Function('bigDecimalToString')]
}
// [END_ENTITY: Class('Converters')]
// [END_FILE_Converters.kt]

Some files were not shown because too many files have changed in this diff Show More