Skip to content

Split formatters by domain (iOS)#325

Draft
DRadmir wants to merge 1 commit into
mainfrom
refactor/formatters-split
Draft

Split formatters by domain (iOS)#325
DRadmir wants to merge 1 commit into
mainfrom
refactor/formatters-split

Conversation

@DRadmir
Copy link
Copy Markdown
Contributor

@DRadmir DRadmir commented May 15, 2026

Reduce CurrencyFormatter to pure fiat formatting. Extract domain-specific formatters with non-overlapping responsibilities:

  • PercentFormatter — proper percent style with sign-strategy, replaces the .percent/.percentSignLess types on CurrencyFormatter.
  • NumericFormatter — Double-input formatting with optional unit suffix and locale-aware parsing (was string(double:symbol:) / double(from:) hacks).
  • AbbreviatedFormatter — made public, used directly where K/M/B is needed.
  • CurrencyFormatter — only fiat currency display (.currency / .fiat / .abbreviated). Internals on Double.FormatStyle.

Shared precision constants, thresholds, and adaptive(for:) selector live in one Precision extension. CurrencyFormatter.precision tuple-switch flattened to a nested switch (no anonymous patterns).

ValueFormatter unchanged vs main except threshold-name aliases (twoPlaces → upToTwoPlaces, fourPlaces → upToFourPlaces) to disambiguate from CurrencyFormatter's pad-zeros twoPlaces.

  • Test

Reduce CurrencyFormatter to pure fiat formatting. Extract domain-specific
formatters with non-overlapping responsibilities:

- PercentFormatter — proper percent style with sign-strategy, replaces the
  .percent/.percentSignLess types on CurrencyFormatter.
- NumericFormatter — Double-input formatting with optional unit suffix and
  locale-aware parsing (was string(double:symbol:) / double(from:) hacks).
- AbbreviatedFormatter — made public, used directly where K/M/B is needed.
- CurrencyFormatter — only fiat currency display (.currency / .fiat /
  .abbreviated). Internals on Double.FormatStyle.

Shared precision constants, thresholds, and adaptive(for:) selector live in
one Precision extension. CurrencyFormatter.precision tuple-switch flattened
to a nested switch (no anonymous patterns).

ValueFormatter unchanged vs main except threshold-name aliases
(twoPlaces → upToTwoPlaces, fourPlaces → upToFourPlaces) to disambiguate
from CurrencyFormatter's pad-zeros twoPlaces.
@DRadmir DRadmir self-assigned this May 15, 2026
@DRadmir DRadmir added the iOS label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant