Repository navigation
feat: add imperative focus, paging, tabs and canvas methods - #34
Merged
Merged
Conversation
Expose client control methods as Ruby methods: focus on buttons, icon buttons, dropdowns and text fields, blur on text fields, PageView go_to_page/jump_to_page/jump_to/next_page/previous_page, Tabs move_to, and Canvas capture/get_capture/clear_capture. Every wrapper sends an args Hash and is a no-op when the control is not on a page.
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.
Engine counterpart: AdamMusa/ruflet-engine#18
What
Adds Ruby wrappers for control methods the Flutter client already handles, so apps can move focus, page, switch tabs and capture canvases from Ruby. The pattern is the SearchBar one:
runtime_page&.invoke(self, name, args: {...}, timeout:, on_result:).API
New
controls/shared/focusable_methods.rb:FocusableMethods#focus(timeout: 10, on_result: nil)sends invokefocus.TextInputMethodsadds#blur(...), which sends invokeblur.They are included (per SPEC R6, the contract classes are what the DSL returns) in:
ButtonControl,FilledButtonControl,FilledTonalButtonControl,OutlinedButtonControl,TextButtonControlandDropdownControlgetfocus;TextFieldControlgetsfocusandblur.CupertinoTextFieldControl(focus,blur) andCupertinoButtonControl,CupertinoFilledButtonControl,CupertinoTintedButtonControl(focus).IconButtonControl,FilledIconButtonControl,FilledTonalIconButtonControl,OutlinedIconButtonControl(focus).Each including file
require_relatives the module, so the mruby framework bundle (ordered by the require graph inruflet-framework/mrbgem.rake) loads it first. Nodefined?, no Regexp.Paging, tab and canvas methods:
go_to_page(index, duration: nil, curve: nil)index,duration,curvejump_to_page(index)indexjump_to(value)valuenext_page(duration: nil, curve: nil),previous_page(...)duration,curvemove_to(index, duration: nil, curve: nil)index,duration,curvecapture(pixel_ratio: nil),get_capture,clear_capturepixel_ratioAll of these also take
timeout: 10, on_result: nil.durationis in milliseconds;curveis a Flutter curve name such as"easeInOut"(symbols are stringified).{}), never nil. The engine PR also makes PageView tolerate nil (SPEC §6 bug push new version to rubygem #3).bluris only offered by text inputs.Events are unchanged.
on_focus/on_blurfire from the client, and PageView/Tabson_changecarry the new index.Note:
pageview_control.rbalso receivesanimation_curve/animation_durationkeywords in a sibling PR. This PR only appends methods afterinitialize, so the two do not overlap.Material vs Cupertino (client)
focus/blurbehave the same on both designs. Material Dropdown only accepts focus wheneditable: true, because Flutter'sDropdownMenuis not focusable otherwise.move_to(-1)selects the last tab on both designs (the engine PR aligns Material with Cupertino).Tests
test/control_methods_compatibility_test.rb(8 runs, 24 assertions), using thesender:page pattern:text_fieldandcupertino_text_fieldfocus/blursend name,{}args,control_idandtimeout.bluris only on text inputs.next_page→{},next_pagewith duration/curve,previous_page,go_to_pagewith a Symbol curve,go_to_page(1),jump_to_page,jump_to.move_towith and without animation args, including -1.capturewith and withoutpixel_ratio,get_capturewithon_resultreturning the call id, andclear_capture.verify_pr.shwith the engine PR: