Closed neilma closed 8 years ago
FXForms does support subforms, but I haven't built in an affordance for them into ProMotion-form yet. Would you want to help do that? :)
There is a ton more functionality in FXForms we can tap into and give a sane RubyMotion-esque API. FXForms' API leaves a lot to be desired, and the longform documentation is difficult to understand.
Read a lot of your docos, great stuff, you are everywhere. I'm happy to give it a shot. I just started using promotion.
What I'm trying to achieve is that clicking on a form option (button if not subform) and it goes to another screen which shows a few sliders, navigating back to the form carries over the sliders' values and update the form values presented on screen.
Without subform for now, how would you implement the above scenario? I'm thinking about passing render_form data in attr_accessor between screens, but would love to know if there is a better workaround.
Great! For now, you could just open
a new tablescreen, and implement an action like this:
class SelectorScreen < PM::TableScreen
title "Select something"
def table_data
[{
cells: [
{ title: "Option 1", action: :select, arguments: 1 },
{ title: "Option 2", action: :select, arguments: 2 },
{ title: "Option 3", action: :select, arguments: 3 },
]
}]
end
def select(arg)
close selected: arg
end
end
In your original form screen:
def on_return(result={})
if result[:selected]
# do something with it?
end
end
Brilliant, and if i want to update one of the cells in the original screen, should I use update_form_data which might be expensive since I'm only looking to update one cell value.
Or I'll need to somehow find the cell and update it?
My current solution (correct me if there is a better way): original form has an instance var @nav_data which keeps the data from render_form().
def on_return(opts={})
@nav_data[:key] = opts[:key]
update_form_data
end
def form_data
[{value: "#{nav_data[:key]}"}]
end
update_form_data
is pretty fast, so go for it! Your solution looks good.
is there a way to set row height to auto with an estimate like for table? I'm trying to make my custom cell expand as the content grows.
Not yet, unfortunately.
ProMotion-form has been officially deprecated. Thanks everyone!
Correct me if I'm wrong, subform (not option) doesn't seem to be supported like formotion does it?
e,g, https://github.com/clayallsopp/formotion/wiki/List-of-all-the-row-types#picker