ruflet_core 0.0.17 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -30
- data/lib/ruflet/version.rb +1 -1
- data/lib/ruflet_core.rb +9 -7
- data/lib/ruflet_protocol/ruflet/protocol.rb +28 -54
- data/lib/ruflet_ui/ruflet/app.rb +1 -1
- data/lib/ruflet_ui/ruflet/colors.rb +4 -50
- data/lib/ruflet_ui/ruflet/control.rb +69 -64
- data/lib/ruflet_ui/ruflet/dsl.rb +10 -3
- data/lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb +2 -2
- data/lib/ruflet_ui/ruflet/icons/cupertino_icon_lookup.rb +1 -0
- data/lib/ruflet_ui/ruflet/icons/icon_constant_names.rb +29 -0
- data/lib/ruflet_ui/ruflet/icons/material/material_icons.rb +2 -2
- data/lib/ruflet_ui/ruflet/icons/material_icon_lookup.rb +1 -0
- data/lib/ruflet_ui/ruflet/page.rb +308 -526
- data/lib/ruflet_ui/ruflet/ui/control_factory.rb +68 -12
- data/lib/ruflet_ui/ruflet/ui/control_registry.rb +13 -6
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactionsheet_control.rb +8 -45
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactionsheetaction_control.rb +45 -2
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactivityindicator_control.rb +43 -2
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoalertdialog_control.rb +0 -5
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinobutton_control.rb +59 -4
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocheckbox_control.rb +56 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocontextmenu_control.rb +1 -3
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocontextmenuaction_control.rb +1 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinodatepicker_control.rb +53 -8
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinodialogaction_control.rb +1 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinofilledbutton_control.rb +59 -4
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinolisttile_control.rb +54 -9
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinonavigationbar_control.rb +47 -9
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinopicker_control.rb +52 -10
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoradio_control.rb +52 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinosegmentedbutton_control.rb +49 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoslider_control.rb +50 -5
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoslidingsegmentedbutton_control.rb +46 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoswitch_control.rb +61 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotextfield_control.rb +145 -1
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotimerpicker_control.rb +47 -12
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotintedbutton_control.rb +59 -4
- data/lib/ruflet_ui/ruflet/ui/controls/materials/alertdialog_control.rb +8 -45
- data/lib/ruflet_ui/ruflet/ui/controls/materials/appbar_control.rb +8 -40
- data/lib/ruflet_ui/ruflet/ui/controls/materials/audio_control.rb +16 -5
- data/lib/ruflet_ui/ruflet/ui/controls/materials/autocomplete_control.rb +44 -1
- data/lib/ruflet_ui/ruflet/ui/controls/materials/badge_control.rb +0 -7
- data/lib/ruflet_ui/ruflet/ui/controls/materials/banner_control.rb +0 -7
- data/lib/ruflet_ui/ruflet/ui/controls/materials/bottomappbar_control.rb +8 -47
- data/lib/ruflet_ui/ruflet/ui/controls/materials/bottomsheet_control.rb +0 -3
- data/lib/ruflet_ui/ruflet/ui/controls/materials/button_control.rb +8 -54
- data/lib/ruflet_ui/ruflet/ui/controls/materials/card_control.rb +8 -50
- data/lib/ruflet_ui/ruflet/ui/controls/materials/chart_controls.rb +19 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/checkbox_control.rb +9 -60
- data/lib/ruflet_ui/ruflet/ui/controls/materials/chip_control.rb +7 -81
- data/lib/ruflet_ui/ruflet/ui/controls/materials/circleavatar_control.rb +7 -56
- data/lib/ruflet_ui/ruflet/ui/controls/materials/container_control.rb +9 -65
- data/lib/ruflet_ui/ruflet/ui/controls/materials/contextmenu_control.rb +50 -4
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datacell_control.rb +1 -3
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datacolumn_control.rb +1 -3
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datatable_control.rb +7 -88
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datepicker_control.rb +9 -55
- data/lib/ruflet_ui/ruflet/ui/controls/materials/daterangepicker_control.rb +8 -58
- data/lib/ruflet_ui/ruflet/ui/controls/materials/divider_control.rb +0 -9
- data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdown_control.rb +8 -93
- data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdownm2_control.rb +9 -103
- data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdownoption_control.rb +0 -2
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansionpanel_control.rb +7 -51
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansionpanellist_control.rb +46 -5
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansiontile_control.rb +69 -3
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledbutton_control.rb +54 -2
- data/lib/ruflet_ui/ruflet/ui/controls/materials/fillediconbutton_control.rb +67 -5
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledtonalbutton_control.rb +54 -2
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledtonaliconbutton_control.rb +67 -5
- data/lib/ruflet_ui/ruflet/ui/controls/materials/floatingactionbutton_control.rb +7 -69
- data/lib/ruflet_ui/ruflet/ui/controls/materials/iconbutton_control.rb +8 -68
- data/lib/ruflet_ui/ruflet/ui/controls/materials/listtile_control.rb +8 -74
- data/lib/ruflet_ui/ruflet/ui/controls/materials/map_control.rb +99 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/menuitembutton_control.rb +8 -56
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationbar_control.rb +7 -59
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationdrawer_control.rb +0 -7
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationrail_control.rb +7 -73
- data/lib/ruflet_ui/ruflet/ui/controls/materials/outlinedbutton_control.rb +51 -2
- data/lib/ruflet_ui/ruflet/ui/controls/materials/outlinediconbutton_control.rb +67 -5
- data/lib/ruflet_ui/ruflet/ui/controls/materials/popupmenubutton_control.rb +8 -61
- data/lib/ruflet_ui/ruflet/ui/controls/materials/popupmenuitem_control.rb +0 -6
- data/lib/ruflet_ui/ruflet/ui/controls/materials/progressbar_control.rb +8 -56
- data/lib/ruflet_ui/ruflet/ui/controls/materials/progressring_control.rb +8 -56
- data/lib/ruflet_ui/ruflet/ui/controls/materials/radio_control.rb +9 -54
- data/lib/ruflet_ui/ruflet/ui/controls/materials/rangeslider_control.rb +7 -62
- data/lib/ruflet_ui/ruflet/ui/controls/materials/reorderablelistview_control.rb +9 -64
- data/lib/ruflet_ui/ruflet/ui/controls/materials/ruflet_controls.rb +5 -26
- data/lib/ruflet_ui/ruflet/ui/controls/materials/searchbar_control.rb +80 -11
- data/lib/ruflet_ui/ruflet/ui/controls/materials/segment_control.rb +0 -3
- data/lib/ruflet_ui/ruflet/ui/controls/materials/segmentedbutton_control.rb +7 -64
- data/lib/ruflet_ui/ruflet/ui/controls/materials/selectionarea_control.rb +1 -3
- data/lib/ruflet_ui/ruflet/ui/controls/materials/slider_control.rb +9 -60
- data/lib/ruflet_ui/ruflet/ui/controls/materials/snackbar_control.rb +37 -4
- data/lib/ruflet_ui/ruflet/ui/controls/materials/snackbaraction_control.rb +38 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/spinkit_control.rb +25 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/submenubutton_control.rb +52 -7
- data/lib/ruflet_ui/ruflet/ui/controls/materials/switch_control.rb +9 -61
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tab_control.rb +0 -7
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabbar_control.rb +8 -64
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabbarview_control.rb +43 -5
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabs_control.rb +7 -47
- data/lib/ruflet_ui/ruflet/ui/controls/materials/textbutton_control.rb +51 -2
- data/lib/ruflet_ui/ruflet/ui/controls/materials/textfield_control.rb +9 -132
- data/lib/ruflet_ui/ruflet/ui/controls/materials/timepicker_control.rb +10 -34
- data/lib/ruflet_ui/ruflet/ui/controls/materials/verticaldivider_control.rb +0 -9
- data/lib/ruflet_ui/ruflet/ui/controls/materials/video_control.rb +9 -42
- data/lib/ruflet_ui/ruflet/ui/controls/materials/webview_control.rb +1 -114
- data/lib/ruflet_ui/ruflet/ui/controls/ruflet_controls.rb +13 -28
- data/lib/ruflet_ui/ruflet/ui/controls/shared/animatedswitcher_control.rb +46 -4
- data/lib/ruflet_ui/ruflet/ui/controls/shared/arc_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/browsercontextmenu_control.rb +1 -12
- data/lib/ruflet_ui/ruflet/ui/controls/shared/canvas_control.rb +8 -54
- data/lib/ruflet_ui/ruflet/ui/controls/shared/circle_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/column_control.rb +9 -51
- data/lib/ruflet_ui/ruflet/ui/controls/shared/dismissible_control.rb +52 -12
- data/lib/ruflet_ui/ruflet/ui/controls/shared/draggable_control.rb +1 -7
- data/lib/ruflet_ui/ruflet/ui/controls/shared/dragtarget_control.rb +1 -3
- data/lib/ruflet_ui/ruflet/ui/controls/shared/fletapp_control.rb +9 -46
- data/lib/ruflet_ui/ruflet/ui/controls/shared/gesturedetector_control.rb +9 -113
- data/lib/ruflet_ui/ruflet/ui/controls/shared/gridview_control.rb +57 -13
- data/lib/ruflet_ui/ruflet/ui/controls/shared/hero_control.rb +9 -40
- data/lib/ruflet_ui/ruflet/ui/controls/shared/icon_control.rb +9 -48
- data/lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb +9 -53
- data/lib/ruflet_ui/ruflet/ui/controls/shared/line_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/listview_control.rb +57 -11
- data/lib/ruflet_ui/ruflet/ui/controls/shared/markdown_control.rb +9 -54
- data/lib/ruflet_ui/ruflet/ui/controls/shared/oval_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/page_control.rb +9 -58
- data/lib/ruflet_ui/ruflet/ui/controls/shared/pagelet_control.rb +9 -48
- data/lib/ruflet_ui/ruflet/ui/controls/shared/pageview_control.rb +50 -4
- data/lib/ruflet_ui/ruflet/ui/controls/shared/path_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/placeholder_control.rb +44 -9
- data/lib/ruflet_ui/ruflet/ui/controls/shared/points_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/rect_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/reorderabledraghandle_control.rb +43 -4
- data/lib/ruflet_ui/ruflet/ui/controls/shared/responsiverow_control.rb +47 -15
- data/lib/ruflet_ui/ruflet/ui/controls/shared/rotatedbox_control.rb +97 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/row_control.rb +9 -51
- data/lib/ruflet_ui/ruflet/ui/controls/shared/ruflet_controls.rb +5 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/safearea_control.rb +48 -4
- data/lib/ruflet_ui/ruflet/ui/{services/ruflet → controls/shared}/screenshot_control.rb +18 -2
- data/lib/ruflet_ui/ruflet/ui/controls/shared/semantics_control.rb +65 -1
- data/lib/ruflet_ui/ruflet/ui/controls/shared/shadermask_control.rb +9 -41
- data/lib/ruflet_ui/ruflet/ui/controls/shared/shimmer_control.rb +9 -44
- data/lib/ruflet_ui/ruflet/ui/controls/shared/stack_control.rb +44 -1
- data/lib/ruflet_ui/ruflet/ui/controls/shared/text_control.rb +9 -35
- data/lib/ruflet_ui/ruflet/ui/controls/shared/transparentpointer_control.rb +9 -38
- data/lib/ruflet_ui/ruflet/ui/controls/shared/view_control.rb +63 -1
- data/lib/ruflet_ui/ruflet/ui/controls/shared/window_control.rb +40 -66
- data/lib/ruflet_ui/ruflet/ui/controls/shared/windowdragarea_control.rb +45 -4
- data/lib/ruflet_ui/ruflet/ui/material_control_methods.rb +61 -17
- data/lib/ruflet_ui/ruflet/ui/material_control_registry.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/accelerometer_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/audio_recorder_control.rb +14 -36
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/barometer_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/battery_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/camera_control.rb +9 -42
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/clipboard_control.rb +31 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/connectivity_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/filepicker_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/flashlight_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/geolocator_control.rb +14 -30
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/gyroscope_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/hapticfeedback_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/magnetometer_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/permissionhandler_control.rb +5 -20
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/screenbrightness_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/securestorage_control.rb +22 -49
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/semanticsservice_control.rb +20 -15
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/shakedetector_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/share_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/sharedpreferences_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/storagepaths_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/urllauncher_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/useraccelerometer_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/wakelock_control.rb +1 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet_services.rb +0 -7
- data/lib/ruflet_ui/ruflet/ui/shared_control_forwarders.rb +20 -1
- data/lib/ruflet_ui.rb +12 -10
- metadata +7 -8
- data/lib/ruflet_ui/ruflet/types/animation.rb +0 -110
- data/lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb +0 -93
- data/lib/ruflet_ui/ruflet/ui/controls/materials/map_controls.rb +0 -311
- data/lib/ruflet_ui/ruflet/ui/controls/materials/rive_control.rb +0 -87
- data/lib/ruflet_ui/ruflet/ui/controls/materials/spinkit_controls.rb +0 -109
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/tester_control.rb +0 -126
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
module Ruflet
|
|
4
4
|
module UI
|
|
5
5
|
module MaterialControlMethods
|
|
6
|
+
def map_coordinates(value)
|
|
7
|
+
case value
|
|
8
|
+
when Array
|
|
9
|
+
return { "latitude" => value[0], "longitude" => value[1] } if value.length >= 2
|
|
10
|
+
when Hash
|
|
11
|
+
latitude = value["latitude"] || value[:latitude] || value["lat"] || value[:lat]
|
|
12
|
+
longitude = value["longitude"] || value[:longitude] || value["lon"] || value[:lon] || value["lng"] || value[:lng]
|
|
13
|
+
return { "latitude" => latitude, "longitude" => longitude } unless latitude.nil? || longitude.nil?
|
|
14
|
+
end
|
|
15
|
+
value.respond_to?(:to_h) ? map_coordinates(value.to_h) : value
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def map_coordinate_list(value)
|
|
19
|
+
Array(value).map { |coordinates| map_coordinates(coordinates) }
|
|
20
|
+
end
|
|
21
|
+
|
|
6
22
|
def view(children = nil, **props, &block)
|
|
7
23
|
mapped = props.dup
|
|
8
24
|
mapped[:children] = children unless children.nil?
|
|
@@ -174,6 +190,7 @@ module Ruflet
|
|
|
174
190
|
def listtile(**props) = list_tile(**props)
|
|
175
191
|
def map(layers = nil, **props)
|
|
176
192
|
mapped = props.dup
|
|
193
|
+
mapped[:initial_center] = map_coordinates(mapped[:initial_center]) if mapped.key?(:initial_center)
|
|
177
194
|
mapped[:layers] = layers unless layers.nil?
|
|
178
195
|
build_widget(:map, **mapped)
|
|
179
196
|
end
|
|
@@ -187,6 +204,7 @@ module Ruflet
|
|
|
187
204
|
def markerlayer(markers = nil, **props) = marker_layer(markers, **props)
|
|
188
205
|
def marker(content = nil, **props)
|
|
189
206
|
mapped = props.dup
|
|
207
|
+
mapped[:coordinates] = map_coordinates(mapped[:coordinates]) if mapped.key?(:coordinates)
|
|
190
208
|
mapped[:content] = content unless content.nil?
|
|
191
209
|
build_widget(:marker, **mapped)
|
|
192
210
|
end
|
|
@@ -196,7 +214,11 @@ module Ruflet
|
|
|
196
214
|
build_widget(:circlelayer, **mapped)
|
|
197
215
|
end
|
|
198
216
|
def circlelayer(circles = nil, **props) = circle_layer(circles, **props)
|
|
199
|
-
def circle_marker(**props)
|
|
217
|
+
def circle_marker(**props)
|
|
218
|
+
mapped = props.dup
|
|
219
|
+
mapped[:coordinates] = map_coordinates(mapped[:coordinates]) if mapped.key?(:coordinates)
|
|
220
|
+
build_widget(:circlemarker, **mapped)
|
|
221
|
+
end
|
|
200
222
|
def circlemarker(**props) = circle_marker(**props)
|
|
201
223
|
def polyline_layer(polylines = nil, **props)
|
|
202
224
|
mapped = props.dup
|
|
@@ -204,7 +226,11 @@ module Ruflet
|
|
|
204
226
|
build_widget(:polylinelayer, **mapped)
|
|
205
227
|
end
|
|
206
228
|
def polylinelayer(polylines = nil, **props) = polyline_layer(polylines, **props)
|
|
207
|
-
def polyline_marker(**props)
|
|
229
|
+
def polyline_marker(**props)
|
|
230
|
+
mapped = props.dup
|
|
231
|
+
mapped[:coordinates] = map_coordinate_list(mapped[:coordinates]) if mapped.key?(:coordinates)
|
|
232
|
+
build_widget(:polylinemarker, **mapped)
|
|
233
|
+
end
|
|
208
234
|
def polylinemarker(**props) = polyline_marker(**props)
|
|
209
235
|
def polygon_layer(polygons = nil, **props)
|
|
210
236
|
mapped = props.dup
|
|
@@ -212,7 +238,11 @@ module Ruflet
|
|
|
212
238
|
build_widget(:polygonlayer, **mapped)
|
|
213
239
|
end
|
|
214
240
|
def polygonlayer(polygons = nil, **props) = polygon_layer(polygons, **props)
|
|
215
|
-
def polygon_marker(**props)
|
|
241
|
+
def polygon_marker(**props)
|
|
242
|
+
mapped = props.dup
|
|
243
|
+
mapped[:coordinates] = map_coordinate_list(mapped[:coordinates]) if mapped.key?(:coordinates)
|
|
244
|
+
build_widget(:polygonmarker, **mapped)
|
|
245
|
+
end
|
|
216
246
|
def polygonmarker(**props) = polygon_marker(**props)
|
|
217
247
|
def simple_attribution(**props) = build_widget(:simpleattribution, **props)
|
|
218
248
|
def simpleattribution(**props) = simple_attribution(**props)
|
|
@@ -329,6 +359,17 @@ module Ruflet
|
|
|
329
359
|
def pageview(children = nil, **props) = page_view(children, **props)
|
|
330
360
|
def progress_ring(**props) = build_widget(:progressring, **props)
|
|
331
361
|
def progressring(**props) = progress_ring(**props)
|
|
362
|
+
SPINKIT_VARIANTS = [:rotating_circle, :rotating_plain, :double_bounce, :wave, :wandering_cubes, :fading_four, :fading_cube, :pulse, :chasing_dots, :three_bounce, :circle, :cube_grid, :fading_circle, :folding_cube, :pumping_heart, :hour_glass, :pouring_hour_glass, :pouring_hour_glass_refined, :fading_grid, :ring, :ripple, :dual_ring, :spinning_circle, :spinning_lines, :square_circle, :three_in_out, :dancing_square, :piano_wave, :pulsing_grid, :wave_spinner].freeze
|
|
363
|
+
|
|
364
|
+
def spinkit(**variants)
|
|
365
|
+
selected = variants.select { |name, _value| SPINKIT_VARIANTS.include?(name) }
|
|
366
|
+
raise ArgumentError, "spinkit requires exactly one variant" unless selected.length == 1 && selected.length == variants.length
|
|
367
|
+
|
|
368
|
+
variant, options = selected.first
|
|
369
|
+
raise ArgumentError, "spinkit variant options must be a Hash" unless options.is_a?(Hash)
|
|
370
|
+
|
|
371
|
+
build_widget(:spinkit, variant: variant.to_s, **options)
|
|
372
|
+
end
|
|
332
373
|
def range_slider(**props) = build_widget(:rangeslider, **props)
|
|
333
374
|
def rangeslider(**props) = range_slider(**props)
|
|
334
375
|
def responsive_row(children = nil, **props, &block)
|
|
@@ -509,6 +550,17 @@ module Ruflet
|
|
|
509
550
|
build_widget(:transparentpointer, **mapped)
|
|
510
551
|
end
|
|
511
552
|
def transparentpointer(content = nil, **props) = transparent_pointer(content, **props)
|
|
553
|
+
def rotated_box(content = nil, **props)
|
|
554
|
+
mapped = props.dup
|
|
555
|
+
mapped[:content] = content unless content.nil?
|
|
556
|
+
build_widget(:rotatedbox, **mapped)
|
|
557
|
+
end
|
|
558
|
+
def rotatedbox(content = nil, **props) = rotated_box(content, **props)
|
|
559
|
+
def screenshot(content = nil, **props)
|
|
560
|
+
mapped = props.dup
|
|
561
|
+
mapped[:content] = content unless content.nil?
|
|
562
|
+
build_widget(:screenshot, **mapped)
|
|
563
|
+
end
|
|
512
564
|
def radio(**props) = build_widget(:radio, **props)
|
|
513
565
|
def radio_group(content = nil, **props)
|
|
514
566
|
mapped = props.dup
|
|
@@ -524,6 +576,12 @@ module Ruflet
|
|
|
524
576
|
build_widget(:snackbar, **mapped)
|
|
525
577
|
end
|
|
526
578
|
def snackbar(content = nil, **props) = snack_bar(content, **props)
|
|
579
|
+
def snack_bar_action(label = nil, **props)
|
|
580
|
+
mapped = props.dup
|
|
581
|
+
mapped[:label] = label unless label.nil?
|
|
582
|
+
build_widget(:snackbaraction, **mapped)
|
|
583
|
+
end
|
|
584
|
+
def snackbaraction(label = nil, **props) = snack_bar_action(label, **props)
|
|
527
585
|
def bottom_sheet(content = nil, **props)
|
|
528
586
|
mapped = props.dup
|
|
529
587
|
mapped[:content] = content unless content.nil?
|
|
@@ -638,26 +696,12 @@ module Ruflet
|
|
|
638
696
|
def web_view(**props) = build_widget(:webview, **props)
|
|
639
697
|
def webview(**props) = web_view(**props)
|
|
640
698
|
def video(**props) = build_widget(:video, **props)
|
|
641
|
-
|
|
642
|
-
# spinkit(wave: { color: "red", size: 50 }) — one variant keyword whose
|
|
643
|
-
# value is the props hash. See https://flet.dev/docs/controls/spinkit/
|
|
644
|
-
def spinkit(**variant)
|
|
645
|
-
raise ArgumentError, "spinkit expects exactly one variant, e.g. spinkit(wave: { color: ... })" unless variant.size == 1
|
|
646
|
-
|
|
647
|
-
name, props = variant.first
|
|
648
|
-
props ||= {}
|
|
649
|
-
raise ArgumentError, "spinkit #{name} options must be a Hash" unless props.is_a?(Hash)
|
|
650
|
-
|
|
651
|
-
build_widget(:"spinkit_#{name}", **props)
|
|
652
|
-
end
|
|
653
|
-
|
|
654
699
|
def code_editor(value = nil, **props)
|
|
655
700
|
mapped = props.dup
|
|
656
701
|
mapped[:value] = value unless value.nil?
|
|
657
702
|
build_widget(:codeeditor, **mapped)
|
|
658
703
|
end
|
|
659
704
|
def codeeditor(value = nil, **props) = code_editor(value, **props)
|
|
660
|
-
|
|
661
705
|
def rive(src = nil, **props)
|
|
662
706
|
mapped = props.dup
|
|
663
707
|
mapped[:src] = src unless src.nil?
|
|
@@ -94,6 +94,28 @@ module Ruflet
|
|
|
94
94
|
"clipboard" => "Clipboard",
|
|
95
95
|
"audio" => "Audio",
|
|
96
96
|
"video" => "Video",
|
|
97
|
+
"map" => "Map",
|
|
98
|
+
"tilelayer" => "TileLayer",
|
|
99
|
+
"tile_layer" => "TileLayer",
|
|
100
|
+
"markerlayer" => "MarkerLayer",
|
|
101
|
+
"marker_layer" => "MarkerLayer",
|
|
102
|
+
"marker" => "Marker",
|
|
103
|
+
"circlelayer" => "CircleLayer",
|
|
104
|
+
"circle_layer" => "CircleLayer",
|
|
105
|
+
"circlemarker" => "CircleMarker",
|
|
106
|
+
"circle_marker" => "CircleMarker",
|
|
107
|
+
"polylinelayer" => "PolylineLayer",
|
|
108
|
+
"polyline_layer" => "PolylineLayer",
|
|
109
|
+
"polylinemarker" => "PolylineMarker",
|
|
110
|
+
"polyline_marker" => "PolylineMarker",
|
|
111
|
+
"polygonlayer" => "PolygonLayer",
|
|
112
|
+
"polygon_layer" => "PolygonLayer",
|
|
113
|
+
"polygonmarker" => "PolygonMarker",
|
|
114
|
+
"polygon_marker" => "PolygonMarker",
|
|
115
|
+
"simpleattribution" => "SimpleAttribution",
|
|
116
|
+
"simple_attribution" => "SimpleAttribution",
|
|
117
|
+
"codeeditor" => "CodeEditor",
|
|
118
|
+
"code_editor" => "CodeEditor",
|
|
97
119
|
"flashlight" => "Flashlight",
|
|
98
120
|
"barchart" => "BarChart",
|
|
99
121
|
"barchartgroup" => "group",
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class AccelerometerControl < Ruflet::Control
|
|
8
8
|
TYPE = "accelerometer".freeze
|
|
9
9
|
WIRE = "Accelerometer".freeze
|
|
10
|
+
KEYWORDS = [:cancel_on_error, :data, :enabled, :interval, :key, :on_error, :on_reading].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, cancel_on_error: nil, data: nil, enabled: nil, interval: nil, key: nil, on_error: nil, on_reading: nil)
|
|
12
13
|
props = {}
|
|
@@ -7,11 +7,12 @@ module Ruflet
|
|
|
7
7
|
class AudioRecorderControl < Ruflet::Control
|
|
8
8
|
TYPE = "audiorecorder".freeze
|
|
9
9
|
WIRE = "AudioRecorder".freeze
|
|
10
|
+
KEYWORDS = [:configuration, :data, :key, :on_state_change, :on_stream, :on_upload].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, configuration: nil, data: nil, key: nil, on_state_change: nil, on_stream: nil, on_upload: nil)
|
|
12
13
|
configuration ||= {}
|
|
13
14
|
props = {}
|
|
14
|
-
props[:configuration] = configuration
|
|
15
|
+
props[:configuration] = configuration
|
|
15
16
|
props[:data] = data unless data.nil?
|
|
16
17
|
props[:key] = key unless key.nil?
|
|
17
18
|
props[:on_state_change] = on_state_change unless on_state_change.nil?
|
|
@@ -20,39 +21,21 @@ module Ruflet
|
|
|
20
21
|
super(type: TYPE, id: id, **props)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
|
-
%w[
|
|
24
|
-
cancel_recording
|
|
25
|
-
get_input_devices
|
|
26
|
-
has_permission
|
|
27
|
-
is_paused
|
|
28
|
-
is_recording
|
|
29
|
-
pause_recording
|
|
30
|
-
resume_recording
|
|
31
|
-
stop_recording
|
|
32
|
-
].each do |method_name|
|
|
24
|
+
%w[cancel_recording get_input_devices has_permission is_paused is_recording pause_recording resume_recording stop_recording].each do |method_name|
|
|
33
25
|
define_method(method_name) do |timeout: 10, on_result: nil|
|
|
34
|
-
|
|
26
|
+
invoke_service(method_name, timeout: timeout, on_result: on_result)
|
|
35
27
|
end
|
|
36
28
|
end
|
|
37
29
|
|
|
38
30
|
def is_supported_encoder(encoder, timeout: 10, on_result: nil)
|
|
39
|
-
|
|
40
|
-
"is_supported_encoder",
|
|
41
|
-
args: { "encoder" => normalize_service_value(encoder) },
|
|
42
|
-
timeout: timeout,
|
|
43
|
-
on_result: on_result
|
|
44
|
-
)
|
|
31
|
+
invoke_service("is_supported_encoder", args: { "encoder" => encoder }, timeout: timeout, on_result: on_result)
|
|
45
32
|
end
|
|
46
33
|
|
|
47
34
|
def start_recording(output_path: nil, configuration: nil, upload: nil, timeout: 10, on_result: nil)
|
|
48
|
-
configuration
|
|
49
|
-
|
|
35
|
+
configuration = props["configuration"] if configuration.nil?
|
|
36
|
+
invoke_service(
|
|
50
37
|
"start_recording",
|
|
51
|
-
args: compact_args(
|
|
52
|
-
"output_path" => output_path,
|
|
53
|
-
"configuration" => configuration,
|
|
54
|
-
"upload" => upload
|
|
55
|
-
),
|
|
38
|
+
args: compact_args("output_path" => output_path, "configuration" => configuration, "upload" => upload),
|
|
56
39
|
timeout: timeout,
|
|
57
40
|
on_result: on_result
|
|
58
41
|
)
|
|
@@ -60,26 +43,21 @@ module Ruflet
|
|
|
60
43
|
|
|
61
44
|
private
|
|
62
45
|
|
|
63
|
-
def
|
|
46
|
+
def invoke_service(method_name, args: nil, timeout:, on_result:)
|
|
64
47
|
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
65
48
|
end
|
|
66
49
|
|
|
67
50
|
def compact_args(hash)
|
|
68
|
-
hash.each_with_object({})
|
|
69
|
-
result[key] = normalize_service_value(value) unless value.nil?
|
|
70
|
-
end
|
|
51
|
+
hash.each_with_object({}) { |(key, value), result| result[key] = normalize_value(value) unless value.nil? }
|
|
71
52
|
end
|
|
72
53
|
|
|
73
|
-
def
|
|
54
|
+
def normalize_value(value)
|
|
74
55
|
case value
|
|
75
|
-
when Array
|
|
76
|
-
value.map { |item| normalize_service_value(item) }
|
|
56
|
+
when Array then value.map { |item| normalize_value(item) }
|
|
77
57
|
when Hash
|
|
78
|
-
value.
|
|
79
|
-
result[key] = normalize_service_value(item) unless item.nil?
|
|
80
|
-
end
|
|
58
|
+
value.each_with_object({}) { |(key, item), result| result[key.to_s] = normalize_value(item) unless item.nil? }
|
|
81
59
|
else
|
|
82
|
-
value.respond_to?(:to_h) ?
|
|
60
|
+
value.respond_to?(:to_h) ? normalize_value(value.to_h) : value
|
|
83
61
|
end
|
|
84
62
|
end
|
|
85
63
|
end
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class BarometerControl < Ruflet::Control
|
|
8
8
|
TYPE = "barometer".freeze
|
|
9
9
|
WIRE = "Barometer".freeze
|
|
10
|
+
KEYWORDS = [:cancel_on_error, :data, :enabled, :interval, :key, :on_error, :on_reading].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, cancel_on_error: nil, data: nil, enabled: nil, interval: nil, key: nil, on_error: nil, on_reading: nil)
|
|
12
13
|
props = {}
|
|
@@ -8,48 +8,15 @@ module Ruflet
|
|
|
8
8
|
TYPE = "camera".freeze
|
|
9
9
|
WIRE = "Camera".freeze
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
props
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
props[:animate_scale] = animate_scale unless animate_scale.nil?
|
|
21
|
-
props[:animate_size] = animate_size unless animate_size.nil?
|
|
22
|
-
props[:aspect_ratio] = aspect_ratio unless aspect_ratio.nil?
|
|
23
|
-
props[:badge] = badge unless badge.nil?
|
|
24
|
-
props[:bottom] = bottom unless bottom.nil?
|
|
25
|
-
props[:col] = col unless col.nil?
|
|
26
|
-
props[:content] = content unless content.nil?
|
|
27
|
-
props[:data] = data unless data.nil?
|
|
28
|
-
props[:disabled] = disabled unless disabled.nil?
|
|
29
|
-
props[:expand] = expand unless expand.nil?
|
|
30
|
-
props[:expand_loose] = expand_loose unless expand_loose.nil?
|
|
31
|
-
props[:height] = height unless height.nil?
|
|
32
|
-
props[:key] = key unless key.nil?
|
|
33
|
-
props[:left] = left unless left.nil?
|
|
34
|
-
props[:margin] = margin unless margin.nil?
|
|
35
|
-
props[:offset] = offset unless offset.nil?
|
|
36
|
-
props[:opacity] = opacity unless opacity.nil?
|
|
37
|
-
props[:preview_enabled] = preview_enabled unless preview_enabled.nil?
|
|
38
|
-
props[:right] = right unless right.nil?
|
|
39
|
-
props[:rotate] = rotate unless rotate.nil?
|
|
40
|
-
props[:rtl] = rtl unless rtl.nil?
|
|
41
|
-
props[:scale] = scale unless scale.nil?
|
|
42
|
-
props[:size_change_interval] = size_change_interval unless size_change_interval.nil?
|
|
43
|
-
props[:tooltip] = tooltip unless tooltip.nil?
|
|
44
|
-
props[:top] = top unless top.nil?
|
|
45
|
-
props[:visible] = visible unless visible.nil?
|
|
46
|
-
props[:width] = width unless width.nil?
|
|
47
|
-
props[:on_animation_end] = on_animation_end unless on_animation_end.nil?
|
|
48
|
-
props[:on_error] = on_error unless on_error.nil?
|
|
49
|
-
props[:on_size_change] = on_size_change unless on_size_change.nil?
|
|
50
|
-
props[:on_state_change] = on_state_change unless on_state_change.nil?
|
|
51
|
-
props[:on_stream_image] = on_stream_image unless on_stream_image.nil?
|
|
52
|
-
super(type: TYPE, id: id, **props)
|
|
11
|
+
KEYWORDS = [:align, :animate_align, :animate_margin, :animate_offset, :animate_opacity, :animate_position, :animate_rotation, :animate_scale, :animate_size, :aspect_ratio, :badge, :bottom, :col, :content, :data, :disabled, :expand, :expand_loose, :height, :key, :left, :margin, :offset, :opacity, :preview_enabled, :right, :rotate, :rtl, :scale, :size_change_interval, :tooltip, :top, :visible, :width, :on_animation_end, :on_error, :on_size_change, :on_state_change, :on_stream_image].freeze
|
|
12
|
+
|
|
13
|
+
def initialize(id: nil, **props)
|
|
14
|
+
compact = {}
|
|
15
|
+
props.each do |key, value|
|
|
16
|
+
raise ArgumentError, "unknown keyword: :#{key}" unless KEYWORDS.include?(key)
|
|
17
|
+
compact[key] = value unless value.nil?
|
|
18
|
+
end
|
|
19
|
+
super(type: TYPE, id: id, **compact)
|
|
53
20
|
end
|
|
54
21
|
end
|
|
55
22
|
end
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class ClipboardControl < Ruflet::Control
|
|
8
8
|
TYPE = "clipboard".freeze
|
|
9
9
|
WIRE = "Clipboard".freeze
|
|
10
|
+
KEYWORDS = [:data, :key].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, data: nil, key: nil)
|
|
12
13
|
props = {}
|
|
@@ -14,6 +15,36 @@ module Ruflet
|
|
|
14
15
|
props[:key] = key unless key.nil?
|
|
15
16
|
super(type: TYPE, id: id, **props)
|
|
16
17
|
end
|
|
18
|
+
|
|
19
|
+
def set(value, timeout: 10, on_result: nil)
|
|
20
|
+
invoke_service("set", args: { "data" => value.to_s }, timeout: timeout, on_result: on_result)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get(timeout: 10, on_result: nil)
|
|
24
|
+
invoke_service("get", timeout: timeout, on_result: on_result)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def set_image(value, timeout: 10, on_result: nil)
|
|
28
|
+
invoke_service("set_image", args: { "data" => value }, timeout: timeout, on_result: on_result)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get_image(timeout: 10, on_result: nil)
|
|
32
|
+
invoke_service("get_image", timeout: timeout, on_result: on_result)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def set_files(files, timeout: 10, on_result: nil)
|
|
36
|
+
invoke_service("set_files", args: { "files" => Array(files).map(&:to_s) }, timeout: timeout, on_result: on_result)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_files(timeout: 10, on_result: nil)
|
|
40
|
+
invoke_service("get_files", timeout: timeout, on_result: on_result)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def invoke_service(method_name, args: nil, timeout:, on_result:)
|
|
46
|
+
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
47
|
+
end
|
|
17
48
|
end
|
|
18
49
|
end
|
|
19
50
|
end
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class FilePickerControl < Ruflet::Control
|
|
8
8
|
TYPE = "filepicker".freeze
|
|
9
9
|
WIRE = "FilePicker".freeze
|
|
10
|
+
KEYWORDS = [:data, :key, :on_result, :on_upload].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, data: nil, key: nil, on_result: nil, on_upload: nil)
|
|
12
13
|
props = {}
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class GeolocatorControl < Ruflet::Control
|
|
8
8
|
TYPE = "geolocator".freeze
|
|
9
9
|
WIRE = "Geolocator".freeze
|
|
10
|
+
KEYWORDS = [:configuration, :data, :key, :on_error, :on_position_change].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, configuration: nil, data: nil, key: nil, on_error: nil, on_position_change: nil)
|
|
12
13
|
props = {}
|
|
@@ -18,21 +19,14 @@ module Ruflet
|
|
|
18
19
|
super(type: TYPE, id: id, **props)
|
|
19
20
|
end
|
|
20
21
|
|
|
21
|
-
%w[
|
|
22
|
-
get_last_known_position
|
|
23
|
-
get_permission_status
|
|
24
|
-
is_location_service_enabled
|
|
25
|
-
open_app_settings
|
|
26
|
-
open_location_settings
|
|
27
|
-
request_permission
|
|
28
|
-
].each do |method_name|
|
|
22
|
+
%w[get_last_known_position get_permission_status is_location_service_enabled open_app_settings open_location_settings request_permission].each do |method_name|
|
|
29
23
|
define_method(method_name) do |timeout: 10, on_result: nil|
|
|
30
|
-
|
|
24
|
+
invoke_service(method_name, timeout: timeout, on_result: on_result)
|
|
31
25
|
end
|
|
32
26
|
end
|
|
33
27
|
|
|
34
28
|
def distance_between(start_latitude, start_longitude, end_latitude, end_longitude, timeout: 10, on_result: nil)
|
|
35
|
-
|
|
29
|
+
invoke_service(
|
|
36
30
|
"distance_between",
|
|
37
31
|
args: {
|
|
38
32
|
"start_latitude" => start_latitude,
|
|
@@ -46,36 +40,26 @@ module Ruflet
|
|
|
46
40
|
end
|
|
47
41
|
|
|
48
42
|
def get_current_position(configuration: nil, timeout: 10, on_result: nil)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
43
|
+
# The public Ruflet/Flet API calls this value `configuration`, while
|
|
44
|
+
# the Flutter service currently reads it from the `settings` invoke
|
|
45
|
+
# argument.
|
|
46
|
+
args = configuration.nil? ? nil : { "settings" => normalize_value(configuration) }
|
|
47
|
+
invoke_service("get_current_position", args: args, timeout: timeout, on_result: on_result)
|
|
55
48
|
end
|
|
56
49
|
|
|
57
50
|
private
|
|
58
51
|
|
|
59
|
-
def
|
|
52
|
+
def invoke_service(method_name, args: nil, timeout:, on_result:)
|
|
60
53
|
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
61
54
|
end
|
|
62
55
|
|
|
63
|
-
def
|
|
64
|
-
hash.each_with_object({}) do |(key, value), result|
|
|
65
|
-
result[key] = normalize_service_value(value) unless value.nil?
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def normalize_service_value(value)
|
|
56
|
+
def normalize_value(value)
|
|
70
57
|
case value
|
|
71
|
-
when Array
|
|
72
|
-
value.map { |item| normalize_service_value(item) }
|
|
58
|
+
when Array then value.map { |item| normalize_value(item) }
|
|
73
59
|
when Hash
|
|
74
|
-
value.
|
|
75
|
-
result[key] = normalize_service_value(item) unless item.nil?
|
|
76
|
-
end
|
|
60
|
+
value.each_with_object({}) { |(key, item), result| result[key.to_s] = normalize_value(item) unless item.nil? }
|
|
77
61
|
else
|
|
78
|
-
value.respond_to?(:to_h) ?
|
|
62
|
+
value.respond_to?(:to_h) ? normalize_value(value.to_h) : value
|
|
79
63
|
end
|
|
80
64
|
end
|
|
81
65
|
end
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class GyroscopeControl < Ruflet::Control
|
|
8
8
|
TYPE = "gyroscope".freeze
|
|
9
9
|
WIRE = "Gyroscope".freeze
|
|
10
|
+
KEYWORDS = [:cancel_on_error, :data, :enabled, :interval, :key, :on_error, :on_reading].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, cancel_on_error: nil, data: nil, enabled: nil, interval: nil, key: nil, on_error: nil, on_reading: nil)
|
|
12
13
|
props = {}
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class MagnetometerControl < Ruflet::Control
|
|
8
8
|
TYPE = "magnetometer".freeze
|
|
9
9
|
WIRE = "Magnetometer".freeze
|
|
10
|
+
KEYWORDS = [:cancel_on_error, :data, :enabled, :interval, :key, :on_error, :on_reading].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, cancel_on_error: nil, data: nil, enabled: nil, interval: nil, key: nil, on_error: nil, on_reading: nil)
|
|
12
13
|
props = {}
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class PermissionHandlerControl < Ruflet::Control
|
|
8
8
|
TYPE = "permissionhandler".freeze
|
|
9
9
|
WIRE = "PermissionHandler".freeze
|
|
10
|
+
KEYWORDS = [:data, :key].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, data: nil, key: nil)
|
|
12
13
|
props = {}
|
|
@@ -16,38 +17,22 @@ module Ruflet
|
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def get_status(permission, timeout: 10, on_result: nil)
|
|
19
|
-
|
|
20
|
-
"get_status",
|
|
21
|
-
args: { "permission" => normalize_service_value(permission) },
|
|
22
|
-
timeout: timeout,
|
|
23
|
-
on_result: on_result
|
|
24
|
-
)
|
|
20
|
+
invoke_service("get_status", args: { "permission" => permission }, timeout: timeout, on_result: on_result)
|
|
25
21
|
end
|
|
26
22
|
|
|
27
23
|
def request(permission, timeout: 10, on_result: nil)
|
|
28
|
-
|
|
29
|
-
"request",
|
|
30
|
-
args: { "permission" => normalize_service_value(permission) },
|
|
31
|
-
timeout: timeout,
|
|
32
|
-
on_result: on_result
|
|
33
|
-
)
|
|
24
|
+
invoke_service("request", args: { "permission" => permission }, timeout: timeout, on_result: on_result)
|
|
34
25
|
end
|
|
35
26
|
|
|
36
27
|
def open_app_settings(timeout: 10, on_result: nil)
|
|
37
|
-
|
|
28
|
+
invoke_service("open_app_settings", timeout: timeout, on_result: on_result)
|
|
38
29
|
end
|
|
39
30
|
|
|
40
31
|
private
|
|
41
32
|
|
|
42
|
-
def
|
|
33
|
+
def invoke_service(method_name, args: nil, timeout:, on_result:)
|
|
43
34
|
runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
|
|
44
35
|
end
|
|
45
|
-
|
|
46
|
-
def normalize_service_value(value)
|
|
47
|
-
return value.to_s if value.is_a?(Symbol)
|
|
48
|
-
|
|
49
|
-
value.respond_to?(:to_h) ? value.to_h.transform_keys(&:to_s) : value
|
|
50
|
-
end
|
|
51
36
|
end
|
|
52
37
|
end
|
|
53
38
|
end
|
|
@@ -7,6 +7,7 @@ module Ruflet
|
|
|
7
7
|
class ScreenBrightnessControl < Ruflet::Control
|
|
8
8
|
TYPE = "screenbrightness".freeze
|
|
9
9
|
WIRE = "ScreenBrightness".freeze
|
|
10
|
+
KEYWORDS = [:data, :key, :on_application_screen_brightness_change, :on_system_screen_brightness_change].freeze
|
|
10
11
|
|
|
11
12
|
def initialize(id: nil, data: nil, key: nil, on_application_screen_brightness_change: nil, on_system_screen_brightness_change: nil)
|
|
12
13
|
props = {}
|