Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / calculator / AGENTS.md
| 1 | # AGENTS.md — calculator/ (':calculator') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `calculator/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install calculator (dev by default)._ |
| 6 | <!-- last-reviewed: 2026-10-16 --> |
| 7 | - Gradle: :calculator / dir: calculator/ |
| 8 | - Package roots present: ui, widget |
| 9 | - Entry files: MainActivity.kt (no Route.kt — single-screen app with pages, not nav destinations) |
| 10 | - Deps: :library:network, :library:widgets |
| 11 | - Metadata: metadata_data/calculator.md (present) |
| 12 | - Rust: no / screenshotTest: yes |
| 13 | |
| 14 | ## Overview |
| 15 | **Purpose:** Modern Material You calculator — scientific/basic modes, function graphing with analysis, and a multi-category unit converter with live currency rates. |
| 16 | **Key features:** |
| 17 | - Scientific + basic keypad with expression history |
| 18 | - Graph page: plots functions with root / intercept / min-max / intersection detection |
| 19 | - Unit converter across many categories incl. live currency rates (`CurrencyApi` over `:library:network`) |
| 20 | - Home-screen widgets for both calculator and unit converter (`:library:widgets` Glance) |
| 21 | **Architecture / data-flow:** Single-screen `MainActivity` hosting `ui/` pages (`CalculatorPage`, `GraphPage`, `UnitConverterPage`) over a `util/` ViewModel + pure expression/graph/units helpers; widget receivers in `widget/` share the same logic. Internet is used only for currency rates. |
| 22 | **Entry points + reading order:** `MainActivity.kt` → `ui/CalculatorPage.kt` → `util/CalculatorViewModel.kt` + `util/CalculatorUiContract.kt` → `util/Expression.kt` / `util/GraphAnalysis.kt` / `util/Units.kt` → `widget/CalculatorGlanceWidget.kt`. |
| 23 | **Gotchas:** |
| 24 | - `util/` is NOT a closed package root — the `util/`→closed-roots migration is pending; don't add more files there |
| 25 | - Currency rates are the only network call — everything else must stay offline-safe |
| 26 | |
| 27 | ## Key files |
| 28 | ### Root — entry (no Route.kt) |
| 29 | - com/vayunmathur/calculator/MainActivity.kt |
| 30 | ### ui/ — keypad, graph, converter pages |
| 31 | - com/vayunmathur/calculator/ui/CalculatorPage.kt |
| 32 | - com/vayunmathur/calculator/ui/CalculatorKeypad.kt |
| 33 | - com/vayunmathur/calculator/ui/CalculatorDialogs.kt |
| 34 | - com/vayunmathur/calculator/ui/GraphPage.kt |
| 35 | - com/vayunmathur/calculator/ui/UnitConverterPage.kt |
| 36 | ### util/ — ViewModel + pure engine (pending migration to closed roots) |
| 37 | - com/vayunmathur/calculator/util/CalculatorViewModel.kt |
| 38 | - com/vayunmathur/calculator/util/CalculatorUiContract.kt |
| 39 | - com/vayunmathur/calculator/util/Expression.kt — expression parsing/eval |
| 40 | - com/vayunmathur/calculator/util/GraphAnalysis.kt — root/intercept/min-max/intersection |
| 41 | - com/vayunmathur/calculator/util/Units.kt |
| 42 | - com/vayunmathur/calculator/util/CurrencyApi.kt — only network call |
| 43 | - com/vayunmathur/calculator/util/Formatting.kt |
| 44 | ### widget/ — Glance widgets sharing the same logic |
| 45 | - com/vayunmathur/calculator/widget/CalculatorGlanceWidget.kt |
| 46 | - com/vayunmathur/calculator/widget/CalculatorGlanceWidgetReceiver.kt |
| 47 | - com/vayunmathur/calculator/widget/CalculatorKeyAction.kt |
| 48 | - com/vayunmathur/calculator/widget/CalculatorWidgetSettingsActivity.kt |
| 49 | - com/vayunmathur/calculator/widget/UnitsGlanceWidget.kt |
| 50 | - com/vayunmathur/calculator/widget/UnitsGlanceWidgetReceiver.kt |
| 51 | - com/vayunmathur/calculator/widget/UnitsWidgetActions.kt |
| 52 | |
| 53 | ## Verify (this module only) |
| 54 | ``` |
| 55 | ./gradlew :calculator:compileDevKotlin |
| 56 | ./gradlew :calculator:lint |
| 57 | ./gradlew :calculator:checkMetadata |
| 58 | ``` |