Skip to content

Icon buttons, Cupertino buttons and the timer picker crash with default arguments: default alignment "center" (and {"all"=>n} padding/radius) cannot be parsed by the renderer #94

Open

Description

@AdamMusa

Summary

Several controls give their default arguments shapes that the Flutter renderer (ruflet-engine) does not parse:

DSL method Wire _c Default sent Renderer expects
filled_icon_button, filled_tonal_icon_button, outlined_icon_button FilledIconButton, FilledTonalIconButton, OutlinedIconButton alignment: "center", padding: {"all"=>8} {x, y}; left/top/right/bottom or a number
cupertino_button, cupertino_filled_button, cupertino_tinted_button Button, FilledButton, FilledTonalButton alignment: "center", border_radius: {"all"=>8.0} {x, y}; per-corner keys or a number
cupertino_timer_picker TimerPicker alignment: "center" {x, y}
cupertino_text_field TextField padding: {"all"=>7} left/top/right/bottom or a number

Minimal repro

require "ruflet"
b = Ruflet.filled_icon_button(icon: "add"); b.wire_id = 1
b.to_patch.slice("alignment", "padding")
# => {"alignment"=>"center", "padding"=>{"all"=>8}}
Ruflet.cupertino_button(content: Ruflet.text("Tap")).to_patch.slice("alignment", "border_radius")
# => {"alignment"=>"center", "border_radius"=>{"all"=>8.0}}

main (dd924eb), 0.0.23 and 0.0.15 emit the same values.

Actual

On the engine (codex/engine-initialization f44e7df7) and on the engine vendored by ruflet-template main, parseAlignment("center") throws a _TypeError, so Flutter shows its error widget where the control should be:

  • The three icon buttons fail on both designs.
  • The Cupertino buttons fail on iOS. On the engine default branch they also fail on android.
  • The timer picker fails on iOS.

With an explicit alignment: the control renders, but {"all"=>8} padding parses to zero and {"all"=>8.0} radius parses to square corners. cupertino_text_field's {"all"=>7} padding also parses to zero. Engine issue: AdamMusa/ruflet-engine#118.

Expected

Controls built with default arguments render with Flet's defaults: Alignment.CENTER, IconButton padding 8, CupertinoButton radius 8, CupertinoTextField padding 7. Container already turns "center" into {x: 0, y: 0} (normalize_container_props).

Code location

  • packages/ruflet_core/lib/ruflet_ui/ruflet/ui/controls/materials/fillediconbutton_control.rb:86,89, plus filledtonaliconbutton_control.rb and outlinediconbutton_control.rb (same lines)
  • packages/ruflet_core/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinobutton_control.rb:78,80, plus cupertinofilledbutton_control.rb and cupertinotintedbutton_control.rb
  • packages/ruflet_core/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotimerpicker_control.rb:58
  • packages/ruflet_core/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotextfield_control.rb:164
  • The tests assert the unparseable values: cupertino_button_compatibility_test.rb:40,42,58, cupertino_timer_picker_compatibility_test.rb:34, filled_icon_button_compatibility_test.rb:70,73 (and the tonal and outlined copies), cupertino_text_field_compatibility_test.rb:62.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions