Class: Ruflet::DSL::App
Instance Attribute Summary collapse
Instance Method Summary
collapse
#cupertino_action_sheet, #cupertino_alert_dialog, #cupertino_button, #cupertino_dialog_action, #cupertino_filled_button, #cupertino_navigation_bar, #cupertino_slider, #cupertino_switch, #cupertino_text_field, #cupertinoactionsheet, #cupertinoalertdialog, #cupertinobutton, #cupertinodialogaction, #cupertinofilledbutton, #cupertinonavigationbar, #cupertinoslider, #cupertinoswitch, #cupertinotextfield
#alert_dialog, #alertdialog, #app_bar, #appbar, #bar_chart, #bar_chart_group, #bar_chart_rod, #bar_chart_rod_stack_item, #barchart, #barchartgroup, #barchartrod, #barchartrodstackitem, #bottom_sheet, #bottomsheet, #button, #candlestick_chart, #candlestick_chart_spot, #candlestickchart, #candlestickchartspot, #center, #chart_axis, #chart_axis_label, #chartaxis, #chartaxislabel, #checkbox, #clipboard, #column, #container, #drag_target, #draggable, #dragtarget, #elevated_button, #fab, #filled_button, #filledbutton, #floating_action_button, #floatingactionbutton, #gesture_detector, #gesturedetector, #grid_view, #gridview, #icon, #icon_button, #iconbutton, #image, #line_chart, #line_chart_data, #line_chart_data_point, #linechart, #linechartdata, #linechartdatapoint, #markdown, #navigation_bar, #navigation_bar_destination, #navigationbar, #navigationbardestination, #pie_chart, #pie_chart_section, #piechart, #piechartsection, #radar_chart, #radar_chart_title, #radar_data_set, #radar_data_set_entry, #radarchart, #radarcharttitle, #radardataset, #radardatasetentry, #radio, #radio_group, #radiogroup, #row, #scatter_chart, #scatter_chart_spot, #scatterchart, #scatterchartspot, #snack_bar, #snackbar, #stack, #tab, #tab_bar, #tab_bar_view, #tabbar, #tabbarview, #tabs, #text, #text_button, #text_field, #textbutton, #textfield, #url_launcher, #view, #web_view, #webview
Constructor Details
#initialize(host:, port:) ⇒ App
Returns a new instance of App.
169
170
171
172
173
174
175
176
177
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 169
def initialize(host:, port:)
@host = host
@port = port
@roots = []
@services = []
@stack = []
@page_props = { "route" => "/" }
@seq = 0
end
|
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
167
168
169
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 167
def host
@host
end
|
#page_props ⇒ Object
Returns the value of attribute page_props.
167
168
169
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 167
def page_props
@page_props
end
|
#port ⇒ Object
Returns the value of attribute port.
167
168
169
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 167
def port
@port
end
|
Instance Method Details
#control(type, **props, &block) ⇒ Object
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 194
def control(type, **props, &block)
mapped_props = props.dup
prop_children = (mapped_props)
id = mapped_props.delete(:id)&.to_s || next_id(type)
c = Ruflet::UI::ControlFactory.build(type.to_s, id: id, **normalize_props(mapped_props))
attach(c)
if block
@stack.push(c)
instance_eval(&block)
@stack.pop
end
if prop_children
Array(prop_children).each { |child| c.children << child if child.is_a?(Ruflet::Control) }
end
c
end
|
#duration(**parts) ⇒ Object
223
224
225
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 223
def duration(**parts)
DSL.duration(**parts)
end
|
#page(**props, &block) ⇒ Object
184
185
186
187
188
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 184
def page(**props, &block)
@page_props.merge!(normalize_props(props))
instance_eval(&block) if block
self
end
|
#run ⇒ Object
227
228
229
230
231
232
233
234
235
236
237
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 227
def run
app_roots = @roots
app_services = @services
page_props = @page_props.dup
Ruflet::Server.new(host: host, port: port) do |runtime_page|
runtime_page.set_view_props(page_props)
runtime_page.add_service(*app_services) if app_services.any?
runtime_page.add(*app_roots)
end.start
end
|
#service(type, **props, &block) ⇒ Object
215
216
217
218
219
220
221
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 215
def service(type, **props, &block)
mapped_props = props.dup
id = mapped_props.delete(:id)&.to_s || next_id(type)
svc = Ruflet::UI::ControlFactory.build(type.to_s, id: id, **normalize_props(mapped_props))
@services << svc unless @services.include?(svc)
svc
end
|
#set_endpoint!(host:, port:) ⇒ Object
179
180
181
182
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 179
def set_endpoint!(host:, port:)
@host = host
@port = port
end
|
190
191
192
|
# File 'lib/ruflet_ui/ruflet/dsl.rb', line 190
def widget(type, **props, &block)
control(type.to_s, **props, &block)
end
|