Repository navigation
feat: add FittedBox control - #31
Merged
Merged
Conversation
Render Ruby fitted_box as a design-neutral FittedBox: fit (BoxFit, default contain; camelCase or snake_case), alignment and clip_behavior, wrapped in LayoutControl.
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.
Adds the
FittedBoxcontrol (Work Package F, item F4). It scales and positions its content inside the box Ruby gives it, for example a price that must fit a fixed slot.Ruby counterpart: AdamMusa/ruflet#46
Rendering
lib/src/controls/fitted_box.dartis one design-neutral file that imports onlywidgets.dart. Material and Cupertino render the same thing: Flutter'sFittedBoxinsideLayoutControl, which applieswidth,height,expand,marginand the other common keywords.Wire keys
contentchildfitfit(BoxFit;scaleDownorscale_down)containalignmentalignmentAlignment.centerclip_behaviorclipBehaviornoneLayoutControlEvents: only the common
on_animation_endandon_size_change.Tests
test/widgets/ruby_fitted_box_test.dart, 20 tests on iOS and Android. A 100x40fitted_boxaround a 400x40 child checks the painted rectangle, mapped through the FittedBox transform, for each fit:scaleDown: (0, 15, 100, 10), with the default alignment and clip checked;scale_downon a small 50x20 child: left unscaled at (25, 10);contain: scales a 50x10 child up to 100x20;fill,cover,fitWidth,fit_heightandnoneeach paint their expected rectangle;alignmentbottom-left withclip_behavior: hard_edgepaints at (0, 30, 100, 10);verify_pr.shwith Flutter 3.41.2: +720: All tests passed! (baseline 695).flutter analyze lib testreports No issues found!. The wire-key audit shows 0 new findings, and FittedBox has every key read.