Apple renderer: Toggle, Spacer, ProgressBar and ActivityIndicator (phase 2) #9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 2 added four widgets to the contract. GTK and Android implement them; the Apple renderer throws for all four, so
docs/12still counts the catalogue as 9 of 32 rather than 13.Why it throws rather than falls back.
sui_create'sdefault:branch returns a separator. Letting a new kind through would silently render a progress bar as a hairline rule — a wrong widget that looks like a layout bug and sends whoever hits it looking in the wrong place entirely.AppleRenderer.kindCodetherefore raisesUnsupportedOperationExceptionnaming the missing widget, and reserves the codes below.Kind codes, already reserved in
AppleRendererToggleNSSwitchUISwitchSpacerNSViewUIViewProgressBarNSProgressIndicator,.barUIProgressViewActivityIndicatorNSProgressIndicator,.spinningUIActivityIndicatorViewWhat to do
Abi.scalaintools/shim-gen: extend thesui_createdoc comment with codes 9-12 and regenerate the header, so the kind table stays in one place. The consistency suite runs on any machine and will tell you if the four artefacts drift.AppleRenderer.kindCode: replace the fourunimplemented(...)calls with the codes.sui_create: add cases 9-12.Prop.Progressis currently a documented no-op inAppleRenderer.update. Implement it:Some(f)sets the fraction (clamp 0.0-1.0;NSProgressIndicatoris 0-100,UIProgressViewis 0.0-1.0),Nonemeans indeterminate and is deliberately not the same asSome(0.0)—isIndeterminate = true/ an animating bar.ActivityIndicatorhas no "running" prop. It spins while mounted;Showis what stops it. So start animating at create (startAnimation,startAnimating) and do not add a prop for it.Togglecarries no label —Prop.Textis not sent to it.NSSwitchandUISwitchhave nowhere to put one; the caption is a sibling. Do not add one.Spacermust be allowed to expand: it takes the room its siblings do not, throughProp.Grow. On a stack view that means a low content-hugging priority on the stack axis, the same thingsui_set_growalready does.How to verify. The shared
TodoAppnow has a settings row (Label,Spacer,Toggle) plus aProgressBarand aShow-gatedSpinner, and both other hosts check them. Mirror those checks in the macOS/iOS self-test:model.busyis set, none again after.Record the numbers in the report, and add a screenshot to
docs/screenshots/.Also worth checking while you are there: on Android the
ProgressBarrenders in the platform's default blue while the buttons are the app's branded green —ColorRole.Accentdoes not reach it. Seedocs/screenshots/android-catalogue.png. If AppKit/UIKit have the same split, say so in the report; it is a theming gap recorded indocs/12rather than part of this issue.See
docs/12-component-status.mdanddocs/13-phases.mdphase 2.Slice 2 adds two more, so this issue now covers six widgets. Same rule as before:
AppleRenderer.kindCodethrows, naming the widget, rather than lettingsui_create'sdefault:render it as a separator.SliderNSSliderUISliderSecureFieldNSSecureTextFieldUITextFieldwithisSecureTextEntry = trueThree more props are documented no-ops in
AppleRenderer.updateand need implementing with them:Prop.Range(min, max)-NSSlider.minValue/maxValue,UISlider.minimumValue/maximumValue.Prop.Value(v)- in the app's own units, not a fraction. Both Apple controls already take app units, so this is near-direct; there is no conversion to write, unlike Android'sSeekBar. Apply the same don't-disturb rule the text field uses: only write when the value actually differs, or the write fights the user's drag.Prop.OnValueChange- target/action onNSSlider,.valueChangedonUISlider, reporting in app units.Rangealways arrives beforeValue; you can rely on that (it is asserted inCatalogueSuite).SecureFieldshares everything but construction withTextField-Prop.Text,Prop.PlaceholderandProp.OnTextChangemust all work on it. On GTK it is literally the sameGtkEntrywith visibility off; only AppKit needs the separate class, which is why this is a kind at all.How to verify. The shared
TodoAppnow has aSliderbound tomodel.volume(0-11, starting at 7.0) and aSecureFieldbound tomodel.secret. Mirror the checks both other hosts run:One trap, found the hard way on Android:
SeekBarextendsProgressBar, so a naive "find the determinate progress bar" predicate matched the slider too and the self-test reported two bars. Check whether the Apple slider and progress indicator share a superclass before writing the equivalent check - on AppKit they may well both beNSControl.Also note
docs/12section 12.2a:RadioandStepperwere in phase 2 and were reclassified rather than built - UIKit has no radio control and Android has no stepper. Please do not add kind codes for them.