Repository navigation
Add RouletteStyle and make the roulette-like layout the default - #51
Merged
fummicc1 merged 4 commits intoAug 24, 2026
Merged
Conversation
Closes #47. 1.x drew labels halfway out from the centre, laid across the wedge, with every separator meeting in a point in the middle — which does not look like a roulette, as reported in #47. Introduces `RouletteStyle`, applied through a `.rouletteStyle(_:)` view modifier backed by an environment value, so no initializer gains another parameter: - `labelPosition` — where the label sits between centre (0) and rim (1) - `labelOrientation` — `.radial` (reads outward, like a real roulette), `.tangential` (the 1.x look) or `.fixed` (always upright) - `innerRadiusRatio` — hub left empty in the middle, so separators no longer converge to a point The default is now labels near the rim, radial, with a hub. `RouletteStyle.pie` restores the 1.x appearance for anyone who wants it. Parts are drawn as annular sectors when a hub is configured, and as full wedges otherwise, so the 1.x path is unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnVAQvHFsMievKMZBpRHTP
Following the wedge exactly, as a real roulette does, leaves every label on the left half of the wheel upside down. That reads fine for the one and two digit numbers on a real wheel, but poorly for the word labels this library is usually given. Adds `.radialUpright`, which keeps the radial layout but turns labels on that half a further 180 degrees, and makes it the default. `.radial` is still there for anyone who wants the true roulette look. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnVAQvHFsMievKMZBpRHTP
#47 asks for a wheel that looks like a real roulette, so that is what the default now is: labels out at the rim (0.74), laid out radially, with a hub in the middle (0.22). As on a real wheel, labels on the left half sit upside down — that is the authentic arrangement, not a defect. The earlier default, .radialUpright, flipped that half to keep every label readable. Rendering the two side by side showed the flip reverses reading direction between neighbouring labels, which reads as less coherent than the faithful layout. It stays available as an opt-in for callers whose labels are words rather than numbers, alongside .tangential, .fixed and the .pie preset for the 1.x appearance. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnVAQvHFsMievKMZBpRHTP
…ude/repository-improvements-fhid6w
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #47. Targets
modernize-ios17-swift6so it ships as part of v2.0.0.The problem
#47 reports that the roulette does not look like a roulette:
The approach
A new
RouletteStyle, applied with a.rouletteStyle(_:)view modifier backed by an environment value. This deliberately avoids adding a parameter to the five existingRouletteView/RouletteInternalViewinitializers.Parts render as annular sectors when a hub is configured and as full wedges otherwise, so the 1.x drawing path is untouched.
The default
The intent of #47 is a wheel that looks like a real roulette, so that is what the default is: labels out at the rim, laid out radially, hub in the middle.
.pie(1.x look)labelPosition0.740.5labelOrientation.radial.tangentialinnerRadiusRatio0.220As on a real wheel, labels on the left half sit upside down. That is the authentic arrangement rather than a defect, and it reads fine for numbers.
An earlier revision of this PR defaulted to
.radialUpright, which flips that half to keep every label readable. Rendering the two side by side showed the flip reverses reading direction between neighbouring labels, which looks less coherent than the faithful layout — so the faithful one won the default and the flip stayed as an opt-in.Every mode stays selectable
labelOrientation.radial.radialUpright.tangential.fixedVisual change
This changes the default appearance. Existing users will see labels move outward, rotate to follow their wedge, and a hub appear in the middle. That is the intent of #47, and it is why this belongs in the v2.0.0 major bump rather than a minor release.
RouletteStyle.pierestores the previous look in one line.Tests
Nine tests covering the default and
.piepresets, ratio clamping, that all four orientations stay selectable, and the rotation maths for each — including the flip boundaries at 90°/270° and angles outside0..<360. Geometry is pure logic, so it is unit-testable; the rendered result is not.Not verified here
CI compiles the package and runs unit tests — it cannot tell whether the roulette looks right. The layout was checked by rasterising the same geometry maths outside SwiftUI, which validates label placement, rotation and hub size but not font metrics. Whether long labels such as "JavaScript" fit at the real system font size still wants a look in the demo app.